1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284 |
- (function webpackUniversalModuleDefinition(root, factory) {
- if (typeof exports === 'object' && typeof module === 'object')
- module.exports = factory(require("echarts"));
- else if (typeof define === 'function' && define.amd)
- define(["echarts"], factory);
- else if (typeof exports === 'object')
- exports["echarts-gl"] = factory(require("echarts"));
- else
- root["echarts-gl"] = factory(root["echarts"]);
- })(this, function (__WEBPACK_EXTERNAL_MODULE_0__) {
- return /******/ (function (modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if (installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/
- }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/
- };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/
- }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function (exports, name, getter) {
- /******/ if (!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/
- });
- /******/
- }
- /******/
- };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function (module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/
- };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function (object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 106);
- /******/
- })
- /************************************************************************/
- /******/([
- /* 0 */
- /***/ (function (module, exports) {
- module.exports = __WEBPACK_EXTERNAL_MODULE_0__;
- /***/
- }),
- /* 1 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Mesh__ = __webpack_require__(40);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__ = __webpack_require__(52);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__ = __webpack_require__(19);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_Node__ = __webpack_require__(35);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_Geometry__ = __webpack_require__(15);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__ = __webpack_require__(36);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU__ = __webpack_require__(60);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__ = __webpack_require__(61);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__EChartsSurface__ = __webpack_require__(124);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13_claygl_src_light_AmbientCubemap__ = __webpack_require__(125);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14_claygl_src_light_AmbientSH__ = __webpack_require__(129);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15_claygl_src_util_sh__ = __webpack_require__(130);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_17_claygl_src_geometry_Sphere__ = __webpack_require__(132);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_18_claygl_src_geometry_Plane__ = __webpack_require__(43);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_19_claygl_src_geometry_Cube__ = __webpack_require__(76);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_20_claygl_src_light_Ambient__ = __webpack_require__(133);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_21_claygl_src_light_Directional__ = __webpack_require__(134);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_22_claygl_src_light_Point__ = __webpack_require__(135);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_23_claygl_src_light_Spot__ = __webpack_require__(136);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_24_claygl_src_camera_Perspective__ = __webpack_require__(41);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_25_claygl_src_camera_Orthographic__ = __webpack_require__(37);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_26_claygl_src_math_Vector2__ = __webpack_require__(26);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_27_claygl_src_math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_28_claygl_src_math_Vector4__ = __webpack_require__(137);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_29_claygl_src_math_Quaternion__ = __webpack_require__(56);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_30_claygl_src_math_Matrix2__ = __webpack_require__(138);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_31_claygl_src_math_Matrix2d__ = __webpack_require__(139);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_32_claygl_src_math_Matrix3__ = __webpack_require__(140);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_33_claygl_src_math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_34_claygl_src_math_Plane__ = __webpack_require__(74);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_35_claygl_src_math_Ray__ = __webpack_require__(54);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_36_claygl_src_math_BoundingBox__ = __webpack_require__(18);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_37_claygl_src_math_Frustum__ = __webpack_require__(59);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_38__animatableMixin__ = __webpack_require__(141);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_39_claygl_src_shader_source_util_glsl_js__ = __webpack_require__(146);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_40_claygl_src_shader_source_prez_glsl_js__ = __webpack_require__(71);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_41__shader_common_glsl_js__ = __webpack_require__(147);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_42__shader_color_glsl_js__ = __webpack_require__(148);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_43__shader_lambert_glsl_js__ = __webpack_require__(149);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_44__shader_realistic_glsl_js__ = __webpack_require__(150);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_45__shader_hatching_glsl_js__ = __webpack_require__(151);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_46__shader_shadow_glsl_js__ = __webpack_require__(152);
- // Math
- // Some common shaders
- __WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts___default.a.util.extend(__WEBPACK_IMPORTED_MODULE_6_claygl_src_Node__["a" /* default */].prototype, __WEBPACK_IMPORTED_MODULE_38__animatableMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_39_claygl_src_shader_source_util_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_40_claygl_src_shader_source_prez_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_41__shader_common_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_42__shader_color_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_43__shader_lambert_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_44__shader_realistic_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_45__shader_hatching_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_46__shader_shadow_glsl_js__["a" /* default */]);
- function isValueNone(value) {
- return !value || value === 'none';
- }
- function isValueImage(value) {
- return value instanceof HTMLCanvasElement
- || value instanceof HTMLImageElement
- || value instanceof Image;
- }
- function isECharts(value) {
- return value.getZr && value.setOption;
- }
- // Overwrite addToScene and removeFromScene
- var oldAddToScene = __WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.addToScene;
- var oldRemoveFromScene = __WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.removeFromScene;
- __WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.addToScene = function (node) {
- oldAddToScene.call(this, node);
- if (this.__zr) {
- var zr = this.__zr;
- node.traverse(function (child) {
- child.__zr = zr;
- if (child.addAnimatorsToZr) {
- child.addAnimatorsToZr(zr);
- }
- });
- }
- };
- __WEBPACK_IMPORTED_MODULE_9_claygl_src_Scene__["a" /* default */].prototype.removeFromScene = function (node) {
- oldRemoveFromScene.call(this, node);
- node.traverse(function (child) {
- var zr = child.__zr;
- child.__zr = null;
- if (zr && child.removeAnimatorsFromZr) {
- child.removeAnimatorsFromZr(zr);
- }
- });
- };
- /**
- * @param {string} textureName
- * @param {string|HTMLImageElement|HTMLCanvasElement} imgValue
- * @param {module:echarts/ExtensionAPI} api
- * @param {Object} [textureOpts]
- */
- __WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__["a" /* default */].prototype.setTextureImage = function (textureName, imgValue, api, textureOpts) {
- if (!this.shader) {
- return;
- }
- var zr = api.getZr();
- var material = this;
- var texture;
- material.autoUpdateTextureStatus = false;
- // disableTexture first
- material.disableTexture(textureName);
- if (!isValueNone(imgValue)) {
- texture = graphicGL.loadTexture(imgValue, api, textureOpts, function (texture) {
- material.enableTexture(textureName);
- zr && zr.refresh();
- });
- // Set texture immediately for other code to verify if have this texture.
- material.set(textureName, texture);
- }
- return texture;
- };
- var graphicGL = {};
- graphicGL.Renderer = __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__["a" /* default */];
- graphicGL.Node = __WEBPACK_IMPORTED_MODULE_6_claygl_src_Node__["a" /* default */];
- graphicGL.Mesh = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Mesh__["a" /* default */];
- graphicGL.Shader = __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */];
- graphicGL.Material = __WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__["a" /* default */];
- graphicGL.Texture = __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */];
- graphicGL.Texture2D = __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */];
- // Geometries
- graphicGL.Geometry = __WEBPACK_IMPORTED_MODULE_7_claygl_src_Geometry__["a" /* default */];
- graphicGL.SphereGeometry = __WEBPACK_IMPORTED_MODULE_17_claygl_src_geometry_Sphere__["a" /* default */];
- graphicGL.PlaneGeometry = __WEBPACK_IMPORTED_MODULE_18_claygl_src_geometry_Plane__["a" /* default */];
- graphicGL.CubeGeometry = __WEBPACK_IMPORTED_MODULE_19_claygl_src_geometry_Cube__["a" /* default */];
- // Lights
- graphicGL.AmbientLight = __WEBPACK_IMPORTED_MODULE_20_claygl_src_light_Ambient__["a" /* default */];
- graphicGL.DirectionalLight = __WEBPACK_IMPORTED_MODULE_21_claygl_src_light_Directional__["a" /* default */];
- graphicGL.PointLight = __WEBPACK_IMPORTED_MODULE_22_claygl_src_light_Point__["a" /* default */];
- graphicGL.SpotLight = __WEBPACK_IMPORTED_MODULE_23_claygl_src_light_Spot__["a" /* default */];
- // Cameras
- graphicGL.PerspectiveCamera = __WEBPACK_IMPORTED_MODULE_24_claygl_src_camera_Perspective__["a" /* default */];
- graphicGL.OrthographicCamera = __WEBPACK_IMPORTED_MODULE_25_claygl_src_camera_Orthographic__["a" /* default */];
- // Math
- graphicGL.Vector2 = __WEBPACK_IMPORTED_MODULE_26_claygl_src_math_Vector2__["a" /* default */];
- graphicGL.Vector3 = __WEBPACK_IMPORTED_MODULE_27_claygl_src_math_Vector3__["a" /* default */];
- graphicGL.Vector4 = __WEBPACK_IMPORTED_MODULE_28_claygl_src_math_Vector4__["a" /* default */];
- graphicGL.Quaternion = __WEBPACK_IMPORTED_MODULE_29_claygl_src_math_Quaternion__["a" /* default */];
- graphicGL.Matrix2 = __WEBPACK_IMPORTED_MODULE_30_claygl_src_math_Matrix2__["a" /* default */];
- graphicGL.Matrix2d = __WEBPACK_IMPORTED_MODULE_31_claygl_src_math_Matrix2d__["a" /* default */];
- graphicGL.Matrix3 = __WEBPACK_IMPORTED_MODULE_32_claygl_src_math_Matrix3__["a" /* default */];
- graphicGL.Matrix4 = __WEBPACK_IMPORTED_MODULE_33_claygl_src_math_Matrix4__["a" /* default */];
- graphicGL.Plane = __WEBPACK_IMPORTED_MODULE_34_claygl_src_math_Plane__["a" /* default */];
- graphicGL.Ray = __WEBPACK_IMPORTED_MODULE_35_claygl_src_math_Ray__["a" /* default */];
- graphicGL.BoundingBox = __WEBPACK_IMPORTED_MODULE_36_claygl_src_math_BoundingBox__["a" /* default */];
- graphicGL.Frustum = __WEBPACK_IMPORTED_MODULE_37_claygl_src_math_Frustum__["a" /* default */];
- // Texture utilities
- var blankImage = __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__["a" /* default */].createBlank('rgba(255,255,255,0)').image;
- function nearestPowerOfTwo(val) {
- return Math.pow(2, Math.round(Math.log(val) / Math.LN2));
- }
- function convertTextureToPowerOfTwo(texture) {
- if ((texture.wrapS === __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].REPEAT || texture.wrapT === __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].REPEAT)
- && texture.image
- ) {
- // var canvas = document.createElement('canvas');
- var width = nearestPowerOfTwo(texture.width);
- var height = nearestPowerOfTwo(texture.height);
- if (width !== texture.width || height !== texture.height) {
- var canvas = document.createElement('canvas');
- canvas.width = width;
- canvas.height = height;
- var ctx = canvas.getContext('2d');
- ctx.drawImage(texture.image, 0, 0, width, height);
- texture.image = canvas;
- }
- }
- }
- /**
- * @param {string|HTMLImageElement|HTMLCanvasElement} imgValue
- * @param {module:echarts/ExtensionAPI} api
- * @param {Object} [textureOpts]
- * @param {Function} cb
- */
- // TODO Promise, test
- graphicGL.loadTexture = function (imgValue, api, textureOpts, cb) {
- if (typeof textureOpts === 'function') {
- cb = textureOpts;
- textureOpts = {};
- }
- textureOpts = textureOpts || {};
- var keys = Object.keys(textureOpts).sort();
- var prefix = '';
- for (var i = 0; i < keys.length; i++) {
- prefix += keys[i] + '_' + textureOpts[keys[i]] + '_';
- }
- var textureCache = api.__textureCache = api.__textureCache || new __WEBPACK_IMPORTED_MODULE_10_zrender_lib_core_LRU___default.a(20);
- if (isECharts(imgValue)) {
- var id = imgValue.__textureid__;
- var textureObj = textureCache.get(prefix + id);
- if (!textureObj) {
- var surface = new __WEBPACK_IMPORTED_MODULE_12__EChartsSurface__["a" /* default */](imgValue);
- surface.onupdate = function () {
- api.getZr().refresh();
- };
- textureObj = {
- texture: surface.getTexture()
- };
- for (var i = 0; i < keys.length; i++) {
- textureObj.texture[keys[i]] = textureOpts[keys[i]];
- }
- id = imgValue.__textureid__ || '__ecgl_ec__' + textureObj.texture.__uid__;
- imgValue.__textureid__ = id;
- textureCache.put(prefix + id, textureObj);
- cb && cb(textureObj.texture);
- }
- else {
- textureObj.texture.surface.setECharts(imgValue);
- cb && cb(textureObj.texture);
- }
- return textureObj.texture;
- }
- else if (isValueImage(imgValue)) {
- var id = imgValue.__textureid__;
- var textureObj = textureCache.get(prefix + id);
- if (!textureObj) {
- textureObj = {
- texture: new graphicGL.Texture2D({
- image: imgValue
- })
- };
- for (var i = 0; i < keys.length; i++) {
- textureObj.texture[keys[i]] = textureOpts[keys[i]];
- }
- id = imgValue.__textureid__ || '__ecgl_image__' + textureObj.texture.__uid__;
- imgValue.__textureid__ = id;
- textureCache.put(prefix + id, textureObj);
- convertTextureToPowerOfTwo(textureObj.texture);
- // TODO Next tick?
- cb && cb(textureObj.texture);
- }
- return textureObj.texture;
- }
- else {
- var textureObj = textureCache.get(prefix + imgValue);
- if (textureObj) {
- if (textureObj.callbacks) {
- // Add to pending callbacks
- textureObj.callbacks.push(cb);
- }
- else {
- // TODO Next tick?
- cb && cb(textureObj.texture);
- }
- }
- else {
- // Maybe base64
- if (imgValue.match(/.hdr$|^data:application\/octet-stream/)) {
- textureObj = {
- callbacks: [cb]
- };
- var texture = __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__["a" /* default */].loadTexture(imgValue, {
- exposure: textureOpts.exposure,
- fileType: 'hdr'
- }, function () {
- texture.dirty();
- textureObj.callbacks.forEach(function (cb) {
- cb && cb(texture);
- });
- textureObj.callbacks = null;
- });
- textureObj.texture = texture;
- textureCache.put(prefix + imgValue, textureObj);
- }
- else {
- var texture = new graphicGL.Texture2D({
- image: new Image()
- });
- for (var i = 0; i < keys.length; i++) {
- texture[keys[i]] = textureOpts[keys[i]];
- }
- textureObj = {
- texture: texture,
- callbacks: [cb]
- };
- var originalImage = texture.image;
- originalImage.onload = function () {
- texture.image = originalImage;
- convertTextureToPowerOfTwo(texture);
- texture.dirty();
- textureObj.callbacks.forEach(function (cb) {
- cb && cb(texture);
- });
- textureObj.callbacks = null;
- };
- originalImage.src = imgValue;
- // Use blank image as place holder.
- texture.image = blankImage;
- textureCache.put(prefix + imgValue, textureObj);
- }
- }
- return textureObj.texture;
- }
- };
- /**
- * Create ambientCubemap and ambientSH light. respectively to have specular and diffuse light
- * @return {Object} { specular, diffuse }
- */
- graphicGL.createAmbientCubemap = function (opt, renderer, api, cb) {
- opt = opt || {};
- var textureUrl = opt.texture;
- var exposure = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(opt.exposure, 1.0);
- var ambientCubemap = new __WEBPACK_IMPORTED_MODULE_13_claygl_src_light_AmbientCubemap__["a" /* default */]({
- intensity: __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(opt.specularIntensity, 1.0)
- });
- var ambientSH = new __WEBPACK_IMPORTED_MODULE_14_claygl_src_light_AmbientSH__["a" /* default */]({
- intensity: __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(opt.diffuseIntensity, 1.0),
- coefficients: [0.844, 0.712, 0.691, -0.037, 0.083, 0.167, 0.343, 0.288, 0.299, -0.041, -0.021, -0.009, -0.003, -0.041, -0.064, -0.011, -0.007, -0.004, -0.031, 0.034, 0.081, -0.060, -0.049, -0.060, 0.046, 0.056, 0.050]
- });
- ambientCubemap.cubemap = graphicGL.loadTexture(textureUrl, api, {
- exposure: exposure
- }, function () {
- // TODO Performance when multiple view
- ambientCubemap.cubemap.flipY = false;
- if (true) {
- var time = Date.now();
- }
- ambientCubemap.prefilter(renderer, 32);
- if (true) {
- var dTime = Date.now() - time;
- console.log('Prefilter environment map: ' + dTime + 'ms');
- }
- ambientSH.coefficients = __WEBPACK_IMPORTED_MODULE_15_claygl_src_util_sh__["a" /* default */].projectEnvironmentMap(renderer, ambientCubemap.cubemap, {
- lod: 1
- });
- cb && cb();
- // TODO Refresh ?
- });
- return {
- specular: ambientCubemap,
- diffuse: ambientSH
- };
- };
- /**
- * Create a blank texture for placeholder
- */
- graphicGL.createBlankTexture = __WEBPACK_IMPORTED_MODULE_11_claygl_src_util_texture__["a" /* default */].createBlank;
- /**
- * If value is image
- * @param {*}
- * @return {boolean}
- */
- graphicGL.isImage = isValueImage;
- graphicGL.additiveBlend = function (gl) {
- gl.blendEquation(gl.FUNC_ADD);
- gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
- };
- /**
- * @param {string|Array.<number>} colorStr
- * @param {Array.<number>} [rgba]
- * @return {Array.<number>} rgba
- */
- graphicGL.parseColor = function (colorStr, rgba) {
- if (colorStr instanceof Array) {
- if (!rgba) {
- rgba = [];
- }
- // Color has been parsed.
- rgba[0] = colorStr[0];
- rgba[1] = colorStr[1];
- rgba[2] = colorStr[2];
- if (colorStr.length > 3) {
- rgba[3] = colorStr[3];
- }
- else {
- rgba[3] = 1;
- }
- return rgba;
- }
- rgba = __WEBPACK_IMPORTED_MODULE_8_echarts_lib_echarts___default.a.color.parse(colorStr || '#000', rgba) || [0, 0, 0, 0];
- rgba[0] /= 255;
- rgba[1] /= 255;
- rgba[2] /= 255;
- return rgba;
- };
- /**
- * Convert alpha beta rotation to direction.
- * @param {number} alpha
- * @param {number} beta
- * @return {Array.<number>}
- */
- graphicGL.directionFromAlphaBeta = function (alpha, beta) {
- var theta = alpha / 180 * Math.PI + Math.PI / 2;
- var phi = -beta / 180 * Math.PI + Math.PI / 2;
- var dir = [];
- var r = Math.sin(theta);
- dir[0] = r * Math.cos(phi);
- dir[1] = -Math.cos(theta);
- dir[2] = r * Math.sin(phi);
- return dir;
- };
- /**
- * Get shadow resolution from shadowQuality configuration
- */
- graphicGL.getShadowResolution = function (shadowQuality) {
- var shadowResolution = 1024;
- switch (shadowQuality) {
- case 'low':
- shadowResolution = 512;
- break;
- case 'medium':
- break;
- case 'high':
- shadowResolution = 2048;
- break;
- case 'ultra':
- shadowResolution = 4096;
- break;
- }
- return shadowResolution;
- };
- /**
- * Shading utilities
- */
- graphicGL.COMMON_SHADERS = ['lambert', 'color', 'realistic', 'hatching'];
- /**
- * Create shader including vertex and fragment
- * @param {string} prefix.
- */
- graphicGL.createShader = function (prefix) {
- var vertexShaderStr = __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source(prefix + '.vertex');
- var fragmentShaderStr = __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source(prefix + '.fragment');
- if (!vertexShaderStr) {
- console.error('Vertex shader of \'%s\' not exits', prefix);
- }
- if (!fragmentShaderStr) {
- console.error('Fragment shader of \'%s\' not exits', prefix);
- }
- var shader = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */](vertexShaderStr, fragmentShaderStr);
- shader.name = prefix;
- return shader;
- };
- graphicGL.createMaterial = function (prefix, defines) {
- if (!(defines instanceof Array)) {
- defines = [defines];
- }
- var shader = graphicGL.createShader(prefix);
- var material = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_Material__["a" /* default */]({
- shader: shader
- });
- defines.forEach(function (defineName) {
- if (typeof defineName === 'string') {
- material.define(defineName);
- }
- });
- return material;
- };
- /**
- * Set material from model.
- * @param {clay.Material} material
- * @param {module:echarts/model/Model} model
- * @param {module:echarts/ExtensionAPI} api
- */
- graphicGL.setMaterialFromModel = function (shading, material, model, api) {
- material.autoUpdateTextureStatus = false;
- var materialModel = model.getModel(shading + 'Material');
- var detailTexture = materialModel.get('detailTexture');
- var uvRepeat = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('textureTiling'), 1.0);
- var uvOffset = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('textureOffset'), 0.0);
- if (typeof uvRepeat === 'number') {
- uvRepeat = [uvRepeat, uvRepeat];
- }
- if (typeof uvOffset === 'number') {
- uvOffset = [uvOffset, uvOffset];
- }
- var repeatParam = (uvRepeat[0] > 1 || uvRepeat[1] > 1) ? graphicGL.Texture.REPEAT : graphicGL.Texture.CLAMP_TO_EDGE;
- var textureOpt = {
- anisotropic: 8,
- wrapS: repeatParam,
- wrapT: repeatParam
- };
- if (shading === 'realistic') {
- var roughness = materialModel.get('roughness');
- var metalness = materialModel.get('metalness');
- if (metalness != null) {
- // Try to treat as a texture, TODO More check
- if (isNaN(metalness)) {
- material.setTextureImage('metalnessMap', metalness, api, textureOpt);
- metalness = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('metalnessAdjust'), 0.5);
- }
- }
- else {
- // Default metalness.
- metalness = 0;
- }
- if (roughness != null) {
- // Try to treat as a texture, TODO More check
- if (isNaN(roughness)) {
- material.setTextureImage('roughnessMap', roughness, api, textureOpt);
- roughness = __WEBPACK_IMPORTED_MODULE_16__retrieve__["a" /* default */].firstNotNull(materialModel.get('roughnessAdjust'), 0.5);
- }
- }
- else {
- // Default roughness.
- roughness = 0.5;
- }
- var normalTextureVal = materialModel.get('normalTexture');
- material.setTextureImage('detailMap', detailTexture, api, textureOpt);
- material.setTextureImage('normalMap', normalTextureVal, api, textureOpt);
- material.set({
- roughness: roughness,
- metalness: metalness,
- detailUvRepeat: uvRepeat,
- detailUvOffset: uvOffset
- });
- // var normalTexture = material.get('normalMap');
- // if (normalTexture) {
- // PENDING
- // normalTexture.format = Texture.SRGB;
- // }
- }
- else if (shading === 'lambert') {
- material.setTextureImage('detailMap', detailTexture, api, textureOpt);
- material.set({
- detailUvRepeat: uvRepeat,
- detailUvOffset: uvOffset
- });
- }
- else if (shading === 'color') {
- material.setTextureImage('detailMap', detailTexture, api, textureOpt);
- material.set({
- detailUvRepeat: uvRepeat,
- detailUvOffset: uvOffset
- });
- }
- else if (shading === 'hatching') {
- var tams = materialModel.get('hatchingTextures') || [];
- if (tams.length < 6) {
- if (true) {
- console.error('Invalid hatchingTextures.');
- }
- }
- for (var i = 0; i < 6; i++) {
- material.setTextureImage('hatch' + (i + 1), tams[i], api, {
- anisotropic: 8,
- wrapS: graphicGL.Texture.REPEAT,
- wrapT: graphicGL.Texture.REPEAT
- });
- }
- material.set({
- detailUvRepeat: uvRepeat,
- detailUvOffset: uvOffset
- });
- }
- };
- graphicGL.updateVertexAnimation = function (
- mappingAttributes, previousMesh, currentMesh, seriesModel
- ) {
- var enableAnimation = seriesModel.get('animation');
- var duration = seriesModel.get('animationDurationUpdate');
- var easing = seriesModel.get('animationEasingUpdate');
- var shadowDepthMaterial = currentMesh.shadowDepthMaterial;
- if (enableAnimation && previousMesh && duration > 0
- // Only animate when bar count are not changed
- && previousMesh.geometry.vertexCount === currentMesh.geometry.vertexCount
- ) {
- currentMesh.material.define('vertex', 'VERTEX_ANIMATION');
- currentMesh.ignorePreZ = true;
- if (shadowDepthMaterial) {
- shadowDepthMaterial.define('vertex', 'VERTEX_ANIMATION');
- }
- for (var i = 0; i < mappingAttributes.length; i++) {
- currentMesh.geometry.attributes[mappingAttributes[i][0]].value =
- previousMesh.geometry.attributes[mappingAttributes[i][1]].value;
- }
- currentMesh.geometry.dirty();
- currentMesh.__percent = 0;
- currentMesh.material.set('percent', 0);
- currentMesh.stopAnimation();
- currentMesh.animate()
- .when(duration, {
- __percent: 1
- })
- .during(function () {
- currentMesh.material.set('percent', currentMesh.__percent);
- if (shadowDepthMaterial) {
- shadowDepthMaterial.set('percent', currentMesh.__percent);
- }
- })
- .done(function () {
- currentMesh.ignorePreZ = false;
- currentMesh.material.undefine('vertex', 'VERTEX_ANIMATION');
- if (shadowDepthMaterial) {
- shadowDepthMaterial.undefine('vertex', 'VERTEX_ANIMATION');
- }
- })
- .start(easing);
- }
- else {
- currentMesh.material.undefine('vertex', 'VERTEX_ANIMATION');
- if (shadowDepthMaterial) {
- shadowDepthMaterial.undefine('vertex', 'VERTEX_ANIMATION');
- }
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (graphicGL);
- /***/
- }),
- /* 2 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- var retrieve = {
- firstNotNull: function () {
- for (var i = 0, len = arguments.length; i < len; i++) {
- if (arguments[i] != null) {
- return arguments[i];
- }
- }
- },
- /**
- * @param {module:echarts/data/List} data
- * @param {Object} payload Contains dataIndex (means rawIndex) / dataIndexInside / name
- * each of which can be Array or primary type.
- * @return {number|Array.<number>} dataIndex If not found, return undefined/null.
- */
- queryDataIndex: function (data, payload) {
- if (payload.dataIndexInside != null) {
- return payload.dataIndexInside;
- }
- else if (payload.dataIndex != null) {
- return __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(payload.dataIndex)
- ? __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.map(payload.dataIndex, function (value) {
- return data.indexOfRawIndex(value);
- })
- : data.indexOfRawIndex(payload.dataIndex);
- }
- else if (payload.name != null) {
- return __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(payload.name)
- ? __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.map(payload.name, function (value) {
- return data.indexOfName(value);
- })
- : data.indexOfName(payload.name);
- }
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (retrieve);
- /***/
- }),
- /* 3 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__ = __webpack_require__(12);
- /**
- * @constructor
- * @alias clay.Vector3
- * @param {number} x
- * @param {number} y
- * @param {number} z
- */
- var Vector3 = function (x, y, z) {
- x = x || 0;
- y = y || 0;
- z = z || 0;
- /**
- * Storage of Vector3, read and write of x, y, z will change the values in array
- * All methods also operate on the array instead of x, y, z components
- * @name array
- * @type {Float32Array}
- * @memberOf clay.Vector3#
- */
- this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].fromValues(x, y, z);
- /**
- * Dirty flag is used by the Node to determine
- * if the matrix is updated to latest
- * @name _dirty
- * @type {boolean}
- * @memberOf clay.Vector3#
- */
- this._dirty = true;
- };
- Vector3.prototype = {
- constructor: Vector3,
- /**
- * Add b to self
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- add: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].add(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Set x, y and z components
- * @param {number} x
- * @param {number} y
- * @param {number} z
- * @return {clay.Vector3}
- */
- set: function (x, y, z) {
- this.array[0] = x;
- this.array[1] = y;
- this.array[2] = z;
- this._dirty = true;
- return this;
- },
- /**
- * Set x, y and z components from array
- * @param {Float32Array|number[]} arr
- * @return {clay.Vector3}
- */
- setArray: function (arr) {
- this.array[0] = arr[0];
- this.array[1] = arr[1];
- this.array[2] = arr[2];
- this._dirty = true;
- return this;
- },
- /**
- * Clone a new Vector3
- * @return {clay.Vector3}
- */
- clone: function () {
- return new Vector3(this.x, this.y, this.z);
- },
- /**
- * Copy from b
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- copy: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].copy(this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Cross product of self and b, written to a Vector3 out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- cross: function (a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].cross(this.array, a.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for distance
- * @param {clay.Vector3} b
- * @return {number}
- */
- dist: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].dist(this.array, b.array);
- },
- /**
- * Distance between self and b
- * @param {clay.Vector3} b
- * @return {number}
- */
- distance: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].distance(this.array, b.array);
- },
- /**
- * Alias for divide
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- div: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].div(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Divide self by b
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- divide: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].divide(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Dot product of self and b
- * @param {clay.Vector3} b
- * @return {number}
- */
- dot: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].dot(this.array, b.array);
- },
- /**
- * Alias of length
- * @return {number}
- */
- len: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].len(this.array);
- },
- /**
- * Calculate the length
- * @return {number}
- */
- length: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].length(this.array);
- },
- /**
- * Linear interpolation between a and b
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @param {number} t
- * @return {clay.Vector3}
- */
- lerp: function (a, b, t) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].lerp(this.array, a.array, b.array, t);
- this._dirty = true;
- return this;
- },
- /**
- * Minimum of self and b
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- min: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].min(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Maximum of self and b
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- max: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].max(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for multiply
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- mul: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].mul(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Mutiply self and b
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- multiply: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].multiply(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Negate self
- * @return {clay.Vector3}
- */
- negate: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].negate(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Normalize self
- * @return {clay.Vector3}
- */
- normalize: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].normalize(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Generate random x, y, z components with a given scale
- * @param {number} scale
- * @return {clay.Vector3}
- */
- random: function (scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].random(this.array, scale);
- this._dirty = true;
- return this;
- },
- /**
- * Scale self
- * @param {number} scale
- * @return {clay.Vector3}
- */
- scale: function (s) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].scale(this.array, this.array, s);
- this._dirty = true;
- return this;
- },
- /**
- * Scale b and add to self
- * @param {clay.Vector3} b
- * @param {number} scale
- * @return {clay.Vector3}
- */
- scaleAndAdd: function (b, s) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].scaleAndAdd(this.array, this.array, b.array, s);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for squaredDistance
- * @param {clay.Vector3} b
- * @return {number}
- */
- sqrDist: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].sqrDist(this.array, b.array);
- },
- /**
- * Squared distance between self and b
- * @param {clay.Vector3} b
- * @return {number}
- */
- squaredDistance: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].squaredDistance(this.array, b.array);
- },
- /**
- * Alias for squaredLength
- * @return {number}
- */
- sqrLen: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].sqrLen(this.array);
- },
- /**
- * Squared length of self
- * @return {number}
- */
- squaredLength: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].squaredLength(this.array);
- },
- /**
- * Alias for subtract
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- sub: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].sub(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Subtract b from self
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- subtract: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].subtract(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transform self with a Matrix3 m
- * @param {clay.Matrix3} m
- * @return {clay.Vector3}
- */
- transformMat3: function (m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformMat3(this.array, this.array, m.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transform self with a Matrix4 m
- * @param {clay.Matrix4} m
- * @return {clay.Vector3}
- */
- transformMat4: function (m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformMat4(this.array, this.array, m.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transform self with a Quaternion q
- * @param {clay.Quaternion} q
- * @return {clay.Vector3}
- */
- transformQuat: function (q) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformQuat(this.array, this.array, q.array);
- this._dirty = true;
- return this;
- },
- /**
- * Trasnform self into projection space with m
- * @param {clay.Matrix4} m
- * @return {clay.Vector3}
- */
- applyProjection: function (m) {
- var v = this.array;
- m = m.array;
- // Perspective projection
- if (m[15] === 0) {
- var w = -1 / v[2];
- v[0] = m[0] * v[0] * w;
- v[1] = m[5] * v[1] * w;
- v[2] = (m[10] * v[2] + m[14]) * w;
- }
- else {
- v[0] = m[0] * v[0] + m[12];
- v[1] = m[5] * v[1] + m[13];
- v[2] = m[10] * v[2] + m[14];
- }
- this._dirty = true;
- return this;
- },
- eulerFromQuat: function (q, order) {
- Vector3.eulerFromQuat(this, q, order);
- },
- eulerFromMat3: function (m, order) {
- Vector3.eulerFromMat3(this, m, order);
- },
- toString: function () {
- return '[' + Array.prototype.join.call(this.array, ',') + ']';
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array);
- }
- };
- var defineProperty = Object.defineProperty;
- // Getter and Setter
- if (defineProperty) {
- var proto = Vector3.prototype;
- /**
- * @name x
- * @type {number}
- * @memberOf clay.Vector3
- * @instance
- */
- defineProperty(proto, 'x', {
- get: function () {
- return this.array[0];
- },
- set: function (value) {
- this.array[0] = value;
- this._dirty = true;
- }
- });
- /**
- * @name y
- * @type {number}
- * @memberOf clay.Vector3
- * @instance
- */
- defineProperty(proto, 'y', {
- get: function () {
- return this.array[1];
- },
- set: function (value) {
- this.array[1] = value;
- this._dirty = true;
- }
- });
- /**
- * @name z
- * @type {number}
- * @memberOf clay.Vector3
- * @instance
- */
- defineProperty(proto, 'z', {
- get: function () {
- return this.array[2];
- },
- set: function (value) {
- this.array[2] = value;
- this._dirty = true;
- }
- });
- }
- // Supply methods that are not in place
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- Vector3.add = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].add(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {number} x
- * @param {number} y
- * @param {number} z
- * @return {clay.Vector3}
- */
- Vector3.set = function (out, x, y, z) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].set(out.array, x, y, z);
- out._dirty = true;
- };
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- Vector3.copy = function (out, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].copy(out.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- Vector3.cross = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].cross(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {number}
- */
- Vector3.dist = function (a, b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].distance(a.array, b.array);
- };
- /**
- * @function
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {number}
- */
- Vector3.distance = Vector3.dist;
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- Vector3.div = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].divide(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- Vector3.divide = Vector3.div;
- /**
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {number}
- */
- Vector3.dot = function (a, b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].dot(a.array, b.array);
- };
- /**
- * @param {clay.Vector3} a
- * @return {number}
- */
- Vector3.len = function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].length(b.array);
- };
- // Vector3.length = Vector3.len;
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @param {number} t
- * @return {clay.Vector3}
- */
- Vector3.lerp = function (out, a, b, t) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].lerp(out.array, a.array, b.array, t);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- Vector3.min = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].min(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- Vector3.max = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].max(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- Vector3.mul = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].multiply(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- Vector3.multiply = Vector3.mul;
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @return {clay.Vector3}
- */
- Vector3.negate = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].negate(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @return {clay.Vector3}
- */
- Vector3.normalize = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].normalize(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {number} scale
- * @return {clay.Vector3}
- */
- Vector3.random = function (out, scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].random(out.array, scale);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {number} scale
- * @return {clay.Vector3}
- */
- Vector3.scale = function (out, a, scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].scale(out.array, a.array, scale);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @param {number} scale
- * @return {clay.Vector3}
- */
- Vector3.scaleAndAdd = function (out, a, b, scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, a.array, b.array, scale);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {number}
- */
- Vector3.sqrDist = function (a, b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].sqrDist(a.array, b.array);
- };
- /**
- * @function
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {number}
- */
- Vector3.squaredDistance = Vector3.sqrDist;
- /**
- * @param {clay.Vector3} a
- * @return {number}
- */
- Vector3.sqrLen = function (a) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].sqrLen(a.array);
- };
- /**
- * @function
- * @param {clay.Vector3} a
- * @return {number}
- */
- Vector3.squaredLength = Vector3.sqrLen;
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- Vector3.sub = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].subtract(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Vector3}
- */
- Vector3.subtract = Vector3.sub;
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {Matrix3} m
- * @return {clay.Vector3}
- */
- Vector3.transformMat3 = function (out, a, m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformMat3(out.array, a.array, m.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Matrix4} m
- * @return {clay.Vector3}
- */
- Vector3.transformMat4 = function (out, a, m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformMat4(out.array, a.array, m.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector3} a
- * @param {clay.Quaternion} q
- * @return {clay.Vector3}
- */
- Vector3.transformQuat = function (out, a, q) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec3__["a" /* default */].transformQuat(out.array, a.array, q.array);
- out._dirty = true;
- return out;
- };
- function clamp(val, min, max) {
- return val < min ? min : (val > max ? max : val);
- }
- var atan2 = Math.atan2;
- var asin = Math.asin;
- var abs = Math.abs;
- /**
- * Convert quaternion to euler angle
- * Quaternion must be normalized
- * From three.js
- */
- Vector3.eulerFromQuat = function (out, q, order) {
- out._dirty = true;
- q = q.array;
- var target = out.array;
- var x = q[0], y = q[1], z = q[2], w = q[3];
- var x2 = x * x;
- var y2 = y * y;
- var z2 = z * z;
- var w2 = w * w;
- var order = (order || 'XYZ').toUpperCase();
- switch (order) {
- case 'XYZ':
- target[0] = atan2(2 * (x * w - y * z), (w2 - x2 - y2 + z2));
- target[1] = asin(clamp(2 * (x * z + y * w), - 1, 1));
- target[2] = atan2(2 * (z * w - x * y), (w2 + x2 - y2 - z2));
- break;
- case 'YXZ':
- target[0] = asin(clamp(2 * (x * w - y * z), - 1, 1));
- target[1] = atan2(2 * (x * z + y * w), (w2 - x2 - y2 + z2));
- target[2] = atan2(2 * (x * y + z * w), (w2 - x2 + y2 - z2));
- break;
- case 'ZXY':
- target[0] = asin(clamp(2 * (x * w + y * z), - 1, 1));
- target[1] = atan2(2 * (y * w - z * x), (w2 - x2 - y2 + z2));
- target[2] = atan2(2 * (z * w - x * y), (w2 - x2 + y2 - z2));
- break;
- case 'ZYX':
- target[0] = atan2(2 * (x * w + z * y), (w2 - x2 - y2 + z2));
- target[1] = asin(clamp(2 * (y * w - x * z), - 1, 1));
- target[2] = atan2(2 * (x * y + z * w), (w2 + x2 - y2 - z2));
- break;
- case 'YZX':
- target[0] = atan2(2 * (x * w - z * y), (w2 - x2 + y2 - z2));
- target[1] = atan2(2 * (y * w - x * z), (w2 + x2 - y2 - z2));
- target[2] = asin(clamp(2 * (x * y + z * w), - 1, 1));
- break;
- case 'XZY':
- target[0] = atan2(2 * (x * w + y * z), (w2 - x2 + y2 - z2));
- target[1] = atan2(2 * (x * z + y * w), (w2 + x2 - y2 - z2));
- target[2] = asin(clamp(2 * (z * w - x * y), - 1, 1));
- break;
- default:
- console.warn('Unkown order: ' + order);
- }
- return out;
- };
- /**
- * Convert rotation matrix to euler angle
- * from three.js
- */
- Vector3.eulerFromMat3 = function (out, m, order) {
- // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
- var te = m.array;
- var m11 = te[0], m12 = te[3], m13 = te[6];
- var m21 = te[1], m22 = te[4], m23 = te[7];
- var m31 = te[2], m32 = te[5], m33 = te[8];
- var target = out.array;
- var order = (order || 'XYZ').toUpperCase();
- switch (order) {
- case 'XYZ':
- target[1] = asin(clamp(m13, -1, 1));
- if (abs(m13) < 0.99999) {
- target[0] = atan2(-m23, m33);
- target[2] = atan2(-m12, m11);
- }
- else {
- target[0] = atan2(m32, m22);
- target[2] = 0;
- }
- break;
- case 'YXZ':
- target[0] = asin(-clamp(m23, -1, 1));
- if (abs(m23) < 0.99999) {
- target[1] = atan2(m13, m33);
- target[2] = atan2(m21, m22);
- }
- else {
- target[1] = atan2(-m31, m11);
- target[2] = 0;
- }
- break;
- case 'ZXY':
- target[0] = asin(clamp(m32, -1, 1));
- if (abs(m32) < 0.99999) {
- target[1] = atan2(-m31, m33);
- target[2] = atan2(-m12, m22);
- }
- else {
- target[1] = 0;
- target[2] = atan2(m21, m11);
- }
- break;
- case 'ZYX':
- target[1] = asin(-clamp(m31, -1, 1));
- if (abs(m31) < 0.99999) {
- target[0] = atan2(m32, m33);
- target[2] = atan2(m21, m11);
- }
- else {
- target[0] = 0;
- target[2] = atan2(-m12, m22);
- }
- break;
- case 'YZX':
- target[2] = asin(clamp(m21, -1, 1));
- if (abs(m21) < 0.99999) {
- target[0] = atan2(-m23, m22);
- target[1] = atan2(-m31, m11);
- }
- else {
- target[0] = 0;
- target[1] = atan2(m13, m33);
- }
- break;
- case 'XZY':
- target[2] = asin(-clamp(m12, -1, 1));
- if (abs(m12) < 0.99999) {
- target[0] = atan2(m32, m22);
- target[1] = atan2(m13, m11);
- }
- else {
- target[0] = atan2(-m23, m33);
- target[1] = 0;
- }
- break;
- default:
- console.warn('Unkown order: ' + order);
- }
- out._dirty = true;
- return out;
- };
- Object.defineProperties(Vector3, {
- /**
- * @type {clay.Vector3}
- * @readOnly
- * @memberOf clay.Vector3
- */
- POSITIVE_X: {
- get: function () {
- return new Vector3(1, 0, 0);
- }
- },
- /**
- * @type {clay.Vector3}
- * @readOnly
- * @memberOf clay.Vector3
- */
- NEGATIVE_X: {
- get: function () {
- return new Vector3(-1, 0, 0);
- }
- },
- /**
- * @type {clay.Vector3}
- * @readOnly
- * @memberOf clay.Vector3
- */
- POSITIVE_Y: {
- get: function () {
- return new Vector3(0, 1, 0);
- }
- },
- /**
- * @type {clay.Vector3}
- * @readOnly
- * @memberOf clay.Vector3
- */
- NEGATIVE_Y: {
- get: function () {
- return new Vector3(0, -1, 0);
- }
- },
- /**
- * @type {clay.Vector3}
- * @readOnly
- * @memberOf clay.Vector3
- */
- POSITIVE_Z: {
- get: function () {
- return new Vector3(0, 0, 1);
- }
- },
- /**
- * @type {clay.Vector3}
- * @readOnly
- */
- NEGATIVE_Z: {
- get: function () {
- return new Vector3(0, 0, -1);
- }
- },
- /**
- * @type {clay.Vector3}
- * @readOnly
- * @memberOf clay.Vector3
- */
- UP: {
- get: function () {
- return new Vector3(0, 1, 0);
- }
- },
- /**
- * @type {clay.Vector3}
- * @readOnly
- * @memberOf clay.Vector3
- */
- ZERO: {
- get: function () {
- return new Vector3();
- }
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Vector3);
- /***/
- }),
- /* 4 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_Cache__ = __webpack_require__(57);
- /**
- * Base class for all textures like compressed texture, texture2d, texturecube
- * TODO mapping
- */
- /**
- * @constructor
- * @alias clay.Texture
- * @extends clay.core.Base
- */
- var Texture = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend( /** @lends clay.Texture# */ {
- /**
- * Texture width, readonly when the texture source is image
- * @type {number}
- */
- width: 512,
- /**
- * Texture height, readonly when the texture source is image
- * @type {number}
- */
- height: 512,
- /**
- * Texel data type.
- * Possible values:
- * + {@link clay.Texture.UNSIGNED_BYTE}
- * + {@link clay.Texture.HALF_FLOAT}
- * + {@link clay.Texture.FLOAT}
- * + {@link clay.Texture.UNSIGNED_INT_24_8_WEBGL}
- * + {@link clay.Texture.UNSIGNED_INT}
- * @type {number}
- */
- type: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_BYTE,
- /**
- * Format of texel data
- * Possible values:
- * + {@link clay.Texture.RGBA}
- * + {@link clay.Texture.DEPTH_COMPONENT}
- * + {@link clay.Texture.DEPTH_STENCIL}
- * @type {number}
- */
- format: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGBA,
- /**
- * Texture wrap. Default to be REPEAT.
- * Possible values:
- * + {@link clay.Texture.CLAMP_TO_EDGE}
- * + {@link clay.Texture.REPEAT}
- * + {@link clay.Texture.MIRRORED_REPEAT}
- * @type {number}
- */
- wrapS: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].REPEAT,
- /**
- * Texture wrap. Default to be REPEAT.
- * Possible values:
- * + {@link clay.Texture.CLAMP_TO_EDGE}
- * + {@link clay.Texture.REPEAT}
- * + {@link clay.Texture.MIRRORED_REPEAT}
- * @type {number}
- */
- wrapT: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].REPEAT,
- /**
- * Possible values:
- * + {@link clay.Texture.NEAREST}
- * + {@link clay.Texture.LINEAR}
- * + {@link clay.Texture.NEAREST_MIPMAP_NEAREST}
- * + {@link clay.Texture.LINEAR_MIPMAP_NEAREST}
- * + {@link clay.Texture.NEAREST_MIPMAP_LINEAR}
- * + {@link clay.Texture.LINEAR_MIPMAP_LINEAR}
- * @type {number}
- */
- minFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR,
- /**
- * Possible values:
- * + {@link clay.Texture.NEAREST}
- * + {@link clay.Texture.LINEAR}
- * @type {number}
- */
- magFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR,
- /**
- * If enable mimap.
- * @type {boolean}
- */
- useMipmap: true,
- /**
- * Anisotropic filtering, enabled if value is larger than 1
- * @see https://developer.mozilla.org/en-US/docs/Web/API/EXT_texture_filter_anisotropic
- * @type {number}
- */
- anisotropic: 1,
- // pixelStorei parameters, not available when texture is used as render target
- // http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml
- /**
- * If flip in y axis for given image source
- * @type {boolean}
- * @default true
- */
- flipY: true,
- /**
- * A flag to indicate if texture source is sRGB
- */
- sRGB: true,
- /**
- * @type {number}
- * @default 4
- */
- unpackAlignment: 4,
- /**
- * @type {boolean}
- * @default false
- */
- premultiplyAlpha: false,
- /**
- * Dynamic option for texture like video
- * @type {boolean}
- */
- dynamic: false,
- NPOT: false,
- // PENDING
- // Init it here to avoid deoptimization when it's assigned in application dynamically
- __used: 0
- }, function () {
- this._cache = new __WEBPACK_IMPORTED_MODULE_2__core_Cache__["a" /* default */]();
- },
- /** @lends clay.Texture.prototype */
- {
- getWebGLTexture: function (renderer) {
- var _gl = renderer.gl;
- var cache = this._cache;
- cache.use(renderer.__uid__);
- if (cache.miss('webgl_texture')) {
- // In a new gl context, create new texture and set dirty true
- cache.put('webgl_texture', _gl.createTexture());
- }
- if (this.dynamic) {
- this.update(renderer);
- }
- else if (cache.isDirty()) {
- this.update(renderer);
- cache.fresh();
- }
- return cache.get('webgl_texture');
- },
- bind: function () { },
- unbind: function () { },
- /**
- * Mark texture is dirty and update in the next frame
- */
- dirty: function () {
- if (this._cache) {
- this._cache.dirtyAll();
- }
- },
- update: function (renderer) { },
- // Update the common parameters of texture
- updateCommon: function (renderer) {
- var _gl = renderer.gl;
- _gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL, this.flipY);
- _gl.pixelStorei(_gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha);
- _gl.pixelStorei(_gl.UNPACK_ALIGNMENT, this.unpackAlignment);
- // Use of none-power of two texture
- // http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences
- if (this.format === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_COMPONENT) {
- this.useMipmap = false;
- }
- var sRGBExt = renderer.getGLExtension('EXT_sRGB');
- // Fallback
- if (this.format === Texture.SRGB && !sRGBExt) {
- this.format = Texture.RGB;
- }
- if (this.format === Texture.SRGB_ALPHA && !sRGBExt) {
- this.format = Texture.RGBA;
- }
- this.NPOT = !this.isPowerOfTwo();
- },
- getAvailableWrapS: function () {
- if (this.NPOT) {
- return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE;
- }
- return this.wrapS;
- },
- getAvailableWrapT: function () {
- if (this.NPOT) {
- return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE;
- }
- return this.wrapT;
- },
- getAvailableMinFilter: function () {
- var minFilter = this.minFilter;
- if (this.NPOT || !this.useMipmap) {
- if (minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_NEAREST ||
- minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_LINEAR
- ) {
- return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST;
- }
- else if (minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR ||
- minFilter === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_NEAREST
- ) {
- return __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR;
- }
- else {
- return minFilter;
- }
- }
- else {
- return minFilter;
- }
- },
- getAvailableMagFilter: function () {
- return this.magFilter;
- },
- nextHighestPowerOfTwo: function (x) {
- --x;
- for (var i = 1; i < 32; i <<= 1) {
- x = x | x >> i;
- }
- return x + 1;
- },
- /**
- * @param {clay.Renderer} renderer
- */
- dispose: function (renderer) {
- var cache = this._cache;
- cache.use(renderer.__uid__);
- var webglTexture = cache.get('webgl_texture');
- if (webglTexture) {
- renderer.gl.deleteTexture(webglTexture);
- }
- cache.deleteContext(renderer.__uid__);
- },
- /**
- * Test if image of texture is valid and loaded.
- * @return {boolean}
- */
- isRenderable: function () { },
- /**
- * Test if texture size is power of two
- * @return {boolean}
- */
- isPowerOfTwo: function () { }
- });
- Object.defineProperty(Texture.prototype, 'width', {
- get: function () {
- return this._width;
- },
- set: function (value) {
- this._width = value;
- }
- });
- Object.defineProperty(Texture.prototype, 'height', {
- get: function () {
- return this._height;
- },
- set: function (value) {
- this._height = value;
- }
- });
- /* DataType */
- /**
- * @type {number}
- */
- Texture.BYTE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BYTE;
- /**
- * @type {number}
- */
- Texture.UNSIGNED_BYTE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_BYTE;
- /**
- * @type {number}
- */
- Texture.SHORT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].SHORT;
- /**
- * @type {number}
- */
- Texture.UNSIGNED_SHORT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_SHORT;
- /**
- * @type {number}
- */
- Texture.INT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].INT;
- /**
- * @type {number}
- */
- Texture.UNSIGNED_INT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_INT;
- /**
- * @type {number}
- */
- Texture.FLOAT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FLOAT;
- /**
- * @type {number}
- */
- Texture.HALF_FLOAT = 0x8D61;
- /**
- * UNSIGNED_INT_24_8_WEBGL for WEBGL_depth_texture extension
- * @type {number}
- */
- Texture.UNSIGNED_INT_24_8_WEBGL = 34042;
- /* PixelFormat */
- /**
- * @type {number}
- */
- Texture.DEPTH_COMPONENT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_COMPONENT;
- /**
- * @type {number}
- */
- Texture.DEPTH_STENCIL = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_STENCIL;
- /**
- * @type {number}
- */
- Texture.ALPHA = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].ALPHA;
- /**
- * @type {number}
- */
- Texture.RGB = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGB;
- /**
- * @type {number}
- */
- Texture.RGBA = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGBA;
- /**
- * @type {number}
- */
- Texture.LUMINANCE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LUMINANCE;
- /**
- * @type {number}
- */
- Texture.LUMINANCE_ALPHA = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LUMINANCE_ALPHA;
- /**
- * @see https://www.khronos.org/registry/webgl/extensions/EXT_sRGB/
- * @type {number}
- */
- Texture.SRGB = 0x8C40;
- /**
- * @see https://www.khronos.org/registry/webgl/extensions/EXT_sRGB/
- * @type {number}
- */
- Texture.SRGB_ALPHA = 0x8C42;
- /* Compressed Texture */
- Texture.COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
- Texture.COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
- Texture.COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;
- Texture.COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
- /* TextureMagFilter */
- /**
- * @type {number}
- */
- Texture.NEAREST = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST;
- /**
- * @type {number}
- */
- Texture.LINEAR = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR;
- /* TextureMinFilter */
- /**
- * @type {number}
- */
- Texture.NEAREST_MIPMAP_NEAREST = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_NEAREST;
- /**
- * @type {number}
- */
- Texture.LINEAR_MIPMAP_NEAREST = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_NEAREST;
- /**
- * @type {number}
- */
- Texture.NEAREST_MIPMAP_LINEAR = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_LINEAR;
- /**
- * @type {number}
- */
- Texture.LINEAR_MIPMAP_LINEAR = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR;
- /* TextureWrapMode */
- /**
- * @type {number}
- */
- Texture.REPEAT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].REPEAT;
- /**
- * @type {number}
- */
- Texture.CLAMP_TO_EDGE = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE;
- /**
- * @type {number}
- */
- Texture.MIRRORED_REPEAT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].MIRRORED_REPEAT;
- /* harmony default export */ __webpack_exports__["a"] = (Texture);
- /***/
- }),
- /* 5 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_vendor__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_util__ = __webpack_require__(73);
- var isPowerOfTwo = __WEBPACK_IMPORTED_MODULE_3__math_util__["a" /* default */].isPowerOfTwo;
- function nearestPowerOfTwo(val) {
- return Math.pow(2, Math.round(Math.log(val) / Math.LN2));
- }
- function convertTextureToPowerOfTwo(texture, canvas) {
- // var canvas = document.createElement('canvas');
- var width = nearestPowerOfTwo(texture.width);
- var height = nearestPowerOfTwo(texture.height);
- canvas = canvas || document.createElement('canvas');
- canvas.width = width;
- canvas.height = height;
- var ctx = canvas.getContext('2d');
- ctx.drawImage(texture.image, 0, 0, width, height);
- return canvas;
- }
- /**
- * @constructor clay.Texture2D
- * @extends clay.Texture
- *
- * @example
- * ...
- * var mat = new clay.Material({
- * shader: clay.shader.library.get('clay.phong', 'diffuseMap')
- * });
- * var diffuseMap = new clay.Texture2D();
- * diffuseMap.load('assets/textures/diffuse.jpg');
- * mat.set('diffuseMap', diffuseMap);
- * ...
- * diffuseMap.success(function () {
- * // Wait for the diffuse texture loaded
- * animation.on('frame', function (frameTime) {
- * renderer.render(scene, camera);
- * });
- * });
- */
- var Texture2D = __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].extend(function () {
- return /** @lends clay.Texture2D# */ {
- /**
- * @type {?HTMLImageElement|HTMLCanvasElemnet}
- */
- // TODO mark dirty when assigned.
- image: null,
- /**
- * Pixels data. Will be ignored if image is set.
- * @type {?Uint8Array|Float32Array}
- */
- pixels: null,
- /**
- * @type {Array.<Object>}
- * @example
- * [{
- * image: mipmap0,
- * pixels: null
- * }, {
- * image: mipmap1,
- * pixels: null
- * }, ....]
- */
- mipmaps: [],
- /**
- * If convert texture to power-of-two
- * @type {boolean}
- */
- convertToPOT: false
- };
- }, {
- textureType: 'texture2D',
- update: function (renderer) {
- var _gl = renderer.gl;
- _gl.bindTexture(_gl.TEXTURE_2D, this._cache.get('webgl_texture'));
- this.updateCommon(renderer);
- var glFormat = this.format;
- var glType = this.type;
- // Convert to pot is only available when using image/canvas/video element.
- var convertToPOT = !!(this.convertToPOT
- && !this.mipmaps.length && this.image
- && (this.wrapS === __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].REPEAT || this.wrapT === __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].REPEAT)
- && this.NPOT
- );
- _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, convertToPOT ? this.wrapS : this.getAvailableWrapS());
- _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, convertToPOT ? this.wrapT : this.getAvailableWrapT());
- _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, convertToPOT ? this.magFilter : this.getAvailableMagFilter());
- _gl.texParameteri(_gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, convertToPOT ? this.minFilter : this.getAvailableMinFilter());
- var anisotropicExt = renderer.getGLExtension('EXT_texture_filter_anisotropic');
- if (anisotropicExt && this.anisotropic > 1) {
- _gl.texParameterf(_gl.TEXTURE_2D, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, this.anisotropic);
- }
- // Fallback to float type if browser don't have half float extension
- if (glType === 36193) {
- var halfFloatExt = renderer.getGLExtension('OES_texture_half_float');
- if (!halfFloatExt) {
- glType = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FLOAT;
- }
- }
- if (this.mipmaps.length) {
- var width = this.width;
- var height = this.height;
- for (var i = 0; i < this.mipmaps.length; i++) {
- var mipmap = this.mipmaps[i];
- this._updateTextureData(_gl, mipmap, i, width, height, glFormat, glType, false);
- width /= 2;
- height /= 2;
- }
- }
- else {
- this._updateTextureData(_gl, this, 0, this.width, this.height, glFormat, glType, convertToPOT);
- if (this.useMipmap && (!this.NPOT || convertToPOT)) {
- _gl.generateMipmap(_gl.TEXTURE_2D);
- }
- }
- _gl.bindTexture(_gl.TEXTURE_2D, null);
- },
- _updateTextureData: function (_gl, data, level, width, height, glFormat, glType, convertToPOT) {
- if (data.image) {
- var imgData = data.image;
- if (convertToPOT) {
- this._potCanvas = convertTextureToPowerOfTwo(this, this._potCanvas);
- imgData = this._potCanvas;
- }
- _gl.texImage2D(_gl.TEXTURE_2D, level, glFormat, glFormat, glType, imgData);
- }
- else {
- // Can be used as a blank texture when writing render to texture(RTT)
- if (
- glFormat <= __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].COMPRESSED_RGBA_S3TC_DXT5_EXT
- && glFormat >= __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].COMPRESSED_RGB_S3TC_DXT1_EXT
- ) {
- _gl.compressedTexImage2D(_gl.TEXTURE_2D, level, glFormat, width, height, 0, data.pixels);
- }
- else {
- // Is a render target if pixels is null
- _gl.texImage2D(_gl.TEXTURE_2D, level, glFormat, width, height, 0, glFormat, glType, data.pixels);
- }
- }
- },
- /**
- * @param {clay.Renderer} renderer
- * @memberOf clay.Texture2D.prototype
- */
- generateMipmap: function (renderer) {
- var _gl = renderer.gl;
- if (this.useMipmap && !this.NPOT) {
- _gl.bindTexture(_gl.TEXTURE_2D, this._cache.get('webgl_texture'));
- _gl.generateMipmap(_gl.TEXTURE_2D);
- }
- },
- isPowerOfTwo: function () {
- return isPowerOfTwo(this.width) && isPowerOfTwo(this.height);
- },
- isRenderable: function () {
- if (this.image) {
- return this.image.nodeName === 'CANVAS'
- || this.image.nodeName === 'VIDEO'
- || this.image.complete;
- }
- else {
- return !!(this.width && this.height);
- }
- },
- bind: function (renderer) {
- renderer.gl.bindTexture(renderer.gl.TEXTURE_2D, this.getWebGLTexture(renderer));
- },
- unbind: function (renderer) {
- renderer.gl.bindTexture(renderer.gl.TEXTURE_2D, null);
- },
- load: function (src, crossOrigin) {
- var image = __WEBPACK_IMPORTED_MODULE_2__core_vendor__["a" /* default */].createImage();
- if (crossOrigin) {
- image.crossOrigin = crossOrigin;
- }
- var self = this;
- image.onload = function () {
- self.dirty();
- self.trigger('success', self);
- image.onload = null;
- };
- image.onerror = function () {
- self.trigger('error', self);
- image.onerror = null;
- };
- image.src = src;
- this.image = image;
- return this;
- }
- });
- Object.defineProperty(Texture2D.prototype, 'width', {
- get: function () {
- if (this.image) {
- return this.image.width;
- }
- return this._width;
- },
- set: function (value) {
- if (this.image) {
- console.warn('Texture from image can\'t set width');
- }
- else {
- if (this._width !== value) {
- this.dirty();
- }
- this._width = value;
- }
- }
- });
- Object.defineProperty(Texture2D.prototype, 'height', {
- get: function () {
- if (this.image) {
- return this.image.height;
- }
- return this._height;
- },
- set: function (value) {
- if (this.image) {
- console.warn('Texture from image can\'t set height');
- }
- else {
- if (this._height !== value) {
- this.dirty();
- }
- this._height = value;
- }
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Texture2D);
- /***/
- }),
- /* 6 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix__ = __webpack_require__(161);
- // DEPRECATED
- /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__glmatrix__["a" /* default */]);
- /***/
- }),
- /* 7 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mixin_extend__ = __webpack_require__(110);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__mixin_notifier__ = __webpack_require__(53);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util__ = __webpack_require__(23);
- /**
- * Base class of all objects
- * @constructor
- * @alias clay.core.Base
- * @mixes clay.core.mixin.notifier
- */
- var Base = function () {
- /**
- * @type {number}
- */
- this.__uid__ = __WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].genGUID();
- };
- Base.__initializers__ = [
- function (opts) {
- __WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].extend(this, opts);
- }
- ];
- __WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].extend(Base, __WEBPACK_IMPORTED_MODULE_0__mixin_extend__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_2__util__["a" /* default */].extend(Base.prototype, __WEBPACK_IMPORTED_MODULE_1__mixin_notifier__["a" /* default */]);
- /* harmony default export */ __webpack_exports__["a"] = (Base);
- /***/
- }),
- /* 8 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_util__ = __webpack_require__(23);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_vendor__ = __webpack_require__(14);
- /**
- * Mainly do the parse and compile of shader string
- * Support shader code chunk import and export
- * Support shader semantics
- * http://www.nvidia.com/object/using_sas.html
- * https://github.com/KhronosGroup/collada2json/issues/45
- */
- var uniformRegex = /uniform\s+(bool|float|int|vec2|vec3|vec4|ivec2|ivec3|ivec4|mat2|mat3|mat4|sampler2D|samplerCube)\s+([\s\S]*?);/g;
- var attributeRegex = /attribute\s+(float|int|vec2|vec3|vec4)\s+([\s\S]*?);/g;
- // Only parse number define.
- var defineRegex = /#define\s+(\w+)?(\s+[\d-.]+)?\s*;?\s*\n/g;
- var uniformTypeMap = {
- 'bool': '1i',
- 'int': '1i',
- 'sampler2D': 't',
- 'samplerCube': 't',
- 'float': '1f',
- 'vec2': '2f',
- 'vec3': '3f',
- 'vec4': '4f',
- 'ivec2': '2i',
- 'ivec3': '3i',
- 'ivec4': '4i',
- 'mat2': 'm2',
- 'mat3': 'm3',
- 'mat4': 'm4'
- };
- function createZeroArray(len) {
- var arr = [];
- for (var i = 0; i < len; i++) {
- arr[i] = 0;
- }
- return arr;
- }
- var uniformValueConstructor = {
- 'bool': function () { return true; },
- 'int': function () { return 0; },
- 'float': function () { return 0; },
- 'sampler2D': function () { return null; },
- 'samplerCube': function () { return null; },
- 'vec2': function () { return createZeroArray(2); },
- 'vec3': function () { return createZeroArray(3); },
- 'vec4': function () { return createZeroArray(4); },
- 'ivec2': function () { return createZeroArray(2); },
- 'ivec3': function () { return createZeroArray(3); },
- 'ivec4': function () { return createZeroArray(4); },
- 'mat2': function () { return createZeroArray(4); },
- 'mat3': function () { return createZeroArray(9); },
- 'mat4': function () { return createZeroArray(16); },
- 'array': function () { return []; }
- };
- var attributeSemantics = [
- 'POSITION',
- 'NORMAL',
- 'BINORMAL',
- 'TANGENT',
- 'TEXCOORD',
- 'TEXCOORD_0',
- 'TEXCOORD_1',
- 'COLOR',
- // Skinning
- // https://github.com/KhronosGroup/glTF/blob/master/specification/README.md#semantics
- 'JOINT',
- 'WEIGHT'
- ];
- var uniformSemantics = [
- 'SKIN_MATRIX',
- // Information about viewport
- 'VIEWPORT_SIZE',
- 'VIEWPORT',
- 'DEVICEPIXELRATIO',
- // Window size for window relative coordinate
- // https://www.opengl.org/sdk/docs/man/html/gl_FragCoord.xhtml
- 'WINDOW_SIZE',
- // Infomation about camera
- 'NEAR',
- 'FAR',
- // Time
- 'TIME'
- ];
- var matrixSemantics = [
- 'WORLD',
- 'VIEW',
- 'PROJECTION',
- 'WORLDVIEW',
- 'VIEWPROJECTION',
- 'WORLDVIEWPROJECTION',
- 'WORLDINVERSE',
- 'VIEWINVERSE',
- 'PROJECTIONINVERSE',
- 'WORLDVIEWINVERSE',
- 'VIEWPROJECTIONINVERSE',
- 'WORLDVIEWPROJECTIONINVERSE',
- 'WORLDTRANSPOSE',
- 'VIEWTRANSPOSE',
- 'PROJECTIONTRANSPOSE',
- 'WORLDVIEWTRANSPOSE',
- 'VIEWPROJECTIONTRANSPOSE',
- 'WORLDVIEWPROJECTIONTRANSPOSE',
- 'WORLDINVERSETRANSPOSE',
- 'VIEWINVERSETRANSPOSE',
- 'PROJECTIONINVERSETRANSPOSE',
- 'WORLDVIEWINVERSETRANSPOSE',
- 'VIEWPROJECTIONINVERSETRANSPOSE',
- 'WORLDVIEWPROJECTIONINVERSETRANSPOSE'
- ];
- var attributeSizeMap = {
- // WebGL does not support integer attributes
- 'vec4': 4,
- 'vec3': 3,
- 'vec2': 2,
- 'float': 1
- };
- var shaderIDCache = {};
- var shaderCodeCache = {};
- function getShaderID(vertex, fragment) {
- var key = 'vertex:' + vertex + 'fragment:' + fragment;
- if (shaderIDCache[key]) {
- return shaderIDCache[key];
- }
- var id = __WEBPACK_IMPORTED_MODULE_0__core_util__["a" /* default */].genGUID();
- shaderIDCache[key] = id;
- shaderCodeCache[id] = {
- vertex: vertex,
- fragment: fragment
- };
- return id;
- }
- function removeComment(code) {
- return code.replace(/[ \t]*\/\/.*\n/g, '') // remove //
- .replace(/[ \t]*\/\*[\s\S]*?\*\//g, ''); // remove /* */
- }
- function logSyntaxError() {
- console.error('Wrong uniform/attributes syntax');
- }
- function parseDeclarations(type, line) {
- var speratorsRegexp = /[,=\(\):]/;
- var tokens = line
- // Convert `symbol: [1,2,3]` to `symbol: vec3(1,2,3)`
- .replace(/:\s*\[\s*(.*)\s*\]/g, '=' + type + '($1)')
- .replace(/\s+/g, '')
- .split(/(?=[,=\(\):])/g);
- var newTokens = [];
- for (var i = 0; i < tokens.length; i++) {
- if (tokens[i].match(speratorsRegexp)) {
- newTokens.push(
- tokens[i].charAt(0),
- tokens[i].slice(1)
- );
- }
- else {
- newTokens.push(tokens[i]);
- }
- }
- tokens = newTokens;
- var TYPE_SYMBOL = 0;
- var TYPE_ASSIGN = 1;
- var TYPE_VEC = 2;
- var TYPE_ARR = 3;
- var TYPE_SEMANTIC = 4;
- var TYPE_NORMAL = 5;
- var opType = TYPE_SYMBOL;
- var declarations = {};
- var declarationValue = null;
- var currentDeclaration;
- addSymbol(tokens[0]);
- function addSymbol(symbol) {
- if (!symbol) {
- logSyntaxError();
- }
- var arrResult = symbol.match(/\[(.*?)\]/);
- currentDeclaration = symbol.replace(/\[(.*?)\]/, '');
- declarations[currentDeclaration] = {};
- if (arrResult) {
- declarations[currentDeclaration].isArray = true;
- declarations[currentDeclaration].arraySize = arrResult[1];
- }
- }
- for (var i = 1; i < tokens.length; i++) {
- var token = tokens[i];
- if (!token) { // Empty token;
- continue;
- }
- if (token === '=') {
- if (opType !== TYPE_SYMBOL
- && opType !== TYPE_ARR) {
- logSyntaxError();
- break;
- }
- opType = TYPE_ASSIGN;
- continue;
- }
- else if (token === ':') {
- opType = TYPE_SEMANTIC;
- continue;
- }
- else if (token === ',') {
- if (opType === TYPE_VEC) {
- if (!(declarationValue instanceof Array)) {
- logSyntaxError();
- break;
- }
- declarationValue.push(+tokens[++i]);
- }
- else {
- opType = TYPE_NORMAL;
- }
- continue;
- }
- else if (token === ')') {
- declarations[currentDeclaration].value = new __WEBPACK_IMPORTED_MODULE_1__core_vendor__["a" /* default */].Float32Array(declarationValue);
- declarationValue = null;
- opType = TYPE_NORMAL;
- continue;
- }
- else if (token === '(') {
- if (opType !== TYPE_VEC) {
- logSyntaxError();
- break;
- }
- if (!(declarationValue instanceof Array)) {
- logSyntaxError();
- break;
- }
- declarationValue.push(+tokens[++i]);
- continue;
- }
- else if (token.indexOf('vec') >= 0) {
- if (opType !== TYPE_ASSIGN
- // Compatitable with old syntax `symbol: [1,2,3]`
- && opType !== TYPE_SEMANTIC) {
- logSyntaxError();
- break;
- }
- opType = TYPE_VEC;
- declarationValue = [];
- continue;
- }
- else if (opType === TYPE_ASSIGN) {
- if (type === 'bool') {
- declarations[currentDeclaration].value = token === 'true';
- }
- else {
- declarations[currentDeclaration].value = parseFloat(token);
- }
- declarationValue = null;
- continue;
- }
- else if (opType === TYPE_SEMANTIC) {
- var semantic = token;
- if (attributeSemantics.indexOf(semantic) >= 0
- || uniformSemantics.indexOf(semantic) >= 0
- || matrixSemantics.indexOf(semantic) >= 0
- ) {
- declarations[currentDeclaration].semantic = semantic;
- }
- else if (semantic === 'ignore' || semantic === 'unconfigurable') {
- declarations[currentDeclaration].ignore = true;
- }
- else {
- // Try to parse as a default tvalue.
- if (type === 'bool') {
- declarations[currentDeclaration].value = semantic === 'true';
- }
- else {
- declarations[currentDeclaration].value = parseFloat(semantic);
- }
- }
- continue;
- }
- // treat as symbol.
- addSymbol(token);
- opType = TYPE_SYMBOL;
- }
- return declarations;
- }
- /**
- * @constructor
- * @extends clay.core.Base
- * @alias clay.Shader
- * @param {string} vertex
- * @param {string} fragment
- * @example
- * // Create a phong shader
- * var shader = new clay.Shader(
- * clay.Shader.source('clay.standard.vertex'),
- * clay.Shader.source('clay.standard.fragment')
- * );
- */
- function Shader(vertex, fragment) {
- // First argument can be { vertex, fragment }
- if (typeof vertex === 'object') {
- fragment = vertex.fragment;
- vertex = vertex.vertex;
- }
- vertex = removeComment(vertex);
- fragment = removeComment(fragment);
- this._shaderID = getShaderID(vertex, fragment);
- this._vertexCode = Shader.parseImport(vertex);
- this._fragmentCode = Shader.parseImport(fragment);
- /**
- * @readOnly
- */
- this.attributeSemantics = {};
- /**
- * @readOnly
- */
- this.matrixSemantics = {};
- /**
- * @readOnly
- */
- this.uniformSemantics = {};
- /**
- * @readOnly
- */
- this.matrixSemanticKeys = [];
- /**
- * @readOnly
- */
- this.uniformTemplates = {};
- /**
- * @readOnly
- */
- this.attributes = {};
- /**
- * @readOnly
- */
- this.textures = {};
- /**
- * @readOnly
- */
- this.vertexDefines = {};
- /**
- * @readOnly
- */
- this.fragmentDefines = {};
- this._parseAttributes();
- this._parseUniforms();
- this._parseDefines();
- }
- Shader.prototype = {
- constructor: Shader,
- // Create a new uniform instance for material
- createUniforms: function () {
- var uniforms = {};
- for (var symbol in this.uniformTemplates) {
- var uniformTpl = this.uniformTemplates[symbol];
- uniforms[symbol] = {
- type: uniformTpl.type,
- value: uniformTpl.value()
- };
- }
- return uniforms;
- },
- _parseImport: function () {
- this._vertexCode = Shader.parseImport(this.vertex);
- this._fragmentCode = Shader.parseImport(this.fragment);
- },
- _addSemanticUniform: function (symbol, uniformType, semantic) {
- // This case is only for SKIN_MATRIX
- // TODO
- if (attributeSemantics.indexOf(semantic) >= 0) {
- this.attributeSemantics[semantic] = {
- symbol: symbol,
- type: uniformType
- };
- }
- else if (matrixSemantics.indexOf(semantic) >= 0) {
- var isTranspose = false;
- var semanticNoTranspose = semantic;
- if (semantic.match(/TRANSPOSE$/)) {
- isTranspose = true;
- semanticNoTranspose = semantic.slice(0, -9);
- }
- this.matrixSemantics[semantic] = {
- symbol: symbol,
- type: uniformType,
- isTranspose: isTranspose,
- semanticNoTranspose: semanticNoTranspose
- };
- }
- else if (uniformSemantics.indexOf(semantic) >= 0) {
- this.uniformSemantics[semantic] = {
- symbol: symbol,
- type: uniformType
- };
- }
- },
- _addMaterialUniform: function (symbol, type, uniformType, defaultValueFunc, isArray, materialUniforms) {
- materialUniforms[symbol] = {
- type: uniformType,
- value: isArray ? uniformValueConstructor['array'] : (defaultValueFunc || uniformValueConstructor[type]),
- semantic: null
- };
- },
- _parseUniforms: function () {
- var uniforms = {};
- var self = this;
- var shaderType = 'vertex';
- this._uniformList = [];
- this._vertexCode = this._vertexCode.replace(uniformRegex, _uniformParser);
- shaderType = 'fragment';
- this._fragmentCode = this._fragmentCode.replace(uniformRegex, _uniformParser);
- self.matrixSemanticKeys = Object.keys(this.matrixSemantics);
- function makeDefaultValueFunc(value) {
- return value != null ? function () { return value; } : null;
- }
- function _uniformParser(str, type, content) {
- var declaredUniforms = parseDeclarations(type, content);
- var uniformMainStr = [];
- for (var symbol in declaredUniforms) {
- var uniformInfo = declaredUniforms[symbol];
- var semantic = uniformInfo.semantic;
- var tmpStr = symbol;
- var uniformType = uniformTypeMap[type];
- var defaultValueFunc = makeDefaultValueFunc(declaredUniforms[symbol].value);
- if (declaredUniforms[symbol].isArray) {
- tmpStr += '[' + declaredUniforms[symbol].arraySize + ']';
- uniformType += 'v';
- }
- uniformMainStr.push(tmpStr);
- self._uniformList.push(symbol);
- if (!uniformInfo.ignore) {
- if (type === 'sampler2D' || type === 'samplerCube') {
- // Texture is default disabled
- self.textures[symbol] = {
- shaderType: shaderType,
- type: type
- };
- }
- if (semantic) {
- // TODO Should not declare multiple symbols if have semantic.
- self._addSemanticUniform(symbol, uniformType, semantic);
- }
- else {
- self._addMaterialUniform(
- symbol, type, uniformType, defaultValueFunc,
- declaredUniforms[symbol].isArray, uniforms
- );
- }
- }
- }
- return uniformMainStr.length > 0
- ? 'uniform ' + type + ' ' + uniformMainStr.join(',') + ';\n' : '';
- }
- this.uniformTemplates = uniforms;
- },
- _parseAttributes: function () {
- var attributes = {};
- var self = this;
- this._vertexCode = this._vertexCode.replace(attributeRegex, _attributeParser);
- function _attributeParser(str, type, content) {
- var declaredAttributes = parseDeclarations(type, content);
- var size = attributeSizeMap[type] || 1;
- var attributeMainStr = [];
- for (var symbol in declaredAttributes) {
- var semantic = declaredAttributes[symbol].semantic;
- attributes[symbol] = {
- // TODO Can only be float
- type: 'float',
- size: size,
- semantic: semantic || null
- };
- // TODO Should not declare multiple symbols if have semantic.
- if (semantic) {
- if (attributeSemantics.indexOf(semantic) < 0) {
- throw new Error('Unkown semantic "' + semantic + '"');
- }
- else {
- self.attributeSemantics[semantic] = {
- symbol: symbol,
- type: type
- };
- }
- }
- attributeMainStr.push(symbol);
- }
- return 'attribute ' + type + ' ' + attributeMainStr.join(',') + ';\n';
- }
- this.attributes = attributes;
- },
- _parseDefines: function () {
- var self = this;
- var shaderType = 'vertex';
- this._vertexCode = this._vertexCode.replace(defineRegex, _defineParser);
- shaderType = 'fragment';
- this._fragmentCode = this._fragmentCode.replace(defineRegex, _defineParser);
- function _defineParser(str, symbol, value) {
- var defines = shaderType === 'vertex' ? self.vertexDefines : self.fragmentDefines;
- if (!defines[symbol]) { // Haven't been defined by user
- if (value === 'false') {
- defines[symbol] = false;
- }
- else if (value === 'true') {
- defines[symbol] = true;
- }
- else {
- defines[symbol] = value
- // If can parse to float
- ? (isNaN(parseFloat(value)) ? value.trim() : parseFloat(value))
- : null;
- }
- }
- return '';
- }
- },
- /**
- * Clone a new shader
- * @return {clay.Shader}
- */
- clone: function () {
- var code = shaderCodeCache[this._shaderID];
- var shader = new Shader(code.vertex, code.fragment);
- return shader;
- }
- };
- if (Object.defineProperty) {
- Object.defineProperty(Shader.prototype, 'shaderID', {
- get: function () {
- return this._shaderID;
- }
- });
- Object.defineProperty(Shader.prototype, 'vertex', {
- get: function () {
- return this._vertexCode;
- }
- });
- Object.defineProperty(Shader.prototype, 'fragment', {
- get: function () {
- return this._fragmentCode;
- }
- });
- Object.defineProperty(Shader.prototype, 'uniforms', {
- get: function () {
- return this._uniformList;
- }
- });
- }
- var importRegex = /(@import)\s*([0-9a-zA-Z_\-\.]*)/g;
- Shader.parseImport = function (shaderStr) {
- shaderStr = shaderStr.replace(importRegex, function (str, importSymbol, importName) {
- var str = Shader.source(importName);
- if (str) {
- // Recursively parse
- return Shader.parseImport(str);
- }
- else {
- console.error('Shader chunk "' + importName + '" not existed in library');
- return '';
- }
- });
- return shaderStr;
- };
- var exportRegex = /(@export)\s*([0-9a-zA-Z_\-\.]*)\s*\n([\s\S]*?)@end/g;
- /**
- * Import shader source
- * @param {string} shaderStr
- * @memberOf clay.Shader
- */
- Shader['import'] = function (shaderStr) {
- shaderStr.replace(exportRegex, function (str, exportSymbol, exportName, code) {
- var code = code.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+\x24)/g, '');
- if (code) {
- var parts = exportName.split('.');
- var obj = Shader.codes;
- var i = 0;
- var key;
- while (i < parts.length - 1) {
- key = parts[i++];
- if (!obj[key]) {
- obj[key] = {};
- }
- obj = obj[key];
- }
- key = parts[i];
- obj[key] = code;
- }
- return code;
- });
- };
- /**
- * Library to store all the loaded shader codes
- * @type {Object}
- * @readOnly
- * @memberOf clay.Shader
- */
- Shader.codes = {};
- /**
- * Get shader source
- * @param {string} name
- * @return {string}
- */
- Shader.source = function (name) {
- var parts = name.split('.');
- var obj = Shader.codes;
- var i = 0;
- while (obj && i < parts.length) {
- var key = parts[i++];
- obj = obj[key];
- }
- if (typeof obj !== 'string') {
- // FIXME Use default instead
- console.error('Shader "' + name + '" not existed in library');
- return '';
- }
- return obj;
- };
- /* harmony default export */ __webpack_exports__["a"] = (Shader);
- /***/
- }),
- /* 9 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__ = __webpack_require__(21);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__ = __webpack_require__(12);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__glmatrix_quat__ = __webpack_require__(55);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__glmatrix_mat3__ = __webpack_require__(34);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Vector3__ = __webpack_require__(3);
- /**
- * @constructor
- * @alias clay.Matrix4
- */
- var Matrix4 = function () {
- this._axisX = new __WEBPACK_IMPORTED_MODULE_4__Vector3__["a" /* default */]();
- this._axisY = new __WEBPACK_IMPORTED_MODULE_4__Vector3__["a" /* default */]();
- this._axisZ = new __WEBPACK_IMPORTED_MODULE_4__Vector3__["a" /* default */]();
- /**
- * Storage of Matrix4
- * @name array
- * @type {Float32Array}
- * @memberOf clay.Matrix4#
- */
- this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].create();
- /**
- * @name _dirty
- * @type {boolean}
- * @memberOf clay.Matrix4#
- */
- this._dirty = true;
- };
- Matrix4.prototype = {
- constructor: Matrix4,
- /**
- * Set components from array
- * @param {Float32Array|number[]} arr
- */
- setArray: function (arr) {
- for (var i = 0; i < this.array.length; i++) {
- this.array[i] = arr[i];
- }
- this._dirty = true;
- return this;
- },
- /**
- * Calculate the adjugate of self, in-place
- * @return {clay.Matrix4}
- */
- adjoint: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].adjoint(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Clone a new Matrix4
- * @return {clay.Matrix4}
- */
- clone: function () {
- return (new Matrix4()).copy(this);
- },
- /**
- * Copy from b
- * @param {clay.Matrix4} b
- * @return {clay.Matrix4}
- */
- copy: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].copy(this.array, a.array);
- this._dirty = true;
- return this;
- },
- /**
- * Calculate matrix determinant
- * @return {number}
- */
- determinant: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].determinant(this.array);
- },
- /**
- * Set upper 3x3 part from quaternion
- * @param {clay.Quaternion} q
- * @return {clay.Matrix4}
- */
- fromQuat: function (q) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].fromQuat(this.array, q.array);
- this._dirty = true;
- return this;
- },
- /**
- * Set from a quaternion rotation and a vector translation
- * @param {clay.Quaternion} q
- * @param {clay.Vector3} v
- * @return {clay.Matrix4}
- */
- fromRotationTranslation: function (q, v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].fromRotationTranslation(this.array, q.array, v.array);
- this._dirty = true;
- return this;
- },
- /**
- * Set from Matrix2d, it is used when converting a 2d shape to 3d space.
- * In 3d space it is equivalent to ranslate on xy plane and rotate about z axis
- * @param {clay.Matrix2d} m2d
- * @return {clay.Matrix4}
- */
- fromMat2d: function (m2d) {
- Matrix4.fromMat2d(this, m2d);
- return this;
- },
- /**
- * Set from frustum bounds
- * @param {number} left
- * @param {number} right
- * @param {number} bottom
- * @param {number} top
- * @param {number} near
- * @param {number} far
- * @return {clay.Matrix4}
- */
- frustum: function (left, right, bottom, top, near, far) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].frustum(this.array, left, right, bottom, top, near, far);
- this._dirty = true;
- return this;
- },
- /**
- * Set to a identity matrix
- * @return {clay.Matrix4}
- */
- identity: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].identity(this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Invert self
- * @return {clay.Matrix4}
- */
- invert: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].invert(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Set as a matrix with the given eye position, focal point, and up axis
- * @param {clay.Vector3} eye
- * @param {clay.Vector3} center
- * @param {clay.Vector3} up
- * @return {clay.Matrix4}
- */
- lookAt: function (eye, center, up) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].lookAt(this.array, eye.array, center.array, up.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for mutiply
- * @param {clay.Matrix4} b
- * @return {clay.Matrix4}
- */
- mul: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].mul(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for multiplyLeft
- * @param {clay.Matrix4} a
- * @return {clay.Matrix4}
- */
- mulLeft: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].mul(this.array, a.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Multiply self and b
- * @param {clay.Matrix4} b
- * @return {clay.Matrix4}
- */
- multiply: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].multiply(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Multiply a and self, a is on the left
- * @param {clay.Matrix3} a
- * @return {clay.Matrix3}
- */
- multiplyLeft: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].multiply(this.array, a.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Set as a orthographic projection matrix
- * @param {number} left
- * @param {number} right
- * @param {number} bottom
- * @param {number} top
- * @param {number} near
- * @param {number} far
- * @return {clay.Matrix4}
- */
- ortho: function (left, right, bottom, top, near, far) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].ortho(this.array, left, right, bottom, top, near, far);
- this._dirty = true;
- return this;
- },
- /**
- * Set as a perspective projection matrix
- * @param {number} fovy
- * @param {number} aspect
- * @param {number} near
- * @param {number} far
- * @return {clay.Matrix4}
- */
- perspective: function (fovy, aspect, near, far) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].perspective(this.array, fovy, aspect, near, far);
- this._dirty = true;
- return this;
- },
- /**
- * Rotate self by rad about axis.
- * Equal to right-multiply a rotaion matrix
- * @param {number} rad
- * @param {clay.Vector3} axis
- * @return {clay.Matrix4}
- */
- rotate: function (rad, axis) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotate(this.array, this.array, rad, axis.array);
- this._dirty = true;
- return this;
- },
- /**
- * Rotate self by a given radian about X axis.
- * Equal to right-multiply a rotaion matrix
- * @param {number} rad
- * @return {clay.Matrix4}
- */
- rotateX: function (rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateX(this.array, this.array, rad);
- this._dirty = true;
- return this;
- },
- /**
- * Rotate self by a given radian about Y axis.
- * Equal to right-multiply a rotaion matrix
- * @param {number} rad
- * @return {clay.Matrix4}
- */
- rotateY: function (rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateY(this.array, this.array, rad);
- this._dirty = true;
- return this;
- },
- /**
- * Rotate self by a given radian about Z axis.
- * Equal to right-multiply a rotaion matrix
- * @param {number} rad
- * @return {clay.Matrix4}
- */
- rotateZ: function (rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateZ(this.array, this.array, rad);
- this._dirty = true;
- return this;
- },
- /**
- * Scale self by s
- * Equal to right-multiply a scale matrix
- * @param {clay.Vector3} s
- * @return {clay.Matrix4}
- */
- scale: function (v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].scale(this.array, this.array, v.array);
- this._dirty = true;
- return this;
- },
- /**
- * Translate self by v.
- * Equal to right-multiply a translate matrix
- * @param {clay.Vector3} v
- * @return {clay.Matrix4}
- */
- translate: function (v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].translate(this.array, this.array, v.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transpose self, in-place.
- * @return {clay.Matrix2}
- */
- transpose: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].transpose(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Decompose a matrix to SRT
- * @param {clay.Vector3} [scale]
- * @param {clay.Quaternion} rotation
- * @param {clay.Vector} position
- * @see http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.matrix.decompose.aspx
- */
- decomposeMatrix: (function () {
- var x = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- var y = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- var z = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- var m3 = __WEBPACK_IMPORTED_MODULE_3__glmatrix_mat3__["a" /* default */].create();
- return function (scale, rotation, position) {
- var el = this.array;
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set(x, el[0], el[1], el[2]);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set(y, el[4], el[5], el[6]);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set(z, el[8], el[9], el[10]);
- var sx = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].length(x);
- var sy = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].length(y);
- var sz = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].length(z);
- // if determine is negative, we need to invert one scale
- var det = this.determinant();
- if (det < 0) {
- sx = -sx;
- }
- if (scale) {
- scale.set(sx, sy, sz);
- }
- position.set(el[12], el[13], el[14]);
- __WEBPACK_IMPORTED_MODULE_3__glmatrix_mat3__["a" /* default */].fromMat4(m3, el);
- // Not like mat4, mat3 in glmatrix seems to be row-based
- // Seems fixed in gl-matrix 2.2.2
- // https://github.com/toji/gl-matrix/issues/114
- // mat3.transpose(m3, m3);
- m3[0] /= sx;
- m3[1] /= sx;
- m3[2] /= sx;
- m3[3] /= sy;
- m3[4] /= sy;
- m3[5] /= sy;
- m3[6] /= sz;
- m3[7] /= sz;
- m3[8] /= sz;
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_quat__["a" /* default */].fromMat3(rotation.array, m3);
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_quat__["a" /* default */].normalize(rotation.array, rotation.array);
- rotation._dirty = true;
- position._dirty = true;
- };
- })(),
- toString: function () {
- return '[' + Array.prototype.join.call(this.array, ',') + ']';
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array);
- }
- };
- var defineProperty = Object.defineProperty;
- if (defineProperty) {
- var proto = Matrix4.prototype;
- /**
- * Z Axis of local transform
- * @name z
- * @type {clay.Vector3}
- * @memberOf clay.Matrix4
- * @instance
- */
- defineProperty(proto, 'z', {
- get: function () {
- var el = this.array;
- this._axisZ.set(el[8], el[9], el[10]);
- return this._axisZ;
- },
- set: function (v) {
- // TODO Here has a problem
- // If only set an item of vector will not work
- var el = this.array;
- v = v.array;
- el[8] = v[0];
- el[9] = v[1];
- el[10] = v[2];
- this._dirty = true;
- }
- });
- /**
- * Y Axis of local transform
- * @name y
- * @type {clay.Vector3}
- * @memberOf clay.Matrix4
- * @instance
- */
- defineProperty(proto, 'y', {
- get: function () {
- var el = this.array;
- this._axisY.set(el[4], el[5], el[6]);
- return this._axisY;
- },
- set: function (v) {
- var el = this.array;
- v = v.array;
- el[4] = v[0];
- el[5] = v[1];
- el[6] = v[2];
- this._dirty = true;
- }
- });
- /**
- * X Axis of local transform
- * @name x
- * @type {clay.Vector3}
- * @memberOf clay.Matrix4
- * @instance
- */
- defineProperty(proto, 'x', {
- get: function () {
- var el = this.array;
- this._axisX.set(el[0], el[1], el[2]);
- return this._axisX;
- },
- set: function (v) {
- var el = this.array;
- v = v.array;
- el[0] = v[0];
- el[1] = v[1];
- el[2] = v[2];
- this._dirty = true;
- }
- })
- }
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @return {clay.Matrix4}
- */
- Matrix4.adjoint = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].adjoint(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @return {clay.Matrix4}
- */
- Matrix4.copy = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].copy(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} a
- * @return {number}
- */
- Matrix4.determinant = function (a) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].determinant(a.array);
- };
- /**
- * @param {clay.Matrix4} out
- * @return {clay.Matrix4}
- */
- Matrix4.identity = function (out) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].identity(out.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {number} left
- * @param {number} right
- * @param {number} bottom
- * @param {number} top
- * @param {number} near
- * @param {number} far
- * @return {clay.Matrix4}
- */
- Matrix4.ortho = function (out, left, right, bottom, top, near, far) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].ortho(out.array, left, right, bottom, top, near, far);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {number} fovy
- * @param {number} aspect
- * @param {number} near
- * @param {number} far
- * @return {clay.Matrix4}
- */
- Matrix4.perspective = function (out, fovy, aspect, near, far) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].perspective(out.array, fovy, aspect, near, far);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Vector3} eye
- * @param {clay.Vector3} center
- * @param {clay.Vector3} up
- * @return {clay.Matrix4}
- */
- Matrix4.lookAt = function (out, eye, center, up) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].lookAt(out.array, eye.array, center.array, up.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @return {clay.Matrix4}
- */
- Matrix4.invert = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].invert(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @param {clay.Matrix4} b
- * @return {clay.Matrix4}
- */
- Matrix4.mul = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].mul(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @param {clay.Matrix4} b
- * @return {clay.Matrix4}
- */
- Matrix4.multiply = Matrix4.mul;
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Quaternion} q
- * @return {clay.Matrix4}
- */
- Matrix4.fromQuat = function (out, q) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].fromQuat(out.array, q.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Quaternion} q
- * @param {clay.Vector3} v
- * @return {clay.Matrix4}
- */
- Matrix4.fromRotationTranslation = function (out, q, v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].fromRotationTranslation(out.array, q.array, v.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} m4
- * @param {clay.Matrix2d} m2d
- * @return {clay.Matrix4}
- */
- Matrix4.fromMat2d = function (m4, m2d) {
- m4._dirty = true;
- var m2d = m2d.array;
- var m4 = m4.array;
- m4[0] = m2d[0];
- m4[4] = m2d[2];
- m4[12] = m2d[4];
- m4[1] = m2d[1];
- m4[5] = m2d[3];
- m4[13] = m2d[5];
- return m4;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @param {number} rad
- * @param {clay.Vector3} axis
- * @return {clay.Matrix4}
- */
- Matrix4.rotate = function (out, a, rad, axis) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotate(out.array, a.array, rad, axis.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @param {number} rad
- * @return {clay.Matrix4}
- */
- Matrix4.rotateX = function (out, a, rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateX(out.array, a.array, rad);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @param {number} rad
- * @return {clay.Matrix4}
- */
- Matrix4.rotateY = function (out, a, rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateY(out.array, a.array, rad);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @param {number} rad
- * @return {clay.Matrix4}
- */
- Matrix4.rotateZ = function (out, a, rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].rotateZ(out.array, a.array, rad);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @param {clay.Vector3} v
- * @return {clay.Matrix4}
- */
- Matrix4.scale = function (out, a, v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].scale(out.array, a.array, v.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @return {clay.Matrix4}
- */
- Matrix4.transpose = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].transpose(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix4} out
- * @param {clay.Matrix4} a
- * @param {clay.Vector3} v
- * @return {clay.Matrix4}
- */
- Matrix4.translate = function (out, a, v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat4__["a" /* default */].translate(out.array, a.array, v.array);
- out._dirty = true;
- return out;
- };
- /* harmony default export */ __webpack_exports__["a"] = (Matrix4);
- /***/
- }),
- /* 10 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__TextureCube__ = __webpack_require__(27);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_glenum__ = __webpack_require__(11);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_Cache__ = __webpack_require__(57);
- var KEY_FRAMEBUFFER = 'framebuffer';
- var KEY_RENDERBUFFER = 'renderbuffer';
- var KEY_RENDERBUFFER_WIDTH = KEY_RENDERBUFFER + '_width';
- var KEY_RENDERBUFFER_HEIGHT = KEY_RENDERBUFFER + '_height';
- var KEY_RENDERBUFFER_ATTACHED = KEY_RENDERBUFFER + '_attached';
- var KEY_DEPTHTEXTURE_ATTACHED = 'depthtexture_attached';
- var GL_FRAMEBUFFER = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].FRAMEBUFFER;
- var GL_RENDERBUFFER = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].RENDERBUFFER;
- var GL_DEPTH_ATTACHMENT = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_ATTACHMENT;
- var GL_COLOR_ATTACHMENT0 = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].COLOR_ATTACHMENT0;
- /**
- * @constructor clay.FrameBuffer
- * @extends clay.core.Base
- */
- var FrameBuffer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(
- /** @lends clay.FrameBuffer# */
- {
- /**
- * If use depth buffer
- * @type {boolean}
- */
- depthBuffer: true,
- /**
- * @type {Object}
- */
- viewport: null,
- _width: 0,
- _height: 0,
- _textures: null,
- _boundRenderer: null,
- }, function () {
- // Use cache
- this._cache = new __WEBPACK_IMPORTED_MODULE_4__core_Cache__["a" /* default */]();
- this._textures = {};
- },
- /**@lends clay.FrameBuffer.prototype. */
- {
- /**
- * Get attached texture width
- * {number}
- */
- // FIXME Can't use before #bind
- getTextureWidth: function () {
- return this._width;
- },
- /**
- * Get attached texture height
- * {number}
- */
- getTextureHeight: function () {
- return this._height;
- },
- /**
- * Bind the framebuffer to given renderer before rendering
- * @param {clay.Renderer} renderer
- */
- bind: function (renderer) {
- if (renderer.__currentFrameBuffer) {
- // Already bound
- if (renderer.__currentFrameBuffer === this) {
- return;
- }
- console.warn('Renderer already bound with another framebuffer. Unbind it first');
- }
- renderer.__currentFrameBuffer = this;
- var _gl = renderer.gl;
- _gl.bindFramebuffer(GL_FRAMEBUFFER, this._getFrameBufferGL(renderer));
- this._boundRenderer = renderer;
- var cache = this._cache;
- cache.put('viewport', renderer.viewport);
- var hasTextureAttached = false;
- var width;
- var height;
- for (var attachment in this._textures) {
- hasTextureAttached = true;
- var obj = this._textures[attachment];
- if (obj) {
- // TODO Do width, height checking, make sure size are same
- width = obj.texture.width;
- height = obj.texture.height;
- // Attach textures
- this._doAttach(renderer, obj.texture, attachment, obj.target);
- }
- }
- this._width = width;
- this._height = height;
- if (!hasTextureAttached && this.depthBuffer) {
- console.error('Must attach texture before bind, or renderbuffer may have incorrect width and height.')
- }
- if (this.viewport) {
- renderer.setViewport(this.viewport);
- }
- else {
- renderer.setViewport(0, 0, width, height, 1);
- }
- var attachedTextures = cache.get('attached_textures');
- if (attachedTextures) {
- for (var attachment in attachedTextures) {
- if (!this._textures[attachment]) {
- var target = attachedTextures[attachment];
- this._doDetach(_gl, attachment, target);
- }
- }
- }
- if (!cache.get(KEY_DEPTHTEXTURE_ATTACHED) && this.depthBuffer) {
- // Create a new render buffer
- if (cache.miss(KEY_RENDERBUFFER)) {
- cache.put(KEY_RENDERBUFFER, _gl.createRenderbuffer());
- }
- var renderbuffer = cache.get(KEY_RENDERBUFFER);
- if (width !== cache.get(KEY_RENDERBUFFER_WIDTH)
- || height !== cache.get(KEY_RENDERBUFFER_HEIGHT)) {
- _gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
- _gl.renderbufferStorage(GL_RENDERBUFFER, _gl.DEPTH_COMPONENT16, width, height);
- cache.put(KEY_RENDERBUFFER_WIDTH, width);
- cache.put(KEY_RENDERBUFFER_HEIGHT, height);
- _gl.bindRenderbuffer(GL_RENDERBUFFER, null);
- }
- if (!cache.get(KEY_RENDERBUFFER_ATTACHED)) {
- _gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbuffer);
- cache.put(KEY_RENDERBUFFER_ATTACHED, true);
- }
- }
- },
- /**
- * Unbind the frame buffer after rendering
- * @param {clay.Renderer} renderer
- */
- unbind: function (renderer) {
- // Remove status record on renderer
- renderer.__currentFrameBuffer = null;
- var _gl = renderer.gl;
- _gl.bindFramebuffer(GL_FRAMEBUFFER, null);
- this._boundRenderer = null;
- this._cache.use(renderer.__uid__);
- var viewport = this._cache.get('viewport');
- // Reset viewport;
- if (viewport) {
- renderer.setViewport(viewport);
- }
- this.updateMipmap(renderer);
- },
- // Because the data of texture is changed over time,
- // Here update the mipmaps of texture each time after rendered;
- updateMipmap: function (renderer) {
- var _gl = renderer.gl;
- for (var attachment in this._textures) {
- var obj = this._textures[attachment];
- if (obj) {
- var texture = obj.texture;
- // FIXME some texture format can't generate mipmap
- if (!texture.NPOT && texture.useMipmap
- && texture.minFilter === __WEBPACK_IMPORTED_MODULE_1__Texture__["a" /* default */].LINEAR_MIPMAP_LINEAR) {
- var target = texture.textureType === 'textureCube' ? __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].TEXTURE_CUBE_MAP : __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].TEXTURE_2D;
- _gl.bindTexture(target, texture.getWebGLTexture(renderer));
- _gl.generateMipmap(target);
- _gl.bindTexture(target, null);
- }
- }
- }
- },
- // 0x8CD5, 36053, FRAMEBUFFER_COMPLETE
- // 0x8CD6, 36054, FRAMEBUFFER_INCOMPLETE_ATTACHMENT
- // 0x8CD7, 36055, FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
- // 0x8CD9, 36057, FRAMEBUFFER_INCOMPLETE_DIMENSIONS
- // 0x8CDD, 36061, FRAMEBUFFER_UNSUPPORTED
- checkStatus: function (_gl) {
- return _gl.checkFramebufferStatus(GL_FRAMEBUFFER);
- },
- _getFrameBufferGL: function (renderer) {
- var cache = this._cache;
- cache.use(renderer.__uid__);
- if (cache.miss(KEY_FRAMEBUFFER)) {
- cache.put(KEY_FRAMEBUFFER, renderer.gl.createFramebuffer());
- }
- return cache.get(KEY_FRAMEBUFFER);
- },
- /**
- * Attach a texture(RTT) to the framebuffer
- * @param {clay.Texture} texture
- * @param {number} [attachment=gl.COLOR_ATTACHMENT0]
- * @param {number} [target=gl.TEXTURE_2D]
- */
- attach: function (texture, attachment, target) {
- if (!texture.width) {
- throw new Error('The texture attached to color buffer is not a valid.');
- }
- // TODO width and height check
- // If the depth_texture extension is enabled, developers
- // Can attach a depth texture to the depth buffer
- // http://blog.tojicode.com/2012/07/using-webgldepthtexture.html
- attachment = attachment || GL_COLOR_ATTACHMENT0;
- target = target || __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].TEXTURE_2D;
- var boundRenderer = this._boundRenderer;
- var _gl = boundRenderer && boundRenderer.gl;
- var attachedTextures;
- if (_gl) {
- var cache = this._cache;
- cache.use(boundRenderer.__uid__);
- attachedTextures = cache.get('attached_textures');
- }
- // Check if texture attached
- var previous = this._textures[attachment];
- if (previous && previous.target === target
- && previous.texture === texture
- && (attachedTextures && attachedTextures[attachment] != null)
- ) {
- return;
- }
- var canAttach = true;
- if (boundRenderer) {
- canAttach = this._doAttach(boundRenderer, texture, attachment, target);
- // Set viewport again incase attached to different size textures.
- if (!this.viewport) {
- boundRenderer.setViewport(0, 0, texture.width, texture.height, 1);
- }
- }
- if (canAttach) {
- this._textures[attachment] = this._textures[attachment] || {};
- this._textures[attachment].texture = texture;
- this._textures[attachment].target = target;
- }
- },
- _doAttach: function (renderer, texture, attachment, target) {
- var _gl = renderer.gl;
- // Make sure texture is always updated
- // Because texture width or height may be changed and in this we can't be notified
- // FIXME awkward;
- var webglTexture = texture.getWebGLTexture(renderer);
- // Assume cache has been used.
- var attachedTextures = this._cache.get('attached_textures');
- if (attachedTextures && attachedTextures[attachment]) {
- var obj = attachedTextures[attachment];
- // Check if texture and target not changed
- if (obj.texture === texture && obj.target === target) {
- return;
- }
- }
- attachment = +attachment;
- var canAttach = true;
- if (attachment === GL_DEPTH_ATTACHMENT || attachment === __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL_ATTACHMENT) {
- var extension = renderer.getGLExtension('WEBGL_depth_texture');
- if (!extension) {
- console.error('Depth texture is not supported by the browser');
- canAttach = false;
- }
- if (texture.format !== __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_COMPONENT
- && texture.format !== __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL
- ) {
- console.error('The texture attached to depth buffer is not a valid.');
- canAttach = false;
- }
- // Dispose render buffer created previous
- if (canAttach) {
- var renderbuffer = this._cache.get(KEY_RENDERBUFFER);
- if (renderbuffer) {
- _gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, null);
- _gl.deleteRenderbuffer(renderbuffer);
- this._cache.put(KEY_RENDERBUFFER, false);
- }
- this._cache.put(KEY_RENDERBUFFER_ATTACHED, false);
- this._cache.put(KEY_DEPTHTEXTURE_ATTACHED, true);
- }
- }
- // Mipmap level can only be 0
- _gl.framebufferTexture2D(GL_FRAMEBUFFER, attachment, target, webglTexture, 0);
- if (!attachedTextures) {
- attachedTextures = {};
- this._cache.put('attached_textures', attachedTextures);
- }
- attachedTextures[attachment] = attachedTextures[attachment] || {};
- attachedTextures[attachment].texture = texture;
- attachedTextures[attachment].target = target;
- return canAttach;
- },
- _doDetach: function (_gl, attachment, target) {
- // Detach a texture from framebuffer
- // https://github.com/KhronosGroup/WebGL/blob/master/conformance-suites/1.0.0/conformance/framebuffer-test.html#L145
- _gl.framebufferTexture2D(GL_FRAMEBUFFER, attachment, target, null, 0);
- // Assume cache has been used.
- var attachedTextures = this._cache.get('attached_textures');
- if (attachedTextures && attachedTextures[attachment]) {
- attachedTextures[attachment] = null;
- }
- if (attachment === GL_DEPTH_ATTACHMENT || attachment === __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL_ATTACHMENT) {
- this._cache.put(KEY_DEPTHTEXTURE_ATTACHED, false);
- }
- },
- /**
- * Detach a texture
- * @param {number} [attachment=gl.COLOR_ATTACHMENT0]
- * @param {number} [target=gl.TEXTURE_2D]
- */
- detach: function (attachment, target) {
- // TODO depth extension check ?
- this._textures[attachment] = null;
- if (this._boundRenderer) {
- var cache = this._cache;
- cache.use(this._boundRenderer.__uid__);
- this._doDetach(this._boundRenderer.gl, attachment, target);
- }
- },
- /**
- * Dispose
- * @param {WebGLRenderingContext} _gl
- */
- dispose: function (renderer) {
- var _gl = renderer.gl;
- var cache = this._cache;
- cache.use(renderer.__uid__);
- var renderBuffer = cache.get(KEY_RENDERBUFFER);
- if (renderBuffer) {
- _gl.deleteRenderbuffer(renderBuffer);
- }
- var frameBuffer = cache.get(KEY_FRAMEBUFFER);
- if (frameBuffer) {
- _gl.deleteFramebuffer(frameBuffer);
- }
- cache.deleteContext(renderer.__uid__);
- // Clear cache for reusing
- this._textures = {};
- }
- });
- FrameBuffer.DEPTH_ATTACHMENT = GL_DEPTH_ATTACHMENT;
- FrameBuffer.COLOR_ATTACHMENT0 = GL_COLOR_ATTACHMENT0;
- FrameBuffer.STENCIL_ATTACHMENT = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].STENCIL_ATTACHMENT;
- FrameBuffer.DEPTH_STENCIL_ATTACHMENT = __WEBPACK_IMPORTED_MODULE_3__core_glenum__["a" /* default */].DEPTH_STENCIL_ATTACHMENT;
- /* harmony default export */ __webpack_exports__["a"] = (FrameBuffer);
- /***/
- }),
- /* 11 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * @namespace clay.core.glenum
- * @see http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14
- */
- /* harmony default export */ __webpack_exports__["a"] = ({
- /* ClearBufferMask */
- DEPTH_BUFFER_BIT: 0x00000100,
- STENCIL_BUFFER_BIT: 0x00000400,
- COLOR_BUFFER_BIT: 0x00004000,
- /* BeginMode */
- POINTS: 0x0000,
- LINES: 0x0001,
- LINE_LOOP: 0x0002,
- LINE_STRIP: 0x0003,
- TRIANGLES: 0x0004,
- TRIANGLE_STRIP: 0x0005,
- TRIANGLE_FAN: 0x0006,
- /* AlphaFunction (not supported in ES20) */
- /* NEVER */
- /* LESS */
- /* EQUAL */
- /* LEQUAL */
- /* GREATER */
- /* NOTEQUAL */
- /* GEQUAL */
- /* ALWAYS */
- /* BlendingFactorDest */
- ZERO: 0,
- ONE: 1,
- SRC_COLOR: 0x0300,
- ONE_MINUS_SRC_COLOR: 0x0301,
- SRC_ALPHA: 0x0302,
- ONE_MINUS_SRC_ALPHA: 0x0303,
- DST_ALPHA: 0x0304,
- ONE_MINUS_DST_ALPHA: 0x0305,
- /* BlendingFactorSrc */
- /* ZERO */
- /* ONE */
- DST_COLOR: 0x0306,
- ONE_MINUS_DST_COLOR: 0x0307,
- SRC_ALPHA_SATURATE: 0x0308,
- /* SRC_ALPHA */
- /* ONE_MINUS_SRC_ALPHA */
- /* DST_ALPHA */
- /* ONE_MINUS_DST_ALPHA */
- /* BlendEquationSeparate */
- FUNC_ADD: 0x8006,
- BLEND_EQUATION: 0x8009,
- BLEND_EQUATION_RGB: 0x8009, /* same as BLEND_EQUATION */
- BLEND_EQUATION_ALPHA: 0x883D,
- /* BlendSubtract */
- FUNC_SUBTRACT: 0x800A,
- FUNC_REVERSE_SUBTRACT: 0x800B,
- /* Separate Blend Functions */
- BLEND_DST_RGB: 0x80C8,
- BLEND_SRC_RGB: 0x80C9,
- BLEND_DST_ALPHA: 0x80CA,
- BLEND_SRC_ALPHA: 0x80CB,
- CONSTANT_COLOR: 0x8001,
- ONE_MINUS_CONSTANT_COLOR: 0x8002,
- CONSTANT_ALPHA: 0x8003,
- ONE_MINUS_CONSTANT_ALPHA: 0x8004,
- BLEND_COLOR: 0x8005,
- /* Buffer Objects */
- ARRAY_BUFFER: 0x8892,
- ELEMENT_ARRAY_BUFFER: 0x8893,
- ARRAY_BUFFER_BINDING: 0x8894,
- ELEMENT_ARRAY_BUFFER_BINDING: 0x8895,
- STREAM_DRAW: 0x88E0,
- STATIC_DRAW: 0x88E4,
- DYNAMIC_DRAW: 0x88E8,
- BUFFER_SIZE: 0x8764,
- BUFFER_USAGE: 0x8765,
- CURRENT_VERTEX_ATTRIB: 0x8626,
- /* CullFaceMode */
- FRONT: 0x0404,
- BACK: 0x0405,
- FRONT_AND_BACK: 0x0408,
- /* DepthFunction */
- /* NEVER */
- /* LESS */
- /* EQUAL */
- /* LEQUAL */
- /* GREATER */
- /* NOTEQUAL */
- /* GEQUAL */
- /* ALWAYS */
- /* EnableCap */
- /* TEXTURE_2D */
- CULL_FACE: 0x0B44,
- BLEND: 0x0BE2,
- DITHER: 0x0BD0,
- STENCIL_TEST: 0x0B90,
- DEPTH_TEST: 0x0B71,
- SCISSOR_TEST: 0x0C11,
- POLYGON_OFFSET_FILL: 0x8037,
- SAMPLE_ALPHA_TO_COVERAGE: 0x809E,
- SAMPLE_COVERAGE: 0x80A0,
- /* ErrorCode */
- NO_ERROR: 0,
- INVALID_ENUM: 0x0500,
- INVALID_VALUE: 0x0501,
- INVALID_OPERATION: 0x0502,
- OUT_OF_MEMORY: 0x0505,
- /* FrontFaceDirection */
- CW: 0x0900,
- CCW: 0x0901,
- /* GetPName */
- LINE_WIDTH: 0x0B21,
- ALIASED_POINT_SIZE_RANGE: 0x846D,
- ALIASED_LINE_WIDTH_RANGE: 0x846E,
- CULL_FACE_MODE: 0x0B45,
- FRONT_FACE: 0x0B46,
- DEPTH_RANGE: 0x0B70,
- DEPTH_WRITEMASK: 0x0B72,
- DEPTH_CLEAR_VALUE: 0x0B73,
- DEPTH_FUNC: 0x0B74,
- STENCIL_CLEAR_VALUE: 0x0B91,
- STENCIL_FUNC: 0x0B92,
- STENCIL_FAIL: 0x0B94,
- STENCIL_PASS_DEPTH_FAIL: 0x0B95,
- STENCIL_PASS_DEPTH_PASS: 0x0B96,
- STENCIL_REF: 0x0B97,
- STENCIL_VALUE_MASK: 0x0B93,
- STENCIL_WRITEMASK: 0x0B98,
- STENCIL_BACK_FUNC: 0x8800,
- STENCIL_BACK_FAIL: 0x8801,
- STENCIL_BACK_PASS_DEPTH_FAIL: 0x8802,
- STENCIL_BACK_PASS_DEPTH_PASS: 0x8803,
- STENCIL_BACK_REF: 0x8CA3,
- STENCIL_BACK_VALUE_MASK: 0x8CA4,
- STENCIL_BACK_WRITEMASK: 0x8CA5,
- VIEWPORT: 0x0BA2,
- SCISSOR_BOX: 0x0C10,
- /* SCISSOR_TEST */
- COLOR_CLEAR_VALUE: 0x0C22,
- COLOR_WRITEMASK: 0x0C23,
- UNPACK_ALIGNMENT: 0x0CF5,
- PACK_ALIGNMENT: 0x0D05,
- MAX_TEXTURE_SIZE: 0x0D33,
- MAX_VIEWPORT_DIMS: 0x0D3A,
- SUBPIXEL_BITS: 0x0D50,
- RED_BITS: 0x0D52,
- GREEN_BITS: 0x0D53,
- BLUE_BITS: 0x0D54,
- ALPHA_BITS: 0x0D55,
- DEPTH_BITS: 0x0D56,
- STENCIL_BITS: 0x0D57,
- POLYGON_OFFSET_UNITS: 0x2A00,
- /* POLYGON_OFFSET_FILL */
- POLYGON_OFFSET_FACTOR: 0x8038,
- TEXTURE_BINDING_2D: 0x8069,
- SAMPLE_BUFFERS: 0x80A8,
- SAMPLES: 0x80A9,
- SAMPLE_COVERAGE_VALUE: 0x80AA,
- SAMPLE_COVERAGE_INVERT: 0x80AB,
- /* GetTextureParameter */
- /* TEXTURE_MAG_FILTER */
- /* TEXTURE_MIN_FILTER */
- /* TEXTURE_WRAP_S */
- /* TEXTURE_WRAP_T */
- COMPRESSED_TEXTURE_FORMATS: 0x86A3,
- /* HintMode */
- DONT_CARE: 0x1100,
- FASTEST: 0x1101,
- NICEST: 0x1102,
- /* HintTarget */
- GENERATE_MIPMAP_HINT: 0x8192,
- /* DataType */
- BYTE: 0x1400,
- UNSIGNED_BYTE: 0x1401,
- SHORT: 0x1402,
- UNSIGNED_SHORT: 0x1403,
- INT: 0x1404,
- UNSIGNED_INT: 0x1405,
- FLOAT: 0x1406,
- /* PixelFormat */
- DEPTH_COMPONENT: 0x1902,
- ALPHA: 0x1906,
- RGB: 0x1907,
- RGBA: 0x1908,
- LUMINANCE: 0x1909,
- LUMINANCE_ALPHA: 0x190A,
- /* PixelType */
- /* UNSIGNED_BYTE */
- UNSIGNED_SHORT_4_4_4_4: 0x8033,
- UNSIGNED_SHORT_5_5_5_1: 0x8034,
- UNSIGNED_SHORT_5_6_5: 0x8363,
- /* Shaders */
- FRAGMENT_SHADER: 0x8B30,
- VERTEX_SHADER: 0x8B31,
- MAX_VERTEX_ATTRIBS: 0x8869,
- MAX_VERTEX_UNIFORM_VECTORS: 0x8DFB,
- MAX_VARYING_VECTORS: 0x8DFC,
- MAX_COMBINED_TEXTURE_IMAGE_UNITS: 0x8B4D,
- MAX_VERTEX_TEXTURE_IMAGE_UNITS: 0x8B4C,
- MAX_TEXTURE_IMAGE_UNITS: 0x8872,
- MAX_FRAGMENT_UNIFORM_VECTORS: 0x8DFD,
- SHADER_TYPE: 0x8B4F,
- DELETE_STATUS: 0x8B80,
- LINK_STATUS: 0x8B82,
- VALIDATE_STATUS: 0x8B83,
- ATTACHED_SHADERS: 0x8B85,
- ACTIVE_UNIFORMS: 0x8B86,
- ACTIVE_ATTRIBUTES: 0x8B89,
- SHADING_LANGUAGE_VERSION: 0x8B8C,
- CURRENT_PROGRAM: 0x8B8D,
- /* StencilFunction */
- NEVER: 0x0200,
- LESS: 0x0201,
- EQUAL: 0x0202,
- LEQUAL: 0x0203,
- GREATER: 0x0204,
- NOTEQUAL: 0x0205,
- GEQUAL: 0x0206,
- ALWAYS: 0x0207,
- /* StencilOp */
- /* ZERO */
- KEEP: 0x1E00,
- REPLACE: 0x1E01,
- INCR: 0x1E02,
- DECR: 0x1E03,
- INVERT: 0x150A,
- INCR_WRAP: 0x8507,
- DECR_WRAP: 0x8508,
- /* StringName */
- VENDOR: 0x1F00,
- RENDERER: 0x1F01,
- VERSION: 0x1F02,
- /* TextureMagFilter */
- NEAREST: 0x2600,
- LINEAR: 0x2601,
- /* TextureMinFilter */
- /* NEAREST */
- /* LINEAR */
- NEAREST_MIPMAP_NEAREST: 0x2700,
- LINEAR_MIPMAP_NEAREST: 0x2701,
- NEAREST_MIPMAP_LINEAR: 0x2702,
- LINEAR_MIPMAP_LINEAR: 0x2703,
- /* TextureParameterName */
- TEXTURE_MAG_FILTER: 0x2800,
- TEXTURE_MIN_FILTER: 0x2801,
- TEXTURE_WRAP_S: 0x2802,
- TEXTURE_WRAP_T: 0x2803,
- /* TextureTarget */
- TEXTURE_2D: 0x0DE1,
- TEXTURE: 0x1702,
- TEXTURE_CUBE_MAP: 0x8513,
- TEXTURE_BINDING_CUBE_MAP: 0x8514,
- TEXTURE_CUBE_MAP_POSITIVE_X: 0x8515,
- TEXTURE_CUBE_MAP_NEGATIVE_X: 0x8516,
- TEXTURE_CUBE_MAP_POSITIVE_Y: 0x8517,
- TEXTURE_CUBE_MAP_NEGATIVE_Y: 0x8518,
- TEXTURE_CUBE_MAP_POSITIVE_Z: 0x8519,
- TEXTURE_CUBE_MAP_NEGATIVE_Z: 0x851A,
- MAX_CUBE_MAP_TEXTURE_SIZE: 0x851C,
- /* TextureUnit */
- TEXTURE0: 0x84C0,
- TEXTURE1: 0x84C1,
- TEXTURE2: 0x84C2,
- TEXTURE3: 0x84C3,
- TEXTURE4: 0x84C4,
- TEXTURE5: 0x84C5,
- TEXTURE6: 0x84C6,
- TEXTURE7: 0x84C7,
- TEXTURE8: 0x84C8,
- TEXTURE9: 0x84C9,
- TEXTURE10: 0x84CA,
- TEXTURE11: 0x84CB,
- TEXTURE12: 0x84CC,
- TEXTURE13: 0x84CD,
- TEXTURE14: 0x84CE,
- TEXTURE15: 0x84CF,
- TEXTURE16: 0x84D0,
- TEXTURE17: 0x84D1,
- TEXTURE18: 0x84D2,
- TEXTURE19: 0x84D3,
- TEXTURE20: 0x84D4,
- TEXTURE21: 0x84D5,
- TEXTURE22: 0x84D6,
- TEXTURE23: 0x84D7,
- TEXTURE24: 0x84D8,
- TEXTURE25: 0x84D9,
- TEXTURE26: 0x84DA,
- TEXTURE27: 0x84DB,
- TEXTURE28: 0x84DC,
- TEXTURE29: 0x84DD,
- TEXTURE30: 0x84DE,
- TEXTURE31: 0x84DF,
- ACTIVE_TEXTURE: 0x84E0,
- /* TextureWrapMode */
- REPEAT: 0x2901,
- CLAMP_TO_EDGE: 0x812F,
- MIRRORED_REPEAT: 0x8370,
- /* Uniform Types */
- FLOAT_VEC2: 0x8B50,
- FLOAT_VEC3: 0x8B51,
- FLOAT_VEC4: 0x8B52,
- INT_VEC2: 0x8B53,
- INT_VEC3: 0x8B54,
- INT_VEC4: 0x8B55,
- BOOL: 0x8B56,
- BOOL_VEC2: 0x8B57,
- BOOL_VEC3: 0x8B58,
- BOOL_VEC4: 0x8B59,
- FLOAT_MAT2: 0x8B5A,
- FLOAT_MAT3: 0x8B5B,
- FLOAT_MAT4: 0x8B5C,
- SAMPLER_2D: 0x8B5E,
- SAMPLER_CUBE: 0x8B60,
- /* Vertex Arrays */
- VERTEX_ATTRIB_ARRAY_ENABLED: 0x8622,
- VERTEX_ATTRIB_ARRAY_SIZE: 0x8623,
- VERTEX_ATTRIB_ARRAY_STRIDE: 0x8624,
- VERTEX_ATTRIB_ARRAY_TYPE: 0x8625,
- VERTEX_ATTRIB_ARRAY_NORMALIZED: 0x886A,
- VERTEX_ATTRIB_ARRAY_POINTER: 0x8645,
- VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 0x889F,
- /* Shader Source */
- COMPILE_STATUS: 0x8B81,
- /* Shader Precision-Specified Types */
- LOW_FLOAT: 0x8DF0,
- MEDIUM_FLOAT: 0x8DF1,
- HIGH_FLOAT: 0x8DF2,
- LOW_INT: 0x8DF3,
- MEDIUM_INT: 0x8DF4,
- HIGH_INT: 0x8DF5,
- /* Framebuffer Object. */
- FRAMEBUFFER: 0x8D40,
- RENDERBUFFER: 0x8D41,
- RGBA4: 0x8056,
- RGB5_A1: 0x8057,
- RGB565: 0x8D62,
- DEPTH_COMPONENT16: 0x81A5,
- STENCIL_INDEX: 0x1901,
- STENCIL_INDEX8: 0x8D48,
- DEPTH_STENCIL: 0x84F9,
- RENDERBUFFER_WIDTH: 0x8D42,
- RENDERBUFFER_HEIGHT: 0x8D43,
- RENDERBUFFER_INTERNAL_FORMAT: 0x8D44,
- RENDERBUFFER_RED_SIZE: 0x8D50,
- RENDERBUFFER_GREEN_SIZE: 0x8D51,
- RENDERBUFFER_BLUE_SIZE: 0x8D52,
- RENDERBUFFER_ALPHA_SIZE: 0x8D53,
- RENDERBUFFER_DEPTH_SIZE: 0x8D54,
- RENDERBUFFER_STENCIL_SIZE: 0x8D55,
- FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: 0x8CD0,
- FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: 0x8CD1,
- FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: 0x8CD2,
- FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: 0x8CD3,
- COLOR_ATTACHMENT0: 0x8CE0,
- DEPTH_ATTACHMENT: 0x8D00,
- STENCIL_ATTACHMENT: 0x8D20,
- DEPTH_STENCIL_ATTACHMENT: 0x821A,
- NONE: 0,
- FRAMEBUFFER_COMPLETE: 0x8CD5,
- FRAMEBUFFER_INCOMPLETE_ATTACHMENT: 0x8CD6,
- FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: 0x8CD7,
- FRAMEBUFFER_INCOMPLETE_DIMENSIONS: 0x8CD9,
- FRAMEBUFFER_UNSUPPORTED: 0x8CDD,
- FRAMEBUFFER_BINDING: 0x8CA6,
- RENDERBUFFER_BINDING: 0x8CA7,
- MAX_RENDERBUFFER_SIZE: 0x84E8,
- INVALID_FRAMEBUFFER_OPERATION: 0x0506,
- /* WebGL-specific enums */
- UNPACK_FLIP_Y_WEBGL: 0x9240,
- UNPACK_PREMULTIPLY_ALPHA_WEBGL: 0x9241,
- CONTEXT_LOST_WEBGL: 0x9242,
- UNPACK_COLORSPACE_CONVERSION_WEBGL: 0x9243,
- BROWSER_DEFAULT_WEBGL: 0x9244,
- });
- /***/
- }),
- /* 12 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20);
- /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
- /**
- * @class 3 Dimensional Vector
- * @name vec3
- */
- var vec3 = {};
- /**
- * Creates a new, empty vec3
- *
- * @returns {vec3} a new 3D vector
- */
- vec3.create = function () {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](3);
- out[0] = 0;
- out[1] = 0;
- out[2] = 0;
- return out;
- };
- /**
- * Creates a new vec3 initialized with values from an existing vector
- *
- * @param {vec3} a vector to clone
- * @returns {vec3} a new 3D vector
- */
- vec3.clone = function (a) {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](3);
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- return out;
- };
- /**
- * Creates a new vec3 initialized with the given values
- *
- * @param {Number} x X component
- * @param {Number} y Y component
- * @param {Number} z Z component
- * @returns {vec3} a new 3D vector
- */
- vec3.fromValues = function (x, y, z) {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](3);
- out[0] = x;
- out[1] = y;
- out[2] = z;
- return out;
- };
- /**
- * Copy the values from one vec3 to another
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the source vector
- * @returns {vec3} out
- */
- vec3.copy = function (out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- return out;
- };
- /**
- * Set the components of a vec3 to the given values
- *
- * @param {vec3} out the receiving vector
- * @param {Number} x X component
- * @param {Number} y Y component
- * @param {Number} z Z component
- * @returns {vec3} out
- */
- vec3.set = function (out, x, y, z) {
- out[0] = x;
- out[1] = y;
- out[2] = z;
- return out;
- };
- /**
- * Adds two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- vec3.add = function (out, a, b) {
- out[0] = a[0] + b[0];
- out[1] = a[1] + b[1];
- out[2] = a[2] + b[2];
- return out;
- };
- /**
- * Subtracts vector b from vector a
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- vec3.subtract = function (out, a, b) {
- out[0] = a[0] - b[0];
- out[1] = a[1] - b[1];
- out[2] = a[2] - b[2];
- return out;
- };
- /**
- * Alias for {@link vec3.subtract}
- * @function
- */
- vec3.sub = vec3.subtract;
- /**
- * Multiplies two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- vec3.multiply = function (out, a, b) {
- out[0] = a[0] * b[0];
- out[1] = a[1] * b[1];
- out[2] = a[2] * b[2];
- return out;
- };
- /**
- * Alias for {@link vec3.multiply}
- * @function
- */
- vec3.mul = vec3.multiply;
- /**
- * Divides two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- vec3.divide = function (out, a, b) {
- out[0] = a[0] / b[0];
- out[1] = a[1] / b[1];
- out[2] = a[2] / b[2];
- return out;
- };
- /**
- * Alias for {@link vec3.divide}
- * @function
- */
- vec3.div = vec3.divide;
- /**
- * Returns the minimum of two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- vec3.min = function (out, a, b) {
- out[0] = Math.min(a[0], b[0]);
- out[1] = Math.min(a[1], b[1]);
- out[2] = Math.min(a[2], b[2]);
- return out;
- };
- /**
- * Returns the maximum of two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- vec3.max = function (out, a, b) {
- out[0] = Math.max(a[0], b[0]);
- out[1] = Math.max(a[1], b[1]);
- out[2] = Math.max(a[2], b[2]);
- return out;
- };
- /**
- * Scales a vec3 by a scalar number
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the vector to scale
- * @param {Number} b amount to scale the vector by
- * @returns {vec3} out
- */
- vec3.scale = function (out, a, b) {
- out[0] = a[0] * b;
- out[1] = a[1] * b;
- out[2] = a[2] * b;
- return out;
- };
- /**
- * Adds two vec3's after scaling the second operand by a scalar value
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @param {Number} scale the amount to scale b by before adding
- * @returns {vec3} out
- */
- vec3.scaleAndAdd = function (out, a, b, scale) {
- out[0] = a[0] + (b[0] * scale);
- out[1] = a[1] + (b[1] * scale);
- out[2] = a[2] + (b[2] * scale);
- return out;
- };
- /**
- * Calculates the euclidian distance between two vec3's
- *
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {Number} distance between a and b
- */
- vec3.distance = function (a, b) {
- var x = b[0] - a[0],
- y = b[1] - a[1],
- z = b[2] - a[2];
- return Math.sqrt(x * x + y * y + z * z);
- };
- /**
- * Alias for {@link vec3.distance}
- * @function
- */
- vec3.dist = vec3.distance;
- /**
- * Calculates the squared euclidian distance between two vec3's
- *
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {Number} squared distance between a and b
- */
- vec3.squaredDistance = function (a, b) {
- var x = b[0] - a[0],
- y = b[1] - a[1],
- z = b[2] - a[2];
- return x * x + y * y + z * z;
- };
- /**
- * Alias for {@link vec3.squaredDistance}
- * @function
- */
- vec3.sqrDist = vec3.squaredDistance;
- /**
- * Calculates the length of a vec3
- *
- * @param {vec3} a vector to calculate length of
- * @returns {Number} length of a
- */
- vec3.length = function (a) {
- var x = a[0],
- y = a[1],
- z = a[2];
- return Math.sqrt(x * x + y * y + z * z);
- };
- /**
- * Alias for {@link vec3.length}
- * @function
- */
- vec3.len = vec3.length;
- /**
- * Calculates the squared length of a vec3
- *
- * @param {vec3} a vector to calculate squared length of
- * @returns {Number} squared length of a
- */
- vec3.squaredLength = function (a) {
- var x = a[0],
- y = a[1],
- z = a[2];
- return x * x + y * y + z * z;
- };
- /**
- * Alias for {@link vec3.squaredLength}
- * @function
- */
- vec3.sqrLen = vec3.squaredLength;
- /**
- * Negates the components of a vec3
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a vector to negate
- * @returns {vec3} out
- */
- vec3.negate = function (out, a) {
- out[0] = -a[0];
- out[1] = -a[1];
- out[2] = -a[2];
- return out;
- };
- /**
- * Returns the inverse of the components of a vec3
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a vector to invert
- * @returns {vec3} out
- */
- vec3.inverse = function (out, a) {
- out[0] = 1.0 / a[0];
- out[1] = 1.0 / a[1];
- out[2] = 1.0 / a[2];
- return out;
- };
- /**
- * Normalize a vec3
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a vector to normalize
- * @returns {vec3} out
- */
- vec3.normalize = function (out, a) {
- var x = a[0],
- y = a[1],
- z = a[2];
- var len = x * x + y * y + z * z;
- if (len > 0) {
- //TODO: evaluate use of glm_invsqrt here?
- len = 1 / Math.sqrt(len);
- out[0] = a[0] * len;
- out[1] = a[1] * len;
- out[2] = a[2] * len;
- }
- return out;
- };
- /**
- * Calculates the dot product of two vec3's
- *
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {Number} dot product of a and b
- */
- vec3.dot = function (a, b) {
- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
- };
- /**
- * Computes the cross product of two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @returns {vec3} out
- */
- vec3.cross = function (out, a, b) {
- var ax = a[0], ay = a[1], az = a[2],
- bx = b[0], by = b[1], bz = b[2];
- out[0] = ay * bz - az * by;
- out[1] = az * bx - ax * bz;
- out[2] = ax * by - ay * bx;
- return out;
- };
- /**
- * Performs a linear interpolation between two vec3's
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the first operand
- * @param {vec3} b the second operand
- * @param {Number} t interpolation amount between the two inputs
- * @returns {vec3} out
- */
- vec3.lerp = function (out, a, b, t) {
- var ax = a[0],
- ay = a[1],
- az = a[2];
- out[0] = ax + t * (b[0] - ax);
- out[1] = ay + t * (b[1] - ay);
- out[2] = az + t * (b[2] - az);
- return out;
- };
- /**
- * Generates a random vector with the given scale
- *
- * @param {vec3} out the receiving vector
- * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
- * @returns {vec3} out
- */
- vec3.random = function (out, scale) {
- scale = scale || 1.0;
- var r = Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_RANDOM */])() * 2.0 * Math.PI;
- var z = (Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_RANDOM */])() * 2.0) - 1.0;
- var zScale = Math.sqrt(1.0 - z * z) * scale;
- out[0] = Math.cos(r) * zScale;
- out[1] = Math.sin(r) * zScale;
- out[2] = z * scale;
- return out;
- };
- /**
- * Transforms the vec3 with a mat4.
- * 4th vector component is implicitly '1'
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the vector to transform
- * @param {mat4} m matrix to transform with
- * @returns {vec3} out
- */
- vec3.transformMat4 = function (out, a, m) {
- var x = a[0], y = a[1], z = a[2],
- w = m[3] * x + m[7] * y + m[11] * z + m[15];
- w = w || 1.0;
- out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
- out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
- out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
- return out;
- };
- /**
- * Transforms the vec3 with a mat3.
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the vector to transform
- * @param {mat4} m the 3x3 matrix to transform with
- * @returns {vec3} out
- */
- vec3.transformMat3 = function (out, a, m) {
- var x = a[0], y = a[1], z = a[2];
- out[0] = x * m[0] + y * m[3] + z * m[6];
- out[1] = x * m[1] + y * m[4] + z * m[7];
- out[2] = x * m[2] + y * m[5] + z * m[8];
- return out;
- };
- /**
- * Transforms the vec3 with a quat
- *
- * @param {vec3} out the receiving vector
- * @param {vec3} a the vector to transform
- * @param {quat} q quaternion to transform with
- * @returns {vec3} out
- */
- vec3.transformQuat = function (out, a, q) {
- // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations
- var x = a[0], y = a[1], z = a[2],
- qx = q[0], qy = q[1], qz = q[2], qw = q[3],
- // calculate quat * vec
- ix = qw * x + qy * z - qz * y,
- iy = qw * y + qz * x - qx * z,
- iz = qw * z + qx * y - qy * x,
- iw = -qx * x - qy * y - qz * z;
- // calculate result * inverse quat
- out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
- out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
- out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
- return out;
- };
- /**
- * Rotate a 3D vector around the x-axis
- * @param {vec3} out The receiving vec3
- * @param {vec3} a The vec3 point to rotate
- * @param {vec3} b The origin of the rotation
- * @param {Number} c The angle of rotation
- * @returns {vec3} out
- */
- vec3.rotateX = function (out, a, b, c) {
- var p = [], r = [];
- //Translate point to the origin
- p[0] = a[0] - b[0];
- p[1] = a[1] - b[1];
- p[2] = a[2] - b[2];
- //perform rotation
- r[0] = p[0];
- r[1] = p[1] * Math.cos(c) - p[2] * Math.sin(c);
- r[2] = p[1] * Math.sin(c) + p[2] * Math.cos(c);
- //translate to correct position
- out[0] = r[0] + b[0];
- out[1] = r[1] + b[1];
- out[2] = r[2] + b[2];
- return out;
- };
- /**
- * Rotate a 3D vector around the y-axis
- * @param {vec3} out The receiving vec3
- * @param {vec3} a The vec3 point to rotate
- * @param {vec3} b The origin of the rotation
- * @param {Number} c The angle of rotation
- * @returns {vec3} out
- */
- vec3.rotateY = function (out, a, b, c) {
- var p = [], r = [];
- //Translate point to the origin
- p[0] = a[0] - b[0];
- p[1] = a[1] - b[1];
- p[2] = a[2] - b[2];
- //perform rotation
- r[0] = p[2] * Math.sin(c) + p[0] * Math.cos(c);
- r[1] = p[1];
- r[2] = p[2] * Math.cos(c) - p[0] * Math.sin(c);
- //translate to correct position
- out[0] = r[0] + b[0];
- out[1] = r[1] + b[1];
- out[2] = r[2] + b[2];
- return out;
- };
- /**
- * Rotate a 3D vector around the z-axis
- * @param {vec3} out The receiving vec3
- * @param {vec3} a The vec3 point to rotate
- * @param {vec3} b The origin of the rotation
- * @param {Number} c The angle of rotation
- * @returns {vec3} out
- */
- vec3.rotateZ = function (out, a, b, c) {
- var p = [], r = [];
- //Translate point to the origin
- p[0] = a[0] - b[0];
- p[1] = a[1] - b[1];
- p[2] = a[2] - b[2];
- //perform rotation
- r[0] = p[0] * Math.cos(c) - p[1] * Math.sin(c);
- r[1] = p[0] * Math.sin(c) + p[1] * Math.cos(c);
- r[2] = p[2];
- //translate to correct position
- out[0] = r[0] + b[0];
- out[1] = r[1] + b[1];
- out[2] = r[2] + b[2];
- return out;
- };
- /**
- * Perform some operation over an array of vec3s.
- *
- * @param {Array} a the array of vectors to iterate over
- * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
- * @param {Number} offset Number of elements to skip at the beginning of the array
- * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
- * @param {Function} fn Function to call for each vector in the array
- * @param {Object} [arg] additional argument to pass to fn
- * @returns {Array} a
- * @function
- */
- vec3.forEach = (function () {
- var vec = vec3.create();
- return function (a, stride, offset, count, fn, arg) {
- var i, l;
- if (!stride) {
- stride = 3;
- }
- if (!offset) {
- offset = 0;
- }
- if (count) {
- l = Math.min((count * stride) + offset, a.length);
- } else {
- l = a.length;
- }
- for (i = offset; i < l; i += stride) {
- vec[0] = a[i]; vec[1] = a[i + 1]; vec[2] = a[i + 2];
- fn(vec, vec, arg);
- a[i] = vec[0]; a[i + 1] = vec[1]; a[i + 2] = vec[2];
- }
- return a;
- };
- })();
- /**
- * Get the angle between two 3D vectors
- * @param {vec3} a The first operand
- * @param {vec3} b The second operand
- * @returns {Number} The angle in radians
- */
- vec3.angle = function (a, b) {
- var tempA = vec3.fromValues(a[0], a[1], a[2]);
- var tempB = vec3.fromValues(b[0], b[1], b[2]);
- vec3.normalize(tempA, tempA);
- vec3.normalize(tempB, tempB);
- var cosine = vec3.dot(tempA, tempB);
- if (cosine > 1.0) {
- return 0;
- } else {
- return Math.acos(cosine);
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (vec3);
- /***/
- }),
- /* 13 */
- /***/ (function (module, exports) {
- /**
- * @module zrender/core/util
- */
- // 用于处ç†mergeæ—¶æ— æ³•é历Dateç‰å¯¹è±¡çš„问题
- var BUILTIN_OBJECT = {
- '[object Function]': 1,
- '[object RegExp]': 1,
- '[object Date]': 1,
- '[object Error]': 1,
- '[object CanvasGradient]': 1,
- '[object CanvasPattern]': 1,
- // For node-canvas
- '[object Image]': 1,
- '[object Canvas]': 1
- };
- var TYPED_ARRAY = {
- '[object Int8Array]': 1,
- '[object Uint8Array]': 1,
- '[object Uint8ClampedArray]': 1,
- '[object Int16Array]': 1,
- '[object Uint16Array]': 1,
- '[object Int32Array]': 1,
- '[object Uint32Array]': 1,
- '[object Float32Array]': 1,
- '[object Float64Array]': 1
- };
- var objToString = Object.prototype.toString;
- var arrayProto = Array.prototype;
- var nativeForEach = arrayProto.forEach;
- var nativeFilter = arrayProto.filter;
- var nativeSlice = arrayProto.slice;
- var nativeMap = arrayProto.map;
- var nativeReduce = arrayProto.reduce; // Avoid assign to an exported variable, for transforming to cjs.
- var methods = {};
- function $override(name, fn) {
- // Clear ctx instance for different environment
- if (name === 'createCanvas') {
- _ctx = null;
- }
- methods[name] = fn;
- }
- /**
- * Those data types can be cloned:
- * Plain object, Array, TypedArray, number, string, null, undefined.
- * Those data types will be assgined using the orginal data:
- * BUILTIN_OBJECT
- * Instance of user defined class will be cloned to a plain object, without
- * properties in prototype.
- * Other data types is not supported (not sure what will happen).
- *
- * Caution: do not support clone Date, for performance consideration.
- * (There might be a large number of date in `series.data`).
- * So date should not be modified in and out of echarts.
- *
- * @param {*} source
- * @return {*} new
- */
- function clone(source) {
- if (source == null || typeof source != 'object') {
- return source;
- }
- var result = source;
- var typeStr = objToString.call(source);
- if (typeStr === '[object Array]') {
- if (!isPrimitive(source)) {
- result = [];
- for (var i = 0, len = source.length; i < len; i++) {
- result[i] = clone(source[i]);
- }
- }
- } else if (TYPED_ARRAY[typeStr]) {
- if (!isPrimitive(source)) {
- var Ctor = source.constructor;
- if (source.constructor.from) {
- result = Ctor.from(source);
- } else {
- result = new Ctor(source.length);
- for (var i = 0, len = source.length; i < len; i++) {
- result[i] = clone(source[i]);
- }
- }
- }
- } else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) {
- result = {};
- for (var key in source) {
- if (source.hasOwnProperty(key)) {
- result[key] = clone(source[key]);
- }
- }
- }
- return result;
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {*} target
- * @param {*} source
- * @param {boolean} [overwrite=false]
- */
- function merge(target, source, overwrite) {
- // We should escapse that source is string
- // and enter for ... in ...
- if (!isObject(source) || !isObject(target)) {
- return overwrite ? clone(source) : target;
- }
- for (var key in source) {
- if (source.hasOwnProperty(key)) {
- var targetProp = target[key];
- var sourceProp = source[key];
- if (isObject(sourceProp) && isObject(targetProp) && !isArray(sourceProp) && !isArray(targetProp) && !isDom(sourceProp) && !isDom(targetProp) && !isBuiltInObject(sourceProp) && !isBuiltInObject(targetProp) && !isPrimitive(sourceProp) && !isPrimitive(targetProp)) {
- // 如果需è¦é€’归覆盖,就递归调用merge
- merge(targetProp, sourceProp, overwrite);
- } else if (overwrite || !(key in target)) {
- // å¦åˆ™åªå¤„ç†overwrite为trueï¼Œæˆ–è€…åœ¨ç›®æ ‡å¯¹è±¡ä¸æ²¡æœ‰æ¤å±žæ€§çš„æƒ…况
- // NOTE,在 target[key] ä¸å˜åœ¨çš„æ—¶å€™ä¹Ÿæ˜¯ç›´æŽ¥è¦†ç›–
- target[key] = clone(source[key], true);
- }
- }
- }
- return target;
- }
- /**
- * @param {Array} targetAndSources The first item is target, and the rests are source.
- * @param {boolean} [overwrite=false]
- * @return {*} target
- */
- function mergeAll(targetAndSources, overwrite) {
- var result = targetAndSources[0];
- for (var i = 1, len = targetAndSources.length; i < len; i++) {
- result = merge(result, targetAndSources[i], overwrite);
- }
- return result;
- }
- /**
- * @param {*} target
- * @param {*} source
- * @memberOf module:zrender/core/util
- */
- function extend(target, source) {
- for (var key in source) {
- if (source.hasOwnProperty(key)) {
- target[key] = source[key];
- }
- }
- return target;
- }
- /**
- * @param {*} target
- * @param {*} source
- * @param {boolean} [overlay=false]
- * @memberOf module:zrender/core/util
- */
- function defaults(target, source, overlay) {
- for (var key in source) {
- if (source.hasOwnProperty(key) && (overlay ? source[key] != null : target[key] == null)) {
- target[key] = source[key];
- }
- }
- return target;
- }
- var createCanvas = function () {
- return methods.createCanvas();
- };
- methods.createCanvas = function () {
- return document.createElement('canvas');
- }; // FIXME
- var _ctx;
- function getContext() {
- if (!_ctx) {
- // Use util.createCanvas instead of createCanvas
- // because createCanvas may be overwritten in different environment
- _ctx = createCanvas().getContext('2d');
- }
- return _ctx;
- }
- /**
- * 查询数组ä¸å…ƒç´ çš„index
- * @memberOf module:zrender/core/util
- */
- function indexOf(array, value) {
- if (array) {
- if (array.indexOf) {
- return array.indexOf(value);
- }
- for (var i = 0, len = array.length; i < len; i++) {
- if (array[i] === value) {
- return i;
- }
- }
- }
- return -1;
- }
- /**
- * æž„é€ ç±»ç»§æ‰¿å…³ç³»
- *
- * @memberOf module:zrender/core/util
- * @param {Function} clazz æºç±»
- * @param {Function} baseClazz 基类
- */
- function inherits(clazz, baseClazz) {
- var clazzPrototype = clazz.prototype;
- function F() { }
- F.prototype = baseClazz.prototype;
- clazz.prototype = new F();
- for (var prop in clazzPrototype) {
- clazz.prototype[prop] = clazzPrototype[prop];
- }
- clazz.prototype.constructor = clazz;
- clazz.superClass = baseClazz;
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {Object|Function} target
- * @param {Object|Function} sorce
- * @param {boolean} overlay
- */
- function mixin(target, source, overlay) {
- target = 'prototype' in target ? target.prototype : target;
- source = 'prototype' in source ? source.prototype : source;
- defaults(target, source, overlay);
- }
- /**
- * Consider typed array.
- * @param {Array|TypedArray} data
- */
- function isArrayLike(data) {
- if (!data) {
- return;
- }
- if (typeof data == 'string') {
- return false;
- }
- return typeof data.length == 'number';
- }
- /**
- * 数组或对象é历
- * @memberOf module:zrender/core/util
- * @param {Object|Array} obj
- * @param {Function} cb
- * @param {*} [context]
- */
- function each(obj, cb, context) {
- if (!(obj && cb)) {
- return;
- }
- if (obj.forEach && obj.forEach === nativeForEach) {
- obj.forEach(cb, context);
- } else if (obj.length === +obj.length) {
- for (var i = 0, len = obj.length; i < len; i++) {
- cb.call(context, obj[i], i, obj);
- }
- } else {
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- cb.call(context, obj[key], key, obj);
- }
- }
- }
- }
- /**
- * æ•°ç»„æ˜ å°„
- * @memberOf module:zrender/core/util
- * @param {Array} obj
- * @param {Function} cb
- * @param {*} [context]
- * @return {Array}
- */
- function map(obj, cb, context) {
- if (!(obj && cb)) {
- return;
- }
- if (obj.map && obj.map === nativeMap) {
- return obj.map(cb, context);
- } else {
- var result = [];
- for (var i = 0, len = obj.length; i < len; i++) {
- result.push(cb.call(context, obj[i], i, obj));
- }
- return result;
- }
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {Array} obj
- * @param {Function} cb
- * @param {Object} [memo]
- * @param {*} [context]
- * @return {Array}
- */
- function reduce(obj, cb, memo, context) {
- if (!(obj && cb)) {
- return;
- }
- if (obj.reduce && obj.reduce === nativeReduce) {
- return obj.reduce(cb, memo, context);
- } else {
- for (var i = 0, len = obj.length; i < len; i++) {
- memo = cb.call(context, memo, obj[i], i, obj);
- }
- return memo;
- }
- }
- /**
- * 数组过滤
- * @memberOf module:zrender/core/util
- * @param {Array} obj
- * @param {Function} cb
- * @param {*} [context]
- * @return {Array}
- */
- function filter(obj, cb, context) {
- if (!(obj && cb)) {
- return;
- }
- if (obj.filter && obj.filter === nativeFilter) {
- return obj.filter(cb, context);
- } else {
- var result = [];
- for (var i = 0, len = obj.length; i < len; i++) {
- if (cb.call(context, obj[i], i, obj)) {
- result.push(obj[i]);
- }
- }
- return result;
- }
- }
- /**
- * 数组项查找
- * @memberOf module:zrender/core/util
- * @param {Array} obj
- * @param {Function} cb
- * @param {*} [context]
- * @return {*}
- */
- function find(obj, cb, context) {
- if (!(obj && cb)) {
- return;
- }
- for (var i = 0, len = obj.length; i < len; i++) {
- if (cb.call(context, obj[i], i, obj)) {
- return obj[i];
- }
- }
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {Function} func
- * @param {*} context
- * @return {Function}
- */
- function bind(func, context) {
- var args = nativeSlice.call(arguments, 2);
- return function () {
- return func.apply(context, args.concat(nativeSlice.call(arguments)));
- };
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {Function} func
- * @return {Function}
- */
- function curry(func) {
- var args = nativeSlice.call(arguments, 1);
- return function () {
- return func.apply(this, args.concat(nativeSlice.call(arguments)));
- };
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {*} value
- * @return {boolean}
- */
- function isArray(value) {
- return objToString.call(value) === '[object Array]';
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {*} value
- * @return {boolean}
- */
- function isFunction(value) {
- return typeof value === 'function';
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {*} value
- * @return {boolean}
- */
- function isString(value) {
- return objToString.call(value) === '[object String]';
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {*} value
- * @return {boolean}
- */
- function isObject(value) {
- // Avoid a V8 JIT bug in Chrome 19-20.
- // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
- var type = typeof value;
- return type === 'function' || !!value && type == 'object';
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {*} value
- * @return {boolean}
- */
- function isBuiltInObject(value) {
- return !!BUILTIN_OBJECT[objToString.call(value)];
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {*} value
- * @return {boolean}
- */
- function isTypedArray(value) {
- return !!TYPED_ARRAY[objToString.call(value)];
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {*} value
- * @return {boolean}
- */
- function isDom(value) {
- return typeof value === 'object' && typeof value.nodeType === 'number' && typeof value.ownerDocument === 'object';
- }
- /**
- * Whether is exactly NaN. Notice isNaN('a') returns true.
- * @param {*} value
- * @return {boolean}
- */
- function eqNaN(value) {
- return value !== value;
- }
- /**
- * If value1 is not null, then return value1, otherwise judget rest of values.
- * Low performance.
- * @memberOf module:zrender/core/util
- * @return {*} Final value
- */
- function retrieve(values) {
- for (var i = 0, len = arguments.length; i < len; i++) {
- if (arguments[i] != null) {
- return arguments[i];
- }
- }
- }
- function retrieve2(value0, value1) {
- return value0 != null ? value0 : value1;
- }
- function retrieve3(value0, value1, value2) {
- return value0 != null ? value0 : value1 != null ? value1 : value2;
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {Array} arr
- * @param {number} startIndex
- * @param {number} endIndex
- * @return {Array}
- */
- function slice() {
- return Function.call.apply(nativeSlice, arguments);
- }
- /**
- * Normalize css liked array configuration
- * e.g.
- * 3 => [3, 3, 3, 3]
- * [4, 2] => [4, 2, 4, 2]
- * [4, 3, 2] => [4, 3, 2, 3]
- * @param {number|Array.<number>} val
- * @return {Array.<number>}
- */
- function normalizeCssArray(val) {
- if (typeof val === 'number') {
- return [val, val, val, val];
- }
- var len = val.length;
- if (len === 2) {
- // vertical | horizontal
- return [val[0], val[1], val[0], val[1]];
- } else if (len === 3) {
- // top | horizontal | bottom
- return [val[0], val[1], val[2], val[1]];
- }
- return val;
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {boolean} condition
- * @param {string} message
- */
- function assert(condition, message) {
- if (!condition) {
- throw new Error(message);
- }
- }
- /**
- * @memberOf module:zrender/core/util
- * @param {string} str string to be trimed
- * @return {string} trimed string
- */
- function trim(str) {
- if (str == null) {
- return null;
- } else if (typeof str.trim === 'function') {
- return str.trim();
- } else {
- return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
- }
- }
- var primitiveKey = '__ec_primitive__';
- /**
- * Set an object as primitive to be ignored traversing children in clone or merge
- */
- function setAsPrimitive(obj) {
- obj[primitiveKey] = true;
- }
- function isPrimitive(obj) {
- return obj[primitiveKey];
- }
- /**
- * @constructor
- * @param {Object} obj Only apply `ownProperty`.
- */
- function HashMap(obj) {
- var isArr = isArray(obj);
- var thisMap = this;
- obj instanceof HashMap ? obj.each(visit) : obj && each(obj, visit);
- function visit(value, key) {
- isArr ? thisMap.set(value, key) : thisMap.set(key, value);
- }
- } // Add prefix to avoid conflict with Object.prototype.
- HashMap.prototype = {
- constructor: HashMap,
- // Do not provide `has` method to avoid defining what is `has`.
- // (We usually treat `null` and `undefined` as the same, different
- // from ES6 Map).
- get: function (key) {
- return this.hasOwnProperty(key) ? this[key] : null;
- },
- set: function (key, value) {
- // Comparing with invocation chaining, `return value` is more commonly
- // used in this case: `var someVal = map.set('a', genVal());`
- return this[key] = value;
- },
- // Although util.each can be performed on this hashMap directly, user
- // should not use the exposed keys, who are prefixed.
- each: function (cb, context) {
- context !== void 0 && (cb = bind(cb, context));
- for (var key in this) {
- this.hasOwnProperty(key) && cb(this[key], key);
- }
- },
- // Do not use this method if performance sensitive.
- removeKey: function (key) {
- delete this[key];
- }
- };
- function createHashMap(obj) {
- return new HashMap(obj);
- }
- function concatArray(a, b) {
- var newArray = new a.constructor(a.length + b.length);
- for (var i = 0; i < a.length; i++) {
- newArray[i] = a[i];
- }
- var offset = a.length;
- for (i = 0; i < b.length; i++) {
- newArray[i + offset] = b[i];
- }
- return newArray;
- }
- function noop() { }
- exports.$override = $override;
- exports.clone = clone;
- exports.merge = merge;
- exports.mergeAll = mergeAll;
- exports.extend = extend;
- exports.defaults = defaults;
- exports.createCanvas = createCanvas;
- exports.getContext = getContext;
- exports.indexOf = indexOf;
- exports.inherits = inherits;
- exports.mixin = mixin;
- exports.isArrayLike = isArrayLike;
- exports.each = each;
- exports.map = map;
- exports.reduce = reduce;
- exports.filter = filter;
- exports.find = find;
- exports.bind = bind;
- exports.curry = curry;
- exports.isArray = isArray;
- exports.isFunction = isFunction;
- exports.isString = isString;
- exports.isObject = isObject;
- exports.isBuiltInObject = isBuiltInObject;
- exports.isTypedArray = isTypedArray;
- exports.isDom = isDom;
- exports.eqNaN = eqNaN;
- exports.retrieve = retrieve;
- exports.retrieve2 = retrieve2;
- exports.retrieve3 = retrieve3;
- exports.slice = slice;
- exports.normalizeCssArray = normalizeCssArray;
- exports.assert = assert;
- exports.trim = trim;
- exports.setAsPrimitive = setAsPrimitive;
- exports.isPrimitive = isPrimitive;
- exports.createHashMap = createHashMap;
- exports.concatArray = concatArray;
- exports.noop = noop;
- /***/
- }),
- /* 14 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function (global) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__request__ = __webpack_require__(112);
- var supportWebGL;
- var vendor = {};
- /**
- * If support WebGL
- * @return {boolean}
- */
- vendor.supportWebGL = function () {
- if (supportWebGL == null) {
- try {
- var canvas = document.createElement('canvas');
- var gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
- if (!gl) {
- throw new Error();
- }
- }
- catch (e) {
- supportWebGL = false;
- }
- }
- return supportWebGL;
- };
- vendor.Int8Array = typeof Int8Array === 'undefined' ? Array : Int8Array;
- vendor.Uint8Array = typeof Uint8Array === 'undefined' ? Array : Uint8Array;
- vendor.Uint16Array = typeof Uint16Array === 'undefined' ? Array : Uint16Array;
- vendor.Uint32Array = typeof Uint32Array === 'undefined' ? Array : Uint32Array;
- vendor.Int16Array = typeof Int16Array === 'undefined' ? Array : Int16Array;
- vendor.Float32Array = typeof Float32Array === 'undefined' ? Array : Float32Array;
- vendor.Float64Array = typeof Float64Array === 'undefined' ? Array : Float64Array;
- var g = {};
- if (typeof window !== 'undefined') {
- g = window;
- }
- else if (typeof global !== 'undefined') {
- g = global;
- }
- vendor.requestAnimationFrame = g.requestAnimationFrame
- || g.msRequestAnimationFrame
- || g.mozRequestAnimationFrame
- || g.webkitRequestAnimationFrame
- || function (func) { setTimeout(func, 16); };
- vendor.createCanvas = function () {
- return document.createElement('canvas');
- };
- vendor.createImage = function () {
- return new g.Image();
- };
- vendor.request = {
- get: __WEBPACK_IMPORTED_MODULE_0__request__["a" /* default */].get
- };
- /* harmony default export */ __webpack_exports__["a"] = (vendor);
- /* WEBPACK VAR INJECTION */
- }.call(__webpack_exports__, __webpack_require__(68)))
- /***/
- }),
- /* 15 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_vendor__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__ = __webpack_require__(12);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__glmatrix_mat4__ = __webpack_require__(21);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__ = __webpack_require__(18);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__GeometryBase__ = __webpack_require__(118);
- var vec3Create = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create;
- var vec3Add = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].add;
- var vec3Set = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set;
- var Attribute = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].Attribute;
- /**
- * Geometry in ClayGL contains vertex attributes of mesh. These vertex attributes will be finally provided to the {@link clay.Shader}.
- * Different {@link clay.Shader} needs different attributes. Here is a list of attributes used in the builtin shaders.
- *
- * + position: `clay.basic`, `clay.lambert`, `clay.standard`
- * + texcoord0: `clay.basic`, `clay.lambert`, `clay.standard`
- * + color: `clay.basic`, `clay.lambert`, `clay.standard`
- * + weight: `clay.basic`, `clay.lambert`, `clay.standard`
- * + joint: `clay.basic`, `clay.lambert`, `clay.standard`
- * + normal: `clay.lambert`, `clay.standard`
- * + tangent: `clay.standard`
- *
- * #### Create a procedural geometry
- *
- * ClayGL provides a couple of builtin procedural geometries. Inlcuding:
- *
- * + {@link clay.geometry.Cube}
- * + {@link clay.geometry.Sphere}
- * + {@link clay.geometry.Plane}
- * + {@link clay.geometry.Cylinder}
- * + {@link clay.geometry.Cone}
- * + {@link clay.geometry.ParametricSurface}
- *
- * It's simple to create a basic geometry with these classes.
- *
- ```js
- var sphere = new clay.geometry.Sphere({
- radius: 2
- });
- ```
- *
- * #### Create the geometry data by yourself
- *
- * Usually the vertex attributes data are created by the {@link clay.loader.GLTF} or procedural geometries like {@link clay.geometry.Sphere}.
- * Besides these, you can create the data manually. Here is a simple example to create a triangle.
- ```js
- var TRIANGLE_POSITIONS = [
- [-0.5, -0.5, 0],
- [0.5, -0.5, 0],
- [0, 0.5, 0]
- ];
- var geometry = new clay.StaticGeometryBase();
- // Add triangle vertices to position attribute.
- geometry.attributes.position.fromArray(TRIANGLE_POSITIONS);
- ```
- * Then you can use the utility methods like `generateVertexNormals`, `generateTangents` to create the remaining necessary attributes.
- *
- *
- * #### Use with custom shaders
- *
- * If you wan't to write custom shaders. Don't forget to add SEMANTICS to these attributes. For example
- *
- ```glsl
- uniform mat4 worldViewProjection : WORLDVIEWPROJECTION;
- uniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;
- uniform mat4 world : WORLD;
-
- attribute vec3 position : POSITION;
- attribute vec2 texcoord : TEXCOORD_0;
- attribute vec3 normal : NORMAL;
- ```
- * These `POSITION`, `TEXCOORD_0`, `NORMAL` are SEMANTICS which will map the attributes in shader to the attributes in the GeometryBase
- *
- * Available attributes SEMANTICS includes `POSITION`, `TEXCOORD_0`, `TEXCOORD_1` `NORMAL`, `TANGENT`, `COLOR`, `WEIGHT`, `JOINT`.
- *
- *
- * @constructor clay.Geometry
- * @extends clay.GeometryBase
- */
- var Geometry = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].extend(function () {
- return /** @lends clay.Geometry# */ {
- /**
- * Attributes of geometry. Including:
- * + `position`
- * + `texcoord0`
- * + `texcoord1`
- * + `normal`
- * + `tangent`
- * + `color`
- * + `weight`
- * + `joint`
- * + `barycentric`
- *
- * @type {Object.<string, clay.Geometry.Attribute>}
- */
- attributes: {
- position: new Attribute('position', 'float', 3, 'POSITION'),
- texcoord0: new Attribute('texcoord0', 'float', 2, 'TEXCOORD_0'),
- texcoord1: new Attribute('texcoord1', 'float', 2, 'TEXCOORD_1'),
- normal: new Attribute('normal', 'float', 3, 'NORMAL'),
- tangent: new Attribute('tangent', 'float', 4, 'TANGENT'),
- color: new Attribute('color', 'float', 4, 'COLOR'),
- // Skinning attributes
- // Each vertex can be bind to 4 bones, because the
- // sum of weights is 1, so the weights is stored in vec3 and the last
- // can be calculated by 1-w.x-w.y-w.z
- weight: new Attribute('weight', 'float', 3, 'WEIGHT'),
- joint: new Attribute('joint', 'float', 4, 'JOINT'),
- // For wireframe display
- // http://codeflow.org/entries/2012/aug/02/easy-wireframe-display-with-barycentric-coordinates/
- barycentric: new Attribute('barycentric', 'float', 3, null),
- },
- /**
- * Calculated bounding box of geometry.
- * @type {clay.BoundingBox}
- */
- boundingBox: null
- };
- },
- /** @lends clay.Geometry.prototype */
- {
- mainAttribute: 'position',
- /**
- * Update boundingBox of Geometry
- */
- updateBoundingBox: function () {
- var bbox = this.boundingBox;
- if (!bbox) {
- bbox = this.boundingBox = new __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__["a" /* default */]();
- }
- var posArr = this.attributes.position.value;
- if (posArr && posArr.length) {
- var min = bbox.min;
- var max = bbox.max;
- var minArr = min.array;
- var maxArr = max.array;
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set(minArr, posArr[0], posArr[1], posArr[2]);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set(maxArr, posArr[0], posArr[1], posArr[2]);
- for (var i = 3; i < posArr.length;) {
- var x = posArr[i++];
- var y = posArr[i++];
- var z = posArr[i++];
- if (x < minArr[0]) { minArr[0] = x; }
- if (y < minArr[1]) { minArr[1] = y; }
- if (z < minArr[2]) { minArr[2] = z; }
- if (x > maxArr[0]) { maxArr[0] = x; }
- if (y > maxArr[1]) { maxArr[1] = y; }
- if (z > maxArr[2]) { maxArr[2] = z; }
- }
- min._dirty = true;
- max._dirty = true;
- }
- },
- /**
- * Generate normals per vertex.
- */
- generateVertexNormals: function () {
- if (!this.vertexCount) {
- return;
- }
- var indices = this.indices;
- var attributes = this.attributes;
- var positions = attributes.position.value;
- var normals = attributes.normal.value;
- if (!normals || normals.length !== positions.length) {
- normals = attributes.normal.value = new __WEBPACK_IMPORTED_MODULE_0__core_vendor__["a" /* default */].Float32Array(positions.length);
- }
- else {
- // Reset
- for (var i = 0; i < normals.length; i++) {
- normals[i] = 0;
- }
- }
- var p1 = vec3Create();
- var p2 = vec3Create();
- var p3 = vec3Create();
- var v21 = vec3Create();
- var v32 = vec3Create();
- var n = vec3Create();
- var len = indices ? indices.length : this.vertexCount;
- var i1, i2, i3;
- for (var f = 0; f < len;) {
- if (indices) {
- i1 = indices[f++];
- i2 = indices[f++];
- i3 = indices[f++];
- }
- else {
- i1 = f++;
- i2 = f++;
- i3 = f++;
- }
- vec3Set(p1, positions[i1 * 3], positions[i1 * 3 + 1], positions[i1 * 3 + 2]);
- vec3Set(p2, positions[i2 * 3], positions[i2 * 3 + 1], positions[i2 * 3 + 2]);
- vec3Set(p3, positions[i3 * 3], positions[i3 * 3 + 1], positions[i3 * 3 + 2]);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v21, p1, p2);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v32, p2, p3);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(n, v21, v32);
- // Already be weighted by the triangle area
- for (var i = 0; i < 3; i++) {
- normals[i1 * 3 + i] = normals[i1 * 3 + i] + n[i];
- normals[i2 * 3 + i] = normals[i2 * 3 + i] + n[i];
- normals[i3 * 3 + i] = normals[i3 * 3 + i] + n[i];
- }
- }
- for (var i = 0; i < normals.length;) {
- vec3Set(n, normals[i], normals[i + 1], normals[i + 2]);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].normalize(n, n);
- normals[i++] = n[0];
- normals[i++] = n[1];
- normals[i++] = n[2];
- }
- this.dirty();
- },
- /**
- * Generate normals per face.
- */
- generateFaceNormals: function () {
- if (!this.vertexCount) {
- return;
- }
- if (!this.isUniqueVertex()) {
- this.generateUniqueVertex();
- }
- var indices = this.indices;
- var attributes = this.attributes;
- var positions = attributes.position.value;
- var normals = attributes.normal.value;
- var p1 = vec3Create();
- var p2 = vec3Create();
- var p3 = vec3Create();
- var v21 = vec3Create();
- var v32 = vec3Create();
- var n = vec3Create();
- if (!normals) {
- normals = attributes.normal.value = new Float32Array(positions.length);
- }
- var len = indices ? indices.length : this.vertexCount;
- var i1, i2, i3;
- for (var f = 0; f < len;) {
- if (indices) {
- i1 = indices[f++];
- i2 = indices[f++];
- i3 = indices[f++];
- }
- else {
- i1 = f++;
- i2 = f++;
- i3 = f++;
- }
- vec3Set(p1, positions[i1 * 3], positions[i1 * 3 + 1], positions[i1 * 3 + 2]);
- vec3Set(p2, positions[i2 * 3], positions[i2 * 3 + 1], positions[i2 * 3 + 2]);
- vec3Set(p3, positions[i3 * 3], positions[i3 * 3 + 1], positions[i3 * 3 + 2]);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v21, p1, p2);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v32, p2, p3);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(n, v21, v32);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].normalize(n, n);
- for (var i = 0; i < 3; i++) {
- normals[i1 * 3 + i] = n[i];
- normals[i2 * 3 + i] = n[i];
- normals[i3 * 3 + i] = n[i];
- }
- }
- this.dirty();
- },
- /**
- * Generate tangents attributes.
- */
- generateTangents: function () {
- if (!this.vertexCount) {
- return;
- }
- var nVertex = this.vertexCount;
- var attributes = this.attributes;
- if (!attributes.tangent.value) {
- attributes.tangent.value = new Float32Array(nVertex * 4);
- }
- var texcoords = attributes.texcoord0.value;
- var positions = attributes.position.value;
- var tangents = attributes.tangent.value;
- var normals = attributes.normal.value;
- if (!texcoords) {
- console.warn('Geometry without texcoords can\'t generate tangents.');
- return;
- }
- var tan1 = [];
- var tan2 = [];
- for (var i = 0; i < nVertex; i++) {
- tan1[i] = [0.0, 0.0, 0.0];
- tan2[i] = [0.0, 0.0, 0.0];
- }
- var sdir = [0.0, 0.0, 0.0];
- var tdir = [0.0, 0.0, 0.0];
- var indices = this.indices;
- var len = indices ? indices.length : this.vertexCount;
- var i1, i2, i3;
- for (var i = 0; i < len;) {
- if (indices) {
- i1 = indices[i++];
- i2 = indices[i++];
- i3 = indices[i++];
- }
- else {
- i1 = i++;
- i2 = i++;
- i3 = i++;
- }
- var st1s = texcoords[i1 * 2],
- st2s = texcoords[i2 * 2],
- st3s = texcoords[i3 * 2],
- st1t = texcoords[i1 * 2 + 1],
- st2t = texcoords[i2 * 2 + 1],
- st3t = texcoords[i3 * 2 + 1],
- p1x = positions[i1 * 3],
- p2x = positions[i2 * 3],
- p3x = positions[i3 * 3],
- p1y = positions[i1 * 3 + 1],
- p2y = positions[i2 * 3 + 1],
- p3y = positions[i3 * 3 + 1],
- p1z = positions[i1 * 3 + 2],
- p2z = positions[i2 * 3 + 2],
- p3z = positions[i3 * 3 + 2];
- var x1 = p2x - p1x,
- x2 = p3x - p1x,
- y1 = p2y - p1y,
- y2 = p3y - p1y,
- z1 = p2z - p1z,
- z2 = p3z - p1z;
- var s1 = st2s - st1s,
- s2 = st3s - st1s,
- t1 = st2t - st1t,
- t2 = st3t - st1t;
- var r = 1.0 / (s1 * t2 - t1 * s2);
- sdir[0] = (t2 * x1 - t1 * x2) * r;
- sdir[1] = (t2 * y1 - t1 * y2) * r;
- sdir[2] = (t2 * z1 - t1 * z2) * r;
- tdir[0] = (s1 * x2 - s2 * x1) * r;
- tdir[1] = (s1 * y2 - s2 * y1) * r;
- tdir[2] = (s1 * z2 - s2 * z1) * r;
- vec3Add(tan1[i1], tan1[i1], sdir);
- vec3Add(tan1[i2], tan1[i2], sdir);
- vec3Add(tan1[i3], tan1[i3], sdir);
- vec3Add(tan2[i1], tan2[i1], tdir);
- vec3Add(tan2[i2], tan2[i2], tdir);
- vec3Add(tan2[i3], tan2[i3], tdir);
- }
- var tmp = vec3Create();
- var nCrossT = vec3Create();
- var n = vec3Create();
- for (var i = 0; i < nVertex; i++) {
- n[0] = normals[i * 3];
- n[1] = normals[i * 3 + 1];
- n[2] = normals[i * 3 + 2];
- var t = tan1[i];
- // Gram-Schmidt orthogonalize
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scale(tmp, n, __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(n, t));
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(tmp, t, tmp);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].normalize(tmp, tmp);
- // Calculate handedness.
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(nCrossT, n, t);
- tangents[i * 4] = tmp[0];
- tangents[i * 4 + 1] = tmp[1];
- tangents[i * 4 + 2] = tmp[2];
- // PENDING can config ?
- tangents[i * 4 + 3] = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(nCrossT, tan2[i]) < 0.0 ? -1.0 : 1.0;
- }
- this.dirty();
- },
- /**
- * If vertices are not shared by different indices.
- */
- isUniqueVertex: function () {
- if (this.isUseIndices()) {
- return this.vertexCount === this.indices.length;
- }
- else {
- return true;
- }
- },
- /**
- * Create a unique vertex for each index.
- */
- generateUniqueVertex: function () {
- if (!this.vertexCount || !this.indices) {
- return;
- }
- if (this.indices.length > 0xffff) {
- this.indices = new __WEBPACK_IMPORTED_MODULE_0__core_vendor__["a" /* default */].Uint32Array(this.indices);
- }
- var attributes = this.attributes;
- var indices = this.indices;
- var attributeNameList = this.getEnabledAttributes();
- var oldAttrValues = {};
- for (var a = 0; a < attributeNameList.length; a++) {
- var name = attributeNameList[a];
- oldAttrValues[name] = attributes[name].value;
- attributes[name].init(this.indices.length);
- }
- var cursor = 0;
- for (var i = 0; i < indices.length; i++) {
- var ii = indices[i];
- for (var a = 0; a < attributeNameList.length; a++) {
- var name = attributeNameList[a];
- var array = attributes[name].value;
- var size = attributes[name].size;
- for (var k = 0; k < size; k++) {
- array[cursor * size + k] = oldAttrValues[name][ii * size + k];
- }
- }
- indices[i] = cursor;
- cursor++;
- }
- this.dirty();
- },
- /**
- * Generate barycentric coordinates for wireframe draw.
- */
- generateBarycentric: function () {
- if (!this.vertexCount) {
- return;
- }
- if (!this.isUniqueVertex()) {
- this.generateUniqueVertex();
- }
- var attributes = this.attributes;
- var array = attributes.barycentric.value;
- var indices = this.indices;
- // Already existed;
- if (array && array.length === indices.length * 3) {
- return;
- }
- array = attributes.barycentric.value = new Float32Array(indices.length * 3);
- for (var i = 0; i < (indices ? indices.length : this.vertexCount / 3);) {
- for (var j = 0; j < 3; j++) {
- var ii = indices ? indices[i++] : (i * 3 + j);
- array[ii * 3 + j] = 1;
- }
- }
- this.dirty();
- },
- /**
- * Apply transform to geometry attributes.
- * @param {clay.Matrix4} matrix
- */
- applyTransform: function (matrix) {
- var attributes = this.attributes;
- var positions = attributes.position.value;
- var normals = attributes.normal.value;
- var tangents = attributes.tangent.value;
- matrix = matrix.array;
- // Normal Matrix
- var inverseTransposeMatrix = __WEBPACK_IMPORTED_MODULE_2__glmatrix_mat4__["a" /* default */].create();
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_mat4__["a" /* default */].invert(inverseTransposeMatrix, matrix);
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_mat4__["a" /* default */].transpose(inverseTransposeMatrix, inverseTransposeMatrix);
- var vec3TransformMat4 = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].transformMat4;
- var vec3ForEach = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].forEach;
- vec3ForEach(positions, 3, 0, null, vec3TransformMat4, matrix);
- if (normals) {
- vec3ForEach(normals, 3, 0, null, vec3TransformMat4, inverseTransposeMatrix);
- }
- if (tangents) {
- vec3ForEach(tangents, 4, 0, null, vec3TransformMat4, inverseTransposeMatrix);
- }
- if (this.boundingBox) {
- this.updateBoundingBox();
- }
- },
- /**
- * Dispose geometry data in GL context.
- * @param {clay.Renderer} renderer
- */
- dispose: function (renderer) {
- var cache = this._cache;
- cache.use(renderer.__uid__);
- var chunks = cache.get('chunks');
- if (chunks) {
- for (var c = 0; c < chunks.length; c++) {
- var chunk = chunks[c];
- for (var k = 0; k < chunk.attributeBuffers.length; k++) {
- var attribs = chunk.attributeBuffers[k];
- renderer.gl.deleteBuffer(attribs.buffer);
- }
- if (chunk.indicesBuffer) {
- renderer.gl.deleteBuffer(chunk.indicesBuffer.buffer);
- }
- }
- }
- if (this.__vaoCache) {
- var vaoExt = renderer.getGLExtension('OES_vertex_array_object');
- for (var id in this.__vaoCache) {
- var vao = this.__vaoCache[id].vao;
- if (vao) {
- vaoExt.deleteVertexArrayOES(vao);
- }
- }
- }
- this.__vaoCache = {};
- cache.deleteContext(renderer.__uid__);
- }
- });
- Geometry.STATIC_DRAW = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].STATIC_DRAW;
- Geometry.DYNAMIC_DRAW = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].DYNAMIC_DRAW;
- Geometry.STREAM_DRAW = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].STREAM_DRAW;
- Geometry.AttributeBuffer = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].AttributeBuffer;
- Geometry.IndicesBuffer = __WEBPACK_IMPORTED_MODULE_4__GeometryBase__["a" /* default */].IndicesBuffer;
- Geometry.Attribute = Attribute;
- /* harmony default export */ __webpack_exports__["a"] = (Geometry);
- /***/
- }),
- /* 16 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__camera_Orthographic__ = __webpack_require__(37);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geometry_Plane__ = __webpack_require__(43);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Material__ = __webpack_require__(19);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Mesh__ = __webpack_require__(40);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__core_glenum__ = __webpack_require__(11);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__shader_source_compositor_vertex_glsl_js__ = __webpack_require__(126);
- __WEBPACK_IMPORTED_MODULE_3__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_7__shader_source_compositor_vertex_glsl_js__["a" /* default */]);
- var planeGeo = new __WEBPACK_IMPORTED_MODULE_2__geometry_Plane__["a" /* default */]();
- var mesh = new __WEBPACK_IMPORTED_MODULE_5__Mesh__["a" /* default */]({
- geometry: planeGeo,
- frustumCulling: false
- });
- var camera = new __WEBPACK_IMPORTED_MODULE_1__camera_Orthographic__["a" /* default */]();
- /**
- * @constructor clay.compositor.Pass
- * @extends clay.core.Base
- */
- var Pass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () {
- return /** @lends clay.compositor.Pass# */ {
- /**
- * Fragment shader string
- * @type {string}
- */
- // PENDING shader or fragment ?
- fragment: '',
- /**
- * @type {Object}
- */
- outputs: null,
- /**
- * @type {clay.Material}
- */
- material: null,
- /**
- * @type {Boolean}
- */
- blendWithPrevious: false,
- /**
- * @type {Boolean}
- */
- clearColor: false,
- /**
- * @type {Boolean}
- */
- clearDepth: true
- };
- }, function () {
- var shader = new __WEBPACK_IMPORTED_MODULE_3__Shader__["a" /* default */](__WEBPACK_IMPORTED_MODULE_3__Shader__["a" /* default */].source('clay.compositor.vertex'), this.fragment);
- var material = new __WEBPACK_IMPORTED_MODULE_4__Material__["a" /* default */]({
- shader: shader
- });
- material.enableTexturesAll();
- this.material = material;
- },
- /** @lends clay.compositor.Pass.prototype */
- {
- /**
- * @param {string} name
- * @param {} value
- */
- setUniform: function (name, value) {
- this.material.setUniform(name, value);
- },
- /**
- * @param {string} name
- * @return {}
- */
- getUniform: function (name) {
- var uniform = this.material.uniforms[name];
- if (uniform) {
- return uniform.value;
- }
- },
- /**
- * @param {clay.Texture} texture
- * @param {number} attachment
- */
- attachOutput: function (texture, attachment) {
- if (!this.outputs) {
- this.outputs = {};
- }
- attachment = attachment || __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].COLOR_ATTACHMENT0;
- this.outputs[attachment] = texture;
- },
- /**
- * @param {clay.Texture} texture
- */
- detachOutput: function (texture) {
- for (var attachment in this.outputs) {
- if (this.outputs[attachment] === texture) {
- this.outputs[attachment] = null;
- }
- }
- },
- bind: function (renderer, frameBuffer) {
- if (this.outputs) {
- for (var attachment in this.outputs) {
- var texture = this.outputs[attachment];
- if (texture) {
- frameBuffer.attach(texture, attachment);
- }
- }
- }
- if (frameBuffer) {
- frameBuffer.bind(renderer);
- }
- },
- unbind: function (renderer, frameBuffer) {
- frameBuffer.unbind(renderer);
- },
- /**
- * @param {clay.Renderer} renderer
- * @param {clay.FrameBuffer} [frameBuffer]
- */
- render: function (renderer, frameBuffer) {
- var _gl = renderer.gl;
- if (frameBuffer) {
- this.bind(renderer, frameBuffer);
- // MRT Support in chrome
- // https://www.khronos.org/registry/webgl/sdk/tests/conformance/extensions/ext-draw-buffers.html
- var ext = renderer.getGLExtension('EXT_draw_buffers');
- if (ext && this.outputs) {
- var bufs = [];
- for (var attachment in this.outputs) {
- attachment = +attachment;
- if (attachment >= _gl.COLOR_ATTACHMENT0 && attachment <= _gl.COLOR_ATTACHMENT0 + 8) {
- bufs.push(attachment);
- }
- }
- ext.drawBuffersEXT(bufs);
- }
- }
- this.trigger('beforerender', this, renderer);
- // FIXME Don't clear in each pass in default, let the color overwrite the buffer
- // FIXME pixels may be discard
- var clearBit = this.clearDepth ? _gl.DEPTH_BUFFER_BIT : 0;
- _gl.depthMask(true);
- if (this.clearColor) {
- clearBit = clearBit | _gl.COLOR_BUFFER_BIT;
- _gl.colorMask(true, true, true, true);
- var cc = this.clearColor;
- if (Array.isArray(cc)) {
- _gl.clearColor(cc[0], cc[1], cc[2], cc[3]);
- }
- }
- _gl.clear(clearBit);
- if (this.blendWithPrevious) {
- // Blend with previous rendered scene in the final output
- // FIXME Configure blend.
- // FIXME It will cause screen blink?
- _gl.enable(_gl.BLEND);
- this.material.transparent = true;
- }
- else {
- _gl.disable(_gl.BLEND);
- this.material.transparent = false;
- }
- this.renderQuad(renderer);
- this.trigger('afterrender', this, renderer);
- if (frameBuffer) {
- this.unbind(renderer, frameBuffer);
- }
- },
- /**
- * Simply do quad rendering
- */
- renderQuad: function (renderer) {
- mesh.material = this.material;
- renderer.renderPass([mesh], camera);
- },
- /**
- * @param {clay.Renderer} renderer
- */
- dispose: function (renderer) { }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Pass);
- /***/
- }),
- /* 17 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = (function (seriesType, ecModel, api) {
- return {
- seriesType: seriesType,
- reset: function (seriesModel, ecModel) {
- var data = seriesModel.getData();
- var opacityAccessPath = seriesModel.visualColorAccessPath.split('.');
- opacityAccessPath[opacityAccessPath.length - 1] = 'opacity';
- var opacity = seriesModel.get(opacityAccessPath);
- data.setVisual('opacity', opacity == null ? 1 : opacity);
- function dataEach(data, idx) {
- var itemModel = data.getItemModel(idx);
- var opacity = itemModel.get(opacityAccessPath, true);
- if (opacity != null) {
- data.setItemVisual(idx, 'opacity', opacity);
- }
- }
- return {
- dataEach: data.hasItemOption ? dataEach : null
- };
- }
- };
- });
- /***/
- }),
- /* 18 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__ = __webpack_require__(12);
- var vec3Set = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].set;
- var vec3Copy = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].copy;
- /**
- * Axis aligned bounding box
- * @constructor
- * @alias clay.BoundingBox
- * @param {clay.Vector3} [min]
- * @param {clay.Vector3} [max]
- */
- var BoundingBox = function (min, max) {
- /**
- * Minimum coords of bounding box
- * @type {clay.Vector3}
- */
- this.min = min || new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](Infinity, Infinity, Infinity);
- /**
- * Maximum coords of bounding box
- * @type {clay.Vector3}
- */
- this.max = max || new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](-Infinity, -Infinity, -Infinity);
- this.vertices = null;
- };
- BoundingBox.prototype = {
- constructor: BoundingBox,
- /**
- * Update min and max coords from a vertices array
- * @param {array} vertices
- */
- updateFromVertices: function (vertices) {
- if (vertices.length > 0) {
- var min = this.min;
- var max = this.max;
- var minArr = min.array;
- var maxArr = max.array;
- vec3Copy(minArr, vertices[0]);
- vec3Copy(maxArr, vertices[0]);
- for (var i = 1; i < vertices.length; i++) {
- var vertex = vertices[i];
- if (vertex[0] < minArr[0]) { minArr[0] = vertex[0]; }
- if (vertex[1] < minArr[1]) { minArr[1] = vertex[1]; }
- if (vertex[2] < minArr[2]) { minArr[2] = vertex[2]; }
- if (vertex[0] > maxArr[0]) { maxArr[0] = vertex[0]; }
- if (vertex[1] > maxArr[1]) { maxArr[1] = vertex[1]; }
- if (vertex[2] > maxArr[2]) { maxArr[2] = vertex[2]; }
- }
- min._dirty = true;
- max._dirty = true;
- }
- },
- /**
- * Union operation with another bounding box
- * @param {clay.BoundingBox} bbox
- */
- union: function (bbox) {
- var min = this.min;
- var max = this.max;
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].min(min.array, min.array, bbox.min.array);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].max(max.array, max.array, bbox.max.array);
- min._dirty = true;
- max._dirty = true;
- return this;
- },
- /**
- * Intersection operation with another bounding box
- * @param {clay.BoundingBox} bbox
- */
- intersection: function (bbox) {
- var min = this.min;
- var max = this.max;
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].max(min.array, min.array, bbox.min.array);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].min(max.array, max.array, bbox.max.array);
- min._dirty = true;
- max._dirty = true;
- return this;
- },
- /**
- * If intersect with another bounding box
- * @param {clay.BoundingBox} bbox
- * @return {boolean}
- */
- intersectBoundingBox: function (bbox) {
- var _min = this.min.array;
- var _max = this.max.array;
- var _min2 = bbox.min.array;
- var _max2 = bbox.max.array;
- return !(_min[0] > _max2[0] || _min[1] > _max2[1] || _min[2] > _max2[2]
- || _max[0] < _min2[0] || _max[1] < _min2[1] || _max[2] < _min2[2]);
- },
- /**
- * If contain another bounding box entirely
- * @param {clay.BoundingBox} bbox
- * @return {boolean}
- */
- containBoundingBox: function (bbox) {
- var _min = this.min.array;
- var _max = this.max.array;
- var _min2 = bbox.min.array;
- var _max2 = bbox.max.array;
- return _min[0] <= _min2[0] && _min[1] <= _min2[1] && _min[2] <= _min2[2]
- && _max[0] >= _max2[0] && _max[1] >= _max2[1] && _max[2] >= _max2[2];
- },
- /**
- * If contain point entirely
- * @param {clay.Vector3} point
- * @return {boolean}
- */
- containPoint: function (p) {
- var _min = this.min.array;
- var _max = this.max.array;
- var _p = p.array;
- return _min[0] <= _p[0] && _min[1] <= _p[1] && _min[2] <= _p[2]
- && _max[0] >= _p[0] && _max[1] >= _p[1] && _max[2] >= _p[2];
- },
- /**
- * If bounding box is finite
- */
- isFinite: function () {
- var _min = this.min.array;
- var _max = this.max.array;
- return isFinite(_min[0]) && isFinite(_min[1]) && isFinite(_min[2])
- && isFinite(_max[0]) && isFinite(_max[1]) && isFinite(_max[2]);
- },
- /**
- * Apply an affine transform matrix to the bounding box
- * @param {clay.Matrix4} matrix
- */
- applyTransform: function (matrix) {
- this.transformFrom(this, matrix);
- },
- /**
- * Get from another bounding box and an affine transform matrix.
- * @param {clay.BoundingBox} source
- * @param {clay.Matrix4} matrix
- */
- transformFrom: (function () {
- // http://dev.theomader.com/transform-bounding-boxes/
- var xa = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- var xb = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- var ya = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- var yb = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- var za = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- var zb = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- return function (source, matrix) {
- var min = source.min.array;
- var max = source.max.array;
- var m = matrix.array;
- xa[0] = m[0] * min[0]; xa[1] = m[1] * min[0]; xa[2] = m[2] * min[0];
- xb[0] = m[0] * max[0]; xb[1] = m[1] * max[0]; xb[2] = m[2] * max[0];
- ya[0] = m[4] * min[1]; ya[1] = m[5] * min[1]; ya[2] = m[6] * min[1];
- yb[0] = m[4] * max[1]; yb[1] = m[5] * max[1]; yb[2] = m[6] * max[1];
- za[0] = m[8] * min[2]; za[1] = m[9] * min[2]; za[2] = m[10] * min[2];
- zb[0] = m[8] * max[2]; zb[1] = m[9] * max[2]; zb[2] = m[10] * max[2];
- min = this.min.array;
- max = this.max.array;
- min[0] = Math.min(xa[0], xb[0]) + Math.min(ya[0], yb[0]) + Math.min(za[0], zb[0]) + m[12];
- min[1] = Math.min(xa[1], xb[1]) + Math.min(ya[1], yb[1]) + Math.min(za[1], zb[1]) + m[13];
- min[2] = Math.min(xa[2], xb[2]) + Math.min(ya[2], yb[2]) + Math.min(za[2], zb[2]) + m[14];
- max[0] = Math.max(xa[0], xb[0]) + Math.max(ya[0], yb[0]) + Math.max(za[0], zb[0]) + m[12];
- max[1] = Math.max(xa[1], xb[1]) + Math.max(ya[1], yb[1]) + Math.max(za[1], zb[1]) + m[13];
- max[2] = Math.max(xa[2], xb[2]) + Math.max(ya[2], yb[2]) + Math.max(za[2], zb[2]) + m[14];
- this.min._dirty = true;
- this.max._dirty = true;
- return this;
- };
- })(),
- /**
- * Apply a projection matrix to the bounding box
- * @param {clay.Matrix4} matrix
- */
- applyProjection: function (matrix) {
- var min = this.min.array;
- var max = this.max.array;
- var m = matrix.array;
- // min in min z
- var v10 = min[0];
- var v11 = min[1];
- var v12 = min[2];
- // max in min z
- var v20 = max[0];
- var v21 = max[1];
- var v22 = min[2];
- // max in max z
- var v30 = max[0];
- var v31 = max[1];
- var v32 = max[2];
- if (m[15] === 1) { // Orthographic projection
- min[0] = m[0] * v10 + m[12];
- min[1] = m[5] * v11 + m[13];
- max[2] = m[10] * v12 + m[14];
- max[0] = m[0] * v30 + m[12];
- max[1] = m[5] * v31 + m[13];
- min[2] = m[10] * v32 + m[14];
- }
- else {
- var w = -1 / v12;
- min[0] = m[0] * v10 * w;
- min[1] = m[5] * v11 * w;
- max[2] = (m[10] * v12 + m[14]) * w;
- w = -1 / v22;
- max[0] = m[0] * v20 * w;
- max[1] = m[5] * v21 * w;
- w = -1 / v32;
- min[2] = (m[10] * v32 + m[14]) * w;
- }
- this.min._dirty = true;
- this.max._dirty = true;
- return this;
- },
- updateVertices: function () {
- var vertices = this.vertices;
- if (!vertices) {
- // Cube vertices
- vertices = [];
- for (var i = 0; i < 8; i++) {
- vertices[i] = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].fromValues(0, 0, 0);
- }
- /**
- * Eight coords of bounding box
- * @type {Float32Array[]}
- */
- this.vertices = vertices;
- }
- var min = this.min.array;
- var max = this.max.array;
- //--- min z
- // min x
- vec3Set(vertices[0], min[0], min[1], min[2]);
- vec3Set(vertices[1], min[0], max[1], min[2]);
- // max x
- vec3Set(vertices[2], max[0], min[1], min[2]);
- vec3Set(vertices[3], max[0], max[1], min[2]);
- //-- max z
- vec3Set(vertices[4], min[0], min[1], max[2]);
- vec3Set(vertices[5], min[0], max[1], max[2]);
- vec3Set(vertices[6], max[0], min[1], max[2]);
- vec3Set(vertices[7], max[0], max[1], max[2]);
- return this;
- },
- /**
- * Copy values from another bounding box
- * @param {clay.BoundingBox} bbox
- */
- copy: function (bbox) {
- var min = this.min;
- var max = this.max;
- vec3Copy(min.array, bbox.min.array);
- vec3Copy(max.array, bbox.max.array);
- min._dirty = true;
- max._dirty = true;
- return this;
- },
- /**
- * Clone a new bounding box
- * @return {clay.BoundingBox}
- */
- clone: function () {
- var boundingBox = new BoundingBox();
- boundingBox.copy(this);
- return boundingBox;
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (BoundingBox);
- /***/
- }),
- /* 19 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_util__ = __webpack_require__(23);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_color__ = __webpack_require__(113);
- var parseColor = __WEBPACK_IMPORTED_MODULE_2__core_color__["a" /* default */].parseToFloat;
- var programKeyCache = {};
- function getDefineCode(defines) {
- var defineKeys = Object.keys(defines);
- defineKeys.sort();
- var defineStr = [];
- // Custom Defines
- for (var i = 0; i < defineKeys.length; i++) {
- var key = defineKeys[i];
- var value = defines[key];
- if (value === null) {
- defineStr.push(key);
- }
- else {
- defineStr.push(key + ' ' + value.toString());
- }
- }
- return defineStr.join('\n');
- }
- function getProgramKey(vertexDefines, fragmentDefines, enabledTextures) {
- enabledTextures.sort();
- var defineStr = [];
- for (var i = 0; i < enabledTextures.length; i++) {
- var symbol = enabledTextures[i];
- defineStr.push(symbol);
- }
- var key = getDefineCode(vertexDefines) + '\n'
- + getDefineCode(fragmentDefines) + '\n'
- + defineStr.join('\n');
- if (programKeyCache[key]) {
- return programKeyCache[key];
- }
- var id = __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].genGUID();
- programKeyCache[key] = id;
- return id;
- }
- /**
- * Material defines the appearance of mesh surface, like `color`, `roughness`, `metalness`, etc.
- * It contains a {@link clay.Shader} and corresponding uniforms.
- *
- * Here is a basic example to create a standard material
- ```js
- var material = new clay.Material({
- shader: new clay.Shader(
- clay.Shader.source('clay.vertex'),
- clay.Shader.source('clay.fragment')
- )
- });
- ```
- * @constructor clay.Material
- * @extends clay.core.Base
- */
- var Material = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () {
- return /** @lends clay.Material# */ {
- /**
- * @type {string}
- */
- name: '',
- /**
- * @type {Object}
- */
- // uniforms: null,
- /**
- * @type {clay.Shader}
- */
- // shader: null,
- /**
- * @type {boolean}
- */
- depthTest: true,
- /**
- * @type {boolean}
- */
- depthMask: true,
- /**
- * @type {boolean}
- */
- transparent: false,
- /**
- * Blend func is a callback function when the material
- * have custom blending
- * The gl context will be the only argument passed in tho the
- * blend function
- * Detail of blend function in WebGL:
- * http://www.khronos.org/registry/gles/specs/2.0/es_full_spec_2.0.25.pdf
- *
- * Example :
- * function(_gl) {
- * _gl.blendEquation(_gl.FUNC_ADD);
- * _gl.blendFunc(_gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA);
- * }
- */
- blend: null,
- /**
- * If update texture status automatically.
- */
- autoUpdateTextureStatus: true,
- uniforms: {},
- vertexDefines: {},
- fragmentDefines: {},
- _textureStatus: {},
- // shadowTransparentMap : null
- // PENDING enable the uniform that only used in shader.
- _enabledUniforms: null,
- };
- }, function () {
- if (!this.name) {
- this.name = 'MATERIAL_' + this.__uid__;
- }
- if (this.shader) {
- // Keep status, mainly preset uniforms, vertexDefines and fragmentDefines
- this.attachShader(this.shader, true);
- }
- },
- /** @lends clay.Material.prototype */
- {
- precision: 'highp',
- /**
- * Set material uniform
- * @example
- * mat.setUniform('color', [1, 1, 1, 1]);
- * @param {string} symbol
- * @param {number|array|clay.Texture|ArrayBufferView} value
- */
- setUniform: function (symbol, value) {
- if (value === undefined) {
- console.warn('Uniform value "' + symbol + '" is undefined');
- }
- var uniform = this.uniforms[symbol];
- if (uniform) {
- if (typeof value === 'string') {
- // Try to parse as a color. Invalid color string will return null.
- value = parseColor(value) || value;
- }
- uniform.value = value;
- if (this.autoUpdateTextureStatus && uniform.type === 't') {
- if (value) {
- this.enableTexture(symbol);
- }
- else {
- this.disableTexture(symbol);
- }
- }
- }
- },
- /**
- * @param {Object} obj
- */
- setUniforms: function (obj) {
- for (var key in obj) {
- var val = obj[key];
- this.setUniform(key, val);
- }
- },
- /**
- * @param {string} symbol
- * @return {boolean}
- */
- isUniformEnabled: function (symbol) {
- return this._enabledUniforms.indexOf(symbol) >= 0;
- },
- getEnabledUniforms: function () {
- return this._enabledUniforms;
- },
- getTextureUniforms: function () {
- return this._textureUniforms;
- },
- /**
- * Alias of setUniform and setUniforms
- * @param {object|string} symbol
- * @param {number|array|clay.Texture|ArrayBufferView} [value]
- */
- set: function (symbol, value) {
- if (typeof (symbol) === 'object') {
- for (var key in symbol) {
- var val = symbol[key];
- this.setUniform(key, val);
- }
- }
- else {
- this.setUniform(symbol, value);
- }
- },
- /**
- * Get uniform value
- * @param {string} symbol
- * @return {number|array|clay.Texture|ArrayBufferView}
- */
- get: function (symbol) {
- var uniform = this.uniforms[symbol];
- if (uniform) {
- return uniform.value;
- }
- },
- /**
- * Attach a shader instance
- * @param {clay.Shader} shader
- * @param {boolean} keepStatus If try to keep uniform and texture
- */
- attachShader: function (shader, keepStatus) {
- var originalUniforms = this.uniforms;
- // Ignore if uniform can use in shader.
- this.uniforms = shader.createUniforms();
- this.shader = shader;
- var uniforms = this.uniforms;
- this._enabledUniforms = Object.keys(uniforms);
- // Make sure uniforms are set in same order to avoid texture slot wrong
- this._enabledUniforms.sort();
- this._textureUniforms = this._enabledUniforms.filter(function (uniformName) {
- var type = this.uniforms[uniformName].type;
- return type === 't' || type === 'tv';
- }, this);
- var originalVertexDefines = this.vertexDefines;
- var originalFragmentDefines = this.fragmentDefines;
- this.vertexDefines = __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].clone(shader.vertexDefines);
- this.fragmentDefines = __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].clone(shader.fragmentDefines);
- if (keepStatus) {
- for (var symbol in originalUniforms) {
- if (uniforms[symbol]) {
- uniforms[symbol].value = originalUniforms[symbol].value;
- }
- }
- __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].defaults(this.vertexDefines, originalVertexDefines);
- __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].defaults(this.fragmentDefines, originalFragmentDefines);
- }
- var textureStatus = {};
- for (var key in shader.textures) {
- textureStatus[key] = {
- shaderType: shader.textures[key].shaderType,
- type: shader.textures[key].type,
- enabled: (keepStatus && this._textureStatus[key]) ? this._textureStatus[key].enabled : false
- };
- }
- this._textureStatus = textureStatus;
- this._programKey = '';
- },
- /**
- * Clone a new material and keep uniforms, shader will not be cloned
- * @return {clay.Material}
- */
- clone: function () {
- var material = new this.constructor({
- name: this.name,
- shader: this.shader
- });
- for (var symbol in this.uniforms) {
- material.uniforms[symbol].value = this.uniforms[symbol].value;
- }
- material.depthTest = this.depthTest;
- material.depthMask = this.depthMask;
- material.transparent = this.transparent;
- material.blend = this.blend;
- material.vertexDefines = __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].clone(this.vertexDefines);
- material.fragmentDefines = __WEBPACK_IMPORTED_MODULE_1__core_util__["a" /* default */].clone(this.fragmentDefines);
- material.enableTexture(this.getEnabledTextures());
- material.precision = this.precision;
- return material;
- },
- /**
- * Add a #define macro in shader code
- * @param {string} shaderType Can be vertex, fragment or both
- * @param {string} symbol
- * @param {number} [val]
- */
- define: function (shaderType, symbol, val) {
- var vertexDefines = this.vertexDefines;
- var fragmentDefines = this.fragmentDefines;
- if (shaderType !== 'vertex' && shaderType !== 'fragment' && shaderType !== 'both'
- && arguments.length < 3
- ) {
- // shaderType default to be 'both'
- val = symbol;
- symbol = shaderType;
- shaderType = 'both';
- }
- val = val != null ? val : null;
- if (shaderType === 'vertex' || shaderType === 'both') {
- if (vertexDefines[symbol] !== val) {
- vertexDefines[symbol] = val;
- // Mark as dirty
- this._programKey = '';
- }
- }
- if (shaderType === 'fragment' || shaderType === 'both') {
- if (fragmentDefines[symbol] !== val) {
- fragmentDefines[symbol] = val;
- if (shaderType !== 'both') {
- this._programKey = '';
- }
- }
- }
- },
- /**
- * Remove a #define macro in shader code
- * @param {string} shaderType Can be vertex, fragment or both
- * @param {string} symbol
- */
- undefine: function (shaderType, symbol) {
- if (shaderType !== 'vertex' && shaderType !== 'fragment' && shaderType !== 'both'
- && arguments.length < 2
- ) {
- // shaderType default to be 'both'
- symbol = shaderType;
- shaderType = 'both';
- }
- if (shaderType === 'vertex' || shaderType === 'both') {
- if (this.isDefined('vertex', symbol)) {
- delete this.vertexDefines[symbol];
- // Mark as dirty
- this._programKey = '';
- }
- }
- if (shaderType === 'fragment' || shaderType === 'both') {
- if (this.isDefined('fragment', symbol)) {
- delete this.fragmentDefines[symbol];
- if (shaderType !== 'both') {
- this._programKey = '';
- }
- }
- }
- },
- /**
- * If macro is defined in shader.
- * @param {string} shaderType Can be vertex, fragment or both
- * @param {string} symbol
- */
- isDefined: function (shaderType, symbol) {
- // PENDING hasOwnProperty ?
- switch (shaderType) {
- case 'vertex':
- return this.vertexDefines[symbol] !== undefined;
- case 'fragment':
- return this.fragmentDefines[symbol] !== undefined;
- }
- },
- /**
- * Get macro value defined in shader.
- * @param {string} shaderType Can be vertex, fragment or both
- * @param {string} symbol
- */
- getDefine: function (shaderType, symbol) {
- switch (shaderType) {
- case 'vertex':
- return this.vertexDefines[symbol];
- case 'fragment':
- return this.fragmentDefines[symbol];
- }
- },
- /**
- * Enable a texture, actually it will add a #define macro in the shader code
- * For example, if texture symbol is diffuseMap, it will add a line `#define DIFFUSEMAP_ENABLED` in the shader code
- * @param {string} symbol
- */
- enableTexture: function (symbol) {
- if (Array.isArray(symbol)) {
- for (var i = 0; i < symbol.length; i++) {
- this.enableTexture(symbol[i]);
- }
- return;
- }
- var status = this._textureStatus[symbol];
- if (status) {
- var isEnabled = status.enabled;
- if (!isEnabled) {
- status.enabled = true;
- this._programKey = '';
- }
- }
- },
- /**
- * Enable all textures used in the shader
- */
- enableTexturesAll: function () {
- var textureStatus = this._textureStatus;
- for (var symbol in textureStatus) {
- textureStatus[symbol].enabled = true;
- }
- this._programKey = '';
- },
- /**
- * Disable a texture, it remove a #define macro in the shader
- * @param {string} symbol
- */
- disableTexture: function (symbol) {
- if (Array.isArray(symbol)) {
- for (var i = 0; i < symbol.length; i++) {
- this.disableTexture(symbol[i]);
- }
- return;
- }
- var status = this._textureStatus[symbol];
- if (status) {
- var isDisabled = !status.enabled;
- if (!isDisabled) {
- status.enabled = false;
- this._programKey = '';
- }
- }
- },
- /**
- * Disable all textures used in the shader
- */
- disableTexturesAll: function () {
- var textureStatus = this._textureStatus;
- for (var symbol in textureStatus) {
- textureStatus[symbol].enabled = false;
- }
- this._programKey = '';
- },
- /**
- * If texture of given type is enabled.
- * @param {string} symbol
- * @return {boolean}
- */
- isTextureEnabled: function (symbol) {
- var textureStatus = this._textureStatus;
- return !!textureStatus[symbol]
- && textureStatus[symbol].enabled;
- },
- /**
- * Get all enabled textures
- * @return {string[]}
- */
- getEnabledTextures: function () {
- var enabledTextures = [];
- var textureStatus = this._textureStatus;
- for (var symbol in textureStatus) {
- if (textureStatus[symbol].enabled) {
- enabledTextures.push(symbol);
- }
- }
- return enabledTextures;
- },
- /**
- * Mark defines are updated.
- */
- dirtyDefines: function () {
- this._programKey = '';
- },
- getProgramKey: function () {
- if (!this._programKey) {
- this._programKey = getProgramKey(
- this.vertexDefines, this.fragmentDefines, this.getEnabledTextures()
- );
- }
- return this._programKey;
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Material);
- /***/
- }),
- /* 20 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function () { return GLMAT_EPSILON; });
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function () { return GLMAT_ARRAY_TYPE; });
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function () { return GLMAT_RANDOM; });
- var GLMAT_EPSILON = 0.000001;
- // Use Array instead of Float32Array. It seems to be much faster and higher precision.
- var GLMAT_ARRAY_TYPE = Array;
- // if(!GLMAT_ARRAY_TYPE) {
- // GLMAT_ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
- // }
- var GLMAT_RANDOM = Math.random;
- /***/
- }),
- /* 21 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20);
- /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
- /**
- * @class 4x4 Matrix
- * @name mat4
- */
- var mat4 = {};
- /**
- * Creates a new identity mat4
- *
- * @returns {mat4} a new 4x4 matrix
- */
- mat4.create = function () {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](16);
- out[0] = 1;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = 0;
- out[5] = 1;
- out[6] = 0;
- out[7] = 0;
- out[8] = 0;
- out[9] = 0;
- out[10] = 1;
- out[11] = 0;
- out[12] = 0;
- out[13] = 0;
- out[14] = 0;
- out[15] = 1;
- return out;
- };
- /**
- * Creates a new mat4 initialized with values from an existing matrix
- *
- * @param {mat4} a matrix to clone
- * @returns {mat4} a new 4x4 matrix
- */
- mat4.clone = function (a) {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](16);
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- out[4] = a[4];
- out[5] = a[5];
- out[6] = a[6];
- out[7] = a[7];
- out[8] = a[8];
- out[9] = a[9];
- out[10] = a[10];
- out[11] = a[11];
- out[12] = a[12];
- out[13] = a[13];
- out[14] = a[14];
- out[15] = a[15];
- return out;
- };
- /**
- * Copy the values from one mat4 to another
- *
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the source matrix
- * @returns {mat4} out
- */
- mat4.copy = function (out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- out[4] = a[4];
- out[5] = a[5];
- out[6] = a[6];
- out[7] = a[7];
- out[8] = a[8];
- out[9] = a[9];
- out[10] = a[10];
- out[11] = a[11];
- out[12] = a[12];
- out[13] = a[13];
- out[14] = a[14];
- out[15] = a[15];
- return out;
- };
- /**
- * Set a mat4 to the identity matrix
- *
- * @param {mat4} out the receiving matrix
- * @returns {mat4} out
- */
- mat4.identity = function (out) {
- out[0] = 1;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = 0;
- out[5] = 1;
- out[6] = 0;
- out[7] = 0;
- out[8] = 0;
- out[9] = 0;
- out[10] = 1;
- out[11] = 0;
- out[12] = 0;
- out[13] = 0;
- out[14] = 0;
- out[15] = 1;
- return out;
- };
- /**
- * Transpose the values of a mat4
- *
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the source matrix
- * @returns {mat4} out
- */
- mat4.transpose = function (out, a) {
- // If we are transposing ourselves we can skip a few steps but have to cache some values
- if (out === a) {
- var a01 = a[1], a02 = a[2], a03 = a[3],
- a12 = a[6], a13 = a[7],
- a23 = a[11];
- out[1] = a[4];
- out[2] = a[8];
- out[3] = a[12];
- out[4] = a01;
- out[6] = a[9];
- out[7] = a[13];
- out[8] = a02;
- out[9] = a12;
- out[11] = a[14];
- out[12] = a03;
- out[13] = a13;
- out[14] = a23;
- } else {
- out[0] = a[0];
- out[1] = a[4];
- out[2] = a[8];
- out[3] = a[12];
- out[4] = a[1];
- out[5] = a[5];
- out[6] = a[9];
- out[7] = a[13];
- out[8] = a[2];
- out[9] = a[6];
- out[10] = a[10];
- out[11] = a[14];
- out[12] = a[3];
- out[13] = a[7];
- out[14] = a[11];
- out[15] = a[15];
- }
- return out;
- };
- /**
- * Inverts a mat4
- *
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the source matrix
- * @returns {mat4} out
- */
- mat4.invert = function (out, a) {
- var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
- a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
- a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
- a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
- b00 = a00 * a11 - a01 * a10,
- b01 = a00 * a12 - a02 * a10,
- b02 = a00 * a13 - a03 * a10,
- b03 = a01 * a12 - a02 * a11,
- b04 = a01 * a13 - a03 * a11,
- b05 = a02 * a13 - a03 * a12,
- b06 = a20 * a31 - a21 * a30,
- b07 = a20 * a32 - a22 * a30,
- b08 = a20 * a33 - a23 * a30,
- b09 = a21 * a32 - a22 * a31,
- b10 = a21 * a33 - a23 * a31,
- b11 = a22 * a33 - a23 * a32,
- // Calculate the determinant
- det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
- if (!det) {
- return null;
- }
- det = 1.0 / det;
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
- out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
- out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
- out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
- out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
- out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
- out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
- out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
- out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
- out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
- out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
- out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
- out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
- out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
- out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
- out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
- return out;
- };
- /**
- * Calculates the adjugate of a mat4
- *
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the source matrix
- * @returns {mat4} out
- */
- mat4.adjoint = function (out, a) {
- var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
- a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
- a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
- a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
- out[0] = (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22));
- out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22));
- out[2] = (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12));
- out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12));
- out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22));
- out[5] = (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22));
- out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12));
- out[7] = (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12));
- out[8] = (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21));
- out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21));
- out[10] = (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11));
- out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11));
- out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21));
- out[13] = (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21));
- out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11));
- out[15] = (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11));
- return out;
- };
- /**
- * Calculates the determinant of a mat4
- *
- * @param {mat4} a the source matrix
- * @returns {Number} determinant of a
- */
- mat4.determinant = function (a) {
- var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
- a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
- a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
- a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
- b00 = a00 * a11 - a01 * a10,
- b01 = a00 * a12 - a02 * a10,
- b02 = a00 * a13 - a03 * a10,
- b03 = a01 * a12 - a02 * a11,
- b04 = a01 * a13 - a03 * a11,
- b05 = a02 * a13 - a03 * a12,
- b06 = a20 * a31 - a21 * a30,
- b07 = a20 * a32 - a22 * a30,
- b08 = a20 * a33 - a23 * a30,
- b09 = a21 * a32 - a22 * a31,
- b10 = a21 * a33 - a23 * a31,
- b11 = a22 * a33 - a23 * a32;
- // Calculate the determinant
- return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
- };
- /**
- * Multiplies two mat4's
- *
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the first operand
- * @param {mat4} b the second operand
- * @returns {mat4} out
- */
- mat4.multiply = function (out, a, b) {
- var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
- a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
- a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
- a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
- // Cache only the current line of the second matrix
- var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
- out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
- out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
- out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
- out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
- b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7];
- out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
- out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
- out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
- out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
- b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11];
- out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
- out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
- out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
- out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
- b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15];
- out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
- out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
- out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
- out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
- return out;
- };
- /**
- * Multiplies two affine mat4's
- * Add by https://github.com/pissang
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the first operand
- * @param {mat4} b the second operand
- * @returns {mat4} out
- */
- mat4.multiplyAffine = function (out, a, b) {
- var a00 = a[0], a01 = a[1], a02 = a[2],
- a10 = a[4], a11 = a[5], a12 = a[6],
- a20 = a[8], a21 = a[9], a22 = a[10],
- a30 = a[12], a31 = a[13], a32 = a[14];
- // Cache only the current line of the second matrix
- var b0 = b[0], b1 = b[1], b2 = b[2];
- out[0] = b0 * a00 + b1 * a10 + b2 * a20;
- out[1] = b0 * a01 + b1 * a11 + b2 * a21;
- out[2] = b0 * a02 + b1 * a12 + b2 * a22;
- // out[3] = 0;
- b0 = b[4]; b1 = b[5]; b2 = b[6];
- out[4] = b0 * a00 + b1 * a10 + b2 * a20;
- out[5] = b0 * a01 + b1 * a11 + b2 * a21;
- out[6] = b0 * a02 + b1 * a12 + b2 * a22;
- // out[7] = 0;
- b0 = b[8]; b1 = b[9]; b2 = b[10];
- out[8] = b0 * a00 + b1 * a10 + b2 * a20;
- out[9] = b0 * a01 + b1 * a11 + b2 * a21;
- out[10] = b0 * a02 + b1 * a12 + b2 * a22;
- // out[11] = 0;
- b0 = b[12]; b1 = b[13]; b2 = b[14];
- out[12] = b0 * a00 + b1 * a10 + b2 * a20 + a30;
- out[13] = b0 * a01 + b1 * a11 + b2 * a21 + a31;
- out[14] = b0 * a02 + b1 * a12 + b2 * a22 + a32;
- // out[15] = 1;
- return out;
- };
- /**
- * Alias for {@link mat4.multiply}
- * @function
- */
- mat4.mul = mat4.multiply;
- /**
- * Alias for {@link mat4.multiplyAffine}
- * @function
- */
- mat4.mulAffine = mat4.multiplyAffine;
- /**
- * Translate a mat4 by the given vector
- *
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the matrix to translate
- * @param {vec3} v vector to translate by
- * @returns {mat4} out
- */
- mat4.translate = function (out, a, v) {
- var x = v[0], y = v[1], z = v[2],
- a00, a01, a02, a03,
- a10, a11, a12, a13,
- a20, a21, a22, a23;
- if (a === out) {
- out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
- out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
- out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
- out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
- } else {
- a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3];
- a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7];
- a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11];
- out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03;
- out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13;
- out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23;
- out[12] = a00 * x + a10 * y + a20 * z + a[12];
- out[13] = a01 * x + a11 * y + a21 * z + a[13];
- out[14] = a02 * x + a12 * y + a22 * z + a[14];
- out[15] = a03 * x + a13 * y + a23 * z + a[15];
- }
- return out;
- };
- /**
- * Scales the mat4 by the dimensions in the given vec3
- *
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the matrix to scale
- * @param {vec3} v the vec3 to scale the matrix by
- * @returns {mat4} out
- **/
- mat4.scale = function (out, a, v) {
- var x = v[0], y = v[1], z = v[2];
- out[0] = a[0] * x;
- out[1] = a[1] * x;
- out[2] = a[2] * x;
- out[3] = a[3] * x;
- out[4] = a[4] * y;
- out[5] = a[5] * y;
- out[6] = a[6] * y;
- out[7] = a[7] * y;
- out[8] = a[8] * z;
- out[9] = a[9] * z;
- out[10] = a[10] * z;
- out[11] = a[11] * z;
- out[12] = a[12];
- out[13] = a[13];
- out[14] = a[14];
- out[15] = a[15];
- return out;
- };
- /**
- * Rotates a mat4 by the given angle
- *
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the matrix to rotate
- * @param {Number} rad the angle to rotate the matrix by
- * @param {vec3} axis the axis to rotate around
- * @returns {mat4} out
- */
- mat4.rotate = function (out, a, rad, axis) {
- var x = axis[0], y = axis[1], z = axis[2],
- len = Math.sqrt(x * x + y * y + z * z),
- s, c, t,
- a00, a01, a02, a03,
- a10, a11, a12, a13,
- a20, a21, a22, a23,
- b00, b01, b02,
- b10, b11, b12,
- b20, b21, b22;
- if (Math.abs(len) < __WEBPACK_IMPORTED_MODULE_0__common__["b" /* GLMAT_EPSILON */]) { return null; }
- len = 1 / len;
- x *= len;
- y *= len;
- z *= len;
- s = Math.sin(rad);
- c = Math.cos(rad);
- t = 1 - c;
- a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3];
- a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7];
- a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11];
- // Construct the elements of the rotation matrix
- b00 = x * x * t + c; b01 = y * x * t + z * s; b02 = z * x * t - y * s;
- b10 = x * y * t - z * s; b11 = y * y * t + c; b12 = z * y * t + x * s;
- b20 = x * z * t + y * s; b21 = y * z * t - x * s; b22 = z * z * t + c;
- // Perform rotation-specific matrix multiplication
- out[0] = a00 * b00 + a10 * b01 + a20 * b02;
- out[1] = a01 * b00 + a11 * b01 + a21 * b02;
- out[2] = a02 * b00 + a12 * b01 + a22 * b02;
- out[3] = a03 * b00 + a13 * b01 + a23 * b02;
- out[4] = a00 * b10 + a10 * b11 + a20 * b12;
- out[5] = a01 * b10 + a11 * b11 + a21 * b12;
- out[6] = a02 * b10 + a12 * b11 + a22 * b12;
- out[7] = a03 * b10 + a13 * b11 + a23 * b12;
- out[8] = a00 * b20 + a10 * b21 + a20 * b22;
- out[9] = a01 * b20 + a11 * b21 + a21 * b22;
- out[10] = a02 * b20 + a12 * b21 + a22 * b22;
- out[11] = a03 * b20 + a13 * b21 + a23 * b22;
- if (a !== out) { // If the source and destination differ, copy the unchanged last row
- out[12] = a[12];
- out[13] = a[13];
- out[14] = a[14];
- out[15] = a[15];
- }
- return out;
- };
- /**
- * Rotates a matrix by the given angle around the X axis
- *
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the matrix to rotate
- * @param {Number} rad the angle to rotate the matrix by
- * @returns {mat4} out
- */
- mat4.rotateX = function (out, a, rad) {
- var s = Math.sin(rad),
- c = Math.cos(rad),
- a10 = a[4],
- a11 = a[5],
- a12 = a[6],
- a13 = a[7],
- a20 = a[8],
- a21 = a[9],
- a22 = a[10],
- a23 = a[11];
- if (a !== out) { // If the source and destination differ, copy the unchanged rows
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- out[12] = a[12];
- out[13] = a[13];
- out[14] = a[14];
- out[15] = a[15];
- }
- // Perform axis-specific matrix multiplication
- out[4] = a10 * c + a20 * s;
- out[5] = a11 * c + a21 * s;
- out[6] = a12 * c + a22 * s;
- out[7] = a13 * c + a23 * s;
- out[8] = a20 * c - a10 * s;
- out[9] = a21 * c - a11 * s;
- out[10] = a22 * c - a12 * s;
- out[11] = a23 * c - a13 * s;
- return out;
- };
- /**
- * Rotates a matrix by the given angle around the Y axis
- *
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the matrix to rotate
- * @param {Number} rad the angle to rotate the matrix by
- * @returns {mat4} out
- */
- mat4.rotateY = function (out, a, rad) {
- var s = Math.sin(rad),
- c = Math.cos(rad),
- a00 = a[0],
- a01 = a[1],
- a02 = a[2],
- a03 = a[3],
- a20 = a[8],
- a21 = a[9],
- a22 = a[10],
- a23 = a[11];
- if (a !== out) { // If the source and destination differ, copy the unchanged rows
- out[4] = a[4];
- out[5] = a[5];
- out[6] = a[6];
- out[7] = a[7];
- out[12] = a[12];
- out[13] = a[13];
- out[14] = a[14];
- out[15] = a[15];
- }
- // Perform axis-specific matrix multiplication
- out[0] = a00 * c - a20 * s;
- out[1] = a01 * c - a21 * s;
- out[2] = a02 * c - a22 * s;
- out[3] = a03 * c - a23 * s;
- out[8] = a00 * s + a20 * c;
- out[9] = a01 * s + a21 * c;
- out[10] = a02 * s + a22 * c;
- out[11] = a03 * s + a23 * c;
- return out;
- };
- /**
- * Rotates a matrix by the given angle around the Z axis
- *
- * @param {mat4} out the receiving matrix
- * @param {mat4} a the matrix to rotate
- * @param {Number} rad the angle to rotate the matrix by
- * @returns {mat4} out
- */
- mat4.rotateZ = function (out, a, rad) {
- var s = Math.sin(rad),
- c = Math.cos(rad),
- a00 = a[0],
- a01 = a[1],
- a02 = a[2],
- a03 = a[3],
- a10 = a[4],
- a11 = a[5],
- a12 = a[6],
- a13 = a[7];
- if (a !== out) { // If the source and destination differ, copy the unchanged last row
- out[8] = a[8];
- out[9] = a[9];
- out[10] = a[10];
- out[11] = a[11];
- out[12] = a[12];
- out[13] = a[13];
- out[14] = a[14];
- out[15] = a[15];
- }
- // Perform axis-specific matrix multiplication
- out[0] = a00 * c + a10 * s;
- out[1] = a01 * c + a11 * s;
- out[2] = a02 * c + a12 * s;
- out[3] = a03 * c + a13 * s;
- out[4] = a10 * c - a00 * s;
- out[5] = a11 * c - a01 * s;
- out[6] = a12 * c - a02 * s;
- out[7] = a13 * c - a03 * s;
- return out;
- };
- /**
- * Creates a matrix from a quaternion rotation and vector translation
- * This is equivalent to (but much faster than):
- *
- * mat4.identity(dest);
- * mat4.translate(dest, vec);
- * var quatMat = mat4.create();
- * quat4.toMat4(quat, quatMat);
- * mat4.multiply(dest, quatMat);
- *
- * @param {mat4} out mat4 receiving operation result
- * @param {quat4} q Rotation quaternion
- * @param {vec3} v Translation vector
- * @returns {mat4} out
- */
- mat4.fromRotationTranslation = function (out, q, v) {
- // Quaternion math
- var x = q[0], y = q[1], z = q[2], w = q[3],
- x2 = x + x,
- y2 = y + y,
- z2 = z + z,
- xx = x * x2,
- xy = x * y2,
- xz = x * z2,
- yy = y * y2,
- yz = y * z2,
- zz = z * z2,
- wx = w * x2,
- wy = w * y2,
- wz = w * z2;
- out[0] = 1 - (yy + zz);
- out[1] = xy + wz;
- out[2] = xz - wy;
- out[3] = 0;
- out[4] = xy - wz;
- out[5] = 1 - (xx + zz);
- out[6] = yz + wx;
- out[7] = 0;
- out[8] = xz + wy;
- out[9] = yz - wx;
- out[10] = 1 - (xx + yy);
- out[11] = 0;
- out[12] = v[0];
- out[13] = v[1];
- out[14] = v[2];
- out[15] = 1;
- return out;
- };
- mat4.fromQuat = function (out, q) {
- var x = q[0], y = q[1], z = q[2], w = q[3],
- x2 = x + x,
- y2 = y + y,
- z2 = z + z,
- xx = x * x2,
- yx = y * x2,
- yy = y * y2,
- zx = z * x2,
- zy = z * y2,
- zz = z * z2,
- wx = w * x2,
- wy = w * y2,
- wz = w * z2;
- out[0] = 1 - yy - zz;
- out[1] = yx + wz;
- out[2] = zx - wy;
- out[3] = 0;
- out[4] = yx - wz;
- out[5] = 1 - xx - zz;
- out[6] = zy + wx;
- out[7] = 0;
- out[8] = zx + wy;
- out[9] = zy - wx;
- out[10] = 1 - xx - yy;
- out[11] = 0;
- out[12] = 0;
- out[13] = 0;
- out[14] = 0;
- out[15] = 1;
- return out;
- };
- /**
- * Generates a frustum matrix with the given bounds
- *
- * @param {mat4} out mat4 frustum matrix will be written into
- * @param {Number} left Left bound of the frustum
- * @param {Number} right Right bound of the frustum
- * @param {Number} bottom Bottom bound of the frustum
- * @param {Number} top Top bound of the frustum
- * @param {Number} near Near bound of the frustum
- * @param {Number} far Far bound of the frustum
- * @returns {mat4} out
- */
- mat4.frustum = function (out, left, right, bottom, top, near, far) {
- var rl = 1 / (right - left),
- tb = 1 / (top - bottom),
- nf = 1 / (near - far);
- out[0] = (near * 2) * rl;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = 0;
- out[5] = (near * 2) * tb;
- out[6] = 0;
- out[7] = 0;
- out[8] = (right + left) * rl;
- out[9] = (top + bottom) * tb;
- out[10] = (far + near) * nf;
- out[11] = -1;
- out[12] = 0;
- out[13] = 0;
- out[14] = (far * near * 2) * nf;
- out[15] = 0;
- return out;
- };
- /**
- * Generates a perspective projection matrix with the given bounds
- *
- * @param {mat4} out mat4 frustum matrix will be written into
- * @param {number} fovy Vertical field of view in radians
- * @param {number} aspect Aspect ratio. typically viewport width/height
- * @param {number} near Near bound of the frustum
- * @param {number} far Far bound of the frustum
- * @returns {mat4} out
- */
- mat4.perspective = function (out, fovy, aspect, near, far) {
- var f = 1.0 / Math.tan(fovy / 2),
- nf = 1 / (near - far);
- out[0] = f / aspect;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = 0;
- out[5] = f;
- out[6] = 0;
- out[7] = 0;
- out[8] = 0;
- out[9] = 0;
- out[10] = (far + near) * nf;
- out[11] = -1;
- out[12] = 0;
- out[13] = 0;
- out[14] = (2 * far * near) * nf;
- out[15] = 0;
- return out;
- };
- /**
- * Generates a orthogonal projection matrix with the given bounds
- *
- * @param {mat4} out mat4 frustum matrix will be written into
- * @param {number} left Left bound of the frustum
- * @param {number} right Right bound of the frustum
- * @param {number} bottom Bottom bound of the frustum
- * @param {number} top Top bound of the frustum
- * @param {number} near Near bound of the frustum
- * @param {number} far Far bound of the frustum
- * @returns {mat4} out
- */
- mat4.ortho = function (out, left, right, bottom, top, near, far) {
- var lr = 1 / (left - right),
- bt = 1 / (bottom - top),
- nf = 1 / (near - far);
- out[0] = -2 * lr;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = 0;
- out[5] = -2 * bt;
- out[6] = 0;
- out[7] = 0;
- out[8] = 0;
- out[9] = 0;
- out[10] = 2 * nf;
- out[11] = 0;
- out[12] = (left + right) * lr;
- out[13] = (top + bottom) * bt;
- out[14] = (far + near) * nf;
- out[15] = 1;
- return out;
- };
- /**
- * Generates a look-at matrix with the given eye position, focal point, and up axis
- *
- * @param {mat4} out mat4 frustum matrix will be written into
- * @param {vec3} eye Position of the viewer
- * @param {vec3} center Point the viewer is looking at
- * @param {vec3} up vec3 pointing up
- * @returns {mat4} out
- */
- mat4.lookAt = function (out, eye, center, up) {
- var x0, x1, x2, y0, y1, y2, z0, z1, z2, len,
- eyex = eye[0],
- eyey = eye[1],
- eyez = eye[2],
- upx = up[0],
- upy = up[1],
- upz = up[2],
- centerx = center[0],
- centery = center[1],
- centerz = center[2];
- if (Math.abs(eyex - centerx) < __WEBPACK_IMPORTED_MODULE_0__common__["b" /* GLMAT_EPSILON */] &&
- Math.abs(eyey - centery) < __WEBPACK_IMPORTED_MODULE_0__common__["b" /* GLMAT_EPSILON */] &&
- Math.abs(eyez - centerz) < __WEBPACK_IMPORTED_MODULE_0__common__["b" /* GLMAT_EPSILON */]) {
- return mat4.identity(out);
- }
- z0 = eyex - centerx;
- z1 = eyey - centery;
- z2 = eyez - centerz;
- len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
- z0 *= len;
- z1 *= len;
- z2 *= len;
- x0 = upy * z2 - upz * z1;
- x1 = upz * z0 - upx * z2;
- x2 = upx * z1 - upy * z0;
- len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
- if (!len) {
- x0 = 0;
- x1 = 0;
- x2 = 0;
- } else {
- len = 1 / len;
- x0 *= len;
- x1 *= len;
- x2 *= len;
- }
- y0 = z1 * x2 - z2 * x1;
- y1 = z2 * x0 - z0 * x2;
- y2 = z0 * x1 - z1 * x0;
- len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
- if (!len) {
- y0 = 0;
- y1 = 0;
- y2 = 0;
- } else {
- len = 1 / len;
- y0 *= len;
- y1 *= len;
- y2 *= len;
- }
- out[0] = x0;
- out[1] = y0;
- out[2] = z0;
- out[3] = 0;
- out[4] = x1;
- out[5] = y1;
- out[6] = z1;
- out[7] = 0;
- out[8] = x2;
- out[9] = y2;
- out[10] = z2;
- out[11] = 0;
- out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);
- out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);
- out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);
- out[15] = 1;
- return out;
- };
- /**
- * Returns Frobenius norm of a mat4
- *
- * @param {mat4} a the matrix to calculate Frobenius norm of
- * @returns {Number} Frobenius norm
- */
- mat4.frob = function (a) {
- return (Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2) + Math.pow(a[9], 2) + Math.pow(a[10], 2) + Math.pow(a[11], 2) + Math.pow(a[12], 2) + Math.pow(a[13], 2) + Math.pow(a[14], 2) + Math.pow(a[15], 2)))
- };
- /* harmony default export */ __webpack_exports__["a"] = (mat4);
- /***/
- }),
- /* 22 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Scene__ = __webpack_require__(36);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_prePass_ShadowMap__ = __webpack_require__(174);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__ = __webpack_require__(41);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_camera_Orthographic__ = __webpack_require__(37);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_math_Vector2__ = __webpack_require__(26);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_claygl_src_core_mixin_notifier__ = __webpack_require__(53);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__effect_EffectCompositor__ = __webpack_require__(176);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__effect_TemporalSuperSampling__ = __webpack_require__(200);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__effect_halton__ = __webpack_require__(49);
- /*
- * @module echarts-gl/core/ViewGL
- * @author Yi Shen(http://github.com/pissang)
- */
- /**
- * @constructor
- * @alias module:echarts-gl/core/ViewGL
- * @param {string} [projection='perspective']
- */
- function ViewGL(projection) {
- projection = projection || 'perspective';
- /**
- * @type {module:echarts-gl/core/LayerGL}
- */
- this.layer = null;
- /**
- * @type {clay.Scene}
- */
- this.scene = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Scene__["a" /* default */]();
- /**
- * @type {clay.Node}
- */
- this.rootNode = this.scene;
- this.viewport = {
- x: 0, y: 0, width: 0, height: 0
- };
- this.setProjection(projection);
- this._compositor = new __WEBPACK_IMPORTED_MODULE_9__effect_EffectCompositor__["a" /* default */]();
- this._temporalSS = new __WEBPACK_IMPORTED_MODULE_10__effect_TemporalSuperSampling__["a" /* default */]();
- this._shadowMapPass = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_prePass_ShadowMap__["a" /* default */]();
- var pcfKernels = [];
- var off = 0;
- for (var i = 0; i < 30; i++) {
- var pcfKernel = [];
- for (var k = 0; k < 6; k++) {
- pcfKernel.push(Object(__WEBPACK_IMPORTED_MODULE_11__effect_halton__["a" /* default */])(off, 2) * 4.0 - 2.0);
- pcfKernel.push(Object(__WEBPACK_IMPORTED_MODULE_11__effect_halton__["a" /* default */])(off, 3) * 4.0 - 2.0);
- off++;
- }
- pcfKernels.push(pcfKernel);
- }
- this._pcfKernels = pcfKernels;
- this.scene.on('beforerender', function (renderer, scene, camera) {
- if (this.needsTemporalSS()) {
- this._temporalSS.jitterProjection(renderer, camera);
- }
- }, this);
- }
- /**
- * Set camera type of group
- * @param {string} cameraType 'perspective' | 'orthographic'
- */
- ViewGL.prototype.setProjection = function (projection) {
- var oldCamera = this.camera;
- oldCamera && oldCamera.update();
- if (projection === 'perspective') {
- if (!(this.camera instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__["a" /* default */])) {
- this.camera = new __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__["a" /* default */]();
- if (oldCamera) {
- this.camera.setLocalTransform(oldCamera.localTransform);
- }
- }
- }
- else {
- if (!(this.camera instanceof __WEBPACK_IMPORTED_MODULE_4_claygl_src_camera_Orthographic__["a" /* default */])) {
- this.camera = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_camera_Orthographic__["a" /* default */]();
- if (oldCamera) {
- this.camera.setLocalTransform(oldCamera.localTransform);
- }
- }
- }
- // PENDING
- this.camera.near = 0.1;
- this.camera.far = 2000;
- };
- /**
- * Set viewport of group
- * @param {number} x Viewport left bottom x
- * @param {number} y Viewport left bottom y
- * @param {number} width Viewport height
- * @param {number} height Viewport height
- * @param {number} [dpr=1]
- */
- ViewGL.prototype.setViewport = function (x, y, width, height, dpr) {
- if (this.camera instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_camera_Perspective__["a" /* default */]) {
- this.camera.aspect = width / height;
- }
- dpr = dpr || 1;
- this.viewport.x = x;
- this.viewport.y = y;
- this.viewport.width = width;
- this.viewport.height = height;
- this.viewport.devicePixelRatio = dpr;
- // Source and output of compositor use high dpr texture.
- // But the intermediate texture of bloom, dof effects use fixed 1.0 dpr
- this._compositor.resize(width * dpr, height * dpr);
- this._temporalSS.resize(width * dpr, height * dpr);
- };
- /**
- * If contain screen point x, y
- * @param {number} x offsetX
- * @param {number} y offsetY
- * @return {boolean}
- */
- ViewGL.prototype.containPoint = function (x, y) {
- var viewport = this.viewport;
- var height = this.layer.renderer.getHeight();
- // Flip y;
- y = height - y;
- return x >= viewport.x && y >= viewport.y
- && x <= viewport.x + viewport.width && y <= viewport.y + viewport.height;
- };
- /**
- * Cast a ray
- * @param {number} x offsetX
- * @param {number} y offsetY
- * @param {clay.math.Ray} out
- * @return {clay.math.Ray}
- */
- var ndc = new __WEBPACK_IMPORTED_MODULE_7_claygl_src_math_Vector2__["a" /* default */]();
- ViewGL.prototype.castRay = function (x, y, out) {
- var renderer = this.layer.renderer;
- var oldViewport = renderer.viewport;
- renderer.viewport = this.viewport;
- renderer.screenToNDC(x, y, ndc);
- this.camera.castRay(ndc, out);
- renderer.viewport = oldViewport;
- return out;
- };
- /**
- * Prepare and update scene before render
- */
- ViewGL.prototype.prepareRender = function () {
- this.scene.update();
- this.camera.update();
- this.scene.updateLights();
- var renderList = this.scene.updateRenderList(this.camera);
- this._needsSortProgressively = false;
- // If has any transparent mesh needs sort triangles progressively.
- for (var i = 0; i < renderList.transparent.length; i++) {
- var renderable = renderList.transparent[i];
- var geometry = renderable.geometry;
- if (geometry.needsSortVerticesProgressively && geometry.needsSortVerticesProgressively()) {
- this._needsSortProgressively = true;
- }
- if (geometry.needsSortTrianglesProgressively && geometry.needsSortTrianglesProgressively()) {
- this._needsSortProgressively = true;
- }
- }
- this._frame = 0;
- this._temporalSS.resetFrame();
- // var lights = this.scene.getLights();
- // for (var i = 0; i < lights.length; i++) {
- // if (lights[i].cubemap) {
- // if (this._compositor && this._compositor.isSSREnabled()) {
- // lights[i].invisible = true;
- // }
- // else {
- // lights[i].invisible = false;
- // }
- // }
- // }
- };
- ViewGL.prototype.render = function (renderer, accumulating) {
- this._doRender(renderer, accumulating, this._frame);
- this._frame++;
- };
- ViewGL.prototype.needsAccumulate = function () {
- return this.needsTemporalSS() || this._needsSortProgressively;
- };
- ViewGL.prototype.needsTemporalSS = function () {
- var enableTemporalSS = this._enableTemporalSS;
- if (enableTemporalSS === 'auto') {
- enableTemporalSS = this._enablePostEffect;
- }
- return enableTemporalSS;
- };
- ViewGL.prototype.hasDOF = function () {
- return this._enableDOF;
- };
- ViewGL.prototype.isAccumulateFinished = function () {
- return this.needsTemporalSS() ? this._temporalSS.isFinished()
- : (this._frame > 30);
- };
- ViewGL.prototype._doRender = function (renderer, accumulating, accumFrame) {
- var scene = this.scene;
- var camera = this.camera;
- accumFrame = accumFrame || 0;
- this._updateTransparent(renderer, scene, camera, accumFrame);
- if (!accumulating) {
- this._shadowMapPass.kernelPCF = this._pcfKernels[0];
- // Not render shadowmap pass in accumulating frame.
- this._shadowMapPass.render(renderer, scene, camera, true);
- }
- this._updateShadowPCFKernel(accumFrame);
- // Shadowmap will set clear color.
- var bgColor = renderer.clearColor;
- renderer.gl.clearColor(bgColor[0], bgColor[1], bgColor[2], bgColor[3]);
- if (this._enablePostEffect) {
- // normal render also needs to be jittered when have edge pass.
- if (this.needsTemporalSS()) {
- this._temporalSS.jitterProjection(renderer, camera);
- }
- this._compositor.updateNormal(renderer, scene, camera, this._temporalSS.getFrame());
- }
- // Always update SSAO to make sure have correct ssaoMap status
- this._updateSSAO(renderer, scene, camera, this._temporalSS.getFrame());
- if (this._enablePostEffect) {
- var frameBuffer = this._compositor.getSourceFrameBuffer();
- frameBuffer.bind(renderer);
- renderer.gl.clear(renderer.gl.DEPTH_BUFFER_BIT | renderer.gl.COLOR_BUFFER_BIT);
- renderer.render(scene, camera, true, true);
- frameBuffer.unbind(renderer);
- if (this.needsTemporalSS() && accumulating) {
- this._compositor.composite(renderer, scene, camera, this._temporalSS.getSourceFrameBuffer(), this._temporalSS.getFrame());
- renderer.setViewport(this.viewport);
- this._temporalSS.render(renderer);
- }
- else {
- renderer.setViewport(this.viewport);
- this._compositor.composite(renderer, scene, camera, null, 0);
- }
- }
- else {
- if (this.needsTemporalSS() && accumulating) {
- var frameBuffer = this._temporalSS.getSourceFrameBuffer();
- frameBuffer.bind(renderer);
- renderer.saveClear();
- renderer.clearBit = renderer.gl.DEPTH_BUFFER_BIT | renderer.gl.COLOR_BUFFER_BIT;
- renderer.render(scene, camera, true, true);
- renderer.restoreClear();
- frameBuffer.unbind(renderer);
- renderer.setViewport(this.viewport);
- this._temporalSS.render(renderer);
- }
- else {
- renderer.setViewport(this.viewport);
- renderer.render(scene, camera, true, true);
- }
- }
- // this._shadowMapPass.renderDebug(renderer);
- // this._compositor._normalPass.renderDebug(renderer);
- };
- ViewGL.prototype._updateTransparent = function (renderer, scene, camera, frame) {
- var v3 = new __WEBPACK_IMPORTED_MODULE_6_claygl_src_math_Vector3__["a" /* default */]();
- var invWorldTransform = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */]();
- var cameraWorldPosition = camera.getWorldPosition();
- var transparentList = scene.getRenderList(camera).transparent;
- // Sort transparent object.
- for (var i = 0; i < transparentList.length; i++) {
- var renderable = transparentList[i];
- var geometry = renderable.geometry;
- __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */].invert(invWorldTransform, renderable.worldTransform);
- __WEBPACK_IMPORTED_MODULE_6_claygl_src_math_Vector3__["a" /* default */].transformMat4(v3, cameraWorldPosition, invWorldTransform);
- if (geometry.needsSortTriangles && geometry.needsSortTriangles()) {
- geometry.doSortTriangles(v3, frame);
- }
- if (geometry.needsSortVertices && geometry.needsSortVertices()) {
- geometry.doSortVertices(v3, frame);
- }
- }
- };
- ViewGL.prototype._updateSSAO = function (renderer, scene, camera) {
- var ifEnableSSAO = this._enableSSAO && this._enablePostEffect;
- if (ifEnableSSAO) {
- this._compositor.updateSSAO(renderer, scene, camera, this._temporalSS.getFrame());
- }
- var renderList = scene.getRenderList(camera);
- for (var i = 0; i < renderList.opaque.length; i++) {
- var renderable = renderList.opaque[i];
- // PENDING
- if (renderable.renderNormal) {
- renderable.material[ifEnableSSAO ? 'enableTexture' : 'disableTexture']('ssaoMap');
- }
- if (ifEnableSSAO) {
- renderable.material.set('ssaoMap', this._compositor.getSSAOTexture());
- }
- }
- };
- ViewGL.prototype._updateShadowPCFKernel = function (frame) {
- var pcfKernel = this._pcfKernels[frame % this._pcfKernels.length];
- var renderList = this.scene.getRenderList(this.camera);
- var opaqueList = renderList.opaque;
- for (var i = 0; i < opaqueList.length; i++) {
- if (opaqueList[i].receiveShadow) {
- opaqueList[i].material.set('pcfKernel', pcfKernel);
- opaqueList[i].material.define('fragment', 'PCF_KERNEL_SIZE', pcfKernel.length / 2);
- }
- }
- };
- ViewGL.prototype.dispose = function (renderer) {
- this._compositor.dispose(renderer.gl);
- this._temporalSS.dispose(renderer.gl);
- this._shadowMapPass.dispose(renderer);
- };
- /**
- * @param {module:echarts/Model} Post effect model
- */
- ViewGL.prototype.setPostEffect = function (postEffectModel, api) {
- var compositor = this._compositor;
- this._enablePostEffect = postEffectModel.get('enable');
- var bloomModel = postEffectModel.getModel('bloom');
- var edgeModel = postEffectModel.getModel('edge');
- var dofModel = postEffectModel.getModel('DOF', postEffectModel.getModel('depthOfField'));
- var ssaoModel = postEffectModel.getModel('SSAO', postEffectModel.getModel('screenSpaceAmbientOcclusion'));
- var ssrModel = postEffectModel.getModel('SSR', postEffectModel.getModel('screenSpaceReflection'));
- var fxaaModel = postEffectModel.getModel('FXAA');
- var colorCorrModel = postEffectModel.getModel('colorCorrection');
- bloomModel.get('enable') ? compositor.enableBloom() : compositor.disableBloom();
- dofModel.get('enable') ? compositor.enableDOF() : compositor.disableDOF();
- ssrModel.get('enable') ? compositor.enableSSR() : compositor.disableSSR();
- colorCorrModel.get('enable') ? compositor.enableColorCorrection() : compositor.disableColorCorrection();
- edgeModel.get('enable') ? compositor.enableEdge() : compositor.disableEdge();
- fxaaModel.get('enable') ? compositor.enableFXAA() : compositor.disableFXAA();
- this._enableDOF = dofModel.get('enable');
- this._enableSSAO = ssaoModel.get('enable');
- this._enableSSAO ? compositor.enableSSAO() : compositor.disableSSAO();
- compositor.setBloomIntensity(bloomModel.get('intensity'));
- compositor.setEdgeColor(edgeModel.get('color'));
- compositor.setColorLookupTexture(colorCorrModel.get('lookupTexture'), api);
- compositor.setExposure(colorCorrModel.get('exposure'));
- ['radius', 'quality', 'intensity'].forEach(function (name) {
- compositor.setSSAOParameter(name, ssaoModel.get(name));
- });
- ['quality', 'maxRoughness', 'physical'].forEach(function (name) {
- compositor.setSSRParameter(name, ssrModel.get(name));
- });
- ['quality', 'focalDistance', 'focalRange', 'blurRadius', 'fstop'].forEach(function (name) {
- compositor.setDOFParameter(name, dofModel.get(name));
- });
- ['brightness', 'contrast', 'saturation'].forEach(function (name) {
- compositor.setColorCorrection(name, colorCorrModel.get(name));
- });
- };
- ViewGL.prototype.setDOFFocusOnPoint = function (depth) {
- if (this._enablePostEffect) {
- if (depth > this.camera.far || depth < this.camera.near) {
- return;
- }
- this._compositor.setDOFParameter('focalDistance', depth);
- return true;
- }
- };
- ViewGL.prototype.setTemporalSuperSampling = function (temporalSuperSamplingModel) {
- this._enableTemporalSS = temporalSuperSamplingModel.get('enable');
- };
- ViewGL.prototype.isLinearSpace = function () {
- return this._enablePostEffect;
- };
- ViewGL.prototype.setRootNode = function (rootNode) {
- if (this.rootNode === rootNode) {
- return;
- }
- var children = this.rootNode.children();
- for (var i = 0; i < children.length; i++) {
- rootNode.add(children[i]);
- }
- if (rootNode !== this.scene) {
- this.scene.add(rootNode);
- }
- this.rootNode = rootNode;
- };
- // Proxies
- ViewGL.prototype.add = function (node3D) {
- this.rootNode.add(node3D);
- };
- ViewGL.prototype.remove = function (node3D) {
- this.rootNode.remove(node3D);
- };
- ViewGL.prototype.removeAll = function (node3D) {
- this.rootNode.removeAll(node3D);
- };
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend(ViewGL.prototype, __WEBPACK_IMPORTED_MODULE_8_claygl_src_core_mixin_notifier__["a" /* default */]);
- /* harmony default export */ __webpack_exports__["a"] = (ViewGL);
- /***/
- }),
- /* 23 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var guid = 0;
- var ArrayProto = Array.prototype;
- var nativeForEach = ArrayProto.forEach;
- /**
- * Util functions
- * @namespace clay.core.util
- */
- var util = {
- /**
- * Generate GUID
- * @return {number}
- * @memberOf clay.core.util
- */
- genGUID: function () {
- return ++guid;
- },
- /**
- * Relative path to absolute path
- * @param {string} path
- * @param {string} basePath
- * @return {string}
- * @memberOf clay.core.util
- */
- relative2absolute: function (path, basePath) {
- if (!basePath || path.match(/^\//)) {
- return path;
- }
- var pathParts = path.split('/');
- var basePathParts = basePath.split('/');
- var item = pathParts[0];
- while (item === '.' || item === '..') {
- if (item === '..') {
- basePathParts.pop();
- }
- pathParts.shift();
- item = pathParts[0];
- }
- return basePathParts.join('/') + '/' + pathParts.join('/');
- },
- /**
- * Extend target with source
- * @param {Object} target
- * @param {Object} source
- * @return {Object}
- * @memberOf clay.core.util
- */
- extend: function (target, source) {
- if (source) {
- for (var name in source) {
- if (source.hasOwnProperty(name)) {
- target[name] = source[name];
- }
- }
- }
- return target;
- },
- /**
- * Extend properties to target if not exist.
- * @param {Object} target
- * @param {Object} source
- * @return {Object}
- * @memberOf clay.core.util
- */
- defaults: function (target, source) {
- if (source) {
- for (var propName in source) {
- if (target[propName] === undefined) {
- target[propName] = source[propName];
- }
- }
- }
- return target;
- },
- /**
- * Extend properties with a given property list to avoid for..in.. iteration.
- * @param {Object} target
- * @param {Object} source
- * @param {Array.<string>} propList
- * @return {Object}
- * @memberOf clay.core.util
- */
- extendWithPropList: function (target, source, propList) {
- if (source) {
- for (var i = 0; i < propList.length; i++) {
- var propName = propList[i];
- target[propName] = source[propName];
- }
- }
- return target;
- },
- /**
- * Extend properties to target if not exist. With a given property list avoid for..in.. iteration.
- * @param {Object} target
- * @param {Object} source
- * @param {Array.<string>} propList
- * @return {Object}
- * @memberOf clay.core.util
- */
- defaultsWithPropList: function (target, source, propList) {
- if (source) {
- for (var i = 0; i < propList.length; i++) {
- var propName = propList[i];
- if (target[propName] == null) {
- target[propName] = source[propName];
- }
- }
- }
- return target;
- },
- /**
- * @param {Object|Array} obj
- * @param {Function} iterator
- * @param {Object} [context]
- * @memberOf clay.core.util
- */
- each: function (obj, iterator, context) {
- if (!(obj && iterator)) {
- return;
- }
- if (obj.forEach && obj.forEach === nativeForEach) {
- obj.forEach(iterator, context);
- }
- else if (obj.length === + obj.length) {
- for (var i = 0, len = obj.length; i < len; i++) {
- iterator.call(context, obj[i], i, obj);
- }
- }
- else {
- for (var key in obj) {
- if (obj.hasOwnProperty(key)) {
- iterator.call(context, obj[key], key, obj);
- }
- }
- }
- },
- /**
- * Is object
- * @param {} obj
- * @return {boolean}
- * @memberOf clay.core.util
- */
- isObject: function (obj) {
- return obj === Object(obj);
- },
- /**
- * Is array ?
- * @param {} obj
- * @return {boolean}
- * @memberOf clay.core.util
- */
- isArray: function (obj) {
- return Array.isArray(obj);
- },
- /**
- * Is array like, which have a length property
- * @param {} obj
- * @return {boolean}
- * @memberOf clay.core.util
- */
- isArrayLike: function (obj) {
- if (!obj) {
- return false;
- }
- else {
- return obj.length === + obj.length;
- }
- },
- /**
- * @param {} obj
- * @return {}
- * @memberOf clay.core.util
- */
- clone: function (obj) {
- if (!util.isObject(obj)) {
- return obj;
- }
- else if (util.isArray(obj)) {
- return obj.slice();
- }
- else if (util.isArrayLike(obj)) { // is typed array
- var ret = new obj.constructor(obj.length);
- for (var i = 0; i < obj.length; i++) {
- ret[i] = obj[i];
- }
- return ret;
- }
- else {
- return util.extend({}, obj);
- }
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (util);
- /***/
- }),
- /* 24 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(35);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__shader_source_header_light__ = __webpack_require__(119);
- __WEBPACK_IMPORTED_MODULE_1__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_2__shader_source_header_light__["a" /* default */]);
- /**
- * @constructor clay.Light
- * @extends clay.Node
- */
- var Light = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(function () {
- return /** @lends clay.Light# */ {
- /**
- * Light RGB color
- * @type {number[]}
- */
- color: [1, 1, 1],
- /**
- * Light intensity
- * @type {number}
- */
- intensity: 1.0,
- // Config for shadow map
- /**
- * If light cast shadow
- * @type {boolean}
- */
- castShadow: true,
- /**
- * Shadow map size
- * @type {number}
- */
- shadowResolution: 512,
- /**
- * Light group, shader with same `lightGroup` will be affected
- *
- * Only useful in forward rendering
- * @type {number}
- */
- group: 0
- };
- },
- /** @lends clay.Light.prototype. */
- {
- /**
- * Light type
- * @type {string}
- * @memberOf clay.Light#
- */
- type: '',
- /**
- * @return {clay.Light}
- * @memberOf clay.Light.prototype
- */
- clone: function () {
- var light = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].prototype.clone.call(this);
- light.color = Array.prototype.slice.call(this.color);
- light.intensity = this.intensity;
- light.castShadow = this.castShadow;
- light.shadowResolution = this.shadowResolution;
- return light;
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Light);
- /***/
- }),
- /* 25 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(15);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(38);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /**
- * Lines geometry
- * Use screen space projected lines lineWidth > MAX_LINE_WIDTH
- * https://mattdesl.svbtle.com/drawing-lines-is-hard
- * @module echarts-gl/util/geometry/LinesGeometry
- * @author Yi Shen(http://github.com/pissang)
- */
- var vec3 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- // var CURVE_RECURSION_LIMIT = 8;
- // var CURVE_COLLINEAR_EPSILON = 40;
- var sampleLinePoints = [[0, 0], [1, 1]];
- /**
- * @constructor
- * @alias module:echarts-gl/util/geometry/LinesGeometry
- * @extends clay.Geometry
- */
- var LinesGeometry = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].extend(function () {
- return {
- segmentScale: 1,
- dynamic: true,
- /**
- * Need to use mesh to expand lines if lineWidth > MAX_LINE_WIDTH
- */
- useNativeLine: true,
- attributes: {
- position: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('position', 'float', 3, 'POSITION'),
- positionPrev: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('positionPrev', 'float', 3),
- positionNext: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('positionNext', 'float', 3),
- prevPositionPrev: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('prevPositionPrev', 'float', 3),
- prevPosition: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('prevPosition', 'float', 3),
- prevPositionNext: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('prevPositionNext', 'float', 3),
- offset: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('offset', 'float', 1),
- color: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('color', 'float', 4, 'COLOR')
- }
- };
- },
- /** @lends module: echarts-gl/util/geometry/LinesGeometry.prototype */
- {
- /**
- * Reset offset
- */
- resetOffset: function () {
- this._vertexOffset = 0;
- this._triangleOffset = 0;
- this._itemVertexOffsets = [];
- },
- /**
- * @param {number} nVertex
- */
- setVertexCount: function (nVertex) {
- var attributes = this.attributes;
- if (this.vertexCount !== nVertex) {
- attributes.position.init(nVertex);
- attributes.color.init(nVertex);
- if (!this.useNativeLine) {
- attributes.positionPrev.init(nVertex);
- attributes.positionNext.init(nVertex);
- attributes.offset.init(nVertex);
- }
- if (nVertex > 0xffff) {
- if (this.indices instanceof Uint16Array) {
- this.indices = new Uint32Array(this.indices);
- }
- }
- else {
- if (this.indices instanceof Uint32Array) {
- this.indices = new Uint16Array(this.indices);
- }
- }
- }
- },
- /**
- * @param {number} nTriangle
- */
- setTriangleCount: function (nTriangle) {
- if (this.triangleCount !== nTriangle) {
- if (nTriangle === 0) {
- this.indices = null;
- }
- else {
- this.indices = this.vertexCount > 0xffff ? new Uint32Array(nTriangle * 3) : new Uint16Array(nTriangle * 3);
- }
- }
- },
- _getCubicCurveApproxStep: function (p0, p1, p2, p3) {
- var len = vec3.dist(p0, p1) + vec3.dist(p2, p1) + vec3.dist(p3, p2);
- var step = 1 / (len + 1) * this.segmentScale;
- return step;
- },
- /**
- * Get vertex count of cubic curve
- * @param {Array.<number>} p0
- * @param {Array.<number>} p1
- * @param {Array.<number>} p2
- * @param {Array.<number>} p3
- * @return number
- */
- getCubicCurveVertexCount: function (p0, p1, p2, p3) {
- var step = this._getCubicCurveApproxStep(p0, p1, p2, p3);
- var segCount = Math.ceil(1 / step);
- if (!this.useNativeLine) {
- return segCount * 2 + 2;
- }
- else {
- return segCount * 2;
- }
- },
- /**
- * Get face count of cubic curve
- * @param {Array.<number>} p0
- * @param {Array.<number>} p1
- * @param {Array.<number>} p2
- * @param {Array.<number>} p3
- * @return number
- */
- getCubicCurveTriangleCount: function (p0, p1, p2, p3) {
- var step = this._getCubicCurveApproxStep(p0, p1, p2, p3);
- var segCount = Math.ceil(1 / step);
- if (!this.useNativeLine) {
- return segCount * 2;
- }
- else {
- return 0;
- }
- },
- /**
- * Get vertex count of line
- * @return {number}
- */
- getLineVertexCount: function () {
- return this.getPolylineVertexCount(sampleLinePoints);
- },
- /**
- * Get face count of line
- * @return {number}
- */
- getLineTriangleCount: function () {
- return this.getPolylineTriangleCount(sampleLinePoints);
- },
- /**
- * Get how many vertices will polyline take.
- * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount.
- * @return {number}
- */
- getPolylineVertexCount: function (points) {
- var pointsLen;
- if (typeof points === 'number') {
- pointsLen = points;
- }
- else {
- var is2DArray = typeof points[0] !== 'number';
- pointsLen = is2DArray ? points.length : (points.length / 3);
- }
- return !this.useNativeLine ? ((pointsLen - 1) * 2 + 2) : (pointsLen - 1) * 2;
- },
- /**
- * Get how many triangles will polyline take.
- * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount.
- * @return {number}
- */
- getPolylineTriangleCount: function (points) {
- var pointsLen;
- if (typeof points === 'number') {
- pointsLen = points;
- }
- else {
- var is2DArray = typeof points[0] !== 'number';
- pointsLen = is2DArray ? points.length : (points.length / 3);
- }
- return !this.useNativeLine ? Math.max(pointsLen - 1, 0) * 2 : 0;
- },
- /**
- * Add a cubic curve
- * @param {Array.<number>} p0
- * @param {Array.<number>} p1
- * @param {Array.<number>} p2
- * @param {Array.<number>} p3
- * @param {Array.<number>} color
- * @param {number} [lineWidth=1]
- */
- addCubicCurve: function (p0, p1, p2, p3, color, lineWidth) {
- if (lineWidth == null) {
- lineWidth = 1;
- }
- // incremental interpolation
- // http://antigrain.com/research/bezier_interpolation/index.html#PAGE_BEZIER_INTERPOLATION
- var x0 = p0[0], y0 = p0[1], z0 = p0[2];
- var x1 = p1[0], y1 = p1[1], z1 = p1[2];
- var x2 = p2[0], y2 = p2[1], z2 = p2[2];
- var x3 = p3[0], y3 = p3[1], z3 = p3[2];
- var step = this._getCubicCurveApproxStep(p0, p1, p2, p3);
- var step2 = step * step;
- var step3 = step2 * step;
- var pre1 = 3.0 * step;
- var pre2 = 3.0 * step2;
- var pre4 = 6.0 * step2;
- var pre5 = 6.0 * step3;
- var tmp1x = x0 - x1 * 2.0 + x2;
- var tmp1y = y0 - y1 * 2.0 + y2;
- var tmp1z = z0 - z1 * 2.0 + z2;
- var tmp2x = (x1 - x2) * 3.0 - x0 + x3;
- var tmp2y = (y1 - y2) * 3.0 - y0 + y3;
- var tmp2z = (z1 - z2) * 3.0 - z0 + z3;
- var fx = x0;
- var fy = y0;
- var fz = z0;
- var dfx = (x1 - x0) * pre1 + tmp1x * pre2 + tmp2x * step3;
- var dfy = (y1 - y0) * pre1 + tmp1y * pre2 + tmp2y * step3;
- var dfz = (z1 - z0) * pre1 + tmp1z * pre2 + tmp2z * step3;
- var ddfx = tmp1x * pre4 + tmp2x * pre5;
- var ddfy = tmp1y * pre4 + tmp2y * pre5;
- var ddfz = tmp1z * pre4 + tmp2z * pre5;
- var dddfx = tmp2x * pre5;
- var dddfy = tmp2y * pre5;
- var dddfz = tmp2z * pre5;
- var t = 0;
- var k = 0;
- var segCount = Math.ceil(1 / step);
- var points = new Float32Array((segCount + 1) * 3);
- var points = [];
- var offset = 0;
- for (var k = 0; k < segCount + 1; k++) {
- points[offset++] = fx;
- points[offset++] = fy;
- points[offset++] = fz;
- fx += dfx; fy += dfy; fz += dfz;
- dfx += ddfx; dfy += ddfy; dfz += ddfz;
- ddfx += dddfx; ddfy += dddfy; ddfz += dddfz;
- t += step;
- if (t > 1) {
- fx = dfx > 0 ? Math.min(fx, x3) : Math.max(fx, x3);
- fy = dfy > 0 ? Math.min(fy, y3) : Math.max(fy, y3);
- fz = dfz > 0 ? Math.min(fz, z3) : Math.max(fz, z3);
- }
- }
- return this.addPolyline(points, color, lineWidth);
- },
- /**
- * Add a straight line
- * @param {Array.<number>} p0
- * @param {Array.<number>} p1
- * @param {Array.<number>} color
- * @param {number} [lineWidth=1]
- */
- addLine: function (p0, p1, color, lineWidth) {
- return this.addPolyline([p0, p1], color, lineWidth);
- },
- /**
- * Add a straight line
- * @param {Array.<Array> | Array.<number>} points
- * @param {Array.<number> | Array.<Array>} color
- * @param {number} [lineWidth=1]
- * @param {number} [startOffset=0]
- * @param {number} [pointsCount] Default to be amount of points in the first argument
- */
- addPolyline: function (points, color, lineWidth, startOffset, pointsCount) {
- if (!points.length) {
- return;
- }
- var is2DArray = typeof points[0] !== 'number';
- if (pointsCount == null) {
- pointsCount = is2DArray ? points.length : points.length / 3;
- }
- if (pointsCount < 2) {
- return;
- }
- if (startOffset == null) {
- startOffset = 0;
- }
- if (lineWidth == null) {
- lineWidth = 1;
- }
- this._itemVertexOffsets.push(this._vertexOffset);
- var is2DArray = typeof points[0] !== 'number';
- var notSharingColor = is2DArray
- ? typeof color[0] !== 'number'
- : color.length / 4 === pointsCount;
- var positionAttr = this.attributes.position;
- var positionPrevAttr = this.attributes.positionPrev;
- var positionNextAttr = this.attributes.positionNext;
- var colorAttr = this.attributes.color;
- var offsetAttr = this.attributes.offset;
- var indices = this.indices;
- var vertexOffset = this._vertexOffset;
- var point;
- var pointColor;
- lineWidth = Math.max(lineWidth, 0.01);
- for (var k = startOffset; k < pointsCount; k++) {
- if (is2DArray) {
- point = points[k];
- if (notSharingColor) {
- pointColor = color[k];
- }
- else {
- pointColor = color;
- }
- }
- else {
- var k3 = k * 3;
- point = point || [];
- point[0] = points[k3];
- point[1] = points[k3 + 1];
- point[2] = points[k3 + 2];
- if (notSharingColor) {
- var k4 = k * 4;
- pointColor = pointColor || [];
- pointColor[0] = color[k4];
- pointColor[1] = color[k4 + 1];
- pointColor[2] = color[k4 + 2];
- pointColor[3] = color[k4 + 3];
- }
- else {
- pointColor = color;
- }
- }
- if (!this.useNativeLine) {
- if (k < pointsCount - 1) {
- // Set to next two points
- positionPrevAttr.set(vertexOffset + 2, point);
- positionPrevAttr.set(vertexOffset + 3, point);
- }
- if (k > 0) {
- // Set to previous two points
- positionNextAttr.set(vertexOffset - 2, point);
- positionNextAttr.set(vertexOffset - 1, point);
- }
- positionAttr.set(vertexOffset, point);
- positionAttr.set(vertexOffset + 1, point);
- colorAttr.set(vertexOffset, pointColor);
- colorAttr.set(vertexOffset + 1, pointColor);
- offsetAttr.set(vertexOffset, lineWidth / 2);
- offsetAttr.set(vertexOffset + 1, -lineWidth / 2);
- vertexOffset += 2;
- }
- else {
- if (k > 1) {
- positionAttr.copy(vertexOffset, vertexOffset - 1);
- colorAttr.copy(vertexOffset, vertexOffset - 1);
- vertexOffset++;
- }
- }
- if (!this.useNativeLine) {
- if (k > 0) {
- var idx3 = this._triangleOffset * 3;
- var indices = this.indices;
- // 0-----2
- // 1-----3
- // 0->1->2, 1->3->2
- indices[idx3] = vertexOffset - 4;
- indices[idx3 + 1] = vertexOffset - 3;
- indices[idx3 + 2] = vertexOffset - 2;
- indices[idx3 + 3] = vertexOffset - 3;
- indices[idx3 + 4] = vertexOffset - 1;
- indices[idx3 + 5] = vertexOffset - 2;
- this._triangleOffset += 2;
- }
- }
- else {
- colorAttr.set(vertexOffset, pointColor);
- positionAttr.set(vertexOffset, point);
- vertexOffset++;
- }
- }
- if (!this.useNativeLine) {
- var start = this._vertexOffset;
- var end = this._vertexOffset + pointsCount * 2;
- positionPrevAttr.copy(start, start + 2);
- positionPrevAttr.copy(start + 1, start + 3);
- positionNextAttr.copy(end - 1, end - 3);
- positionNextAttr.copy(end - 2, end - 4);
- }
- this._vertexOffset = vertexOffset;
- return this._vertexOffset;
- },
- /**
- * Set color of single line.
- */
- setItemColor: function (idx, color) {
- var startOffset = this._itemVertexOffsets[idx];
- var endOffset = idx < this._itemVertexOffsets.length - 1 ? this._itemVertexOffsets[idx + 1] : this._vertexOffset;
- for (var i = startOffset; i < endOffset; i++) {
- this.attributes.color.set(i, color);
- }
- this.dirty('color');
- },
- /**
- * @return {number}
- */
- currentTriangleOffset: function () {
- return this._triangleOffset;
- },
- /**
- * @return {number}
- */
- currentVertexOffset: function () {
- return this._vertexOffset;
- }
- });
- __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.util.defaults(LinesGeometry.prototype, __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__["a" /* default */]);
- /* harmony default export */ __webpack_exports__["a"] = (LinesGeometry);
- /***/
- }),
- /* 26 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__ = __webpack_require__(70);
- /**
- * @constructor
- * @alias clay.Vector2
- * @param {number} x
- * @param {number} y
- */
- var Vector2 = function (x, y) {
- x = x || 0;
- y = y || 0;
- /**
- * Storage of Vector2, read and write of x, y will change the values in array
- * All methods also operate on the array instead of x, y components
- * @name array
- * @type {Float32Array}
- * @memberOf clay.Vector2#
- */
- this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].fromValues(x, y);
- /**
- * Dirty flag is used by the Node to determine
- * if the matrix is updated to latest
- * @name _dirty
- * @type {boolean}
- * @memberOf clay.Vector2#
- */
- this._dirty = true;
- };
- Vector2.prototype = {
- constructor: Vector2,
- /**
- * Add b to self
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- add: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].add(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Set x and y components
- * @param {number} x
- * @param {number} y
- * @return {clay.Vector2}
- */
- set: function (x, y) {
- this.array[0] = x;
- this.array[1] = y;
- this._dirty = true;
- return this;
- },
- /**
- * Set x and y components from array
- * @param {Float32Array|number[]} arr
- * @return {clay.Vector2}
- */
- setArray: function (arr) {
- this.array[0] = arr[0];
- this.array[1] = arr[1];
- this._dirty = true;
- return this;
- },
- /**
- * Clone a new Vector2
- * @return {clay.Vector2}
- */
- clone: function () {
- return new Vector2(this.x, this.y);
- },
- /**
- * Copy x, y from b
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- copy: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].copy(this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Cross product of self and b, written to a Vector3 out
- * @param {clay.Vector3} out
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- cross: function (out, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].cross(out.array, this.array, b.array);
- out._dirty = true;
- return this;
- },
- /**
- * Alias for distance
- * @param {clay.Vector2} b
- * @return {number}
- */
- dist: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].dist(this.array, b.array);
- },
- /**
- * Distance between self and b
- * @param {clay.Vector2} b
- * @return {number}
- */
- distance: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].distance(this.array, b.array);
- },
- /**
- * Alias for divide
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- div: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].div(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Divide self by b
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- divide: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].divide(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Dot product of self and b
- * @param {clay.Vector2} b
- * @return {number}
- */
- dot: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].dot(this.array, b.array);
- },
- /**
- * Alias of length
- * @return {number}
- */
- len: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].len(this.array);
- },
- /**
- * Calculate the length
- * @return {number}
- */
- length: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].length(this.array);
- },
- /**
- * Linear interpolation between a and b
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @param {number} t
- * @return {clay.Vector2}
- */
- lerp: function (a, b, t) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].lerp(this.array, a.array, b.array, t);
- this._dirty = true;
- return this;
- },
- /**
- * Minimum of self and b
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- min: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].min(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Maximum of self and b
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- max: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].max(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for multiply
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- mul: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].mul(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Mutiply self and b
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- multiply: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].multiply(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Negate self
- * @return {clay.Vector2}
- */
- negate: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].negate(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Normalize self
- * @return {clay.Vector2}
- */
- normalize: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].normalize(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Generate random x, y components with a given scale
- * @param {number} scale
- * @return {clay.Vector2}
- */
- random: function (scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].random(this.array, scale);
- this._dirty = true;
- return this;
- },
- /**
- * Scale self
- * @param {number} scale
- * @return {clay.Vector2}
- */
- scale: function (s) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].scale(this.array, this.array, s);
- this._dirty = true;
- return this;
- },
- /**
- * Scale b and add to self
- * @param {clay.Vector2} b
- * @param {number} scale
- * @return {clay.Vector2}
- */
- scaleAndAdd: function (b, s) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].scaleAndAdd(this.array, this.array, b.array, s);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for squaredDistance
- * @param {clay.Vector2} b
- * @return {number}
- */
- sqrDist: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].sqrDist(this.array, b.array);
- },
- /**
- * Squared distance between self and b
- * @param {clay.Vector2} b
- * @return {number}
- */
- squaredDistance: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].squaredDistance(this.array, b.array);
- },
- /**
- * Alias for squaredLength
- * @return {number}
- */
- sqrLen: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].sqrLen(this.array);
- },
- /**
- * Squared length of self
- * @return {number}
- */
- squaredLength: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].squaredLength(this.array);
- },
- /**
- * Alias for subtract
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- sub: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].sub(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Subtract b from self
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- subtract: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].subtract(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transform self with a Matrix2 m
- * @param {clay.Matrix2} m
- * @return {clay.Vector2}
- */
- transformMat2: function (m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat2(this.array, this.array, m.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transform self with a Matrix2d m
- * @param {clay.Matrix2d} m
- * @return {clay.Vector2}
- */
- transformMat2d: function (m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat2d(this.array, this.array, m.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transform self with a Matrix3 m
- * @param {clay.Matrix3} m
- * @return {clay.Vector2}
- */
- transformMat3: function (m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat3(this.array, this.array, m.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transform self with a Matrix4 m
- * @param {clay.Matrix4} m
- * @return {clay.Vector2}
- */
- transformMat4: function (m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat4(this.array, this.array, m.array);
- this._dirty = true;
- return this;
- },
- toString: function () {
- return '[' + Array.prototype.join.call(this.array, ',') + ']';
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array);
- }
- };
- // Getter and Setter
- if (Object.defineProperty) {
- var proto = Vector2.prototype;
- /**
- * @name x
- * @type {number}
- * @memberOf clay.Vector2
- * @instance
- */
- Object.defineProperty(proto, 'x', {
- get: function () {
- return this.array[0];
- },
- set: function (value) {
- this.array[0] = value;
- this._dirty = true;
- }
- });
- /**
- * @name y
- * @type {number}
- * @memberOf clay.Vector2
- * @instance
- */
- Object.defineProperty(proto, 'y', {
- get: function () {
- return this.array[1];
- },
- set: function (value) {
- this.array[1] = value;
- this._dirty = true;
- }
- });
- }
- // Supply methods that are not in place
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- Vector2.add = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].add(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {number} x
- * @param {number} y
- * @return {clay.Vector2}
- */
- Vector2.set = function (out, x, y) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].set(out.array, x, y);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- Vector2.copy = function (out, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].copy(out.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector3} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- Vector2.cross = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].cross(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {number}
- */
- Vector2.dist = function (a, b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].distance(a.array, b.array);
- };
- /**
- * @function
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {number}
- */
- Vector2.distance = Vector2.dist;
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- Vector2.div = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].divide(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- Vector2.divide = Vector2.div;
- /**
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {number}
- */
- Vector2.dot = function (a, b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].dot(a.array, b.array);
- };
- /**
- * @param {clay.Vector2} a
- * @return {number}
- */
- Vector2.len = function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].length(b.array);
- };
- // Vector2.length = Vector2.len;
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @param {number} t
- * @return {clay.Vector2}
- */
- Vector2.lerp = function (out, a, b, t) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].lerp(out.array, a.array, b.array, t);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- Vector2.min = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].min(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- Vector2.max = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].max(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- Vector2.mul = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].multiply(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- Vector2.multiply = Vector2.mul;
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @return {clay.Vector2}
- */
- Vector2.negate = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].negate(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @return {clay.Vector2}
- */
- Vector2.normalize = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].normalize(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {number} scale
- * @return {clay.Vector2}
- */
- Vector2.random = function (out, scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].random(out.array, scale);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {number} scale
- * @return {clay.Vector2}
- */
- Vector2.scale = function (out, a, scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].scale(out.array, a.array, scale);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @param {number} scale
- * @return {clay.Vector2}
- */
- Vector2.scaleAndAdd = function (out, a, b, scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].scaleAndAdd(out.array, a.array, b.array, scale);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {number}
- */
- Vector2.sqrDist = function (a, b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].sqrDist(a.array, b.array);
- };
- /**
- * @function
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {number}
- */
- Vector2.squaredDistance = Vector2.sqrDist;
- /**
- * @param {clay.Vector2} a
- * @return {number}
- */
- Vector2.sqrLen = function (a) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].sqrLen(a.array);
- };
- /**
- * @function
- * @param {clay.Vector2} a
- * @return {number}
- */
- Vector2.squaredLength = Vector2.sqrLen;
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- Vector2.sub = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].subtract(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Vector2} b
- * @return {clay.Vector2}
- */
- Vector2.subtract = Vector2.sub;
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Matrix2} m
- * @return {clay.Vector2}
- */
- Vector2.transformMat2 = function (out, a, m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat2(out.array, a.array, m.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Matrix2d} m
- * @return {clay.Vector2}
- */
- Vector2.transformMat2d = function (out, a, m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat2d(out.array, a.array, m.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {Matrix3} m
- * @return {clay.Vector2}
- */
- Vector2.transformMat3 = function (out, a, m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat3(out.array, a.array, m.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector2} out
- * @param {clay.Vector2} a
- * @param {clay.Matrix4} m
- * @return {clay.Vector2}
- */
- Vector2.transformMat4 = function (out, a, m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec2__["a" /* default */].transformMat4(out.array, a.array, m.array);
- out._dirty = true;
- return out;
- };
- /* harmony default export */ __webpack_exports__["a"] = (Vector2);
- /***/
- }),
- /* 27 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_util__ = __webpack_require__(23);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_util__ = __webpack_require__(73);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_vendor__ = __webpack_require__(14);
- var isPowerOfTwo = __WEBPACK_IMPORTED_MODULE_3__math_util__["a" /* default */].isPowerOfTwo;
- var targetList = ['px', 'nx', 'py', 'ny', 'pz', 'nz'];
- /**
- * @constructor clay.TextureCube
- * @extends clay.Texture
- *
- * @example
- * ...
- * var mat = new clay.Material({
- * shader: clay.shader.library.get('clay.phong', 'environmentMap')
- * });
- * var envMap = new clay.TextureCube();
- * envMap.load({
- * 'px': 'assets/textures/sky/px.jpg',
- * 'nx': 'assets/textures/sky/nx.jpg'
- * 'py': 'assets/textures/sky/py.jpg'
- * 'ny': 'assets/textures/sky/ny.jpg'
- * 'pz': 'assets/textures/sky/pz.jpg'
- * 'nz': 'assets/textures/sky/nz.jpg'
- * });
- * mat.set('environmentMap', envMap);
- * ...
- * envMap.success(function () {
- * // Wait for the sky texture loaded
- * animation.on('frame', function (frameTime) {
- * renderer.render(scene, camera);
- * });
- * });
- */
- var TextureCube = __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].extend(function () {
- return /** @lends clay.TextureCube# */{
- /**
- * @type {boolean}
- * @default false
- */
- // PENDING cubemap should not flipY in default.
- // flipY: false,
- /**
- * @type {Object}
- * @property {?HTMLImageElement|HTMLCanvasElemnet} px
- * @property {?HTMLImageElement|HTMLCanvasElemnet} nx
- * @property {?HTMLImageElement|HTMLCanvasElemnet} py
- * @property {?HTMLImageElement|HTMLCanvasElemnet} ny
- * @property {?HTMLImageElement|HTMLCanvasElemnet} pz
- * @property {?HTMLImageElement|HTMLCanvasElemnet} nz
- */
- image: {
- px: null,
- nx: null,
- py: null,
- ny: null,
- pz: null,
- nz: null
- },
- /**
- * Pixels data of each side. Will be ignored if images are set.
- * @type {Object}
- * @property {?Uint8Array} px
- * @property {?Uint8Array} nx
- * @property {?Uint8Array} py
- * @property {?Uint8Array} ny
- * @property {?Uint8Array} pz
- * @property {?Uint8Array} nz
- */
- pixels: {
- px: null,
- nx: null,
- py: null,
- ny: null,
- pz: null,
- nz: null
- },
- /**
- * @type {Array.<Object>}
- */
- mipmaps: []
- };
- }, {
- textureType: 'textureCube',
- update: function (renderer) {
- var _gl = renderer.gl;
- _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, this._cache.get('webgl_texture'));
- this.updateCommon(renderer);
- var glFormat = this.format;
- var glType = this.type;
- _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_WRAP_S, this.getAvailableWrapS());
- _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_WRAP_T, this.getAvailableWrapT());
- _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_MAG_FILTER, this.getAvailableMagFilter());
- _gl.texParameteri(_gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_MIN_FILTER, this.getAvailableMinFilter());
- var anisotropicExt = renderer.getGLExtension('EXT_texture_filter_anisotropic');
- if (anisotropicExt && this.anisotropic > 1) {
- _gl.texParameterf(_gl.TEXTURE_CUBE_MAP, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, this.anisotropic);
- }
- // Fallback to float type if browser don't have half float extension
- if (glType === 36193) {
- var halfFloatExt = renderer.getGLExtension('OES_texture_half_float');
- if (!halfFloatExt) {
- glType = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FLOAT;
- }
- }
- if (this.mipmaps.length) {
- var width = this.width;
- var height = this.height;
- for (var i = 0; i < this.mipmaps.length; i++) {
- var mipmap = this.mipmaps[i];
- this._updateTextureData(_gl, mipmap, i, width, height, glFormat, glType);
- width /= 2;
- height /= 2;
- }
- }
- else {
- this._updateTextureData(_gl, this, 0, this.width, this.height, glFormat, glType);
- if (!this.NPOT && this.useMipmap) {
- _gl.generateMipmap(_gl.TEXTURE_CUBE_MAP);
- }
- }
- _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, null);
- },
- _updateTextureData: function (_gl, data, level, width, height, glFormat, glType) {
- for (var i = 0; i < 6; i++) {
- var target = targetList[i];
- var img = data.image && data.image[target];
- if (img) {
- _gl.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, glFormat, glFormat, glType, img);
- }
- else {
- _gl.texImage2D(_gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, glFormat, width, height, 0, glFormat, glType, data.pixels && data.pixels[target]);
- }
- }
- },
- /**
- * @param {clay.Renderer} renderer
- * @memberOf clay.TextureCube.prototype
- */
- generateMipmap: function (renderer) {
- var _gl = renderer.gl;
- if (this.useMipmap && !this.NPOT) {
- _gl.bindTexture(_gl.TEXTURE_CUBE_MAP, this._cache.get('webgl_texture'));
- _gl.generateMipmap(_gl.TEXTURE_CUBE_MAP);
- }
- },
- bind: function (renderer) {
- renderer.gl.bindTexture(renderer.gl.TEXTURE_CUBE_MAP, this.getWebGLTexture(renderer));
- },
- unbind: function (renderer) {
- renderer.gl.bindTexture(renderer.gl.TEXTURE_CUBE_MAP, null);
- },
- // Overwrite the isPowerOfTwo method
- isPowerOfTwo: function () {
- if (this.image.px) {
- return isPowerOfTwo(this.image.px.width)
- && isPowerOfTwo(this.image.px.height);
- }
- else {
- return isPowerOfTwo(this.width)
- && isPowerOfTwo(this.height);
- }
- },
- isRenderable: function () {
- if (this.image.px) {
- return isImageRenderable(this.image.px)
- && isImageRenderable(this.image.nx)
- && isImageRenderable(this.image.py)
- && isImageRenderable(this.image.ny)
- && isImageRenderable(this.image.pz)
- && isImageRenderable(this.image.nz);
- }
- else {
- return !!(this.width && this.height);
- }
- },
- load: function (imageList, crossOrigin) {
- var loading = 0;
- var self = this;
- __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].each(imageList, function (src, target) {
- var image = __WEBPACK_IMPORTED_MODULE_4__core_vendor__["a" /* default */].createImage();
- if (crossOrigin) {
- image.crossOrigin = crossOrigin;
- }
- image.onload = function () {
- loading--;
- if (loading === 0) {
- self.dirty();
- self.trigger('success', self);
- }
- image.onload = null;
- };
- image.onerror = function () {
- loading--;
- image.onerror = null;
- };
- loading++;
- image.src = src;
- self.image[target] = image;
- });
- return this;
- }
- });
- Object.defineProperty(TextureCube.prototype, 'width', {
- get: function () {
- if (this.image && this.image.px) {
- return this.image.px.width;
- }
- return this._width;
- },
- set: function (value) {
- if (this.image && this.image.px) {
- console.warn('Texture from image can\'t set width');
- }
- else {
- if (this._width !== value) {
- this.dirty();
- }
- this._width = value;
- }
- }
- });
- Object.defineProperty(TextureCube.prototype, 'height', {
- get: function () {
- if (this.image && this.image.px) {
- return this.image.px.height;
- }
- return this._height;
- },
- set: function (value) {
- if (this.image && this.image.px) {
- console.warn('Texture from image can\'t set height');
- }
- else {
- if (this._height !== value) {
- this.dirty();
- }
- this._height = value;
- }
- }
- });
- function isImageRenderable(image) {
- return image.nodeName === 'CANVAS' ||
- image.nodeName === 'VIDEO' ||
- image.complete;
- }
- /* harmony default export */ __webpack_exports__["a"] = (TextureCube);
- /***/
- }),
- /* 28 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ({
- defaultOption: {
- // Post effect
- postEffect: {
- enable: false,
- bloom: {
- enable: true,
- intensity: 0.1
- },
- depthOfField: {
- enable: false,
- focalRange: 20,
- focalDistance: 50,
- blurRadius: 10,
- fstop: 2.8,
- quality: 'medium'
- },
- screenSpaceAmbientOcclusion: {
- enable: false,
- radius: 2,
- // low, medium, high, ultra
- quality: 'medium',
- intensity: 1
- },
- screenSpaceReflection: {
- enable: false,
- quality: 'medium',
- maxRoughness: 0.8
- },
- colorCorrection: {
- enable: true,
- exposure: 0,
- brightness: 0,
- contrast: 1,
- saturation: 1,
- lookupTexture: ''
- },
- edge: {
- enable: false
- },
- FXAA: {
- enable: false
- }
- },
- // Temporal super sampling when the picture is still.
- temporalSuperSampling: {
- // Only enabled when postEffect is enabled
- enable: 'auto'
- }
- }
- });
- /***/
- }),
- /* 29 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ({
- defaultOption: {
- // Light is available when material.shading is not color
- light: {
- // Main light
- main: {
- shadow: false,
- // low, medium, high, ultra
- shadowQuality: 'high',
- color: '#fff',
- intensity: 1,
- alpha: 0,
- beta: 0
- },
- ambient: {
- color: '#fff',
- intensity: 0.2
- },
- ambientCubemap: {
- // Panorama environment texture,
- // Support .hdr and commmon web formats.
- texture: null,
- // Available when texture is hdr.
- exposure: 1,
- // Intensity for diffuse term
- diffuseIntensity: 0.5,
- // Intensity for specular term, only available when shading is realastic
- specularIntensity: 0.5
- }
- }
- }
- });
- /***/
- }),
- /* 30 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_plugin_Skybox__ = __webpack_require__(42);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__);
- function SceneHelper() {
- }
- SceneHelper.prototype = {
- constructor: SceneHelper,
- setScene: function (scene) {
- this._scene = scene;
- if (this._skybox) {
- this._skybox.attachScene(this._scene);
- }
- },
- initLight: function (rootNode) {
- this._lightRoot = rootNode;
- /**
- * @type {clay.light.Directional}
- */
- this.mainLight = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].DirectionalLight({
- shadowBias: 0.005
- });
- /**
- * @type {clay.light.Ambient}
- */
- this.ambientLight = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].AmbientLight();
- rootNode.add(this.mainLight);
- rootNode.add(this.ambientLight);
- },
- dispose: function () {
- if (this._lightRoot) {
- this._lightRoot.remove(this.mainLight);
- this._lightRoot.remove(this.ambientLight);
- }
- },
- updateLight: function (componentModel) {
- var mainLight = this.mainLight;
- var ambientLight = this.ambientLight;
- var lightModel = componentModel.getModel('light');
- var mainLightModel = lightModel.getModel('main');
- var ambientLightModel = lightModel.getModel('ambient');
- mainLight.intensity = mainLightModel.get('intensity');
- ambientLight.intensity = ambientLightModel.get('intensity');
- mainLight.color = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].parseColor(mainLightModel.get('color')).slice(0, 3);
- ambientLight.color = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].parseColor(ambientLightModel.get('color')).slice(0, 3);
- var alpha = mainLightModel.get('alpha') || 0;
- var beta = mainLightModel.get('beta') || 0;
- mainLight.position.setArray(__WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].directionFromAlphaBeta(alpha, beta));
- mainLight.lookAt(__WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Vector3.ZERO);
- mainLight.castShadow = mainLightModel.get('shadow');
- mainLight.shadowResolution = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].getShadowResolution(mainLightModel.get('shadowQuality'));
- },
- updateAmbientCubemap: function (renderer, componentModel, api) {
- var ambientCubemapModel = componentModel.getModel('light.ambientCubemap');
- var textureUrl = ambientCubemapModel.get('texture');
- if (textureUrl) {
- this._cubemapLightsCache = this._cubemapLightsCache || {};
- var lights = this._cubemapLightsCache[textureUrl];
- if (!lights) {
- var self = this;
- lights = this._cubemapLightsCache[textureUrl]
- = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].createAmbientCubemap(ambientCubemapModel.option, renderer, api, function () {
- // Use prefitered cubemap
- if (self._isSkyboxFromAmbientCubemap) {
- self._skybox.setEnvironmentMap(lights.specular.cubemap);
- }
- api.getZr().refresh();
- });
- }
- this._lightRoot.add(lights.diffuse);
- this._lightRoot.add(lights.specular);
- this._currentCubemapLights = lights;
- }
- else if (this._currentCubemapLights) {
- this._lightRoot.remove(this._currentCubemapLights.diffuse);
- this._lightRoot.remove(this._currentCubemapLights.specular);
- this._currentCubemapLights = null;
- }
- },
- updateSkybox: function (renderer, componentModel, api) {
- var environmentUrl = componentModel.get('environment');
- var self = this;
- function getSkybox() {
- self._skybox = self._skybox || new __WEBPACK_IMPORTED_MODULE_1_claygl_src_plugin_Skybox__["a" /* default */]();
- return self._skybox;
- }
- var skybox = getSkybox();
- if (environmentUrl && environmentUrl !== 'none') {
- if (environmentUrl === 'auto') {
- this._isSkyboxFromAmbientCubemap = true;
- // Use environment in ambient cubemap
- if (this._currentCubemapLights) {
- var cubemap = this._currentCubemapLights.specular.cubemap;
- skybox.setEnvironmentMap(cubemap);
- if (this._scene) {
- skybox.attachScene(this._scene);
- }
- skybox.material.set('lod', 3);
- }
- else if (this._skybox) {
- this._skybox.detachScene();
- }
- }
- // Is gradient or color string
- else if ((typeof environmentUrl === 'object' && environmentUrl.colorStops)
- || (typeof environmentUrl === 'string' && __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default.a.color.parse(environmentUrl))
- ) {
- this._isSkyboxFromAmbientCubemap = false;
- var texture = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Texture2D({
- anisotropic: 8,
- flipY: false
- });
- skybox.setEnvironmentMap(texture);
- var canvas = texture.image = document.createElement('canvas');
- canvas.width = canvas.height = 16;
- var ctx = canvas.getContext('2d');
- var rect = new __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default.a.graphic.Rect({
- shape: { x: 0, y: 0, width: 16, height: 16 },
- style: { fill: environmentUrl }
- });
- rect.brush(ctx);
- skybox.attachScene(this._scene);
- }
- else {
- this._isSkyboxFromAmbientCubemap = false;
- // Panorama
- var texture = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].loadTexture(environmentUrl, api, {
- anisotropic: 8,
- flipY: false
- });
- skybox.setEnvironmentMap(texture);
- skybox.attachScene(this._scene);
- }
- }
- else {
- if (this._skybox) {
- this._skybox.detachScene(this._scene);
- }
- this._skybox = null;
- }
- var coordSys = componentModel.coordinateSystem;
- if (this._skybox) {
- if (coordSys && coordSys.viewGL
- && environmentUrl !== 'auto'
- && !(environmentUrl.match && environmentUrl.match(/.hdr$/))
- ) {
- var srgbDefineMethod = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine';
- this._skybox.material[srgbDefineMethod]('fragment', 'SRGB_DECODE');
- }
- else {
- this._skybox.material.undefine('fragment', 'SRGB_DECODE');
- }
- // var ambientCubemapUrl = environmentUrl === 'auto'
- // ? componentModel.get('light.ambientCubemap.texture')
- // : environmentUrl;
- }
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (SceneHelper);
- /***/
- }),
- /* 31 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ({
- defaultOption: {
- shading: null,
- realisticMaterial: {
- textureTiling: 1,
- textureOffset: 0,
- detailTexture: null
- },
- lambertMaterial: {
- textureTiling: 1,
- textureOffset: 0,
- detailTexture: null
- },
- colorMaterial: {
- textureTiling: 1,
- textureOffset: 0,
- detailTexture: null
- },
- hatchingMaterial: {
- textureTiling: 1,
- textureOffset: 0,
- paperColor: '#fff'
- }
- }
- });
- /***/
- }),
- /* 32 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- var formatUtil = {};
- formatUtil.getFormattedLabel = function (seriesModel, dataIndex, status, dataType, dimIndex) {
- status = status || 'normal';
- var data = seriesModel.getData(dataType);
- var itemModel = data.getItemModel(dataIndex);
- var params = seriesModel.getDataParams(dataIndex, dataType);
- if (dimIndex != null && (params.value instanceof Array)) {
- params.value = params.value[dimIndex];
- }
- var formatter = itemModel.get(status === 'normal' ? ['label', 'formatter'] : ['emphasis', 'label', 'formatter']);
- if (formatter == null) {
- formatter = itemModel.get(['label', 'formatter']);
- }
- var text;
- if (typeof formatter === 'function') {
- params.status = status;
- text = formatter(params);
- }
- else if (typeof formatter === 'string') {
- text = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.formatTpl(formatter, params);
- }
- return text;
- };
- /**
- * If value is not array, then convert it to array.
- * @param {*} value
- * @return {Array} [value] or value
- */
- formatUtil.normalizeToArray = function (value) {
- return value instanceof Array
- ? value
- : value == null
- ? []
- : [value];
- };
- /* harmony default export */ __webpack_exports__["a"] = (formatUtil);
- /***/
- }),
- /* 33 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* unused harmony export vec4 */
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20);
- /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
- /**
- * @class 4 Dimensional Vector
- * @name vec4
- */
- var vec4 = {};
- /**
- * Creates a new, empty vec4
- *
- * @returns {vec4} a new 4D vector
- */
- vec4.create = function () {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4);
- out[0] = 0;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- return out;
- };
- /**
- * Creates a new vec4 initialized with values from an existing vector
- *
- * @param {vec4} a vector to clone
- * @returns {vec4} a new 4D vector
- */
- vec4.clone = function (a) {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4);
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- return out;
- };
- /**
- * Creates a new vec4 initialized with the given values
- *
- * @param {Number} x X component
- * @param {Number} y Y component
- * @param {Number} z Z component
- * @param {Number} w W component
- * @returns {vec4} a new 4D vector
- */
- vec4.fromValues = function (x, y, z, w) {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4);
- out[0] = x;
- out[1] = y;
- out[2] = z;
- out[3] = w;
- return out;
- };
- /**
- * Copy the values from one vec4 to another
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the source vector
- * @returns {vec4} out
- */
- vec4.copy = function (out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- return out;
- };
- /**
- * Set the components of a vec4 to the given values
- *
- * @param {vec4} out the receiving vector
- * @param {Number} x X component
- * @param {Number} y Y component
- * @param {Number} z Z component
- * @param {Number} w W component
- * @returns {vec4} out
- */
- vec4.set = function (out, x, y, z, w) {
- out[0] = x;
- out[1] = y;
- out[2] = z;
- out[3] = w;
- return out;
- };
- /**
- * Adds two vec4's
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the first operand
- * @param {vec4} b the second operand
- * @returns {vec4} out
- */
- vec4.add = function (out, a, b) {
- out[0] = a[0] + b[0];
- out[1] = a[1] + b[1];
- out[2] = a[2] + b[2];
- out[3] = a[3] + b[3];
- return out;
- };
- /**
- * Subtracts vector b from vector a
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the first operand
- * @param {vec4} b the second operand
- * @returns {vec4} out
- */
- vec4.subtract = function (out, a, b) {
- out[0] = a[0] - b[0];
- out[1] = a[1] - b[1];
- out[2] = a[2] - b[2];
- out[3] = a[3] - b[3];
- return out;
- };
- /**
- * Alias for {@link vec4.subtract}
- * @function
- */
- vec4.sub = vec4.subtract;
- /**
- * Multiplies two vec4's
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the first operand
- * @param {vec4} b the second operand
- * @returns {vec4} out
- */
- vec4.multiply = function (out, a, b) {
- out[0] = a[0] * b[0];
- out[1] = a[1] * b[1];
- out[2] = a[2] * b[2];
- out[3] = a[3] * b[3];
- return out;
- };
- /**
- * Alias for {@link vec4.multiply}
- * @function
- */
- vec4.mul = vec4.multiply;
- /**
- * Divides two vec4's
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the first operand
- * @param {vec4} b the second operand
- * @returns {vec4} out
- */
- vec4.divide = function (out, a, b) {
- out[0] = a[0] / b[0];
- out[1] = a[1] / b[1];
- out[2] = a[2] / b[2];
- out[3] = a[3] / b[3];
- return out;
- };
- /**
- * Alias for {@link vec4.divide}
- * @function
- */
- vec4.div = vec4.divide;
- /**
- * Returns the minimum of two vec4's
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the first operand
- * @param {vec4} b the second operand
- * @returns {vec4} out
- */
- vec4.min = function (out, a, b) {
- out[0] = Math.min(a[0], b[0]);
- out[1] = Math.min(a[1], b[1]);
- out[2] = Math.min(a[2], b[2]);
- out[3] = Math.min(a[3], b[3]);
- return out;
- };
- /**
- * Returns the maximum of two vec4's
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the first operand
- * @param {vec4} b the second operand
- * @returns {vec4} out
- */
- vec4.max = function (out, a, b) {
- out[0] = Math.max(a[0], b[0]);
- out[1] = Math.max(a[1], b[1]);
- out[2] = Math.max(a[2], b[2]);
- out[3] = Math.max(a[3], b[3]);
- return out;
- };
- /**
- * Scales a vec4 by a scalar number
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the vector to scale
- * @param {Number} b amount to scale the vector by
- * @returns {vec4} out
- */
- vec4.scale = function (out, a, b) {
- out[0] = a[0] * b;
- out[1] = a[1] * b;
- out[2] = a[2] * b;
- out[3] = a[3] * b;
- return out;
- };
- /**
- * Adds two vec4's after scaling the second operand by a scalar value
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the first operand
- * @param {vec4} b the second operand
- * @param {Number} scale the amount to scale b by before adding
- * @returns {vec4} out
- */
- vec4.scaleAndAdd = function (out, a, b, scale) {
- out[0] = a[0] + (b[0] * scale);
- out[1] = a[1] + (b[1] * scale);
- out[2] = a[2] + (b[2] * scale);
- out[3] = a[3] + (b[3] * scale);
- return out;
- };
- /**
- * Calculates the euclidian distance between two vec4's
- *
- * @param {vec4} a the first operand
- * @param {vec4} b the second operand
- * @returns {Number} distance between a and b
- */
- vec4.distance = function (a, b) {
- var x = b[0] - a[0],
- y = b[1] - a[1],
- z = b[2] - a[2],
- w = b[3] - a[3];
- return Math.sqrt(x * x + y * y + z * z + w * w);
- };
- /**
- * Alias for {@link vec4.distance}
- * @function
- */
- vec4.dist = vec4.distance;
- /**
- * Calculates the squared euclidian distance between two vec4's
- *
- * @param {vec4} a the first operand
- * @param {vec4} b the second operand
- * @returns {Number} squared distance between a and b
- */
- vec4.squaredDistance = function (a, b) {
- var x = b[0] - a[0],
- y = b[1] - a[1],
- z = b[2] - a[2],
- w = b[3] - a[3];
- return x * x + y * y + z * z + w * w;
- };
- /**
- * Alias for {@link vec4.squaredDistance}
- * @function
- */
- vec4.sqrDist = vec4.squaredDistance;
- /**
- * Calculates the length of a vec4
- *
- * @param {vec4} a vector to calculate length of
- * @returns {Number} length of a
- */
- vec4.length = function (a) {
- var x = a[0],
- y = a[1],
- z = a[2],
- w = a[3];
- return Math.sqrt(x * x + y * y + z * z + w * w);
- };
- /**
- * Alias for {@link vec4.length}
- * @function
- */
- vec4.len = vec4.length;
- /**
- * Calculates the squared length of a vec4
- *
- * @param {vec4} a vector to calculate squared length of
- * @returns {Number} squared length of a
- */
- vec4.squaredLength = function (a) {
- var x = a[0],
- y = a[1],
- z = a[2],
- w = a[3];
- return x * x + y * y + z * z + w * w;
- };
- /**
- * Alias for {@link vec4.squaredLength}
- * @function
- */
- vec4.sqrLen = vec4.squaredLength;
- /**
- * Negates the components of a vec4
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a vector to negate
- * @returns {vec4} out
- */
- vec4.negate = function (out, a) {
- out[0] = -a[0];
- out[1] = -a[1];
- out[2] = -a[2];
- out[3] = -a[3];
- return out;
- };
- /**
- * Returns the inverse of the components of a vec4
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a vector to invert
- * @returns {vec4} out
- */
- vec4.inverse = function (out, a) {
- out[0] = 1.0 / a[0];
- out[1] = 1.0 / a[1];
- out[2] = 1.0 / a[2];
- out[3] = 1.0 / a[3];
- return out;
- };
- /**
- * Normalize a vec4
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a vector to normalize
- * @returns {vec4} out
- */
- vec4.normalize = function (out, a) {
- var x = a[0],
- y = a[1],
- z = a[2],
- w = a[3];
- var len = x * x + y * y + z * z + w * w;
- if (len > 0) {
- len = 1 / Math.sqrt(len);
- out[0] = a[0] * len;
- out[1] = a[1] * len;
- out[2] = a[2] * len;
- out[3] = a[3] * len;
- }
- return out;
- };
- /**
- * Calculates the dot product of two vec4's
- *
- * @param {vec4} a the first operand
- * @param {vec4} b the second operand
- * @returns {Number} dot product of a and b
- */
- vec4.dot = function (a, b) {
- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
- };
- /**
- * Performs a linear interpolation between two vec4's
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the first operand
- * @param {vec4} b the second operand
- * @param {Number} t interpolation amount between the two inputs
- * @returns {vec4} out
- */
- vec4.lerp = function (out, a, b, t) {
- var ax = a[0],
- ay = a[1],
- az = a[2],
- aw = a[3];
- out[0] = ax + t * (b[0] - ax);
- out[1] = ay + t * (b[1] - ay);
- out[2] = az + t * (b[2] - az);
- out[3] = aw + t * (b[3] - aw);
- return out;
- };
- /**
- * Generates a random vector with the given scale
- *
- * @param {vec4} out the receiving vector
- * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
- * @returns {vec4} out
- */
- vec4.random = function (out, scale) {
- scale = scale || 1.0;
- //TODO: This is a pretty awful way of doing this. Find something better.
- out[0] = Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_RANDOM */])();
- out[1] = Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_RANDOM */])();
- out[2] = Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_RANDOM */])();
- out[3] = Object(__WEBPACK_IMPORTED_MODULE_0__common__["c" /* GLMAT_RANDOM */])();
- vec4.normalize(out, out);
- vec4.scale(out, out, scale);
- return out;
- };
- /**
- * Transforms the vec4 with a mat4.
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the vector to transform
- * @param {mat4} m matrix to transform with
- * @returns {vec4} out
- */
- vec4.transformMat4 = function (out, a, m) {
- var x = a[0], y = a[1], z = a[2], w = a[3];
- out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
- out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
- out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
- out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
- return out;
- };
- /**
- * Transforms the vec4 with a quat
- *
- * @param {vec4} out the receiving vector
- * @param {vec4} a the vector to transform
- * @param {quat} q quaternion to transform with
- * @returns {vec4} out
- */
- vec4.transformQuat = function (out, a, q) {
- var x = a[0], y = a[1], z = a[2],
- qx = q[0], qy = q[1], qz = q[2], qw = q[3],
- // calculate quat * vec
- ix = qw * x + qy * z - qz * y,
- iy = qw * y + qz * x - qx * z,
- iz = qw * z + qx * y - qy * x,
- iw = -qx * x - qy * y - qz * z;
- // calculate result * inverse quat
- out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
- out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
- out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
- return out;
- };
- /**
- * Perform some operation over an array of vec4s.
- *
- * @param {Array} a the array of vectors to iterate over
- * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
- * @param {Number} offset Number of elements to skip at the beginning of the array
- * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
- * @param {Function} fn Function to call for each vector in the array
- * @param {Object} [arg] additional argument to pass to fn
- * @returns {Array} a
- * @function
- */
- vec4.forEach = (function () {
- var vec = vec4.create();
- return function (a, stride, offset, count, fn, arg) {
- var i, l;
- if (!stride) {
- stride = 4;
- }
- if (!offset) {
- offset = 0;
- }
- if (count) {
- l = Math.min((count * stride) + offset, a.length);
- } else {
- l = a.length;
- }
- for (i = offset; i < l; i += stride) {
- vec[0] = a[i]; vec[1] = a[i + 1]; vec[2] = a[i + 2]; vec[3] = a[i + 3];
- fn(vec, vec, arg);
- a[i] = vec[0]; a[i + 1] = vec[1]; a[i + 2] = vec[2]; a[i + 3] = vec[3];
- }
- return a;
- };
- })();
- /* harmony default export */ __webpack_exports__["a"] = (vec4);
- /***/
- }),
- /* 34 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20);
- /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
- /**
- * @class 3x3 Matrix
- * @name mat3
- */
- var mat3 = {};
- /**
- * Creates a new identity mat3
- *
- * @returns {mat3} a new 3x3 matrix
- */
- mat3.create = function () {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](9);
- out[0] = 1;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = 1;
- out[5] = 0;
- out[6] = 0;
- out[7] = 0;
- out[8] = 1;
- return out;
- };
- /**
- * Copies the upper-left 3x3 values into the given mat3.
- *
- * @param {mat3} out the receiving 3x3 matrix
- * @param {mat4} a the source 4x4 matrix
- * @returns {mat3} out
- */
- mat3.fromMat4 = function (out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[4];
- out[4] = a[5];
- out[5] = a[6];
- out[6] = a[8];
- out[7] = a[9];
- out[8] = a[10];
- return out;
- };
- /**
- * Creates a new mat3 initialized with values from an existing matrix
- *
- * @param {mat3} a matrix to clone
- * @returns {mat3} a new 3x3 matrix
- */
- mat3.clone = function (a) {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](9);
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- out[4] = a[4];
- out[5] = a[5];
- out[6] = a[6];
- out[7] = a[7];
- out[8] = a[8];
- return out;
- };
- /**
- * Copy the values from one mat3 to another
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the source matrix
- * @returns {mat3} out
- */
- mat3.copy = function (out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- out[4] = a[4];
- out[5] = a[5];
- out[6] = a[6];
- out[7] = a[7];
- out[8] = a[8];
- return out;
- };
- /**
- * Set a mat3 to the identity matrix
- *
- * @param {mat3} out the receiving matrix
- * @returns {mat3} out
- */
- mat3.identity = function (out) {
- out[0] = 1;
- out[1] = 0;
- out[2] = 0;
- out[3] = 0;
- out[4] = 1;
- out[5] = 0;
- out[6] = 0;
- out[7] = 0;
- out[8] = 1;
- return out;
- };
- /**
- * Transpose the values of a mat3
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the source matrix
- * @returns {mat3} out
- */
- mat3.transpose = function (out, a) {
- // If we are transposing ourselves we can skip a few steps but have to cache some values
- if (out === a) {
- var a01 = a[1], a02 = a[2], a12 = a[5];
- out[1] = a[3];
- out[2] = a[6];
- out[3] = a01;
- out[5] = a[7];
- out[6] = a02;
- out[7] = a12;
- } else {
- out[0] = a[0];
- out[1] = a[3];
- out[2] = a[6];
- out[3] = a[1];
- out[4] = a[4];
- out[5] = a[7];
- out[6] = a[2];
- out[7] = a[5];
- out[8] = a[8];
- }
- return out;
- };
- /**
- * Inverts a mat3
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the source matrix
- * @returns {mat3} out
- */
- mat3.invert = function (out, a) {
- var a00 = a[0], a01 = a[1], a02 = a[2],
- a10 = a[3], a11 = a[4], a12 = a[5],
- a20 = a[6], a21 = a[7], a22 = a[8],
- b01 = a22 * a11 - a12 * a21,
- b11 = -a22 * a10 + a12 * a20,
- b21 = a21 * a10 - a11 * a20,
- // Calculate the determinant
- det = a00 * b01 + a01 * b11 + a02 * b21;
- if (!det) {
- return null;
- }
- det = 1.0 / det;
- out[0] = b01 * det;
- out[1] = (-a22 * a01 + a02 * a21) * det;
- out[2] = (a12 * a01 - a02 * a11) * det;
- out[3] = b11 * det;
- out[4] = (a22 * a00 - a02 * a20) * det;
- out[5] = (-a12 * a00 + a02 * a10) * det;
- out[6] = b21 * det;
- out[7] = (-a21 * a00 + a01 * a20) * det;
- out[8] = (a11 * a00 - a01 * a10) * det;
- return out;
- };
- /**
- * Calculates the adjugate of a mat3
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the source matrix
- * @returns {mat3} out
- */
- mat3.adjoint = function (out, a) {
- var a00 = a[0], a01 = a[1], a02 = a[2],
- a10 = a[3], a11 = a[4], a12 = a[5],
- a20 = a[6], a21 = a[7], a22 = a[8];
- out[0] = (a11 * a22 - a12 * a21);
- out[1] = (a02 * a21 - a01 * a22);
- out[2] = (a01 * a12 - a02 * a11);
- out[3] = (a12 * a20 - a10 * a22);
- out[4] = (a00 * a22 - a02 * a20);
- out[5] = (a02 * a10 - a00 * a12);
- out[6] = (a10 * a21 - a11 * a20);
- out[7] = (a01 * a20 - a00 * a21);
- out[8] = (a00 * a11 - a01 * a10);
- return out;
- };
- /**
- * Calculates the determinant of a mat3
- *
- * @param {mat3} a the source matrix
- * @returns {Number} determinant of a
- */
- mat3.determinant = function (a) {
- var a00 = a[0], a01 = a[1], a02 = a[2],
- a10 = a[3], a11 = a[4], a12 = a[5],
- a20 = a[6], a21 = a[7], a22 = a[8];
- return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
- };
- /**
- * Multiplies two mat3's
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the first operand
- * @param {mat3} b the second operand
- * @returns {mat3} out
- */
- mat3.multiply = function (out, a, b) {
- var a00 = a[0], a01 = a[1], a02 = a[2],
- a10 = a[3], a11 = a[4], a12 = a[5],
- a20 = a[6], a21 = a[7], a22 = a[8],
- b00 = b[0], b01 = b[1], b02 = b[2],
- b10 = b[3], b11 = b[4], b12 = b[5],
- b20 = b[6], b21 = b[7], b22 = b[8];
- out[0] = b00 * a00 + b01 * a10 + b02 * a20;
- out[1] = b00 * a01 + b01 * a11 + b02 * a21;
- out[2] = b00 * a02 + b01 * a12 + b02 * a22;
- out[3] = b10 * a00 + b11 * a10 + b12 * a20;
- out[4] = b10 * a01 + b11 * a11 + b12 * a21;
- out[5] = b10 * a02 + b11 * a12 + b12 * a22;
- out[6] = b20 * a00 + b21 * a10 + b22 * a20;
- out[7] = b20 * a01 + b21 * a11 + b22 * a21;
- out[8] = b20 * a02 + b21 * a12 + b22 * a22;
- return out;
- };
- /**
- * Alias for {@link mat3.multiply}
- * @function
- */
- mat3.mul = mat3.multiply;
- /**
- * Translate a mat3 by the given vector
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the matrix to translate
- * @param {vec2} v vector to translate by
- * @returns {mat3} out
- */
- mat3.translate = function (out, a, v) {
- var a00 = a[0], a01 = a[1], a02 = a[2],
- a10 = a[3], a11 = a[4], a12 = a[5],
- a20 = a[6], a21 = a[7], a22 = a[8],
- x = v[0], y = v[1];
- out[0] = a00;
- out[1] = a01;
- out[2] = a02;
- out[3] = a10;
- out[4] = a11;
- out[5] = a12;
- out[6] = x * a00 + y * a10 + a20;
- out[7] = x * a01 + y * a11 + a21;
- out[8] = x * a02 + y * a12 + a22;
- return out;
- };
- /**
- * Rotates a mat3 by the given angle
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the matrix to rotate
- * @param {Number} rad the angle to rotate the matrix by
- * @returns {mat3} out
- */
- mat3.rotate = function (out, a, rad) {
- var a00 = a[0], a01 = a[1], a02 = a[2],
- a10 = a[3], a11 = a[4], a12 = a[5],
- a20 = a[6], a21 = a[7], a22 = a[8],
- s = Math.sin(rad),
- c = Math.cos(rad);
- out[0] = c * a00 + s * a10;
- out[1] = c * a01 + s * a11;
- out[2] = c * a02 + s * a12;
- out[3] = c * a10 - s * a00;
- out[4] = c * a11 - s * a01;
- out[5] = c * a12 - s * a02;
- out[6] = a20;
- out[7] = a21;
- out[8] = a22;
- return out;
- };
- /**
- * Scales the mat3 by the dimensions in the given vec2
- *
- * @param {mat3} out the receiving matrix
- * @param {mat3} a the matrix to rotate
- * @param {vec2} v the vec2 to scale the matrix by
- * @returns {mat3} out
- **/
- mat3.scale = function (out, a, v) {
- var x = v[0], y = v[1];
- out[0] = x * a[0];
- out[1] = x * a[1];
- out[2] = x * a[2];
- out[3] = y * a[3];
- out[4] = y * a[4];
- out[5] = y * a[5];
- out[6] = a[6];
- out[7] = a[7];
- out[8] = a[8];
- return out;
- };
- /**
- * Copies the values from a mat2d into a mat3
- *
- * @param {mat3} out the receiving matrix
- * @param {mat2d} a the matrix to copy
- * @returns {mat3} out
- **/
- mat3.fromMat2d = function (out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = 0;
- out[3] = a[2];
- out[4] = a[3];
- out[5] = 0;
- out[6] = a[4];
- out[7] = a[5];
- out[8] = 1;
- return out;
- };
- /**
- * Calculates a 3x3 matrix from the given quaternion
- *
- * @param {mat3} out mat3 receiving operation result
- * @param {quat} q Quaternion to create matrix from
- *
- * @returns {mat3} out
- */
- mat3.fromQuat = function (out, q) {
- var x = q[0], y = q[1], z = q[2], w = q[3],
- x2 = x + x,
- y2 = y + y,
- z2 = z + z,
- xx = x * x2,
- yx = y * x2,
- yy = y * y2,
- zx = z * x2,
- zy = z * y2,
- zz = z * z2,
- wx = w * x2,
- wy = w * y2,
- wz = w * z2;
- out[0] = 1 - yy - zz;
- out[3] = yx - wz;
- out[6] = zx + wy;
- out[1] = yx + wz;
- out[4] = 1 - xx - zz;
- out[7] = zy - wx;
- out[2] = zx - wy;
- out[5] = zy + wx;
- out[8] = 1 - xx - yy;
- return out;
- };
- /**
- * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
- *
- * @param {mat3} out mat3 receiving operation result
- * @param {mat4} a Mat4 to derive the normal matrix from
- *
- * @returns {mat3} out
- */
- mat3.normalFromMat4 = function (out, a) {
- var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
- a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
- a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
- a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
- b00 = a00 * a11 - a01 * a10,
- b01 = a00 * a12 - a02 * a10,
- b02 = a00 * a13 - a03 * a10,
- b03 = a01 * a12 - a02 * a11,
- b04 = a01 * a13 - a03 * a11,
- b05 = a02 * a13 - a03 * a12,
- b06 = a20 * a31 - a21 * a30,
- b07 = a20 * a32 - a22 * a30,
- b08 = a20 * a33 - a23 * a30,
- b09 = a21 * a32 - a22 * a31,
- b10 = a21 * a33 - a23 * a31,
- b11 = a22 * a33 - a23 * a32,
- // Calculate the determinant
- det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
- if (!det) {
- return null;
- }
- det = 1.0 / det;
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
- out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
- out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
- out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
- out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
- out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
- out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
- out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
- out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
- return out;
- };
- /**
- * Returns Frobenius norm of a mat3
- *
- * @param {mat3} a the matrix to calculate Frobenius norm of
- * @returns {Number} Frobenius norm
- */
- mat3.frob = function (a) {
- return (Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2)))
- };
- /* harmony default export */ __webpack_exports__["a"] = (mat3);
- /***/
- }),
- /* 35 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Quaternion__ = __webpack_require__(56);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__ = __webpack_require__(21);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math_BoundingBox__ = __webpack_require__(18);
- var nameId = 0;
- /**
- * @constructor clay.Node
- * @extends clay.core.Base
- */
- var Node = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(/** @lends clay.Node# */{
- /**
- * Scene node name
- * @type {string}
- */
- name: '',
- /**
- * Position relative to its parent node. aka translation.
- * @type {clay.Vector3}
- */
- position: null,
- /**
- * Rotation relative to its parent node. Represented by a quaternion
- * @type {clay.Quaternion}
- */
- rotation: null,
- /**
- * Scale relative to its parent node
- * @type {clay.Vector3}
- */
- scale: null,
- /**
- * Affine transform matrix relative to its root scene.
- * @type {clay.Matrix4}
- */
- worldTransform: null,
- /**
- * Affine transform matrix relative to its parent node.
- * Composited with position, rotation and scale.
- * @type {clay.Matrix4}
- */
- localTransform: null,
- /**
- * If the local transform is update from SRT(scale, rotation, translation, which is position here) each frame
- * @type {boolean}
- */
- autoUpdateLocalTransform: true,
- /**
- * Parent of current scene node
- * @type {?clay.Node}
- * @private
- */
- _parent: null,
- /**
- * The root scene mounted. Null if it is a isolated node
- * @type {?clay.Scene}
- * @private
- */
- _scene: null,
- /**
- * @type {boolean}
- * @private
- */
- _needsUpdateWorldTransform: true,
- /**
- * @type {boolean}
- * @private
- */
- _inIterating: false,
- // Depth for transparent list sorting
- __depth: 0
- }, function () {
- if (!this.name) {
- this.name = (this.type || 'NODE') + '_' + (nameId++);
- }
- if (!this.position) {
- this.position = new __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */]();
- }
- if (!this.rotation) {
- this.rotation = new __WEBPACK_IMPORTED_MODULE_2__math_Quaternion__["a" /* default */]();
- }
- if (!this.scale) {
- this.scale = new __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */](1, 1, 1);
- }
- this.worldTransform = new __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__["a" /* default */]();
- this.localTransform = new __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__["a" /* default */]();
- this._children = [];
- },
- /**@lends clay.Node.prototype. */
- {
- /**
- * @type {?clay.Vector3}
- * @instance
- */
- target: null,
- /**
- * If node and its chilren invisible
- * @type {boolean}
- * @instance
- */
- invisible: false,
- /**
- * If Node is a skinned mesh
- * @return {boolean}
- */
- isSkinnedMesh: function () {
- return false;
- },
- /**
- * Return true if it is a renderable scene node, like Mesh and ParticleSystem
- * @return {boolean}
- */
- isRenderable: function () {
- return false;
- },
- /**
- * Set the name of the scene node
- * @param {string} name
- */
- setName: function (name) {
- var scene = this._scene;
- if (scene) {
- var nodeRepository = scene._nodeRepository;
- delete nodeRepository[this.name];
- nodeRepository[name] = this;
- }
- this.name = name;
- },
- /**
- * Add a child node
- * @param {clay.Node} node
- */
- add: function (node) {
- var originalParent = node._parent;
- if (originalParent === this) {
- return;
- }
- if (originalParent) {
- originalParent.remove(node);
- }
- node._parent = this;
- this._children.push(node);
- var scene = this._scene;
- if (scene && scene !== node.scene) {
- node.traverse(this._addSelfToScene, this);
- }
- // Mark children needs update transform
- // In case child are remove and added again after parent moved
- node._needsUpdateWorldTransform = true;
- },
- /**
- * Remove the given child scene node
- * @param {clay.Node} node
- */
- remove: function (node) {
- var children = this._children;
- var idx = children.indexOf(node);
- if (idx < 0) {
- return;
- }
- children.splice(idx, 1);
- node._parent = null;
- if (this._scene) {
- node.traverse(this._removeSelfFromScene, this);
- }
- },
- /**
- * Remove all children
- */
- removeAll: function () {
- var children = this._children;
- for (var idx = 0; idx < children.length; idx++) {
- children[idx]._parent = null;
- if (this._scene) {
- children[idx].traverse(this._removeSelfFromScene, this);
- }
- }
- this._children = [];
- },
- /**
- * Get the scene mounted
- * @return {clay.Scene}
- */
- getScene: function () {
- return this._scene;
- },
- /**
- * Get parent node
- * @return {clay.Scene}
- */
- getParent: function () {
- return this._parent;
- },
- _removeSelfFromScene: function (descendant) {
- descendant._scene.removeFromScene(descendant);
- descendant._scene = null;
- },
- _addSelfToScene: function (descendant) {
- this._scene.addToScene(descendant);
- descendant._scene = this._scene;
- },
- /**
- * Return true if it is ancestor of the given scene node
- * @param {clay.Node} node
- */
- isAncestor: function (node) {
- var parent = node._parent;
- while (parent) {
- if (parent === this) {
- return true;
- }
- parent = parent._parent;
- }
- return false;
- },
- /**
- * Get a new created array of all children nodes
- * @return {clay.Node[]}
- */
- children: function () {
- return this._children.slice();
- },
- /**
- * Get child scene node at given index.
- * @param {number} idx
- * @return {clay.Node}
- */
- childAt: function (idx) {
- return this._children[idx];
- },
- /**
- * Get first child with the given name
- * @param {string} name
- * @return {clay.Node}
- */
- getChildByName: function (name) {
- var children = this._children;
- for (var i = 0; i < children.length; i++) {
- if (children[i].name === name) {
- return children[i];
- }
- }
- },
- /**
- * Get first descendant have the given name
- * @param {string} name
- * @return {clay.Node}
- */
- getDescendantByName: function (name) {
- var children = this._children;
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
- if (child.name === name) {
- return child;
- } else {
- var res = child.getDescendantByName(name);
- if (res) {
- return res;
- }
- }
- }
- },
- /**
- * Query descendant node by path
- * @param {string} path
- * @return {clay.Node}
- * @example
- * node.queryNode('root/parent/child');
- */
- queryNode: function (path) {
- if (!path) {
- return;
- }
- // TODO Name have slash ?
- var pathArr = path.split('/');
- var current = this;
- for (var i = 0; i < pathArr.length; i++) {
- var name = pathArr[i];
- // Skip empty
- if (!name) {
- continue;
- }
- var found = false;
- var children = current._children;
- for (var j = 0; j < children.length; j++) {
- var child = children[j];
- if (child.name === name) {
- current = child;
- found = true;
- break;
- }
- }
- // Early return if not found
- if (!found) {
- return;
- }
- }
- return current;
- },
- /**
- * Get query path, relative to rootNode(default is scene)
- * @param {clay.Node} [rootNode]
- * @return {string}
- */
- getPath: function (rootNode) {
- if (!this._parent) {
- return '/';
- }
- var current = this._parent;
- var path = this.name;
- while (current._parent) {
- path = current.name + '/' + path;
- if (current._parent == rootNode) {
- break;
- }
- current = current._parent;
- }
- if (!current._parent && rootNode) {
- return null;
- }
- return path;
- },
- /**
- * Depth first traverse all its descendant scene nodes.
- *
- * **WARN** Don't do `add`, `remove` operation in the callback during traverse.
- * @param {Function} callback
- * @param {Node} [context]
- */
- traverse: function (callback, context) {
- callback.call(context, this);
- var _children = this._children;
- for (var i = 0, len = _children.length; i < len; i++) {
- _children[i].traverse(callback, context);
- }
- },
- /**
- * Traverse all children nodes.
- *
- * **WARN** DON'T do `add`, `remove` operation in the callback during iteration.
- *
- * @param {Function} callback
- * @param {Node} [context]
- */
- eachChild: function (callback, context) {
- var _children = this._children;
- for (var i = 0, len = _children.length; i < len; i++) {
- var child = _children[i];
- callback.call(context, child, i);
- }
- },
- /**
- * Set the local transform and decompose to SRT
- * @param {clay.Matrix4} matrix
- */
- setLocalTransform: function (matrix) {
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].copy(this.localTransform.array, matrix.array);
- this.decomposeLocalTransform();
- },
- /**
- * Decompose the local transform to SRT
- */
- decomposeLocalTransform: function (keepScale) {
- var scale = !keepScale ? this.scale : null;
- this.localTransform.decomposeMatrix(scale, this.rotation, this.position);
- },
- /**
- * Set the world transform and decompose to SRT
- * @param {clay.Matrix4} matrix
- */
- setWorldTransform: function (matrix) {
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].copy(this.worldTransform.array, matrix.array);
- this.decomposeWorldTransform();
- },
- /**
- * Decompose the world transform to SRT
- * @function
- */
- decomposeWorldTransform: (function () {
- var tmp = __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].create();
- return function (keepScale) {
- var localTransform = this.localTransform;
- var worldTransform = this.worldTransform;
- // Assume world transform is updated
- if (this._parent) {
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].invert(tmp, this._parent.worldTransform.array);
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].multiply(localTransform.array, tmp, worldTransform.array);
- } else {
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].copy(localTransform.array, worldTransform.array);
- }
- var scale = !keepScale ? this.scale : null;
- localTransform.decomposeMatrix(scale, this.rotation, this.position);
- };
- })(),
- transformNeedsUpdate: function () {
- return this.position._dirty
- || this.rotation._dirty
- || this.scale._dirty;
- },
- /**
- * Update local transform from SRT
- * Notice that local transform will not be updated if _dirty mark of position, rotation, scale is all false
- */
- updateLocalTransform: function () {
- var position = this.position;
- var rotation = this.rotation;
- var scale = this.scale;
- if (this.transformNeedsUpdate()) {
- var m = this.localTransform.array;
- // Transform order, scale->rotation->position
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].fromRotationTranslation(m, rotation.array, position.array);
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].scale(m, m, scale.array);
- rotation._dirty = false;
- scale._dirty = false;
- position._dirty = false;
- this._needsUpdateWorldTransform = true;
- }
- },
- /**
- * Update world transform, assume its parent world transform have been updated
- * @private
- */
- _updateWorldTransformTopDown: function () {
- var localTransform = this.localTransform.array;
- var worldTransform = this.worldTransform.array;
- if (this._parent) {
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].multiplyAffine(
- worldTransform,
- this._parent.worldTransform.array,
- localTransform
- );
- }
- else {
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_mat4__["a" /* default */].copy(worldTransform, localTransform);
- }
- },
- /**
- * Update world transform before whole scene is updated.
- */
- updateWorldTransform: function () {
- // Find the root node which transform needs update;
- var rootNodeIsDirty = this;
- while (rootNodeIsDirty && rootNodeIsDirty.getParent()
- && rootNodeIsDirty.getParent().transformNeedsUpdate()
- ) {
- rootNodeIsDirty = rootNodeIsDirty.getParent();
- }
- rootNodeIsDirty.update();
- },
- /**
- * Update local transform and world transform recursively
- * @param {boolean} forceUpdateWorld
- */
- update: function (forceUpdateWorld) {
- if (this.autoUpdateLocalTransform) {
- this.updateLocalTransform();
- }
- else {
- // Transform is manually setted
- forceUpdateWorld = true;
- }
- if (forceUpdateWorld || this._needsUpdateWorldTransform) {
- this._updateWorldTransformTopDown();
- forceUpdateWorld = true;
- this._needsUpdateWorldTransform = false;
- }
- var children = this._children;
- for (var i = 0, len = children.length; i < len; i++) {
- children[i].update(forceUpdateWorld);
- }
- },
- /**
- * Get bounding box of node
- * @param {Function} [filter]
- * @param {clay.BoundingBox} [out]
- * @return {clay.BoundingBox}
- */
- // TODO Skinning
- getBoundingBox: (function () {
- function defaultFilter(el) {
- return !el.invisible && el.geometry;
- }
- var tmpBBox = new __WEBPACK_IMPORTED_MODULE_5__math_BoundingBox__["a" /* default */]();
- var tmpMat4 = new __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__["a" /* default */]();
- var invWorldTransform = new __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__["a" /* default */]();
- return function (filter, out) {
- out = out || new __WEBPACK_IMPORTED_MODULE_5__math_BoundingBox__["a" /* default */]();
- filter = filter || defaultFilter;
- if (this._parent) {
- __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__["a" /* default */].invert(invWorldTransform, this._parent.worldTransform);
- }
- else {
- __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__["a" /* default */].identity(invWorldTransform);
- }
- this.traverse(function (mesh) {
- if (mesh.geometry && mesh.geometry.boundingBox) {
- tmpBBox.copy(mesh.geometry.boundingBox);
- __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__["a" /* default */].multiply(tmpMat4, invWorldTransform, mesh.worldTransform);
- tmpBBox.applyTransform(tmpMat4);
- out.union(tmpBBox);
- }
- }, this, defaultFilter);
- return out;
- };
- })(),
- /**
- * Get world position, extracted from world transform
- * @param {clay.Vector3} [out]
- * @return {clay.Vector3}
- */
- getWorldPosition: function (out) {
- // PENDING
- if (this.transformNeedsUpdate()) {
- this.updateWorldTransform();
- }
- var m = this.worldTransform.array;
- if (out) {
- var arr = out.array;
- arr[0] = m[12];
- arr[1] = m[13];
- arr[2] = m[14];
- return out;
- }
- else {
- return new __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */](m[12], m[13], m[14]);
- }
- },
- /**
- * Clone a new node
- * @return {Node}
- */
- clone: function () {
- var node = new this.constructor();
- var children = this._children;
- node.setName(this.name);
- node.position.copy(this.position);
- node.rotation.copy(this.rotation);
- node.scale.copy(this.scale);
- for (var i = 0; i < children.length; i++) {
- node.add(children[i].clone());
- }
- return node;
- },
- /**
- * Rotate the node around a axis by angle degrees, axis passes through point
- * @param {clay.Vector3} point Center point
- * @param {clay.Vector3} axis Center axis
- * @param {number} angle Rotation angle
- * @see http://docs.unity3d.com/Documentation/ScriptReference/Transform.RotateAround.html
- * @function
- */
- rotateAround: (function () {
- var v = new __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */]();
- var RTMatrix = new __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__["a" /* default */]();
- // TODO improve performance
- return function (point, axis, angle) {
- v.copy(this.position).subtract(point);
- var localTransform = this.localTransform;
- localTransform.identity();
- // parent node
- localTransform.translate(point);
- localTransform.rotate(angle, axis);
- RTMatrix.fromRotationTranslation(this.rotation, v);
- localTransform.multiply(RTMatrix);
- localTransform.scale(this.scale);
- this.decomposeLocalTransform();
- this._needsUpdateWorldTransform = true;
- };
- })(),
- /**
- * @param {clay.Vector3} target
- * @param {clay.Vector3} [up]
- * @see http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml
- * @function
- */
- lookAt: (function () {
- var m = new __WEBPACK_IMPORTED_MODULE_3__math_Matrix4__["a" /* default */]();
- return function (target, up) {
- m.lookAt(this.position, target, up || this.localTransform.y).invert();
- this.setLocalTransform(m);
- this.target = target;
- };
- })()
- });
- /* harmony default export */ __webpack_exports__["a"] = (Node);
- /***/
- }),
- /* 36 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(35);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Light__ = __webpack_require__(24);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Camera__ = __webpack_require__(58);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__ = __webpack_require__(18);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_util__ = __webpack_require__(23);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__glmatrix_mat4__ = __webpack_require__(21);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__core_LRU__ = __webpack_require__(69);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__math_Matrix4__ = __webpack_require__(9);
- var IDENTITY = __WEBPACK_IMPORTED_MODULE_5__glmatrix_mat4__["a" /* default */].create();
- var WORLDVIEW = __WEBPACK_IMPORTED_MODULE_5__glmatrix_mat4__["a" /* default */].create();
- var programKeyCache = {};
- function getProgramKey(lightNumbers) {
- var defineStr = [];
- var lightTypes = Object.keys(lightNumbers);
- lightTypes.sort();
- for (var i = 0; i < lightTypes.length; i++) {
- var lightType = lightTypes[i];
- defineStr.push(lightType + ' ' + lightNumbers[lightType]);
- }
- var key = defineStr.join('\n');
- if (programKeyCache[key]) {
- return programKeyCache[key];
- }
- var id = __WEBPACK_IMPORTED_MODULE_4__core_util__["a" /* default */].genGUID();
- programKeyCache[key] = id;
- return id;
- }
- function RenderList() {
- this.opaque = [];
- this.transparent = [];
- this._opaqueCount = 0;
- this._transparentCount = 0;
- }
- RenderList.prototype.startCount = function () {
- this._opaqueCount = 0;
- this._transparentCount = 0;
- };
- RenderList.prototype.add = function (object, isTransparent) {
- if (isTransparent) {
- this.transparent[this._transparentCount++] = object;
- }
- else {
- this.opaque[this._opaqueCount++] = object;
- }
- };
- RenderList.prototype.endCount = function () {
- this.transparent.length = this._transparentCount;
- this.opaque.length = this._opaqueCount;
- };
- /**
- * @typedef {Object} clay.Scene.RenderList
- * @property {Array.<clay.Renderable>} opaque
- * @property {Array.<clay.Renderable>} transparent
- */
- /**
- * @constructor clay.Scene
- * @extends clay.Node
- */
- var Scene = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(function () {
- return /** @lends clay.Scene# */ {
- /**
- * Global material of scene
- * @type {clay.Material}
- */
- material: null,
- lights: [],
- /**
- * Scene bounding box in view space.
- * Used when camera needs to adujst the near and far plane automatically
- * so that the view frustum contains the visible objects as tightly as possible.
- * Notice:
- * It is updated after rendering (in the step of frustum culling passingly). So may be not so accurate, but saves a lot of calculation
- *
- * @type {clay.BoundingBox}
- */
- viewBoundingBoxLastFrame: new __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__["a" /* default */](),
- // Uniforms for shadow map.
- shadowUniforms: {},
- _cameraList: [],
- // Properties to save the light information in the scene
- // Will be set in the render function
- _lightUniforms: {},
- _previousLightNumber: {},
- _lightNumber: {
- // groupId: {
- // POINT_LIGHT: 0,
- // DIRECTIONAL_LIGHT: 0,
- // SPOT_LIGHT: 0,
- // AMBIENT_LIGHT: 0,
- // AMBIENT_SH_LIGHT: 0
- // }
- },
- _lightProgramKeys: {},
- _nodeRepository: {},
- _renderLists: new __WEBPACK_IMPORTED_MODULE_6__core_LRU__["a" /* default */](20)
- };
- }, function () {
- this._scene = this;
- },
- /** @lends clay.Scene.prototype. */
- {
- // Add node to scene
- addToScene: function (node) {
- if (node instanceof __WEBPACK_IMPORTED_MODULE_2__Camera__["a" /* default */]) {
- if (this._cameraList.length > 0) {
- console.warn('Found multiple camera in one scene. Use the fist one.');
- }
- this._cameraList.push(node);
- }
- else if (node instanceof __WEBPACK_IMPORTED_MODULE_1__Light__["a" /* default */]) {
- this.lights.push(node);
- }
- if (node.name) {
- this._nodeRepository[node.name] = node;
- }
- },
- // Remove node from scene
- removeFromScene: function (node) {
- var idx;
- if (node instanceof __WEBPACK_IMPORTED_MODULE_2__Camera__["a" /* default */]) {
- idx = this._cameraList.indexOf(node);
- if (idx >= 0) {
- this._cameraList.splice(idx, 1);
- }
- }
- else if (node instanceof __WEBPACK_IMPORTED_MODULE_1__Light__["a" /* default */]) {
- idx = this.lights.indexOf(node);
- if (idx >= 0) {
- this.lights.splice(idx, 1);
- }
- }
- if (node.name) {
- delete this._nodeRepository[node.name];
- }
- },
- /**
- * Get node by name
- * @param {string} name
- * @return {Node}
- * @DEPRECATED
- */
- getNode: function (name) {
- return this._nodeRepository[name];
- },
- /**
- * Set main camera of the scene.
- * @param {claygl.Camera} camera
- */
- setMainCamera: function (camera) {
- var idx = this._cameraList.indexOf(camera);
- if (idx >= 0) {
- this._cameraList.splice(idx, 1);
- }
- this._cameraList.unshift(camera);
- },
- /**
- * Get main camera of the scene.
- */
- getMainCamera: function () {
- return this._cameraList[0];
- },
- getLights: function () {
- return this.lights;
- },
- updateLights: function () {
- var lights = this.lights;
- this._previousLightNumber = this._lightNumber;
- var lightNumber = {};
- for (var i = 0; i < lights.length; i++) {
- var light = lights[i];
- if (light.invisible) {
- continue;
- }
- var group = light.group;
- if (!lightNumber[group]) {
- lightNumber[group] = {};
- }
- // User can use any type of light
- lightNumber[group][light.type] = lightNumber[group][light.type] || 0;
- lightNumber[group][light.type]++;
- }
- this._lightNumber = lightNumber;
- for (var groupId in lightNumber) {
- this._lightProgramKeys[groupId] = getProgramKey(lightNumber[groupId]);
- }
- this._updateLightUniforms();
- },
- /**
- * Clone a node and it's children, including mesh, camera, light, etc.
- * Unlike using `Node#clone`. It will clone skeleton and remap the joints. Material will also be cloned.
- *
- * @param {clay.Node} node
- * @return {clay.Node}
- */
- cloneNode: function (node) {
- var newNode = node.clone();
- var clonedNodesMap = {};
- function buildNodesMap(sNode, tNode) {
- clonedNodesMap[sNode.__uid__] = tNode;
- for (var i = 0; i < sNode._children.length; i++) {
- var sChild = sNode._children[i];
- var tChild = tNode._children[i];
- buildNodesMap(sChild, tChild);
- }
- }
- buildNodesMap(node, newNode);
- newNode.traverse(function (newChild) {
- if (newChild.skeleton) {
- newChild.skeleton = newChild.skeleton.clone(clonedNodesMap);
- }
- if (newChild.material) {
- newChild.material = newChild.material.clone();
- }
- });
- return newNode;
- },
- /**
- * Traverse the scene and add the renderable object to the render list.
- * It needs camera for the frustum culling.
- *
- * @param {clay.Camera} camera
- * @param {boolean} updateSceneBoundingBox
- * @return {clay.Scene.RenderList}
- */
- updateRenderList: function (camera, updateSceneBoundingBox) {
- var id = camera.__uid__;
- var renderList = this._renderLists.get(id);
- if (!renderList) {
- renderList = new RenderList();
- this._renderLists.put(id, renderList);
- }
- renderList.startCount();
- if (updateSceneBoundingBox) {
- this.viewBoundingBoxLastFrame.min.set(Infinity, Infinity, Infinity);
- this.viewBoundingBoxLastFrame.max.set(-Infinity, -Infinity, -Infinity);
- }
- var sceneMaterialTransparent = this.material && this.material.transparent || false;
- this._doUpdateRenderList(this, camera, sceneMaterialTransparent, renderList, updateSceneBoundingBox);
- renderList.endCount();
- return renderList;
- },
- /**
- * Get render list. Used after {@link clay.Scene#updateRenderList}
- * @param {clay.Camera} camera
- * @return {clay.Scene.RenderList}
- */
- getRenderList: function (camera) {
- return this._renderLists.get(camera.__uid__);
- },
- _doUpdateRenderList: function (parent, camera, sceneMaterialTransparent, renderList, updateSceneBoundingBox) {
- if (parent.invisible) {
- return;
- }
- // TODO Optimize
- for (var i = 0; i < parent._children.length; i++) {
- var child = parent._children[i];
- if (child.isRenderable()) {
- // Frustum culling
- var worldM = child.isSkinnedMesh() ? IDENTITY : child.worldTransform.array;
- var geometry = child.geometry;
- __WEBPACK_IMPORTED_MODULE_5__glmatrix_mat4__["a" /* default */].multiplyAffine(WORLDVIEW, camera.viewMatrix.array, worldM);
- if (updateSceneBoundingBox && !geometry.boundingBox || !this.isFrustumCulled(child, camera, WORLDVIEW)) {
- renderList.add(child, child.material.transparent || sceneMaterialTransparent);
- }
- }
- if (child._children.length > 0) {
- this._doUpdateRenderList(child, camera, sceneMaterialTransparent, renderList, updateSceneBoundingBox);
- }
- }
- },
- /**
- * If an scene object is culled by camera frustum
- *
- * Object can be a renderable or a light
- *
- * @param {clay.Node} object
- * @param {clay.Camera} camera
- * @param {Array.<number>} worldViewMat represented with array
- * @param {Array.<number>} projectionMat represented with array
- */
- isFrustumCulled: (function () {
- // Frustum culling
- // http://www.cse.chalmers.se/~uffe/vfc_bbox.pdf
- var cullingBoundingBox = new __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__["a" /* default */]();
- var cullingMatrix = new __WEBPACK_IMPORTED_MODULE_7__math_Matrix4__["a" /* default */]();
- return function (object, camera, worldViewMat) {
- // Bounding box can be a property of object(like light) or renderable.geometry
- // PENDING
- var geoBBox = object.boundingBox;
- if (!geoBBox) {
- if (object.skeleton && object.skeleton.boundingBox) {
- geoBBox = object.skeleton.boundingBox;
- }
- else {
- geoBBox = object.geometry.boundingBox;
- }
- }
- if (!geoBBox) {
- return false;
- }
- cullingMatrix.array = worldViewMat;
- cullingBoundingBox.transformFrom(geoBBox, cullingMatrix);
- // Passingly update the scene bounding box
- // FIXME exclude very large mesh like ground plane or terrain ?
- // FIXME Only rendererable which cast shadow ?
- // FIXME boundingBox becomes much larger after transformd.
- if (object.castShadow) {
- this.viewBoundingBoxLastFrame.union(cullingBoundingBox);
- }
- // Ignore frustum culling if object is skinned mesh.
- if (object.frustumCulling) {
- if (!cullingBoundingBox.intersectBoundingBox(camera.frustum.boundingBox)) {
- return true;
- }
- cullingMatrix.array = camera.projectionMatrix.array;
- if (
- cullingBoundingBox.max.array[2] > 0 &&
- cullingBoundingBox.min.array[2] < 0
- ) {
- // Clip in the near plane
- cullingBoundingBox.max.array[2] = -1e-20;
- }
- cullingBoundingBox.applyProjection(cullingMatrix);
- var min = cullingBoundingBox.min.array;
- var max = cullingBoundingBox.max.array;
- if (
- max[0] < -1 || min[0] > 1
- || max[1] < -1 || min[1] > 1
- || max[2] < -1 || min[2] > 1
- ) {
- return true;
- }
- }
- return false;
- };
- })(),
- _updateLightUniforms: function () {
- var lights = this.lights;
- // Put the light cast shadow before the light not cast shadow
- lights.sort(lightSortFunc);
- var lightUniforms = this._lightUniforms;
- for (var group in lightUniforms) {
- for (var symbol in lightUniforms[group]) {
- lightUniforms[group][symbol].value.length = 0;
- }
- }
- for (var i = 0; i < lights.length; i++) {
- var light = lights[i];
- if (light.invisible) {
- continue;
- }
- var group = light.group;
- for (var symbol in light.uniformTemplates) {
- var uniformTpl = light.uniformTemplates[symbol];
- var value = uniformTpl.value(light);
- if (value == null) {
- continue;
- }
- if (!lightUniforms[group]) {
- lightUniforms[group] = {};
- }
- if (!lightUniforms[group][symbol]) {
- lightUniforms[group][symbol] = {
- type: '',
- value: []
- };
- }
- var lu = lightUniforms[group][symbol];
- lu.type = uniformTpl.type + 'v';
- switch (uniformTpl.type) {
- case '1i':
- case '1f':
- case 't':
- lu.value.push(value);
- break;
- case '2f':
- case '3f':
- case '4f':
- for (var j = 0; j < value.length; j++) {
- lu.value.push(value[j]);
- }
- break;
- default:
- console.error('Unkown light uniform type ' + uniformTpl.type);
- }
- }
- }
- },
- getLightGroups: function () {
- var lightGroups = [];
- for (var groupId in this._lightNumber) {
- lightGroups.push(groupId);
- }
- return lightGroups;
- },
- getNumberChangedLightGroups: function () {
- var lightGroups = [];
- for (var groupId in this._lightNumber) {
- if (this.isLightNumberChanged(groupId)) {
- lightGroups.push(groupId);
- }
- }
- return lightGroups;
- },
- // Determine if light group is different with since last frame
- // Used to determine whether to update shader and scene's uniforms in Renderer.render
- isLightNumberChanged: function (lightGroup) {
- var prevLightNumber = this._previousLightNumber;
- var currentLightNumber = this._lightNumber;
- // PENDING Performance
- for (var type in currentLightNumber[lightGroup]) {
- if (!prevLightNumber[lightGroup]) {
- return true;
- }
- if (currentLightNumber[lightGroup][type] !== prevLightNumber[lightGroup][type]) {
- return true;
- }
- }
- for (var type in prevLightNumber[lightGroup]) {
- if (!currentLightNumber[lightGroup]) {
- return true;
- }
- if (currentLightNumber[lightGroup][type] !== prevLightNumber[lightGroup][type]) {
- return true;
- }
- }
- return false;
- },
- getLightsNumbers: function (lightGroup) {
- return this._lightNumber[lightGroup];
- },
- getProgramKey: function (lightGroup) {
- return this._lightProgramKeys[lightGroup];
- },
- setLightUniforms: (function () {
- function setUniforms(uniforms, program, renderer) {
- for (var symbol in uniforms) {
- var lu = uniforms[symbol];
- if (lu.type === 'tv') {
- if (!program.hasUniform(symbol)) {
- continue;
- }
- var texSlots = [];
- for (var i = 0; i < lu.value.length; i++) {
- var texture = lu.value[i];
- var slot = program.takeCurrentTextureSlot(renderer, texture);
- texSlots.push(slot);
- }
- program.setUniform(renderer.gl, '1iv', symbol, texSlots);
- }
- else {
- program.setUniform(renderer.gl, lu.type, symbol, lu.value);
- }
- }
- }
- return function (program, lightGroup, renderer) {
- setUniforms(this._lightUniforms[lightGroup], program, renderer);
- // Set shadows
- setUniforms(this.shadowUniforms, program, renderer);
- };
- })(),
- /**
- * Dispose self, clear all the scene objects
- * But resources of gl like texuture, shader will not be disposed.
- * Mostly you should use disposeScene method in Renderer to do dispose.
- */
- dispose: function () {
- this.material = null;
- this._opaqueList = [];
- this._transparentList = [];
- this.lights = [];
- this._lightUniforms = {};
- this._lightNumber = {};
- this._nodeRepository = {};
- }
- });
- function lightSortFunc(a, b) {
- if (b.castShadow && !a.castShadow) {
- return true;
- }
- }
- /* harmony default export */ __webpack_exports__["a"] = (Scene);
- /***/
- }),
- /* 37 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Camera__ = __webpack_require__(58);
- /**
- * @constructor clay.camera.Orthographic
- * @extends clay.Camera
- */
- var Orthographic = __WEBPACK_IMPORTED_MODULE_0__Camera__["a" /* default */].extend(
- /** @lends clay.camera.Orthographic# */
- {
- /**
- * @type {number}
- */
- left: -1,
- /**
- * @type {number}
- */
- right: 1,
- /**
- * @type {number}
- */
- near: -1,
- /**
- * @type {number}
- */
- far: 1,
- /**
- * @type {number}
- */
- top: 1,
- /**
- * @type {number}
- */
- bottom: -1
- },
- /** @lends clay.camera.Orthographic.prototype */
- {
- updateProjectionMatrix: function () {
- this.projectionMatrix.ortho(this.left, this.right, this.bottom, this.top, this.near, this.far);
- },
- decomposeProjectionMatrix: function () {
- var m = this.projectionMatrix.array;
- this.left = (-1 - m[12]) / m[0];
- this.right = (1 - m[12]) / m[0];
- this.top = (1 - m[13]) / m[5];
- this.bottom = (-1 - m[13]) / m[5];
- this.near = -(-1 - m[14]) / m[10];
- this.far = -(1 - m[14]) / m[10];
- },
- /**
- * @return {clay.camera.Orthographic}
- */
- clone: function () {
- var camera = __WEBPACK_IMPORTED_MODULE_0__Camera__["a" /* default */].prototype.clone.call(this);
- camera.left = this.left;
- camera.right = this.right;
- camera.near = this.near;
- camera.far = this.far;
- camera.top = this.top;
- camera.bottom = this.bottom;
- return camera;
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Orthographic);
- /***/
- }),
- /* 38 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ({
- convertToDynamicArray: function (clear) {
- if (clear) {
- this.resetOffset();
- }
- var attributes = this.attributes;
- for (var name in attributes) {
- if (clear || !attributes[name].value) {
- attributes[name].value = [];
- }
- else {
- attributes[name].value = Array.prototype.slice.call(attributes[name].value);
- }
- }
- if (clear || !this.indices) {
- this.indices = [];
- }
- else {
- this.indices = Array.prototype.slice.call(this.indices);
- }
- },
- convertToTypedArray: function () {
- var attributes = this.attributes;
- for (var name in attributes) {
- if (attributes[name].value && attributes[name].value.length > 0) {
- attributes[name].value = new Float32Array(attributes[name].value);
- }
- else {
- attributes[name].value = null;
- }
- }
- if (this.indices && this.indices.length > 0) {
- this.indices = this.vertexCount > 0xffff ? new Uint32Array(this.indices) : new Uint16Array(this.indices);
- }
- this.dirty();
- }
- });
- /***/
- }),
- /* 39 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- function otherDimToDataDim(data, otherDim) {
- var dataDim = [];
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.each(data.dimensions, function (dimName) {
- var dimItem = data.getDimensionInfo(dimName);
- var otherDims = dimItem.otherDims;
- var dimIndex = otherDims[otherDim];
- if (dimIndex != null && dimIndex !== false) {
- dataDim[dimIndex] = dimItem.name;
- }
- });
- return dataDim;
- }
- /* harmony default export */ __webpack_exports__["a"] = (function (seriesModel, dataIndex, multipleSeries) {
- function formatArrayValue(value) {
- var vertially = true;
- var result = [];
- var tooltipDims = otherDimToDataDim(data, 'tooltip');
- tooltipDims.length
- ? __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.each(tooltipDims, function (dimIdx) {
- setEachItem(data.get(dimIdx, dataIndex), dimIdx);
- })
- // By default, all dims is used on tooltip.
- : __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.each(value, setEachItem);
- function setEachItem(val, dimIdx) {
- var dimInfo = data.getDimensionInfo(dimIdx);
- // If `dimInfo.tooltip` is not set, show tooltip.
- if (!dimInfo || dimInfo.otherDims.tooltip === false) {
- return;
- }
- var dimType = dimInfo.type;
- var valStr = (vertially ? '- ' + (dimInfo.tooltipName || dimInfo.name) + ': ' : '')
- + (dimType === 'ordinal'
- ? val + ''
- : dimType === 'time'
- ? (multipleSeries ? '' : __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.formatTime('yyyy/MM/dd hh:mm:ss', val))
- : __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.addCommas(val)
- );
- valStr && result.push(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.encodeHTML(valStr));
- }
- return (vertially ? '<br/>' : '') + result.join(vertially ? '<br/>' : ', ');
- }
- var data = seriesModel.getData();
- var value = seriesModel.getRawValue(dataIndex);
- var formattedValue = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(value)
- ? formatArrayValue(value) : __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.encodeHTML(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.addCommas(value));
- var name = data.getName(dataIndex);
- var color = data.getItemVisual(dataIndex, 'color');
- if (__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isObject(color) && color.colorStops) {
- color = (color.colorStops[0] || {}).color;
- }
- color = color || 'transparent';
- var colorEl = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.getTooltipMarker(color);
- var seriesName = seriesModel.name;
- // FIXME
- if (seriesName === '\0-') {
- // Not show '-'
- seriesName = '';
- }
- seriesName = seriesName
- ? __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.encodeHTML(seriesName) + (!multipleSeries ? '<br/>' : ': ')
- : '';
- return !multipleSeries
- ? seriesName + colorEl
- + (name
- ? __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.encodeHTML(name) + ': ' + formattedValue
- : formattedValue
- )
- : colorEl + seriesName + formattedValue;
- });;
- /***/
- }),
- /* 40 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Renderable__ = __webpack_require__(72);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11);
- /**
- * @constructor clay.Mesh
- * @extends clay.Renderable
- */
- var Mesh = __WEBPACK_IMPORTED_MODULE_0__Renderable__["a" /* default */].extend(/** @lends clay.Mesh# */ {
- /**
- * Used when it is a skinned mesh
- * @type {clay.Skeleton}
- */
- skeleton: null,
- /**
- * Joints indices Meshes can share the one skeleton instance and each mesh can use one part of joints. Joints indices indicate the index of joint in the skeleton instance
- * @type {number[]}
- */
- joints: null,
- /**
- * If store the skin matrices in vertex texture
- * @type {bool}
- */
- useSkinMatricesTexture: false
- }, function () {
- if (!this.joints) {
- this.joints = [];
- }
- }, {
- isSkinnedMesh: function () {
- return !!(this.skeleton && this.joints && this.joints.length > 0);
- },
- clone: function () {
- var mesh = __WEBPACK_IMPORTED_MODULE_0__Renderable__["a" /* default */].prototype.clone.call(this);
- mesh.skeleton = this.skeleton;
- if (this.joints) {
- mesh.joints = this.joints.slice();
- }
- return mesh;
- }
- });
- // Enums
- Mesh.POINTS = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].POINTS;
- Mesh.LINES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINES;
- Mesh.LINE_LOOP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_LOOP;
- Mesh.LINE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_STRIP;
- Mesh.TRIANGLES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLES;
- Mesh.TRIANGLE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_STRIP;
- Mesh.TRIANGLE_FAN = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_FAN;
- Mesh.BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BACK;
- Mesh.FRONT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT;
- Mesh.FRONT_AND_BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT_AND_BACK;
- Mesh.CW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CW;
- Mesh.CCW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CCW;
- /* harmony default export */ __webpack_exports__["a"] = (Mesh);
- /***/
- }),
- /* 41 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Camera__ = __webpack_require__(58);
- /**
- * @constructor clay.camera.Perspective
- * @extends clay.Camera
- */
- var Perspective = __WEBPACK_IMPORTED_MODULE_0__Camera__["a" /* default */].extend(/** @lends clay.camera.Perspective# */{
- /**
- * Vertical field of view in degrees
- * @type {number}
- */
- fov: 50,
- /**
- * Aspect ratio, typically viewport width / height
- * @type {number}
- */
- aspect: 1,
- /**
- * Near bound of the frustum
- * @type {number}
- */
- near: 0.1,
- /**
- * Far bound of the frustum
- * @type {number}
- */
- far: 2000
- },
- /** @lends clay.camera.Perspective.prototype */
- {
- updateProjectionMatrix: function () {
- var rad = this.fov / 180 * Math.PI;
- this.projectionMatrix.perspective(rad, this.aspect, this.near, this.far);
- },
- decomposeProjectionMatrix: function () {
- var m = this.projectionMatrix.array;
- var rad = Math.atan(1 / m[5]) * 2;
- this.fov = rad / Math.PI * 180;
- this.aspect = m[5] / m[0];
- this.near = m[14] / (m[10] - 1);
- this.far = m[14] / (m[10] + 1);
- },
- /**
- * @return {clay.camera.Perspective}
- */
- clone: function () {
- var camera = __WEBPACK_IMPORTED_MODULE_0__Camera__["a" /* default */].prototype.clone.call(this);
- camera.fov = this.fov;
- camera.aspect = this.aspect;
- camera.near = this.near;
- camera.far = this.far;
- return camera;
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Perspective);
- /***/
- }),
- /* 42 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Mesh__ = __webpack_require__(40);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geometry_Cube__ = __webpack_require__(76);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Material__ = __webpack_require__(19);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__shader_source_skybox_glsl_js__ = __webpack_require__(121);
- // TODO Should not derived from mesh?
- __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_5__shader_source_skybox_glsl_js__["a" /* default */]);
- /**
- * @constructor clay.plugin.Skybox
- *
- * @example
- * var skyTex = new clay.TextureCube();
- * skyTex.load({
- * 'px': 'assets/textures/sky/px.jpg',
- * 'nx': 'assets/textures/sky/nx.jpg'
- * 'py': 'assets/textures/sky/py.jpg'
- * 'ny': 'assets/textures/sky/ny.jpg'
- * 'pz': 'assets/textures/sky/pz.jpg'
- * 'nz': 'assets/textures/sky/nz.jpg'
- * });
- * var skybox = new clay.plugin.Skybox({
- * scene: scene
- * });
- * skybox.material.set('environmentMap', skyTex);
- */
- var Skybox = __WEBPACK_IMPORTED_MODULE_0__Mesh__["a" /* default */].extend(function () {
- var skyboxShader = new __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */]({
- vertex: __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].source('clay.skybox.vertex'),
- fragment: __WEBPACK_IMPORTED_MODULE_2__Shader__["a" /* default */].source('clay.skybox.fragment')
- });
- var material = new __WEBPACK_IMPORTED_MODULE_3__Material__["a" /* default */]({
- shader: skyboxShader,
- depthMask: false
- });
- return {
- /**
- * @type {clay.Scene}
- * @memberOf clay.plugin.Skybox.prototype
- */
- scene: null,
- geometry: new __WEBPACK_IMPORTED_MODULE_1__geometry_Cube__["a" /* default */](),
- material: material,
- environmentMap: null,
- culling: false
- };
- }, function () {
- var scene = this.scene;
- if (scene) {
- this.attachScene(scene);
- }
- if (this.environmentMap) {
- this.setEnvironmentMap(this.environmentMap);
- }
- }, /** @lends clay.plugin.Skybox# */ {
- /**
- * Attach the skybox to the scene
- * @param {clay.Scene} scene
- */
- attachScene: function (scene) {
- if (this.scene) {
- this.detachScene();
- }
- scene.skybox = this;
- this.scene = scene;
- scene.on('beforerender', this._beforeRenderScene, this);
- },
- /**
- * Detach from scene
- */
- detachScene: function () {
- if (this.scene) {
- this.scene.off('beforerender', this._beforeRenderScene);
- this.scene.skybox = null;
- }
- this.scene = null;
- },
- /**
- * Dispose skybox
- * @param {clay.Renderer} renderer
- */
- dispose: function (renderer) {
- this.detachScene();
- this.geometry.dispose(renderer);
- },
- /**
- * Set environment map
- * @param {clay.TextureCube} envMap
- */
- setEnvironmentMap: function (envMap) {
- if (envMap.textureType === 'texture2D') {
- this.material.define('EQUIRECTANGULAR');
- // LINEAR filter can remove the artifacts in pole
- envMap.minFilter = __WEBPACK_IMPORTED_MODULE_4__Texture__["a" /* default */].LINEAR;
- }
- else {
- this.material.undefine('EQUIRECTANGULAR');
- }
- this.material.set('environmentMap', envMap);
- },
- /**
- * Get environment map
- * @return {clay.TextureCube}
- */
- getEnvironmentMap: function () {
- return this.material.get('environmentMap');
- },
- _beforeRenderScene: function (renderer, scene, camera) {
- this.renderSkybox(renderer, camera);
- },
- renderSkybox: function (renderer, camera) {
- this.position.copy(camera.getWorldPosition());
- this.update();
- // Don't remember to disable blend
- renderer.gl.disable(renderer.gl.BLEND);
- if (this.material.get('lod') > 0) {
- this.material.define('fragment', 'LOD');
- }
- else {
- this.material.undefine('fragment', 'LOD');
- }
- renderer.renderPass([this], camera);
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Skybox);
- /***/
- }),
- /* 43 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(15);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_BoundingBox__ = __webpack_require__(18);
- /**
- * @constructor clay.geometry.Plane
- * @extends clay.Geometry
- * @param {Object} [opt]
- * @param {number} [opt.widthSegments]
- * @param {number} [opt.heightSegments]
- */
- var Plane = __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].extend(
- /** @lends clay.geometry.Plane# */
- {
- dynamic: false,
- /**
- * @type {number}
- */
- widthSegments: 1,
- /**
- * @type {number}
- */
- heightSegments: 1
- }, function () {
- this.build();
- },
- /** @lends clay.geometry.Plane.prototype */
- {
- /**
- * Build plane geometry
- */
- build: function () {
- var heightSegments = this.heightSegments;
- var widthSegments = this.widthSegments;
- var attributes = this.attributes;
- var positions = [];
- var texcoords = [];
- var normals = [];
- var faces = [];
- for (var y = 0; y <= heightSegments; y++) {
- var t = y / heightSegments;
- for (var x = 0; x <= widthSegments; x++) {
- var s = x / widthSegments;
- positions.push([2 * s - 1, 2 * t - 1, 0]);
- if (texcoords) {
- texcoords.push([s, t]);
- }
- if (normals) {
- normals.push([0, 0, 1]);
- }
- if (x < widthSegments && y < heightSegments) {
- var i = x + y * (widthSegments + 1);
- faces.push([i, i + 1, i + widthSegments + 1]);
- faces.push([i + widthSegments + 1, i + 1, i + widthSegments + 2]);
- }
- }
- }
- attributes.position.fromArray(positions);
- attributes.texcoord0.fromArray(texcoords);
- attributes.normal.fromArray(normals);
- this.initIndicesFromArray(faces);
- this.boundingBox = new __WEBPACK_IMPORTED_MODULE_1__math_BoundingBox__["a" /* default */]();
- this.boundingBox.min.set(-1, -1, 0);
- this.boundingBox.max.set(1, 1, 0);
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Plane);
- /***/
- }),
- /* 44 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ({
- defaultOption: {
- viewControl: {
- // perspective, orthographic.
- // TODO Isometric
- projection: 'perspective',
- // If rotate on on init
- autoRotate: false,
- // cw or ccw
- autoRotateDirection: 'cw',
- // Degree per second
- autoRotateSpeed: 10,
- // Start rotating after still for a given time
- // default is 3 seconds
- autoRotateAfterStill: 3,
- // Rotate, zoom damping.
- damping: 0.8,
- // Sensitivities for operations.
- // Can be array to set x,y respectively
- rotateSensitivity: 1,
- zoomSensitivity: 1,
- // Can be array to set x,y respectively
- panSensitivity: 1,
- // Which mouse button do rotate or pan
- panMouseButton: 'middle',
- rotateMouseButton: 'left',
- // Distance to the target
- // Only available when camera is perspective.
- distance: 150,
- // Min distance mouse can zoom in
- minDistance: 40,
- // Max distance mouse can zoom out
- maxDistance: 400,
- // Size of viewing volume.
- // Only available when camera is orthographic
- orthographicSize: 150,
- maxOrthographicSize: 400,
- minOrthographicSize: 20,
- // Center view point
- center: [0, 0, 0],
- // Alpha angle for top-down rotation
- // Positive to rotate to top.
- alpha: 0,
- // beta angle for left-right rotation
- // Positive to rotate to right.
- beta: 0,
- minAlpha: -90,
- maxAlpha: 90
- // minBeta: -Infinity
- // maxBeta: -Infinity
- }
- },
- setView: function (opts) {
- opts = opts || {};
- this.option.viewControl = this.option.viewControl || {};
- if (opts.alpha != null) {
- this.option.viewControl.alpha = opts.alpha;
- }
- if (opts.beta != null) {
- this.option.viewControl.beta = opts.beta;
- }
- if (opts.distance != null) {
- this.option.viewControl.distance = opts.distance;
- }
- if (opts.center != null) {
- this.option.viewControl.center = opts.center;
- }
- }
- });
- /***/
- }),
- /* 45 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector2__ = __webpack_require__(26);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_math_Quaternion__ = __webpack_require__(56);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__retrieve__ = __webpack_require__(2);
- /**
- * Provide orbit control for 3D objects
- *
- * @module echarts-gl/util/OrbitControl
- * @author Yi Shen(http://github.com/pissang)
- */
- // TODO Remove magic numbers on sensitivity
- var firstNotNull = __WEBPACK_IMPORTED_MODULE_4__retrieve__["a" /* default */].firstNotNull;
- var MOUSE_BUTTON_KEY_MAP = {
- left: 0,
- middle: 1,
- right: 2
- };
- function convertToArray(val) {
- if (!(val instanceof Array)) {
- val = [val, val];
- }
- return val;
- }
- /**
- * @alias module:echarts-x/util/OrbitControl
- */
- var OrbitControl = __WEBPACK_IMPORTED_MODULE_0_claygl_src_core_Base__["a" /* default */].extend(function () {
- return {
- /**
- * @type {module:zrender~ZRender}
- */
- zr: null,
- /**
- * @type {module:echarts-gl/core/ViewGL}
- */
- viewGL: null,
- /**
- * @type {clay.math.Vector3}
- */
- _center: new __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector3__["a" /* default */](),
- /**
- * Minimum distance to the center
- * Only available when camera is perspective.
- * @type {number}
- * @default 0.5
- */
- minDistance: 0.5,
- /**
- * Maximum distance to the center
- * Only available when camera is perspective.
- * @type {number}
- * @default 2
- */
- maxDistance: 1.5,
- /**
- * Only available when camera is orthographic
- */
- maxOrthographicSize: 300,
- /**
- * Only available when camera is orthographic
- */
- minOrthographicSize: 30,
- /**
- * Minimum alpha rotation
- */
- minAlpha: -90,
- /**
- * Maximum alpha rotation
- */
- maxAlpha: 90,
- /**
- * Minimum beta rotation
- */
- minBeta: -Infinity,
- /**
- * Maximum beta rotation
- */
- maxBeta: Infinity,
- /**
- * Start auto rotating after still for the given time
- */
- autoRotateAfterStill: 0,
- /**
- * Direction of autoRotate. cw or ccw when looking top down.
- */
- autoRotateDirection: 'cw',
- /**
- * Degree per second
- */
- autoRotateSpeed: 60,
- /**
- * @param {number}
- */
- damping: 0.8,
- /**
- * @param {number}
- */
- rotateSensitivity: 1,
- /**
- * @param {number}
- */
- zoomSensitivity: 1,
- /**
- * @param {number}
- */
- panSensitivity: 1,
- panMouseButton: 'middle',
- rotateMouseButton: 'left',
- /**
- * Pan or rotate
- * @private
- * @type {String}
- */
- _mode: 'rotate',
- /**
- * @private
- * @type {clay.Camera}
- */
- _camera: null,
- _needsUpdate: false,
- _rotating: false,
- // Rotation around yAxis in radian
- _phi: 0,
- // Rotation around xAxis in radian
- _theta: 0,
- _mouseX: 0,
- _mouseY: 0,
- _rotateVelocity: new __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector2__["a" /* default */](),
- _panVelocity: new __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector2__["a" /* default */](),
- _distance: 500,
- _zoomSpeed: 0,
- _stillTimeout: 0,
- _animators: []
- };
- }, function () {
- // Each OrbitControl has it's own handler
- ['_mouseDownHandler', '_mouseWheelHandler', '_mouseMoveHandler', '_mouseUpHandler',
- '_pinchHandler', '_contextMenuHandler', '_update'].forEach(function (hdlName) {
- this[hdlName] = this[hdlName].bind(this);
- }, this);
- }, {
- /**
- * Initialize.
- * Mouse event binding
- */
- init: function () {
- var zr = this.zr;
- if (zr) {
- zr.on('mousedown', this._mouseDownHandler);
- zr.on('globalout', this._mouseUpHandler);
- zr.on('mousewheel', this._mouseWheelHandler);
- zr.on('pinch', this._pinchHandler);
- zr.animation.on('frame', this._update);
- zr.dom.addEventListener('contextmenu', this._contextMenuHandler);
- }
- },
- /**
- * Dispose.
- * Mouse event unbinding
- */
- dispose: function () {
- var zr = this.zr;
- if (zr) {
- zr.off('mousedown', this._mouseDownHandler);
- zr.off('mousemove', this._mouseMoveHandler);
- zr.off('mouseup', this._mouseUpHandler);
- zr.off('mousewheel', this._mouseWheelHandler);
- zr.off('pinch', this._pinchHandler);
- zr.off('globalout', this._mouseUpHandler);
- zr.dom.removeEventListener('contextmenu', this._contextMenuHandler);
- zr.animation.off('frame', this._update);
- }
- this.stopAllAnimation();
- },
- /**
- * Get distance
- * @return {number}
- */
- getDistance: function () {
- return this._distance;
- },
- /**
- * Set distance
- * @param {number} distance
- */
- setDistance: function (distance) {
- this._distance = distance;
- this._needsUpdate = true;
- },
- /**
- * Get size of orthographic viewing volume
- * @return {number}
- */
- getOrthographicSize: function () {
- return this._orthoSize;
- },
- /**
- * Set size of orthographic viewing volume
- * @param {number} size
- */
- setOrthographicSize: function (size) {
- this._orthoSize = size;
- this._needsUpdate = true;
- },
- /**
- * Get alpha rotation
- * Alpha angle for top-down rotation. Positive to rotate to top.
- *
- * Which means camera rotation around x axis.
- */
- getAlpha: function () {
- return this._theta / Math.PI * 180;
- },
- /**
- * Get beta rotation
- * Beta angle for left-right rotation. Positive to rotate to right.
- *
- * Which means camera rotation around y axis.
- */
- getBeta: function () {
- return -this._phi / Math.PI * 180;
- },
- /**
- * Get control center
- * @return {Array.<number>}
- */
- getCenter: function () {
- return this._center.toArray();
- },
- /**
- * Set alpha rotation angle
- * @param {number} alpha
- */
- setAlpha: function (alpha) {
- alpha = Math.max(Math.min(this.maxAlpha, alpha), this.minAlpha);
- this._theta = alpha / 180 * Math.PI;
- this._needsUpdate = true;
- },
- /**
- * Set beta rotation angle
- * @param {number} beta
- */
- setBeta: function (beta) {
- beta = Math.max(Math.min(this.maxBeta, beta), this.minBeta);
- this._phi = -beta / 180 * Math.PI;
- this._needsUpdate = true;
- },
- /**
- * Set control center
- * @param {Array.<number>} center
- */
- setCenter: function (centerArr) {
- this._center.setArray(centerArr);
- },
- /**
- * @param {module:echarts-gl/core/ViewGL} viewGL
- */
- setViewGL: function (viewGL) {
- this.viewGL = viewGL;
- },
- /**
- * @return {clay.Camera}
- */
- getCamera: function () {
- return this.viewGL.camera;
- },
- setFromViewControlModel: function (viewControlModel, extraOpts) {
- extraOpts = extraOpts || {};
- var baseDistance = extraOpts.baseDistance || 0;
- var baseOrthoSize = extraOpts.baseOrthoSize || 1;
- var projection = viewControlModel.get('projection');
- if (projection !== 'perspective' && projection !== 'orthographic' && projection !== 'isometric') {
- if (true) {
- console.error('Unkown projection type %s, use perspective projection instead.', projection);
- }
- projection = 'perspective';
- }
- this._projection = projection;
- this.viewGL.setProjection(projection);
- var targetDistance = viewControlModel.get('distance') + baseDistance;
- var targetOrthographicSize = viewControlModel.get('orthographicSize') + baseOrthoSize;
- [
- ['damping', 0.8],
- ['autoRotate', false],
- ['autoRotateAfterStill', 3],
- ['autoRotateDirection', 'cw'],
- ['autoRotateSpeed', 10],
- ['minDistance', 30],
- ['maxDistance', 400],
- ['minOrthographicSize', 30],
- ['maxOrthographicSize', 300],
- ['minAlpha', -90],
- ['maxAlpha', 90],
- ['minBeta', -Infinity],
- ['maxBeta', Infinity],
- ['rotateSensitivity', 1],
- ['zoomSensitivity', 1],
- ['panSensitivity', 1],
- ['panMouseButton', 'left'],
- ['rotateMouseButton', 'middle'],
- ].forEach(function (prop) {
- this[prop[0]] = firstNotNull(viewControlModel.get(prop[0]), prop[1]);
- }, this);
- this.minDistance += baseDistance;
- this.maxDistance += baseDistance;
- this.minOrthographicSize += baseOrthoSize,
- this.maxOrthographicSize += baseOrthoSize;
- var ecModel = viewControlModel.ecModel;
- var animationOpts = {};
- ['animation', 'animationDurationUpdate', 'animationEasingUpdate'].forEach(function (key) {
- animationOpts[key] = firstNotNull(
- viewControlModel.get(key), ecModel && ecModel.get(key)
- );
- });
- var alpha = firstNotNull(extraOpts.alpha, viewControlModel.get('alpha')) || 0;
- var beta = firstNotNull(extraOpts.beta, viewControlModel.get('beta')) || 0;
- var center = firstNotNull(extraOpts.center, viewControlModel.get('center')) || [0, 0, 0];
- if (animationOpts.animation && animationOpts.animationDurationUpdate > 0 && this._notFirst) {
- this.animateTo({
- alpha: alpha,
- beta: beta,
- center: center,
- distance: targetDistance,
- targetOrthographicSize: targetOrthographicSize,
- easing: animationOpts.animationEasingUpdate,
- duration: animationOpts.animationDurationUpdate
- });
- }
- else {
- this.setDistance(targetDistance);
- this.setAlpha(alpha);
- this.setBeta(beta);
- this.setCenter(center);
- this.setOrthographicSize(targetOrthographicSize);
- }
- this._notFirst = true;
- this._validateProperties();
- },
- _validateProperties: function () {
- if (true) {
- if (MOUSE_BUTTON_KEY_MAP[this.panMouseButton] == null) {
- console.error('Unkown panMouseButton %s. It should be left|middle|right', this.panMouseButton);
- }
- if (MOUSE_BUTTON_KEY_MAP[this.rotateMouseButton] == null) {
- console.error('Unkown rotateMouseButton %s. It should be left|middle|right', this.rotateMouseButton);
- }
- if (this.autoRotateDirection !== 'cw' && this.autoRotateDirection !== 'ccw') {
- console.error('Unkown autoRotateDirection %s. It should be cw|ccw', this.autoRotateDirection);
- }
- }
- },
- /**
- * @param {Object} opts
- * @param {number} opts.distance
- * @param {number} opts.alpha
- * @param {number} opts.beta
- * @param {number} opts.orthographicSize
- * @param {number} [opts.duration=1000]
- * @param {number} [opts.easing='linear']
- */
- animateTo: function (opts) {
- var zr = this.zr;
- var self = this;
- var obj = {};
- var target = {};
- if (opts.distance != null) {
- obj.distance = this.getDistance();
- target.distance = opts.distance;
- }
- if (opts.orthographicSize != null) {
- obj.orthographicSize = this.getOrthographicSize();
- target.orthographicSize = opts.orthographicSize;
- }
- if (opts.alpha != null) {
- obj.alpha = this.getAlpha();
- target.alpha = opts.alpha;
- }
- if (opts.beta != null) {
- obj.beta = this.getBeta();
- target.beta = opts.beta;
- }
- if (opts.center != null) {
- obj.center = this.getCenter();
- target.center = opts.center;
- }
- return this._addAnimator(
- zr.animation.animate(obj)
- .when(opts.duration || 1000, target)
- .during(function () {
- if (obj.alpha != null) {
- self.setAlpha(obj.alpha);
- }
- if (obj.beta != null) {
- self.setBeta(obj.beta);
- }
- if (obj.distance != null) {
- self.setDistance(obj.distance);
- }
- if (obj.center != null) {
- self.setCenter(obj.center);
- }
- if (obj.orthographicSize != null) {
- self.setOrthographicSize(obj.orthographicSize);
- }
- self._needsUpdate = true;
- })
- ).start(opts.easing || 'linear');
- },
- /**
- * Stop all animation
- */
- stopAllAnimation: function () {
- for (var i = 0; i < this._animators.length; i++) {
- this._animators[i].stop();
- }
- this._animators.length = 0;
- },
- update: function () {
- this._needsUpdate = true;
- this._update(20);
- },
- _isAnimating: function () {
- return this._animators.length > 0;
- },
- /**
- * Call update each frame
- * @param {number} deltaTime Frame time
- */
- _update: function (deltaTime) {
- if (this._rotating) {
- var radian = (this.autoRotateDirection === 'cw' ? 1 : -1)
- * this.autoRotateSpeed / 180 * Math.PI;
- this._phi -= radian * deltaTime / 1000;
- this._needsUpdate = true;
- }
- else if (this._rotateVelocity.len() > 0) {
- this._needsUpdate = true;
- }
- if (Math.abs(this._zoomSpeed) > 0.1 || this._panVelocity.len() > 0) {
- this._needsUpdate = true;
- }
- if (!this._needsUpdate) {
- return;
- }
- deltaTime = Math.min(deltaTime, 50);
- this._updateDistanceOrSize(deltaTime);
- this._updatePan(deltaTime);
- this._updateRotate(deltaTime);
- this._updateTransform();
- this.getCamera().update();
- this.zr && this.zr.refresh();
- this.trigger('update');
- this._needsUpdate = false;
- },
- _updateRotate: function (deltaTime) {
- var velocity = this._rotateVelocity;
- this._phi = velocity.y * deltaTime / 20 + this._phi;
- this._theta = velocity.x * deltaTime / 20 + this._theta;
- this.setAlpha(this.getAlpha());
- this.setBeta(this.getBeta());
- this._vectorDamping(velocity, Math.pow(this.damping, deltaTime / 16));
- },
- _updateDistanceOrSize: function (deltaTime) {
- if (this._projection === 'perspective') {
- this._setDistance(this._distance + this._zoomSpeed * deltaTime / 20);
- }
- else {
- this._setOrthoSize(this._orthoSize + this._zoomSpeed * deltaTime / 20);
- }
- this._zoomSpeed *= Math.pow(this.damping, deltaTime / 16);
- },
- _setDistance: function (distance) {
- this._distance = Math.max(Math.min(distance, this.maxDistance), this.minDistance);
- },
- _setOrthoSize: function (size) {
- this._orthoSize = Math.max(Math.min(size, this.maxOrthographicSize), this.minOrthographicSize);
- var camera = this.getCamera();
- var cameraHeight = this._orthoSize;
- var cameraWidth = cameraHeight / this.viewGL.viewport.height * this.viewGL.viewport.width;
- camera.left = -cameraWidth / 2;
- camera.right = cameraWidth / 2;
- camera.top = cameraHeight / 2;
- camera.bottom = -cameraHeight / 2;
- },
- _updatePan: function (deltaTime) {
- var velocity = this._panVelocity;
- var len = this._distance;
- var target = this.getCamera();
- var yAxis = target.worldTransform.y;
- var xAxis = target.worldTransform.x;
- // PENDING
- this._center
- .scaleAndAdd(xAxis, -velocity.x * len / 200)
- .scaleAndAdd(yAxis, -velocity.y * len / 200);
- this._vectorDamping(velocity, 0);
- },
- _updateTransform: function () {
- var camera = this.getCamera();
- var dir = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector3__["a" /* default */]();
- var theta = this._theta + Math.PI / 2;
- var phi = this._phi + Math.PI / 2;
- var r = Math.sin(theta);
- dir.x = r * Math.cos(phi);
- dir.y = -Math.cos(theta);
- dir.z = r * Math.sin(phi);
- camera.position.copy(this._center).scaleAndAdd(dir, this._distance);
- camera.rotation.identity()
- // First around y, then around x
- .rotateY(-this._phi)
- .rotateX(-this._theta);
- },
- _startCountingStill: function () {
- clearTimeout(this._stillTimeout);
- var time = this.autoRotateAfterStill;
- var self = this;
- if (!isNaN(time) && time > 0) {
- this._stillTimeout = setTimeout(function () {
- self._rotating = true;
- }, time * 1000);
- }
- },
- _vectorDamping: function (v, damping) {
- var speed = v.len();
- speed = speed * damping;
- if (speed < 1e-4) {
- speed = 0;
- }
- v.normalize().scale(speed);
- },
- _decomposeTransform: function () {
- if (!this.getCamera()) {
- return;
- }
- this.getCamera().updateWorldTransform();
- var forward = this.getCamera().worldTransform.z;
- var alpha = Math.asin(forward.y);
- var beta = Math.atan2(forward.x, forward.z);
- this._theta = alpha;
- this._phi = -beta;
- this.setBeta(this.getBeta());
- this.setAlpha(this.getAlpha());
- // Is perspective
- if (this.getCamera().aspect) {
- this._setDistance(this.getCamera().position.dist(this._center));
- }
- else {
- this._setOrthoSize(this.getCamera().top - this.getCamera().bottom);
- }
- },
- _mouseDownHandler: function (e) {
- if (e.target) {
- // If mouseon some zrender element.
- return;
- }
- if (this._isAnimating()) {
- return;
- }
- var x = e.offsetX;
- var y = e.offsetY;
- if (this.viewGL && !this.viewGL.containPoint(x, y)) {
- return;
- }
- this.zr.on('mousemove', this._mouseMoveHandler);
- this.zr.on('mouseup', this._mouseUpHandler);
- if (e.event.targetTouches) {
- if (e.event.targetTouches.length === 1) {
- this._mode = 'rotate';
- }
- }
- else {
- if (e.event.button === MOUSE_BUTTON_KEY_MAP[this.rotateMouseButton]) {
- this._mode = 'rotate';
- }
- else if (e.event.button === MOUSE_BUTTON_KEY_MAP[this.panMouseButton]) {
- this._mode = 'pan';
- }
- else {
- this._mode = '';
- }
- }
- // Reset rotate velocity
- this._rotateVelocity.set(0, 0);
- this._rotating = false;
- if (this.autoRotate) {
- this._startCountingStill();
- }
- this._mouseX = e.offsetX;
- this._mouseY = e.offsetY;
- },
- _mouseMoveHandler: function (e) {
- if (e.target && e.target.__isGLToZRProxy) {
- return;
- }
- if (this._isAnimating()) {
- return;
- }
- var panSensitivity = convertToArray(this.panSensitivity);
- var rotateSensitivity = convertToArray(this.rotateSensitivity);
- if (this._mode === 'rotate') {
- this._rotateVelocity.y = (e.offsetX - this._mouseX) / this.zr.getHeight() * 2 * rotateSensitivity[0];
- this._rotateVelocity.x = (e.offsetY - this._mouseY) / this.zr.getWidth() * 2 * rotateSensitivity[1];
- }
- else if (this._mode === 'pan') {
- this._panVelocity.x = (e.offsetX - this._mouseX) / this.zr.getWidth() * panSensitivity[0] * 400;
- this._panVelocity.y = (-e.offsetY + this._mouseY) / this.zr.getHeight() * panSensitivity[1] * 400;
- }
- this._mouseX = e.offsetX;
- this._mouseY = e.offsetY;
- e.event.preventDefault();
- },
- _mouseWheelHandler: function (e) {
- if (this._isAnimating()) {
- return;
- }
- var delta = e.event.wheelDelta // Webkit
- || -e.event.detail; // Firefox
- this._zoomHandler(e, delta);
- },
- _pinchHandler: function (e) {
- if (this._isAnimating()) {
- return;
- }
- this._zoomHandler(e, e.pinchScale > 1 ? 1 : -1);
- // Not rotate when pinch
- this._mode = '';
- },
- _zoomHandler: function (e, delta) {
- if (delta === 0) {
- return;
- }
- var x = e.offsetX;
- var y = e.offsetY;
- if (this.viewGL && !this.viewGL.containPoint(x, y)) {
- return;
- }
- var speed;
- if (this._projection === 'perspective') {
- speed = Math.max(Math.max(Math.min(
- this._distance - this.minDistance,
- this.maxDistance - this._distance
- )) / 20, 0.5);
- }
- else {
- speed = Math.max(Math.max(Math.min(
- this._orthoSize - this.minOrthographicSize,
- this.maxOrthographicSize - this._orthoSize
- )) / 20, 0.5);
- }
- this._zoomSpeed = (delta > 0 ? -1 : 1) * speed * this.zoomSensitivity;
- this._rotating = false;
- if (this.autoRotate && this._mode === 'rotate') {
- this._startCountingStill();
- }
- e.event.preventDefault();
- },
- _mouseUpHandler: function () {
- this.zr.off('mousemove', this._mouseMoveHandler);
- this.zr.off('mouseup', this._mouseUpHandler);
- },
- _isRightMouseButtonUsed: function () {
- return this.rotateMouseButton === 'right'
- || this.panMouseButton === 'right';
- },
- _contextMenuHandler: function (e) {
- if (this._isRightMouseButtonUsed()) {
- e.preventDefault();
- }
- },
- _addAnimator: function (animator) {
- var animators = this._animators;
- animators.push(animator);
- animator.done(function () {
- var idx = animators.indexOf(animator);
- if (idx >= 0) {
- animators.splice(idx, 1);
- }
- });
- return animator;
- }
- });
- /**
- * If auto rotate the target
- * @type {boolean}
- * @default false
- */
- Object.defineProperty(OrbitControl.prototype, 'autoRotate', {
- get: function (val) {
- return this._autoRotate;
- },
- set: function (val) {
- this._autoRotate = val;
- this._rotating = val;
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (OrbitControl);
- /***/
- }),
- /* 46 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.lines3D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, 1.0);\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n}\n@end\n\n\n\n@export ecgl.lines3D.clipNear\n\nvec4 clipNear(vec4 p1, vec4 p2) {\n float n = (p1.w - near) / (p1.w - p2.w);\n return vec4(mix(p1.xy, p2.xy, n), -near, near);\n}\n\n@end\n\n@export ecgl.lines3D.expandLine\n#ifdef VERTEX_ANIMATION\n vec4 prevProj = worldViewProjection * vec4(mix(prevPositionPrev, positionPrev, percent), 1.0);\n vec4 currProj = worldViewProjection * vec4(mix(prevPosition, position, percent), 1.0);\n vec4 nextProj = worldViewProjection * vec4(mix(prevPositionNext, positionNext, percent), 1.0);\n#else\n vec4 prevProj = worldViewProjection * vec4(positionPrev, 1.0);\n vec4 currProj = worldViewProjection * vec4(position, 1.0);\n vec4 nextProj = worldViewProjection * vec4(positionNext, 1.0);\n#endif\n\n if (currProj.w < 0.0) {\n if (nextProj.w > 0.0) {\n currProj = clipNear(currProj, nextProj);\n }\n else if (prevProj.w > 0.0) {\n currProj = clipNear(currProj, prevProj);\n }\n }\n\n vec2 prevScreen = (prevProj.xy / abs(prevProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 currScreen = (currProj.xy / abs(currProj.w) + 1.0) * 0.5 * viewport.zw;\n vec2 nextScreen = (nextProj.xy / abs(nextProj.w) + 1.0) * 0.5 * viewport.zw;\n\n vec2 dir;\n float len = offset;\n if (position == positionPrev) {\n dir = normalize(nextScreen - currScreen);\n }\n else if (position == positionNext) {\n dir = normalize(currScreen - prevScreen);\n }\n else {\n vec2 dirA = normalize(currScreen - prevScreen);\n vec2 dirB = normalize(nextScreen - currScreen);\n\n vec2 tanget = normalize(dirA + dirB);\n\n float miter = 1.0 / max(dot(tanget, dirA), 0.5);\n len *= miter;\n dir = tanget;\n }\n\n dir = vec2(-dir.y, dir.x) * len;\n currScreen += dir;\n\n currProj.xy = (currScreen / viewport.zw - 0.5) * 2.0 * abs(currProj.w);\n@end\n\n\n@export ecgl.meshLines3D.vertex\n\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevPositionPrev;\nattribute vec3 prevPositionNext;\nuniform float percent : 1.0;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n}\n@end\n\n\n@export ecgl.meshLines3D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end");
- /***/
- }),
- /* 47 */
- /***/ (function (module, exports, __webpack_require__) {
- var zrUtil = __webpack_require__(13);
- var BoundingRect = __webpack_require__(82);
- var _number = __webpack_require__(85);
- var parsePercent = _number.parsePercent;
- var formatUtil = __webpack_require__(171);
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- // Layout helpers for each component positioning
- var each = zrUtil.each;
- /**
- * @public
- */
- var LOCATION_PARAMS = ['left', 'right', 'top', 'bottom', 'width', 'height'];
- /**
- * @public
- */
- var HV_NAMES = [['width', 'left', 'right'], ['height', 'top', 'bottom']];
- function boxLayout(orient, group, gap, maxWidth, maxHeight) {
- var x = 0;
- var y = 0;
- if (maxWidth == null) {
- maxWidth = Infinity;
- }
- if (maxHeight == null) {
- maxHeight = Infinity;
- }
- var currentLineMaxSize = 0;
- group.eachChild(function (child, idx) {
- var position = child.position;
- var rect = child.getBoundingRect();
- var nextChild = group.childAt(idx + 1);
- var nextChildRect = nextChild && nextChild.getBoundingRect();
- var nextX;
- var nextY;
- if (orient === 'horizontal') {
- var moveX = rect.width + (nextChildRect ? -nextChildRect.x + rect.x : 0);
- nextX = x + moveX; // Wrap when width exceeds maxWidth or meet a `newline` group
- // FIXME compare before adding gap?
- if (nextX > maxWidth || child.newline) {
- x = 0;
- nextX = moveX;
- y += currentLineMaxSize + gap;
- currentLineMaxSize = rect.height;
- } else {
- // FIXME: consider rect.y is not `0`?
- currentLineMaxSize = Math.max(currentLineMaxSize, rect.height);
- }
- } else {
- var moveY = rect.height + (nextChildRect ? -nextChildRect.y + rect.y : 0);
- nextY = y + moveY; // Wrap when width exceeds maxHeight or meet a `newline` group
- if (nextY > maxHeight || child.newline) {
- x += currentLineMaxSize + gap;
- y = 0;
- nextY = moveY;
- currentLineMaxSize = rect.width;
- } else {
- currentLineMaxSize = Math.max(currentLineMaxSize, rect.width);
- }
- }
- if (child.newline) {
- return;
- }
- position[0] = x;
- position[1] = y;
- orient === 'horizontal' ? x = nextX + gap : y = nextY + gap;
- });
- }
- /**
- * VBox or HBox layouting
- * @param {string} orient
- * @param {module:zrender/container/Group} group
- * @param {number} gap
- * @param {number} [width=Infinity]
- * @param {number} [height=Infinity]
- */
- var box = boxLayout;
- /**
- * VBox layouting
- * @param {module:zrender/container/Group} group
- * @param {number} gap
- * @param {number} [width=Infinity]
- * @param {number} [height=Infinity]
- */
- var vbox = zrUtil.curry(boxLayout, 'vertical');
- /**
- * HBox layouting
- * @param {module:zrender/container/Group} group
- * @param {number} gap
- * @param {number} [width=Infinity]
- * @param {number} [height=Infinity]
- */
- var hbox = zrUtil.curry(boxLayout, 'horizontal');
- /**
- * If x or x2 is not specified or 'center' 'left' 'right',
- * the width would be as long as possible.
- * If y or y2 is not specified or 'middle' 'top' 'bottom',
- * the height would be as long as possible.
- *
- * @param {Object} positionInfo
- * @param {number|string} [positionInfo.x]
- * @param {number|string} [positionInfo.y]
- * @param {number|string} [positionInfo.x2]
- * @param {number|string} [positionInfo.y2]
- * @param {Object} containerRect {width, height}
- * @param {string|number} margin
- * @return {Object} {width, height}
- */
- function getAvailableSize(positionInfo, containerRect, margin) {
- var containerWidth = containerRect.width;
- var containerHeight = containerRect.height;
- var x = parsePercent(positionInfo.x, containerWidth);
- var y = parsePercent(positionInfo.y, containerHeight);
- var x2 = parsePercent(positionInfo.x2, containerWidth);
- var y2 = parsePercent(positionInfo.y2, containerHeight);
- (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0);
- (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth);
- (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0);
- (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight);
- margin = formatUtil.normalizeCssArray(margin || 0);
- return {
- width: Math.max(x2 - x - margin[1] - margin[3], 0),
- height: Math.max(y2 - y - margin[0] - margin[2], 0)
- };
- }
- /**
- * Parse position info.
- *
- * @param {Object} positionInfo
- * @param {number|string} [positionInfo.left]
- * @param {number|string} [positionInfo.top]
- * @param {number|string} [positionInfo.right]
- * @param {number|string} [positionInfo.bottom]
- * @param {number|string} [positionInfo.width]
- * @param {number|string} [positionInfo.height]
- * @param {number|string} [positionInfo.aspect] Aspect is width / height
- * @param {Object} containerRect
- * @param {string|number} [margin]
- *
- * @return {module:zrender/core/BoundingRect}
- */
- function getLayoutRect(positionInfo, containerRect, margin) {
- margin = formatUtil.normalizeCssArray(margin || 0);
- var containerWidth = containerRect.width;
- var containerHeight = containerRect.height;
- var left = parsePercent(positionInfo.left, containerWidth);
- var top = parsePercent(positionInfo.top, containerHeight);
- var right = parsePercent(positionInfo.right, containerWidth);
- var bottom = parsePercent(positionInfo.bottom, containerHeight);
- var width = parsePercent(positionInfo.width, containerWidth);
- var height = parsePercent(positionInfo.height, containerHeight);
- var verticalMargin = margin[2] + margin[0];
- var horizontalMargin = margin[1] + margin[3];
- var aspect = positionInfo.aspect; // If width is not specified, calculate width from left and right
- if (isNaN(width)) {
- width = containerWidth - right - horizontalMargin - left;
- }
- if (isNaN(height)) {
- height = containerHeight - bottom - verticalMargin - top;
- }
- if (aspect != null) {
- // If width and height are not given
- // 1. Graph should not exceeds the container
- // 2. Aspect must be keeped
- // 3. Graph should take the space as more as possible
- // FIXME
- // Margin is not considered, because there is no case that both
- // using margin and aspect so far.
- if (isNaN(width) && isNaN(height)) {
- if (aspect > containerWidth / containerHeight) {
- width = containerWidth * 0.8;
- } else {
- height = containerHeight * 0.8;
- }
- } // Calculate width or height with given aspect
- if (isNaN(width)) {
- width = aspect * height;
- }
- if (isNaN(height)) {
- height = width / aspect;
- }
- } // If left is not specified, calculate left from right and width
- if (isNaN(left)) {
- left = containerWidth - right - width - horizontalMargin;
- }
- if (isNaN(top)) {
- top = containerHeight - bottom - height - verticalMargin;
- } // Align left and top
- switch (positionInfo.left || positionInfo.right) {
- case 'center':
- left = containerWidth / 2 - width / 2 - margin[3];
- break;
- case 'right':
- left = containerWidth - width - horizontalMargin;
- break;
- }
- switch (positionInfo.top || positionInfo.bottom) {
- case 'middle':
- case 'center':
- top = containerHeight / 2 - height / 2 - margin[0];
- break;
- case 'bottom':
- top = containerHeight - height - verticalMargin;
- break;
- } // If something is wrong and left, top, width, height are calculated as NaN
- left = left || 0;
- top = top || 0;
- if (isNaN(width)) {
- // Width may be NaN if only one value is given except width
- width = containerWidth - horizontalMargin - left - (right || 0);
- }
- if (isNaN(height)) {
- // Height may be NaN if only one value is given except height
- height = containerHeight - verticalMargin - top - (bottom || 0);
- }
- var rect = new BoundingRect(left + margin[3], top + margin[0], width, height);
- rect.margin = margin;
- return rect;
- }
- /**
- * Position a zr element in viewport
- * Group position is specified by either
- * {left, top}, {right, bottom}
- * If all properties exists, right and bottom will be igonred.
- *
- * Logic:
- * 1. Scale (against origin point in parent coord)
- * 2. Rotate (against origin point in parent coord)
- * 3. Traslate (with el.position by this method)
- * So this method only fixes the last step 'Traslate', which does not affect
- * scaling and rotating.
- *
- * If be called repeatly with the same input el, the same result will be gotten.
- *
- * @param {module:zrender/Element} el Should have `getBoundingRect` method.
- * @param {Object} positionInfo
- * @param {number|string} [positionInfo.left]
- * @param {number|string} [positionInfo.top]
- * @param {number|string} [positionInfo.right]
- * @param {number|string} [positionInfo.bottom]
- * @param {number|string} [positionInfo.width] Only for opt.boundingModel: 'raw'
- * @param {number|string} [positionInfo.height] Only for opt.boundingModel: 'raw'
- * @param {Object} containerRect
- * @param {string|number} margin
- * @param {Object} [opt]
- * @param {Array.<number>} [opt.hv=[1,1]] Only horizontal or only vertical.
- * @param {Array.<number>} [opt.boundingMode='all']
- * Specify how to calculate boundingRect when locating.
- * 'all': Position the boundingRect that is transformed and uioned
- * both itself and its descendants.
- * This mode simplies confine the elements in the bounding
- * of their container (e.g., using 'right: 0').
- * 'raw': Position the boundingRect that is not transformed and only itself.
- * This mode is useful when you want a element can overflow its
- * container. (Consider a rotated circle needs to be located in a corner.)
- * In this mode positionInfo.width/height can only be number.
- */
- function positionElement(el, positionInfo, containerRect, margin, opt) {
- var h = !opt || !opt.hv || opt.hv[0];
- var v = !opt || !opt.hv || opt.hv[1];
- var boundingMode = opt && opt.boundingMode || 'all';
- if (!h && !v) {
- return;
- }
- var rect;
- if (boundingMode === 'raw') {
- rect = el.type === 'group' ? new BoundingRect(0, 0, +positionInfo.width || 0, +positionInfo.height || 0) : el.getBoundingRect();
- } else {
- rect = el.getBoundingRect();
- if (el.needLocalTransform()) {
- var transform = el.getLocalTransform(); // Notice: raw rect may be inner object of el,
- // which should not be modified.
- rect = rect.clone();
- rect.applyTransform(transform);
- }
- } // The real width and height can not be specified but calculated by the given el.
- positionInfo = getLayoutRect(zrUtil.defaults({
- width: rect.width,
- height: rect.height
- }, positionInfo), containerRect, margin); // Because 'tranlate' is the last step in transform
- // (see zrender/core/Transformable#getLocalTransform),
- // we can just only modify el.position to get final result.
- var elPos = el.position;
- var dx = h ? positionInfo.x - rect.x : 0;
- var dy = v ? positionInfo.y - rect.y : 0;
- el.attr('position', boundingMode === 'raw' ? [dx, dy] : [elPos[0] + dx, elPos[1] + dy]);
- }
- /**
- * @param {Object} option Contains some of the properties in HV_NAMES.
- * @param {number} hvIdx 0: horizontal; 1: vertical.
- */
- function sizeCalculable(option, hvIdx) {
- return option[HV_NAMES[hvIdx][0]] != null || option[HV_NAMES[hvIdx][1]] != null && option[HV_NAMES[hvIdx][2]] != null;
- }
- /**
- * Consider Case:
- * When defulat option has {left: 0, width: 100}, and we set {right: 0}
- * through setOption or media query, using normal zrUtil.merge will cause
- * {right: 0} does not take effect.
- *
- * @example
- * ComponentModel.extend({
- * init: function () {
- * ...
- * var inputPositionParams = layout.getLayoutParams(option);
- * this.mergeOption(inputPositionParams);
- * },
- * mergeOption: function (newOption) {
- * newOption && zrUtil.merge(thisOption, newOption, true);
- * layout.mergeLayoutParam(thisOption, newOption);
- * }
- * });
- *
- * @param {Object} targetOption
- * @param {Object} newOption
- * @param {Object|string} [opt]
- * @param {boolean|Array.<boolean>} [opt.ignoreSize=false] Used for the components
- * that width (or height) should not be calculated by left and right (or top and bottom).
- */
- function mergeLayoutParam(targetOption, newOption, opt) {
- !zrUtil.isObject(opt) && (opt = {});
- var ignoreSize = opt.ignoreSize;
- !zrUtil.isArray(ignoreSize) && (ignoreSize = [ignoreSize, ignoreSize]);
- var hResult = merge(HV_NAMES[0], 0);
- var vResult = merge(HV_NAMES[1], 1);
- copy(HV_NAMES[0], targetOption, hResult);
- copy(HV_NAMES[1], targetOption, vResult);
- function merge(names, hvIdx) {
- var newParams = {};
- var newValueCount = 0;
- var merged = {};
- var mergedValueCount = 0;
- var enoughParamNumber = 2;
- each(names, function (name) {
- merged[name] = targetOption[name];
- });
- each(names, function (name) {
- // Consider case: newOption.width is null, which is
- // set by user for removing width setting.
- hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]);
- hasValue(newParams, name) && newValueCount++;
- hasValue(merged, name) && mergedValueCount++;
- });
- if (ignoreSize[hvIdx]) {
- // Only one of left/right is premitted to exist.
- if (hasValue(newOption, names[1])) {
- merged[names[2]] = null;
- } else if (hasValue(newOption, names[2])) {
- merged[names[1]] = null;
- }
- return merged;
- } // Case: newOption: {width: ..., right: ...},
- // or targetOption: {right: ...} and newOption: {width: ...},
- // There is no conflict when merged only has params count
- // little than enoughParamNumber.
- if (mergedValueCount === enoughParamNumber || !newValueCount) {
- return merged;
- } // Case: newOption: {width: ..., right: ...},
- // Than we can make sure user only want those two, and ignore
- // all origin params in targetOption.
- else if (newValueCount >= enoughParamNumber) {
- return newParams;
- } else {
- // Chose another param from targetOption by priority.
- for (var i = 0; i < names.length; i++) {
- var name = names[i];
- if (!hasProp(newParams, name) && hasProp(targetOption, name)) {
- newParams[name] = targetOption[name];
- break;
- }
- }
- return newParams;
- }
- }
- function hasProp(obj, name) {
- return obj.hasOwnProperty(name);
- }
- function hasValue(obj, name) {
- return obj[name] != null && obj[name] !== 'auto';
- }
- function copy(names, target, source) {
- each(names, function (name) {
- target[name] = source[name];
- });
- }
- }
- /**
- * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
- * @param {Object} source
- * @return {Object} Result contains those props.
- */
- function getLayoutParams(source) {
- return copyLayoutParams({}, source);
- }
- /**
- * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
- * @param {Object} source
- * @return {Object} Result contains those props.
- */
- function copyLayoutParams(target, source) {
- source && target && each(LOCATION_PARAMS, function (name) {
- source.hasOwnProperty(name) && (target[name] = source[name]);
- });
- return target;
- }
- exports.LOCATION_PARAMS = LOCATION_PARAMS;
- exports.HV_NAMES = HV_NAMES;
- exports.box = box;
- exports.vbox = vbox;
- exports.hbox = hbox;
- exports.getAvailableSize = getAvailableSize;
- exports.getLayoutRect = getLayoutRect;
- exports.positionElement = positionElement;
- exports.sizeCalculable = sizeCalculable;
- exports.mergeLayoutParam = mergeLayoutParam;
- exports.getLayoutParams = getLayoutParams;
- exports.copyLayoutParams = copyLayoutParams;
- /***/
- }),
- /* 48 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- // PENDING
- // Use topological sort ?
- /**
- * Node of graph based post processing.
- *
- * @constructor clay.compositor.CompositorNode
- * @extends clay.core.Base
- *
- */
- var CompositorNode = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () {
- return /** @lends clay.compositor.CompositorNode# */ {
- /**
- * @type {string}
- */
- name: '',
- /**
- * Input links, will be updated by the graph
- * @example:
- * inputName: {
- * node: someNode,
- * pin: 'xxxx'
- * }
- * @type {Object}
- */
- inputLinks: {},
- /**
- * Output links, will be updated by the graph
- * @example:
- * outputName: {
- * node: someNode,
- * pin: 'xxxx'
- * }
- * @type {Object}
- */
- outputLinks: {},
- // Save the output texture of previous frame
- // Will be used when there exist a circular reference
- _prevOutputTextures: {},
- _outputTextures: {},
- // Example: { name: 2 }
- _outputReferences: {},
- _rendering: false,
- // If rendered in this frame
- _rendered: false,
- _compositor: null
- };
- },
- /** @lends clay.compositor.CompositorNode.prototype */
- {
- // TODO Remove parameter function callback
- updateParameter: function (outputName, renderer) {
- var outputInfo = this.outputs[outputName];
- var parameters = outputInfo.parameters;
- var parametersCopy = outputInfo._parametersCopy;
- if (!parametersCopy) {
- parametersCopy = outputInfo._parametersCopy = {};
- }
- if (parameters) {
- for (var key in parameters) {
- if (key !== 'width' && key !== 'height') {
- parametersCopy[key] = parameters[key];
- }
- }
- }
- var width, height;
- if (parameters.width instanceof Function) {
- width = parameters.width.call(this, renderer);
- }
- else {
- width = parameters.width;
- }
- if (parameters.height instanceof Function) {
- height = parameters.height.call(this, renderer);
- }
- else {
- height = parameters.height;
- }
- if (
- parametersCopy.width !== width
- || parametersCopy.height !== height
- ) {
- if (this._outputTextures[outputName]) {
- this._outputTextures[outputName].dispose(renderer.gl);
- }
- }
- parametersCopy.width = width;
- parametersCopy.height = height;
- return parametersCopy;
- },
- /**
- * Set parameter
- * @param {string} name
- * @param {} value
- */
- setParameter: function (name, value) { },
- /**
- * Get parameter value
- * @param {string} name
- * @return {}
- */
- getParameter: function (name) { },
- /**
- * Set parameters
- * @param {Object} obj
- */
- setParameters: function (obj) {
- for (var name in obj) {
- this.setParameter(name, obj[name]);
- }
- },
- render: function () { },
- getOutput: function (renderer /*optional*/, name) {
- if (name == null) {
- // Return the output texture without rendering
- name = renderer;
- return this._outputTextures[name];
- }
- var outputInfo = this.outputs[name];
- if (!outputInfo) {
- return;
- }
- // Already been rendered in this frame
- if (this._rendered) {
- // Force return texture in last frame
- if (outputInfo.outputLastFrame) {
- return this._prevOutputTextures[name];
- }
- else {
- return this._outputTextures[name];
- }
- }
- else if (
- // TODO
- this._rendering // Solve Circular Reference
- ) {
- if (!this._prevOutputTextures[name]) {
- // Create a blank texture at first pass
- this._prevOutputTextures[name] = this._compositor.allocateTexture(outputInfo.parameters || {});
- }
- return this._prevOutputTextures[name];
- }
- this.render(renderer);
- return this._outputTextures[name];
- },
- removeReference: function (outputName) {
- this._outputReferences[outputName]--;
- if (this._outputReferences[outputName] === 0) {
- var outputInfo = this.outputs[outputName];
- if (outputInfo.keepLastFrame) {
- if (this._prevOutputTextures[outputName]) {
- this._compositor.releaseTexture(this._prevOutputTextures[outputName]);
- }
- this._prevOutputTextures[outputName] = this._outputTextures[outputName];
- }
- else {
- // Output of this node have alreay been used by all other nodes
- // Put the texture back to the pool.
- this._compositor.releaseTexture(this._outputTextures[outputName]);
- }
- }
- },
- link: function (inputPinName, fromNode, fromPinName) {
- // The relationship from output pin to input pin is one-on-multiple
- this.inputLinks[inputPinName] = {
- node: fromNode,
- pin: fromPinName
- };
- if (!fromNode.outputLinks[fromPinName]) {
- fromNode.outputLinks[fromPinName] = [];
- }
- fromNode.outputLinks[fromPinName].push({
- node: this,
- pin: inputPinName
- });
- // Enabled the pin texture in shader
- this.pass.material.enableTexture(inputPinName);
- },
- clear: function () {
- this.inputLinks = {};
- this.outputLinks = {};
- },
- updateReference: function (outputName) {
- if (!this._rendering) {
- this._rendering = true;
- for (var inputName in this.inputLinks) {
- var link = this.inputLinks[inputName];
- link.node.updateReference(link.pin);
- }
- this._rendering = false;
- }
- if (outputName) {
- this._outputReferences[outputName]++;
- }
- },
- beforeFrame: function () {
- this._rendered = false;
- for (var name in this.outputLinks) {
- this._outputReferences[name] = 0;
- }
- },
- afterFrame: function () {
- // Put back all the textures to pool
- for (var name in this.outputLinks) {
- if (this._outputReferences[name] > 0) {
- var outputInfo = this.outputs[name];
- if (outputInfo.keepLastFrame) {
- if (this._prevOutputTextures[name]) {
- this._compositor.releaseTexture(this._prevOutputTextures[name]);
- }
- this._prevOutputTextures[name] = this._outputTextures[name];
- }
- else {
- this._compositor.releaseTexture(this._outputTextures[name]);
- }
- }
- }
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (CompositorNode);
- /***/
- }),
- /* 49 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- // Generate halton sequence
- // https://en.wikipedia.org/wiki/Halton_sequence
- function halton(index, base) {
- var result = 0;
- var f = 1 / base;
- var i = index;
- while (i > 0) {
- result = result + f * (i % base);
- i = Math.floor(i / base);
- f = f / base;
- }
- return result;
- }
- /* harmony default export */ __webpack_exports__["a"] = (halton);
- /***/
- }),
- /* 50 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony default export */ __webpack_exports__["a"] = (function (seriesModel, dims, source) {
- source = source || seriesModel.getSource();
- var coordSysDimensions = dims || __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.getCoordinateSystemDimensions(seriesModel.get('coordinateSystem')) || ['x', 'y', 'z'];
- var dimensions = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.createDimensions(source, {
- dimensionsDefine: source.dimensionsDefine || seriesModel.get('dimensions'),
- encodeDefine: source.encodeDefine || seriesModel.get('encode'),
- coordDimensions: coordSysDimensions.map(function (dim) {
- var axis3DModel = seriesModel.getReferringComponents(dim + 'Axis3D')[0];
- return {
- type: (axis3DModel && axis3DModel.get('type') === 'category') ? 'ordinal' : 'float',
- name: dim
- // Find stackable dimension. Which will represent value.
- // stackable: dim === 'z'
- };
- })
- });
- if (seriesModel.get('coordinateSystem') === 'cartesian3D') {
- dimensions.forEach(function (dimInfo) {
- if (coordSysDimensions.indexOf(dimInfo.coordDim) >= 0) {
- var axis3DModel = seriesModel.getReferringComponents(dimInfo.coordDim + 'Axis3D')[0];
- if (axis3DModel && axis3DModel.get('type') === 'category') {
- dimInfo.ordinalMeta = axis3DModel.getOrdinalMeta();
- }
- }
- });
- }
- var stackCalculationInfo = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.dataStack.enableDataStack(
- // Only support 'z' and `byIndex` now.
- seriesModel, dimensions, { byIndex: true, stackedCoordDimension: 'z' }
- );
- var data = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.List(dimensions, seriesModel);
- data.setCalculationInfo(stackCalculationInfo);
- data.initData(source);
- return data;
- });
- /***/
- }),
- /* 51 */
- /***/ (function (module, exports) {
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- function _default(seriesType, defaultSymbolType, legendSymbol) {
- // Encoding visual for all series include which is filtered for legend drawing
- return {
- seriesType: seriesType,
- // For legend.
- performRawSeries: true,
- reset: function (seriesModel, ecModel, api) {
- var data = seriesModel.getData();
- var symbolType = seriesModel.get('symbol') || defaultSymbolType;
- var symbolSize = seriesModel.get('symbolSize');
- var keepAspect = seriesModel.get('symbolKeepAspect');
- data.setVisual({
- legendSymbol: legendSymbol || symbolType,
- symbol: symbolType,
- symbolSize: symbolSize,
- symbolKeepAspect: keepAspect
- }); // Only visible series has each data be visual encoded
- if (ecModel.isSeriesFiltered(seriesModel)) {
- return;
- }
- var hasCallback = typeof symbolSize === 'function';
- function dataEach(data, idx) {
- if (typeof symbolSize === 'function') {
- var rawValue = seriesModel.getRawValue(idx); // FIXME
- var params = seriesModel.getDataParams(idx);
- data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params));
- }
- if (data.hasItemOption) {
- var itemModel = data.getItemModel(idx);
- var itemSymbolType = itemModel.getShallow('symbol', true);
- var itemSymbolSize = itemModel.getShallow('symbolSize', true);
- var itemSymbolKeepAspect = itemModel.getShallow('symbolKeepAspect', true); // If has item symbol
- if (itemSymbolType != null) {
- data.setItemVisual(idx, 'symbol', itemSymbolType);
- }
- if (itemSymbolSize != null) {
- // PENDING Transform symbolSize ?
- data.setItemVisual(idx, 'symbolSize', itemSymbolSize);
- }
- if (itemSymbolKeepAspect != null) {
- data.setItemVisual(idx, 'symbolKeepAspect', itemSymbolKeepAspect);
- }
- }
- }
- return {
- dataEach: data.hasItemOption || hasCallback ? dataEach : null
- };
- }
- };
- }
- module.exports = _default;
- /***/
- }),
- /* 52 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_GLInfo__ = __webpack_require__(111);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_glenum__ = __webpack_require__(11);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_vendor__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Material__ = __webpack_require__(19);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math_Vector2__ = __webpack_require__(26);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__gpu_ProgramManager__ = __webpack_require__(115);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__shader_source_prez_glsl_js__ = __webpack_require__(71);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__ = __webpack_require__(21);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__glmatrix_vec3__ = __webpack_require__(12);
- // TODO Resources like shader, texture, geometry reference management
- // Trace and find out which shader, texture, geometry can be destroyed
- // Light header
- __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_8__shader_source_prez_glsl_js__["a" /* default */]);
- var mat4Create = __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].create;
- var errorShader = {};
- function defaultGetMaterial(renderable) {
- return renderable.material;
- }
- function defaultGetUniform(renderable, material, symbol) {
- return material.uniforms[symbol].value;
- }
- function defaultIsMaterialChanged(renderabled, prevRenderable, material, prevMaterial) {
- return material !== prevMaterial;
- }
- function defaultIfRender(renderable) {
- return true;
- }
- function noop() { }
- var attributeBufferTypeMap = {
- float: __WEBPACK_IMPORTED_MODULE_2__core_glenum__["a" /* default */].FLOAT,
- byte: __WEBPACK_IMPORTED_MODULE_2__core_glenum__["a" /* default */].BYTE,
- ubyte: __WEBPACK_IMPORTED_MODULE_2__core_glenum__["a" /* default */].UNSIGNED_BYTE,
- short: __WEBPACK_IMPORTED_MODULE_2__core_glenum__["a" /* default */].SHORT,
- ushort: __WEBPACK_IMPORTED_MODULE_2__core_glenum__["a" /* default */].UNSIGNED_SHORT
- };
- function VertexArrayObject(availableAttributes, availableAttributeSymbols, indicesBuffer) {
- this.availableAttributes = availableAttributes;
- this.availableAttributeSymbols = availableAttributeSymbols;
- this.indicesBuffer = indicesBuffer;
- this.vao = null;
- }
- function PlaceHolderTexture(renderer) {
- var blankCanvas;
- var webglTexture;
- this.bind = function (renderer) {
- if (!blankCanvas) {
- // TODO Environment not support createCanvas.
- blankCanvas = __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].createCanvas();
- blankCanvas.width = blankCanvas.height = 1;
- blankCanvas.getContext('2d');
- }
- var gl = renderer.gl;
- var firstBind = !webglTexture;
- if (firstBind) {
- webglTexture = gl.createTexture();
- }
- gl.bindTexture(gl.TEXTURE_2D, webglTexture);
- if (firstBind) {
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, blankCanvas);
- }
- };
- this.unbind = function (renderer) {
- renderer.gl.bindTexture(renderer.gl.TEXTURE_2D, null);
- };
- this.isRenderable = function () {
- return true;
- };
- }
- /**
- * @constructor clay.Renderer
- * @extends clay.core.Base
- */
- var Renderer = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () {
- return /** @lends clay.Renderer# */ {
- /**
- * @type {HTMLCanvasElement}
- * @readonly
- */
- canvas: null,
- /**
- * Canvas width, set by resize method
- * @type {number}
- * @private
- */
- _width: 100,
- /**
- * Canvas width, set by resize method
- * @type {number}
- * @private
- */
- _height: 100,
- /**
- * Device pixel ratio, set by setDevicePixelRatio method
- * Specially for high defination display
- * @see http://www.khronos.org/webgl/wiki/HandlingHighDPI
- * @type {number}
- * @private
- */
- devicePixelRatio: (typeof window !== 'undefined' && window.devicePixelRatio) || 1.0,
- /**
- * Clear color
- * @type {number[]}
- */
- clearColor: [0.0, 0.0, 0.0, 0.0],
- /**
- * Default:
- * _gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT | _gl.STENCIL_BUFFER_BIT
- * @type {number}
- */
- clearBit: 17664,
- // Settings when getting context
- // http://www.khronos.org/registry/webgl/specs/latest/#2.4
- /**
- * If enable alpha, default true
- * @type {boolean}
- */
- alpha: true,
- /**
- * If enable depth buffer, default true
- * @type {boolean}
- */
- depth: true,
- /**
- * If enable stencil buffer, default false
- * @type {boolean}
- */
- stencil: false,
- /**
- * If enable antialias, default true
- * @type {boolean}
- */
- antialias: true,
- /**
- * If enable premultiplied alpha, default true
- * @type {boolean}
- */
- premultipliedAlpha: true,
- /**
- * If preserve drawing buffer, default false
- * @type {boolean}
- */
- preserveDrawingBuffer: false,
- /**
- * If throw context error, usually turned on in debug mode
- * @type {boolean}
- */
- throwError: true,
- /**
- * WebGL Context created from given canvas
- * @type {WebGLRenderingContext}
- */
- gl: null,
- /**
- * Renderer viewport, read-only, can be set by setViewport method
- * @type {Object}
- */
- viewport: {},
- // Set by FrameBuffer#bind
- __currentFrameBuffer: null,
- _viewportStack: [],
- _clearStack: [],
- _sceneRendering: null
- };
- }, function () {
- if (!this.canvas) {
- this.canvas = __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].createCanvas();
- }
- var canvas = this.canvas;
- try {
- var opts = {
- alpha: this.alpha,
- depth: this.depth,
- stencil: this.stencil,
- antialias: this.antialias,
- premultipliedAlpha: this.premultipliedAlpha,
- preserveDrawingBuffer: this.preserveDrawingBuffer
- };
- this.gl = canvas.getContext('webgl', opts)
- || canvas.getContext('experimental-webgl', opts);
- if (!this.gl) {
- throw new Error();
- }
- this._glinfo = new __WEBPACK_IMPORTED_MODULE_1__core_GLInfo__["a" /* default */](this.gl);
- if (this.gl.targetRenderer) {
- console.error('Already created a renderer');
- }
- this.gl.targetRenderer = this;
- this.resize();
- }
- catch (e) {
- throw 'Error creating WebGL Context ' + e;
- }
- // Init managers
- this._programMgr = new __WEBPACK_IMPORTED_MODULE_6__gpu_ProgramManager__["a" /* default */](this);
- this._placeholderTexture = new PlaceHolderTexture(this);
- },
- /** @lends clay.Renderer.prototype. **/
- {
- /**
- * Resize the canvas
- * @param {number} width
- * @param {number} height
- */
- resize: function (width, height) {
- var canvas = this.canvas;
- // http://www.khronos.org/webgl/wiki/HandlingHighDPI
- // set the display size of the canvas.
- var dpr = this.devicePixelRatio;
- if (width != null) {
- canvas.style.width = width + 'px';
- canvas.style.height = height + 'px';
- // set the size of the drawingBuffer
- canvas.width = width * dpr;
- canvas.height = height * dpr;
- this._width = width;
- this._height = height;
- }
- else {
- this._width = canvas.width / dpr;
- this._height = canvas.height / dpr;
- }
- this.setViewport(0, 0, this._width, this._height);
- },
- /**
- * Get renderer width
- * @return {number}
- */
- getWidth: function () {
- return this._width;
- },
- /**
- * Get renderer height
- * @return {number}
- */
- getHeight: function () {
- return this._height;
- },
- /**
- * Get viewport aspect,
- * @return {number}
- */
- getViewportAspect: function () {
- var viewport = this.viewport;
- return viewport.width / viewport.height;
- },
- /**
- * Set devicePixelRatio
- * @param {number} devicePixelRatio
- */
- setDevicePixelRatio: function (devicePixelRatio) {
- this.devicePixelRatio = devicePixelRatio;
- this.resize(this._width, this._height);
- },
- /**
- * Get devicePixelRatio
- * @param {number} devicePixelRatio
- */
- getDevicePixelRatio: function () {
- return this.devicePixelRatio;
- },
- /**
- * Get WebGL extension
- * @param {string} name
- * @return {object}
- */
- getGLExtension: function (name) {
- return this._glinfo.getExtension(name);
- },
- /**
- * Get WebGL parameter
- * @param {string} name
- * @return {*}
- */
- getGLParameter: function (name) {
- return this._glinfo.getParameter(name);
- },
- /**
- * Set rendering viewport
- * @param {number|Object} x
- * @param {number} [y]
- * @param {number} [width]
- * @param {number} [height]
- * @param {number} [devicePixelRatio]
- * Defaultly use the renderere devicePixelRatio
- * It needs to be 1 when setViewport is called by frameBuffer
- *
- * @example
- * setViewport(0,0,width,height,1)
- * setViewport({
- * x: 0,
- * y: 0,
- * width: width,
- * height: height,
- * devicePixelRatio: 1
- * })
- */
- setViewport: function (x, y, width, height, dpr) {
- if (typeof x === 'object') {
- var obj = x;
- x = obj.x;
- y = obj.y;
- width = obj.width;
- height = obj.height;
- dpr = obj.devicePixelRatio;
- }
- dpr = dpr || this.devicePixelRatio;
- this.gl.viewport(
- x * dpr, y * dpr, width * dpr, height * dpr
- );
- // Use a fresh new object, not write property.
- this.viewport = {
- x: x,
- y: y,
- width: width,
- height: height,
- devicePixelRatio: dpr
- };
- },
- /**
- * Push current viewport into a stack
- */
- saveViewport: function () {
- this._viewportStack.push(this.viewport);
- },
- /**
- * Pop viewport from stack, restore in the renderer
- */
- restoreViewport: function () {
- if (this._viewportStack.length > 0) {
- this.setViewport(this._viewportStack.pop());
- }
- },
- /**
- * Push current clear into a stack
- */
- saveClear: function () {
- this._clearStack.push({
- clearBit: this.clearBit,
- clearColor: this.clearColor
- });
- },
- /**
- * Pop clear from stack, restore in the renderer
- */
- restoreClear: function () {
- if (this._clearStack.length > 0) {
- var opt = this._clearStack.pop();
- this.clearColor = opt.clearColor;
- this.clearBit = opt.clearBit;
- }
- },
- bindSceneRendering: function (scene) {
- this._sceneRendering = scene;
- },
- /**
- * Render the scene in camera to the screen or binded offline framebuffer
- * @param {clay.Scene} scene
- * @param {clay.Camera} camera
- * @param {boolean} [notUpdateScene] If not call the scene.update methods in the rendering, default true
- * @param {boolean} [preZ] If use preZ optimization, default false
- * @return {IRenderInfo}
- */
- render: function (scene, camera, notUpdateScene, preZ) {
- var _gl = this.gl;
- var clearColor = this.clearColor;
- if (this.clearBit) {
- // Must set depth and color mask true before clear
- _gl.colorMask(true, true, true, true);
- _gl.depthMask(true);
- var viewport = this.viewport;
- var needsScissor = false;
- var viewportDpr = viewport.devicePixelRatio;
- if (viewport.width !== this._width || viewport.height !== this._height
- || (viewportDpr && viewportDpr !== this.devicePixelRatio)
- || viewport.x || viewport.y
- ) {
- needsScissor = true;
- // http://stackoverflow.com/questions/11544608/how-to-clear-a-rectangle-area-in-webgl
- // Only clear the viewport
- _gl.enable(_gl.SCISSOR_TEST);
- _gl.scissor(viewport.x * viewportDpr, viewport.y * viewportDpr, viewport.width * viewportDpr, viewport.height * viewportDpr);
- }
- _gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
- _gl.clear(this.clearBit);
- if (needsScissor) {
- _gl.disable(_gl.SCISSOR_TEST);
- }
- }
- // If the scene have been updated in the prepass like shadow map
- // There is no need to update it again
- if (!notUpdateScene) {
- scene.update(false);
- }
- scene.updateLights();
- camera = camera || scene.getMainCamera();
- if (!camera) {
- console.error('Can\'t find camera in the scene.');
- return;
- }
- camera.update();
- var renderList = scene.updateRenderList(camera, true);
- this._sceneRendering = scene;
- var opaqueList = renderList.opaque;
- var transparentList = renderList.transparent;
- var sceneMaterial = scene.material;
- scene.trigger('beforerender', this, scene, camera, renderList);
- // Render pre z
- if (preZ) {
- this.renderPreZ(opaqueList, scene, camera);
- _gl.depthFunc(_gl.LEQUAL);
- }
- else {
- _gl.depthFunc(_gl.LESS);
- }
- // Update the depth of transparent list.
- var worldViewMat = mat4Create();
- var posViewSpace = __WEBPACK_IMPORTED_MODULE_10__glmatrix_vec3__["a" /* default */].create();
- for (var i = 0; i < transparentList.length; i++) {
- var renderable = transparentList[i];
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].multiplyAffine(worldViewMat, camera.viewMatrix.array, renderable.worldTransform.array);
- __WEBPACK_IMPORTED_MODULE_10__glmatrix_vec3__["a" /* default */].transformMat4(posViewSpace, renderable.position.array, worldViewMat);
- renderable.__depth = posViewSpace[2];
- }
- // Render opaque list
- this.renderPass(opaqueList, camera, {
- getMaterial: function (renderable) {
- return sceneMaterial || renderable.material;
- },
- sortCompare: this.opaqueSortCompare
- });
- this.renderPass(transparentList, camera, {
- getMaterial: function (renderable) {
- return sceneMaterial || renderable.material;
- },
- sortCompare: this.transparentSortCompare
- });
- scene.trigger('afterrender', this, scene, camera, renderList);
- // Cleanup
- this._sceneRendering = null;
- },
- getProgram: function (renderable, renderMaterial, scene) {
- renderMaterial = renderMaterial || renderable.material;
- return this._programMgr.getProgram(renderable, renderMaterial, scene);
- },
- validateProgram: function (program) {
- if (program.__error) {
- var errorMsg = program.__error;
- if (errorShader[program.__uid__]) {
- return;
- }
- errorShader[program.__uid__] = true;
- if (this.throwError) {
- throw new Error(errorMsg);
- }
- else {
- this.trigger('error', errorMsg);
- }
- }
- },
- updatePrograms: function (list, scene, passConfig) {
- var getMaterial = (passConfig && passConfig.getMaterial) || defaultGetMaterial;
- scene = scene || null;
- for (var i = 0; i < list.length; i++) {
- var renderable = list[i];
- var renderMaterial = getMaterial.call(this, renderable);
- if (i > 0) {
- var prevRenderable = list[i - 1];
- var prevJointsLen = prevRenderable.joints ? prevRenderable.joints.length : 0;
- var jointsLen = renderable.joints ? renderable.joints.length : 0;
- // Keep program not change if joints, material, lightGroup are same of two renderables.
- if (jointsLen === prevJointsLen
- && renderable.material === prevRenderable.material
- && renderable.lightGroup === prevRenderable.lightGroup
- ) {
- renderable.__program = prevRenderable.__program;
- continue;
- }
- }
- var program = this._programMgr.getProgram(renderable, renderMaterial, scene);
- this.validateProgram(program);
- renderable.__program = program;
- }
- },
- /**
- * Render a single renderable list in camera in sequence
- * @param {clay.Renderable[]} list List of all renderables.
- * @param {clay.Camera} [camera] Camera provide view matrix and porjection matrix. It can be null.
- * @param {Object} [passConfig]
- * @param {Function} [passConfig.getMaterial] Get renderable material.
- * @param {Function} [passConfig.getUniform] Get material uniform value.
- * @param {Function} [passConfig.isMaterialChanged] If material changed.
- * @param {Function} [passConfig.beforeRender] Before render each renderable.
- * @param {Function} [passConfig.afterRender] After render each renderable
- * @param {Function} [passConfig.ifRender] If render the renderable.
- * @param {Function} [passConfig.sortCompare] Sort compare function.
- * @return {IRenderInfo}
- */
- renderPass: function (list, camera, passConfig) {
- this.trigger('beforerenderpass', this, list, camera, passConfig);
- passConfig = passConfig || {};
- passConfig.getMaterial = passConfig.getMaterial || defaultGetMaterial;
- passConfig.getUniform = passConfig.getUniform || defaultGetUniform;
- // PENDING Better solution?
- passConfig.isMaterialChanged = passConfig.isMaterialChanged || defaultIsMaterialChanged;
- passConfig.beforeRender = passConfig.beforeRender || noop;
- passConfig.afterRender = passConfig.afterRender || noop;
- var ifRenderObject = passConfig.ifRender || defaultIfRender;
- this.updatePrograms(list, this._sceneRendering, passConfig);
- if (passConfig.sortCompare) {
- list.sort(passConfig.sortCompare);
- }
- // Some common builtin uniforms
- var viewport = this.viewport;
- var vDpr = viewport.devicePixelRatio;
- var viewportUniform = [
- viewport.x * vDpr, viewport.y * vDpr,
- viewport.width * vDpr, viewport.height * vDpr
- ];
- var windowDpr = this.devicePixelRatio;
- var windowSizeUniform = this.__currentFrameBuffer
- ? [this.__currentFrameBuffer.getTextureWidth(), this.__currentFrameBuffer.getTextureHeight()]
- : [this._width * windowDpr, this._height * windowDpr];
- // DEPRECATED
- var viewportSizeUniform = [
- viewportUniform[2], viewportUniform[3]
- ];
- var time = Date.now();
- // Calculate view and projection matrix
- if (camera) {
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].copy(matrices.VIEW, camera.viewMatrix.array);
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].copy(matrices.PROJECTION, camera.projectionMatrix.array);
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].copy(matrices.VIEWINVERSE, camera.worldTransform.array);
- }
- else {
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].identity(matrices.VIEW);
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].identity(matrices.PROJECTION);
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].identity(matrices.VIEWINVERSE);
- }
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].multiply(matrices.VIEWPROJECTION, matrices.PROJECTION, matrices.VIEW);
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].invert(matrices.PROJECTIONINVERSE, matrices.PROJECTION);
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].invert(matrices.VIEWPROJECTIONINVERSE, matrices.VIEWPROJECTION);
- var _gl = this.gl;
- var scene = this._sceneRendering;
- var prevMaterial;
- var prevProgram;
- var prevRenderable;
- // Status
- var depthTest, depthMask;
- var culling, cullFace, frontFace;
- var transparent;
- var drawID;
- var currentVAO;
- var materialTakesTextureSlot;
- var vaoExt = this.getGLExtension('OES_vertex_array_object');
- for (var i = 0; i < list.length; i++) {
- var renderable = list[i];
- var isSceneNode = renderable.worldTransform != null;
- var worldM;
- if (!ifRenderObject(renderable)) {
- continue;
- }
- // Skinned mesh will transformed to joint space. Ignore the mesh transform
- if (isSceneNode) {
- worldM = (renderable.isSkinnedMesh && renderable.isSkinnedMesh())
- ? matrices.IDENTITY : renderable.worldTransform.array;
- }
- var geometry = renderable.geometry;
- var material = passConfig.getMaterial.call(this, renderable);
- var program = renderable.__program;
- var shader = material.shader;
- var currentDrawID = geometry.__uid__ + '-' + program.__uid__;
- var drawIDChanged = currentDrawID !== drawID;
- drawID = currentDrawID;
- if (drawIDChanged && vaoExt) {
- // TODO Seems need to be bound to null immediately (or before bind another program?) if vao is changed
- vaoExt.bindVertexArrayOES(null);
- }
- if (isSceneNode) {
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].copy(matrices.WORLD, worldM);
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].multiply(matrices.WORLDVIEWPROJECTION, matrices.VIEWPROJECTION, worldM);
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].multiplyAffine(matrices.WORLDVIEW, matrices.VIEW, worldM);
- if (shader.matrixSemantics.WORLDINVERSE ||
- shader.matrixSemantics.WORLDINVERSETRANSPOSE) {
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].invert(matrices.WORLDINVERSE, worldM);
- }
- if (shader.matrixSemantics.WORLDVIEWINVERSE ||
- shader.matrixSemantics.WORLDVIEWINVERSETRANSPOSE) {
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].invert(matrices.WORLDVIEWINVERSE, matrices.WORLDVIEW);
- }
- if (shader.matrixSemantics.WORLDVIEWPROJECTIONINVERSE ||
- shader.matrixSemantics.WORLDVIEWPROJECTIONINVERSETRANSPOSE) {
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].invert(matrices.WORLDVIEWPROJECTIONINVERSE, matrices.WORLDVIEWPROJECTION);
- }
- }
- // Before render hook
- renderable.beforeRender && renderable.beforeRender(this);
- passConfig.beforeRender.call(this, renderable, material, prevMaterial);
- var programChanged = program !== prevProgram;
- if (programChanged) {
- // Set lights number
- program.bind(this);
- // Set some common uniforms
- program.setUniformOfSemantic(_gl, 'VIEWPORT', viewportUniform);
- program.setUniformOfSemantic(_gl, 'WINDOW_SIZE', windowSizeUniform);
- if (camera) {
- program.setUniformOfSemantic(_gl, 'NEAR', camera.near);
- program.setUniformOfSemantic(_gl, 'FAR', camera.far);
- }
- program.setUniformOfSemantic(_gl, 'DEVICEPIXELRATIO', vDpr);
- program.setUniformOfSemantic(_gl, 'TIME', time);
- // DEPRECATED
- program.setUniformOfSemantic(_gl, 'VIEWPORT_SIZE', viewportSizeUniform);
- // Set lights uniforms
- // TODO needs optimized
- if (scene) {
- scene.setLightUniforms(program, renderable.lightGroup, this);
- }
- }
- else {
- program = prevProgram;
- }
- // Program changes also needs reset the materials.
- if (programChanged || passConfig.isMaterialChanged(
- renderable, prevRenderable, material, prevMaterial
- )) {
- if (material.depthTest !== depthTest) {
- material.depthTest ? _gl.enable(_gl.DEPTH_TEST) : _gl.disable(_gl.DEPTH_TEST);
- depthTest = material.depthTest;
- }
- if (material.depthMask !== depthMask) {
- _gl.depthMask(material.depthMask);
- depthMask = material.depthMask;
- }
- if (material.transparent !== transparent) {
- material.transparent ? _gl.enable(_gl.BLEND) : _gl.disable(_gl.BLEND);
- transparent = material.transparent;
- }
- // TODO cache blending
- if (material.transparent) {
- if (material.blend) {
- material.blend(_gl);
- }
- else {
- // Default blend function
- _gl.blendEquationSeparate(_gl.FUNC_ADD, _gl.FUNC_ADD);
- _gl.blendFuncSeparate(_gl.SRC_ALPHA, _gl.ONE_MINUS_SRC_ALPHA, _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA);
- }
- }
- materialTakesTextureSlot = this._bindMaterial(
- renderable, material, program,
- prevRenderable || null, prevMaterial || null, prevProgram || null,
- passConfig.getUniform
- );
- prevMaterial = material;
- }
- var matrixSemanticKeys = shader.matrixSemanticKeys;
- if (isSceneNode) {
- for (var k = 0; k < matrixSemanticKeys.length; k++) {
- var semantic = matrixSemanticKeys[k];
- var semanticInfo = shader.matrixSemantics[semantic];
- var matrix = matrices[semantic];
- if (semanticInfo.isTranspose) {
- var matrixNoTranspose = matrices[semanticInfo.semanticNoTranspose];
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_mat4__["a" /* default */].transpose(matrix, matrixNoTranspose);
- }
- program.setUniform(_gl, semanticInfo.type, semanticInfo.symbol, matrix);
- }
- }
- if (renderable.cullFace !== cullFace) {
- cullFace = renderable.cullFace;
- _gl.cullFace(cullFace);
- }
- if (renderable.frontFace !== frontFace) {
- frontFace = renderable.frontFace;
- _gl.frontFace(frontFace);
- }
- if (renderable.culling !== culling) {
- culling = renderable.culling;
- culling ? _gl.enable(_gl.CULL_FACE) : _gl.disable(_gl.CULL_FACE);
- }
- // TODO Not update skeleton in each renderable.
- this._updateSkeleton(renderable, program, materialTakesTextureSlot);
- if (drawIDChanged) {
- currentVAO = this._bindVAO(vaoExt, shader, geometry, program);
- }
- this._renderObject(renderable, currentVAO);
- // After render hook
- passConfig.afterRender(this, renderable);
- renderable.afterRender && renderable.afterRender(this);
- prevProgram = program;
- prevRenderable = renderable;
- }
- // TODO Seems need to be bound to null immediately if vao is changed?
- if (vaoExt) {
- vaoExt.bindVertexArrayOES(null);
- }
- this.trigger('afterrenderpass', this, list, camera, passConfig);
- },
- getMaxJointNumber: function () {
- return this._glinfo.getMaxJointNumber();
- },
- _updateSkeleton: function (object, program, slot) {
- var _gl = this.gl;
- var skeleton = object.skeleton;
- // Set pose matrices of skinned mesh
- if (skeleton) {
- // TODO Update before culling.
- skeleton.update();
- if (object.joints.length > this._glinfo.getMaxJointNumber()) {
- var skinMatricesTexture = skeleton.getSubSkinMatricesTexture(object.__uid__, object.joints);
- program.useTextureSlot(this, skinMatricesTexture, slot);
- program.setUniform(_gl, '1i', 'skinMatricesTexture', slot);
- program.setUniform(_gl, '1f', 'skinMatricesTextureSize', skinMatricesTexture.width);
- }
- else {
- var skinMatricesArray = skeleton.getSubSkinMatrices(object.__uid__, object.joints);
- program.setUniformOfSemantic(_gl, 'SKIN_MATRIX', skinMatricesArray);
- }
- }
- },
- _renderObject: function (renderable, vao) {
- var _gl = this.gl;
- var geometry = renderable.geometry;
- var glDrawMode = renderable.mode;
- if (glDrawMode == null) {
- glDrawMode = 0x0004;
- }
- // if (glDrawMode === glenum.LINES || glDrawMode === glenum.LINE_STRIP || glDrawMode === glenum.LINE_LOOP) {
- // _gl.lineWidth(this.lineWidth);
- // }
- if (vao.indicesBuffer) {
- var uintExt = this.getGLExtension('OES_element_index_uint');
- var useUintExt = uintExt && (geometry.indices instanceof Uint32Array);
- var indicesType = useUintExt ? _gl.UNSIGNED_INT : _gl.UNSIGNED_SHORT;
- _gl.drawElements(glDrawMode, vao.indicesBuffer.count, indicesType, 0);
- }
- else {
- // FIXME Use vertex number in buffer
- // vertexCount may get the wrong value when geometry forget to mark dirty after update
- _gl.drawArrays(glDrawMode, 0, geometry.vertexCount);
- }
- },
- _bindMaterial: function (renderable, material, program, prevRenderable, prevMaterial, prevProgram, getUniformValue) {
- var _gl = this.gl;
- // PENDING Same texture in different material take different slot?
- // May use shader of other material if shader code are same
- var sameProgram = prevProgram === program;
- var currentTextureSlot = program.currentTextureSlot();
- var enabledUniforms = material.getEnabledUniforms();
- var textureUniforms = material.getTextureUniforms();
- var placeholderTexture = this._placeholderTexture;
- for (var u = 0; u < textureUniforms.length; u++) {
- var symbol = textureUniforms[u];
- var uniformValue = getUniformValue(renderable, material, symbol);
- var uniformType = material.uniforms[symbol].type;
- // Not use `instanceof` to determine if a value is texture in Material#bind.
- // Use type instead, in some case texture may be in different namespaces.
- // TODO Duck type validate.
- if (uniformType === 't' && uniformValue) {
- // Reset slot
- uniformValue.__slot = -1;
- }
- else if (uniformType === 'tv') {
- for (var i = 0; i < uniformValue.length; i++) {
- if (uniformValue[i]) {
- uniformValue[i].__slot = -1;
- }
- }
- }
- }
- placeholderTexture.__slot = -1;
- // Set uniforms
- for (var u = 0; u < enabledUniforms.length; u++) {
- var symbol = enabledUniforms[u];
- var uniform = material.uniforms[symbol];
- var uniformValue = getUniformValue(renderable, material, symbol);
- var uniformType = uniform.type;
- var isTexture = uniformType === 't';
- if (isTexture) {
- if (!uniformValue || !uniformValue.isRenderable()) {
- uniformValue = placeholderTexture;
- }
- }
- // PENDING
- // When binding two materials with the same shader
- // Many uniforms will be be set twice even if they have the same value
- // So add a evaluation to see if the uniform is really needed to be set
- if (prevMaterial && sameProgram) {
- var prevUniformValue = getUniformValue(prevRenderable, prevMaterial, symbol);
- if (isTexture) {
- if (!prevUniformValue || !prevUniformValue.isRenderable()) {
- prevUniformValue = placeholderTexture;
- }
- }
- if (prevUniformValue === uniformValue) {
- if (isTexture) {
- // Still take the slot to make sure same texture in different materials have same slot.
- program.takeCurrentTextureSlot(this, null);
- }
- else if (uniformType === 'tv' && uniformValue) {
- for (var i = 0; i < uniformValue.length; i++) {
- program.takeCurrentTextureSlot(this, null);
- }
- }
- continue;
- }
- }
- if (uniformValue == null) {
- continue;
- }
- else if (isTexture) {
- if (uniformValue.__slot < 0) {
- var slot = program.currentTextureSlot();
- var res = program.setUniform(_gl, '1i', symbol, slot);
- if (res) { // Texture uniform is enabled
- program.takeCurrentTextureSlot(this, uniformValue);
- uniformValue.__slot = slot;
- }
- }
- // Multiple uniform use same texture..
- else {
- program.setUniform(_gl, '1i', symbol, uniformValue.__slot);
- }
- }
- else if (Array.isArray(uniformValue)) {
- if (uniformValue.length === 0) {
- continue;
- }
- // Texture Array
- if (uniformType === 'tv') {
- if (!program.hasUniform(symbol)) {
- continue;
- }
- var arr = [];
- for (var i = 0; i < uniformValue.length; i++) {
- var texture = uniformValue[i];
- if (texture.__slot < 0) {
- var slot = program.currentTextureSlot();
- arr.push(slot);
- program.takeCurrentTextureSlot(this, texture);
- texture.__slot = slot;
- }
- else {
- arr.push(texture.__slot);
- }
- }
- program.setUniform(_gl, '1iv', symbol, arr);
- }
- else {
- program.setUniform(_gl, uniform.type, symbol, uniformValue);
- }
- }
- else {
- program.setUniform(_gl, uniform.type, symbol, uniformValue);
- }
- }
- var newSlot = program.currentTextureSlot();
- // Texture slot maybe used out of material.
- program.resetTextureSlot(currentTextureSlot);
- return newSlot;
- },
- _bindVAO: function (vaoExt, shader, geometry, program) {
- var isStatic = !geometry.dynamic;
- var _gl = this.gl;
- var vaoId = this.__uid__ + '-' + program.__uid__;
- var vao = geometry.__vaoCache[vaoId];
- if (!vao) {
- var chunks = geometry.getBufferChunks(this);
- if (!chunks || !chunks.length) { // Empty mesh
- return;
- }
- var chunk = chunks[0];
- var attributeBuffers = chunk.attributeBuffers;
- var indicesBuffer = chunk.indicesBuffer;
- var availableAttributes = [];
- var availableAttributeSymbols = [];
- for (var a = 0; a < attributeBuffers.length; a++) {
- var attributeBufferInfo = attributeBuffers[a];
- var name = attributeBufferInfo.name;
- var semantic = attributeBufferInfo.semantic;
- var symbol;
- if (semantic) {
- var semanticInfo = shader.attributeSemantics[semantic];
- symbol = semanticInfo && semanticInfo.symbol;
- }
- else {
- symbol = name;
- }
- if (symbol && program.attributes[symbol]) {
- availableAttributes.push(attributeBufferInfo);
- availableAttributeSymbols.push(symbol);
- }
- }
- vao = new VertexArrayObject(
- availableAttributes,
- availableAttributeSymbols,
- indicesBuffer
- );
- if (isStatic) {
- geometry.__vaoCache[vaoId] = vao;
- }
- }
- var needsBindAttributes = true;
- // Create vertex object array cost a lot
- // So we don't use it on the dynamic object
- if (vaoExt && isStatic) {
- // Use vertex array object
- // http://blog.tojicode.com/2012/10/oesvertexarrayobject-extension.html
- if (vao.vao == null) {
- vao.vao = vaoExt.createVertexArrayOES();
- }
- else {
- needsBindAttributes = false;
- }
- vaoExt.bindVertexArrayOES(vao.vao);
- }
- var availableAttributes = vao.availableAttributes;
- var indicesBuffer = vao.indicesBuffer;
- if (needsBindAttributes) {
- var locationList = program.enableAttributes(this, vao.availableAttributeSymbols, (vaoExt && isStatic && vao));
- // Setting attributes;
- for (var a = 0; a < availableAttributes.length; a++) {
- var location = locationList[a];
- if (location === -1) {
- continue;
- }
- var attributeBufferInfo = availableAttributes[a];
- var buffer = attributeBufferInfo.buffer;
- var size = attributeBufferInfo.size;
- var glType = attributeBufferTypeMap[attributeBufferInfo.type] || _gl.FLOAT;
- _gl.bindBuffer(_gl.ARRAY_BUFFER, buffer);
- _gl.vertexAttribPointer(location, size, glType, false, 0, 0);
- }
- if (geometry.isUseIndices()) {
- _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, indicesBuffer.buffer);
- }
- }
- return vao;
- },
- renderPreZ: function (list, scene, camera) {
- var _gl = this.gl;
- var preZPassMaterial = this._prezMaterial || new __WEBPACK_IMPORTED_MODULE_4__Material__["a" /* default */]({
- shader: new __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */](__WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */].source('clay.prez.vertex'), __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */].source('clay.prez.fragment'))
- });
- this._prezMaterial = preZPassMaterial;
- _gl.colorMask(false, false, false, false);
- _gl.depthMask(true);
- // Status
- this.renderPass(list, camera, {
- ifRender: function (renderable) {
- return !renderable.ignorePreZ;
- },
- isMaterialChanged: function (renderable, prevRenderable) {
- var matA = renderable.material;
- var matB = prevRenderable.material;
- return matA.get('diffuseMap') !== matB.get('diffuseMap')
- || (matA.get('alphaCutoff') || 0) !== (matB.get('alphaCutoff') || 0);
- },
- getUniform: function (renderable, depthMaterial, symbol) {
- if (symbol === 'alphaMap') {
- return renderable.material.get('diffuseMap');
- }
- else if (symbol === 'alphaCutoff') {
- if (renderable.material.isDefined('fragment', 'ALPHA_TEST')
- && renderable.material.get('diffuseMap')
- ) {
- var alphaCutoff = renderable.material.get('alphaCutoff');
- return alphaCutoff || 0;
- }
- return 0;
- }
- else {
- return depthMaterial.get(symbol);
- }
- },
- getMaterial: function () {
- return preZPassMaterial;
- },
- sort: this.opaqueSortCompare
- });
- _gl.colorMask(true, true, true, true);
- _gl.depthMask(true);
- },
- /**
- * Dispose given scene, including all geometris, textures and shaders in the scene
- * @param {clay.Scene} scene
- */
- disposeScene: function (scene) {
- this.disposeNode(scene, true, true);
- scene.dispose();
- },
- /**
- * Dispose given node, including all geometries, textures and shaders attached on it or its descendant
- * @param {clay.Node} node
- * @param {boolean} [disposeGeometry=false] If dispose the geometries used in the descendant mesh
- * @param {boolean} [disposeTexture=false] If dispose the textures used in the descendant mesh
- */
- disposeNode: function (root, disposeGeometry, disposeTexture) {
- // Dettached from parent
- if (root.getParent()) {
- root.getParent().remove(root);
- }
- var disposedMap = {};
- root.traverse(function (node) {
- var material = node.material;
- if (node.geometry && disposeGeometry) {
- node.geometry.dispose(this);
- }
- if (disposeTexture && material && !disposedMap[material.__uid__]) {
- var textureUniforms = material.getTextureUniforms();
- for (var u = 0; u < textureUniforms.length; u++) {
- var uniformName = textureUniforms[u];
- var val = material.uniforms[uniformName].value;
- var uniformType = material.uniforms[uniformName].type;
- if (!val) {
- continue;
- }
- if (uniformType === 't') {
- val.dispose && val.dispose(this);
- }
- else if (uniformType === 'tv') {
- for (var k = 0; k < val.length; k++) {
- if (val[k]) {
- val[k].dispose && val[k].dispose(this);
- }
- }
- }
- }
- disposedMap[material.__uid__] = true;
- }
- // Particle system and AmbientCubemap light need to dispose
- if (node.dispose) {
- node.dispose(this);
- }
- }, this);
- },
- /**
- * Dispose given geometry
- * @param {clay.Geometry} geometry
- */
- disposeGeometry: function (geometry) {
- geometry.dispose(this);
- },
- /**
- * Dispose given texture
- * @param {clay.Texture} texture
- */
- disposeTexture: function (texture) {
- texture.dispose(this);
- },
- /**
- * Dispose given frame buffer
- * @param {clay.FrameBuffer} frameBuffer
- */
- disposeFrameBuffer: function (frameBuffer) {
- frameBuffer.dispose(this);
- },
- /**
- * Dispose renderer
- */
- dispose: function () { },
- /**
- * Convert screen coords to normalized device coordinates(NDC)
- * Screen coords can get from mouse event, it is positioned relative to canvas element
- * NDC can be used in ray casting with Camera.prototype.castRay methods
- *
- * @param {number} x
- * @param {number} y
- * @param {clay.Vector2} [out]
- * @return {clay.Vector2}
- */
- screenToNDC: function (x, y, out) {
- if (!out) {
- out = new __WEBPACK_IMPORTED_MODULE_5__math_Vector2__["a" /* default */]();
- }
- // Invert y;
- y = this._height - y;
- var viewport = this.viewport;
- var arr = out.array;
- arr[0] = (x - viewport.x) / viewport.width;
- arr[0] = arr[0] * 2 - 1;
- arr[1] = (y - viewport.y) / viewport.height;
- arr[1] = arr[1] * 2 - 1;
- return out;
- }
- });
- /**
- * Opaque renderables compare function
- * @param {clay.Renderable} x
- * @param {clay.Renderable} y
- * @return {boolean}
- * @static
- */
- Renderer.opaqueSortCompare = Renderer.prototype.opaqueSortCompare = function (x, y) {
- // Priority renderOrder -> program -> material -> geometry
- if (x.renderOrder === y.renderOrder) {
- if (x.__program === y.__program) {
- if (x.material === y.material) {
- return x.geometry.__uid__ - y.geometry.__uid__;
- }
- return x.material.__uid__ - y.material.__uid__;
- }
- if (x.__program && y.__program) {
- return x.__program.__uid__ - y.__program.__uid__;
- }
- return 0;
- }
- return x.renderOrder - y.renderOrder;
- };
- /**
- * Transparent renderables compare function
- * @param {clay.Renderable} a
- * @param {clay.Renderable} b
- * @return {boolean}
- * @static
- */
- Renderer.transparentSortCompare = Renderer.prototype.transparentSortCompare = function (x, y) {
- // Priority renderOrder -> depth -> program -> material -> geometry
- if (x.renderOrder === y.renderOrder) {
- if (x.__depth === y.__depth) {
- if (x.__program === y.__program) {
- if (x.material === y.material) {
- return x.geometry.__uid__ - y.geometry.__uid__;
- }
- return x.material.__uid__ - y.material.__uid__;
- }
- if (x.__program && y.__program) {
- return x.__program.__uid__ - y.__program.__uid__;
- }
- return 0;
- }
- // Depth is negative
- // So farther object has smaller depth value
- return x.__depth - y.__depth;
- }
- return x.renderOrder - y.renderOrder;
- };
- // Temporary variables
- var matrices = {
- IDENTITY: mat4Create(),
- WORLD: mat4Create(),
- VIEW: mat4Create(),
- PROJECTION: mat4Create(),
- WORLDVIEW: mat4Create(),
- VIEWPROJECTION: mat4Create(),
- WORLDVIEWPROJECTION: mat4Create(),
- WORLDINVERSE: mat4Create(),
- VIEWINVERSE: mat4Create(),
- PROJECTIONINVERSE: mat4Create(),
- WORLDVIEWINVERSE: mat4Create(),
- VIEWPROJECTIONINVERSE: mat4Create(),
- WORLDVIEWPROJECTIONINVERSE: mat4Create(),
- WORLDTRANSPOSE: mat4Create(),
- VIEWTRANSPOSE: mat4Create(),
- PROJECTIONTRANSPOSE: mat4Create(),
- WORLDVIEWTRANSPOSE: mat4Create(),
- VIEWPROJECTIONTRANSPOSE: mat4Create(),
- WORLDVIEWPROJECTIONTRANSPOSE: mat4Create(),
- WORLDINVERSETRANSPOSE: mat4Create(),
- VIEWINVERSETRANSPOSE: mat4Create(),
- PROJECTIONINVERSETRANSPOSE: mat4Create(),
- WORLDVIEWINVERSETRANSPOSE: mat4Create(),
- VIEWPROJECTIONINVERSETRANSPOSE: mat4Create(),
- WORLDVIEWPROJECTIONINVERSETRANSPOSE: mat4Create()
- };
- /**
- * @name clay.Renderer.COLOR_BUFFER_BIT
- * @type {number}
- */
- Renderer.COLOR_BUFFER_BIT = __WEBPACK_IMPORTED_MODULE_2__core_glenum__["a" /* default */].COLOR_BUFFER_BIT;
- /**
- * @name clay.Renderer.DEPTH_BUFFER_BIT
- * @type {number}
- */
- Renderer.DEPTH_BUFFER_BIT = __WEBPACK_IMPORTED_MODULE_2__core_glenum__["a" /* default */].DEPTH_BUFFER_BIT;
- /**
- * @name clay.Renderer.STENCIL_BUFFER_BIT
- * @type {number}
- */
- Renderer.STENCIL_BUFFER_BIT = __WEBPACK_IMPORTED_MODULE_2__core_glenum__["a" /* default */].STENCIL_BUFFER_BIT;
- /* harmony default export */ __webpack_exports__["a"] = (Renderer);
- /***/
- }),
- /* 53 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- function Handler(action, context) {
- this.action = action;
- this.context = context;
- }
- /**
- * @mixin
- * @alias clay.core.mixin.notifier
- */
- var notifier = {
- /**
- * Trigger event
- * @param {string} name
- */
- trigger: function (name) {
- if (!this.hasOwnProperty('__handlers__')) {
- return;
- }
- if (!this.__handlers__.hasOwnProperty(name)) {
- return;
- }
- var hdls = this.__handlers__[name];
- var l = hdls.length, i = -1, args = arguments;
- // Optimize advise from backbone
- switch (args.length) {
- case 1:
- while (++i < l) {
- hdls[i].action.call(hdls[i].context);
- }
- return;
- case 2:
- while (++i < l) {
- hdls[i].action.call(hdls[i].context, args[1]);
- }
- return;
- case 3:
- while (++i < l) {
- hdls[i].action.call(hdls[i].context, args[1], args[2]);
- }
- return;
- case 4:
- while (++i < l) {
- hdls[i].action.call(hdls[i].context, args[1], args[2], args[3]);
- }
- return;
- case 5:
- while (++i < l) {
- hdls[i].action.call(hdls[i].context, args[1], args[2], args[3], args[4]);
- }
- return;
- default:
- while (++i < l) {
- hdls[i].action.apply(hdls[i].context, Array.prototype.slice.call(args, 1));
- }
- return;
- }
- },
- /**
- * Register event handler
- * @param {string} name
- * @param {Function} action
- * @param {Object} [context]
- * @chainable
- */
- on: function (name, action, context) {
- if (!name || !action) {
- return;
- }
- var handlers = this.__handlers__ || (this.__handlers__ = {});
- if (!handlers[name]) {
- handlers[name] = [];
- }
- else {
- if (this.has(name, action)) {
- return;
- }
- }
- var handler = new Handler(action, context || this);
- handlers[name].push(handler);
- return this;
- },
- /**
- * Register event, event will only be triggered once and then removed
- * @param {string} name
- * @param {Function} action
- * @param {Object} [context]
- * @chainable
- */
- once: function (name, action, context) {
- if (!name || !action) {
- return;
- }
- var self = this;
- function wrapper() {
- self.off(name, wrapper);
- action.apply(this, arguments);
- }
- return this.on(name, wrapper, context);
- },
- /**
- * Alias of once('before' + name)
- * @param {string} name
- * @param {Function} action
- * @param {Object} [context]
- * @chainable
- */
- before: function (name, action, context) {
- if (!name || !action) {
- return;
- }
- name = 'before' + name;
- return this.on(name, action, context);
- },
- /**
- * Alias of once('after' + name)
- * @param {string} name
- * @param {Function} action
- * @param {Object} [context]
- * @chainable
- */
- after: function (name, action, context) {
- if (!name || !action) {
- return;
- }
- name = 'after' + name;
- return this.on(name, action, context);
- },
- /**
- * Alias of on('success')
- * @param {Function} action
- * @param {Object} [context]
- * @chainable
- */
- success: function (action, context) {
- return this.once('success', action, context);
- },
- /**
- * Alias of on('error')
- * @param {Function} action
- * @param {Object} [context]
- * @chainable
- */
- error: function (action, context) {
- return this.once('error', action, context);
- },
- /**
- * Remove event listener
- * @param {Function} action
- * @param {Object} [context]
- * @chainable
- */
- off: function (name, action) {
- var handlers = this.__handlers__ || (this.__handlers__ = {});
- if (!action) {
- handlers[name] = [];
- return;
- }
- if (handlers[name]) {
- var hdls = handlers[name];
- var retains = [];
- for (var i = 0; i < hdls.length; i++) {
- if (action && hdls[i].action !== action) {
- retains.push(hdls[i]);
- }
- }
- handlers[name] = retains;
- }
- return this;
- },
- /**
- * If registered the event handler
- * @param {string} name
- * @param {Function} action
- * @return {boolean}
- */
- has: function (name, action) {
- var handlers = this.__handlers__;
- if (!handlers ||
- !handlers[name]) {
- return false;
- }
- var hdls = handlers[name];
- for (var i = 0; i < hdls.length; i++) {
- if (hdls[i].action === action) {
- return true;
- }
- }
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (notifier);
- /***/
- }),
- /* 54 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__ = __webpack_require__(12);
- var EPSILON = 1e-5;
- /**
- * @constructor
- * @alias clay.Ray
- * @param {clay.Vector3} [origin]
- * @param {clay.Vector3} [direction]
- */
- var Ray = function (origin, direction) {
- /**
- * @type {clay.Vector3}
- */
- this.origin = origin || new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */]();
- /**
- * @type {clay.Vector3}
- */
- this.direction = direction || new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */]();
- };
- Ray.prototype = {
- constructor: Ray,
- // http://www.siggraph.org/education/materials/HyperGraph/raytrace/rayplane_intersection.htm
- /**
- * Calculate intersection point between ray and a give plane
- * @param {clay.Plane} plane
- * @param {clay.Vector3} [out]
- * @return {clay.Vector3}
- */
- intersectPlane: function (plane, out) {
- var pn = plane.normal.array;
- var d = plane.distance;
- var ro = this.origin.array;
- var rd = this.direction.array;
- var divider = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(pn, rd);
- // ray is parallel to the plane
- if (divider === 0) {
- return null;
- }
- if (!out) {
- out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */]();
- }
- var t = (__WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(pn, ro) - d) / divider;
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, ro, rd, -t);
- out._dirty = true;
- return out;
- },
- /**
- * Mirror the ray against plane
- * @param {clay.Plane} plane
- */
- mirrorAgainstPlane: function (plane) {
- // Distance to plane
- var d = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(plane.normal.array, this.direction.array);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(this.direction.array, this.direction.array, plane.normal.array, -d * 2);
- this.direction._dirty = true;
- },
- distanceToPoint: (function () {
- var v = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- return function (point) {
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v, point, this.origin.array);
- // Distance from projection point to origin
- var b = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(v, this.direction.array);
- if (b < 0) {
- return __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].distance(this.origin.array, point);
- }
- // Squared distance from center to origin
- var c2 = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].lenSquared(v);
- // Squared distance from center to projection point
- return Math.sqrt(c2 - b * b);
- };
- })(),
- /**
- * Calculate intersection point between ray and sphere
- * @param {clay.Vector3} center
- * @param {number} radius
- * @param {clay.Vector3} out
- * @return {clay.Vector3}
- */
- intersectSphere: (function () {
- var v = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- return function (center, radius, out) {
- var origin = this.origin.array;
- var direction = this.direction.array;
- center = center.array;
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(v, center, origin);
- // Distance from projection point to origin
- var b = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(v, direction);
- // Squared distance from center to origin
- var c2 = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].squaredLength(v);
- // Squared distance from center to projection point
- var d2 = c2 - b * b;
- var r2 = radius * radius;
- // No intersection
- if (d2 > r2) {
- return;
- }
- var a = Math.sqrt(r2 - d2);
- // First intersect point
- var t0 = b - a;
- // Second intersect point
- var t1 = b + a;
- if (!out) {
- out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */]();
- }
- if (t0 < 0) {
- if (t1 < 0) {
- return null;
- }
- else {
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, origin, direction, t1);
- return out;
- }
- }
- else {
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, origin, direction, t0);
- return out;
- }
- };
- })(),
- // http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-box-intersection/
- /**
- * Calculate intersection point between ray and bounding box
- * @param {clay.BoundingBox} bbox
- * @param {clay.Vector3}
- * @return {clay.Vector3}
- */
- intersectBoundingBox: function (bbox, out) {
- var dir = this.direction.array;
- var origin = this.origin.array;
- var min = bbox.min.array;
- var max = bbox.max.array;
- var invdirx = 1 / dir[0];
- var invdiry = 1 / dir[1];
- var invdirz = 1 / dir[2];
- var tmin, tmax, tymin, tymax, tzmin, tzmax;
- if (invdirx >= 0) {
- tmin = (min[0] - origin[0]) * invdirx;
- tmax = (max[0] - origin[0]) * invdirx;
- }
- else {
- tmax = (min[0] - origin[0]) * invdirx;
- tmin = (max[0] - origin[0]) * invdirx;
- }
- if (invdiry >= 0) {
- tymin = (min[1] - origin[1]) * invdiry;
- tymax = (max[1] - origin[1]) * invdiry;
- }
- else {
- tymax = (min[1] - origin[1]) * invdiry;
- tymin = (max[1] - origin[1]) * invdiry;
- }
- if ((tmin > tymax) || (tymin > tmax)) {
- return null;
- }
- if (tymin > tmin || tmin !== tmin) {
- tmin = tymin;
- }
- if (tymax < tmax || tmax !== tmax) {
- tmax = tymax;
- }
- if (invdirz >= 0) {
- tzmin = (min[2] - origin[2]) * invdirz;
- tzmax = (max[2] - origin[2]) * invdirz;
- }
- else {
- tzmax = (min[2] - origin[2]) * invdirz;
- tzmin = (max[2] - origin[2]) * invdirz;
- }
- if ((tmin > tzmax) || (tzmin > tmax)) {
- return null;
- }
- if (tzmin > tmin || tmin !== tmin) {
- tmin = tzmin;
- }
- if (tzmax < tmax || tmax !== tmax) {
- tmax = tzmax;
- }
- if (tmax < 0) {
- return null;
- }
- var t = tmin >= 0 ? tmin : tmax;
- if (!out) {
- out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */]();
- }
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, origin, dir, t);
- return out;
- },
- // http://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
- /**
- * Calculate intersection point between ray and three triangle vertices
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @param {clay.Vector3} c
- * @param {boolean} singleSided, CW triangle will be ignored
- * @param {clay.Vector3} [out]
- * @param {clay.Vector3} [barycenteric] barycentric coords
- * @return {clay.Vector3}
- */
- intersectTriangle: (function () {
- var eBA = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- var eCA = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- var AO = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- var vCross = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].create();
- return function (a, b, c, singleSided, out, barycenteric) {
- var dir = this.direction.array;
- var origin = this.origin.array;
- a = a.array;
- b = b.array;
- c = c.array;
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(eBA, b, a);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(eCA, c, a);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(vCross, eCA, dir);
- var det = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(eBA, vCross);
- if (singleSided) {
- if (det > -EPSILON) {
- return null;
- }
- }
- else {
- if (det > -EPSILON && det < EPSILON) {
- return null;
- }
- }
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].sub(AO, origin, a);
- var u = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(vCross, AO) / det;
- if (u < 0 || u > 1) {
- return null;
- }
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(vCross, eBA, AO);
- var v = __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(dir, vCross) / det;
- if (v < 0 || v > 1 || (u + v > 1)) {
- return null;
- }
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].cross(vCross, eBA, eCA);
- var t = -__WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].dot(AO, vCross) / det;
- if (t < 0) {
- return null;
- }
- if (!out) {
- out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */]();
- }
- if (barycenteric) {
- __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].set(barycenteric, (1 - u - v), u, v);
- }
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, origin, dir, t);
- return out;
- };
- })(),
- /**
- * Apply an affine transform matrix to the ray
- * @return {clay.Matrix4} matrix
- */
- applyTransform: function (matrix) {
- __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].add(this.direction, this.direction, this.origin);
- __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].transformMat4(this.origin, this.origin, matrix);
- __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].transformMat4(this.direction, this.direction, matrix);
- __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].sub(this.direction, this.direction, this.origin);
- __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].normalize(this.direction, this.direction);
- },
- /**
- * Copy values from another ray
- * @param {clay.Ray} ray
- */
- copy: function (ray) {
- __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].copy(this.origin, ray.origin);
- __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */].copy(this.direction, ray.direction);
- },
- /**
- * Clone a new ray
- * @return {clay.Ray}
- */
- clone: function () {
- var ray = new Ray();
- ray.copy(this);
- return ray;
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (Ray);
- /***/
- }),
- /* 55 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__vec3__ = __webpack_require__(12);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__vec4__ = __webpack_require__(33);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__mat3__ = __webpack_require__(34);
- /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
- /**
- * @class Quaternion
- * @name quat
- */
- var quat = {};
- /**
- * Creates a new identity quat
- *
- * @returns {quat} a new quaternion
- */
- quat.create = function () {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4);
- out[0] = 0;
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
- return out;
- };
- /**
- * Sets a quaternion to represent the shortest rotation from one
- * vector to another.
- *
- * Both vectors are assumed to be unit length.
- *
- * @param {quat} out the receiving quaternion.
- * @param {vec3} a the initial vector
- * @param {vec3} b the destination vector
- * @returns {quat} out
- */
- quat.rotationTo = (function () {
- var tmpvec3 = __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].create();
- var xUnitVec3 = __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].fromValues(1, 0, 0);
- var yUnitVec3 = __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].fromValues(0, 1, 0);
- return function (out, a, b) {
- var dot = __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].dot(a, b);
- if (dot < -0.999999) {
- __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].cross(tmpvec3, xUnitVec3, a);
- if (__WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].length(tmpvec3) < 0.000001)
- __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].cross(tmpvec3, yUnitVec3, a);
- __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].normalize(tmpvec3, tmpvec3);
- quat.setAxisAngle(out, tmpvec3, Math.PI);
- return out;
- } else if (dot > 0.999999) {
- out[0] = 0;
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
- return out;
- } else {
- __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */].cross(tmpvec3, a, b);
- out[0] = tmpvec3[0];
- out[1] = tmpvec3[1];
- out[2] = tmpvec3[2];
- out[3] = 1 + dot;
- return quat.normalize(out, out);
- }
- };
- })();
- /**
- * Sets the specified quaternion with values corresponding to the given
- * axes. Each axis is a vec3 and is expected to be unit length and
- * perpendicular to all other specified axes.
- *
- * @param {vec3} view the vector representing the viewing direction
- * @param {vec3} right the vector representing the local "right" direction
- * @param {vec3} up the vector representing the local "up" direction
- * @returns {quat} out
- */
- quat.setAxes = (function () {
- var matr = __WEBPACK_IMPORTED_MODULE_3__mat3__["a" /* default */].create();
- return function (out, view, right, up) {
- matr[0] = right[0];
- matr[3] = right[1];
- matr[6] = right[2];
- matr[1] = up[0];
- matr[4] = up[1];
- matr[7] = up[2];
- matr[2] = -view[0];
- matr[5] = -view[1];
- matr[8] = -view[2];
- return quat.normalize(out, quat.fromMat3(out, matr));
- };
- })();
- /**
- * Creates a new quat initialized with values from an existing quaternion
- *
- * @param {quat} a quaternion to clone
- * @returns {quat} a new quaternion
- * @function
- */
- quat.clone = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].clone;
- /**
- * Creates a new quat initialized with the given values
- *
- * @param {Number} x X component
- * @param {Number} y Y component
- * @param {Number} z Z component
- * @param {Number} w W component
- * @returns {quat} a new quaternion
- * @function
- */
- quat.fromValues = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].fromValues;
- /**
- * Copy the values from one quat to another
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a the source quaternion
- * @returns {quat} out
- * @function
- */
- quat.copy = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].copy;
- /**
- * Set the components of a quat to the given values
- *
- * @param {quat} out the receiving quaternion
- * @param {Number} x X component
- * @param {Number} y Y component
- * @param {Number} z Z component
- * @param {Number} w W component
- * @returns {quat} out
- * @function
- */
- quat.set = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].set;
- /**
- * Set a quat to the identity quaternion
- *
- * @param {quat} out the receiving quaternion
- * @returns {quat} out
- */
- quat.identity = function (out) {
- out[0] = 0;
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
- return out;
- };
- /**
- * Sets a quat from the given angle and rotation axis,
- * then returns it.
- *
- * @param {quat} out the receiving quaternion
- * @param {vec3} axis the axis around which to rotate
- * @param {Number} rad the angle in radians
- * @returns {quat} out
- **/
- quat.setAxisAngle = function (out, axis, rad) {
- rad = rad * 0.5;
- var s = Math.sin(rad);
- out[0] = s * axis[0];
- out[1] = s * axis[1];
- out[2] = s * axis[2];
- out[3] = Math.cos(rad);
- return out;
- };
- /**
- * Adds two quat's
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a the first operand
- * @param {quat} b the second operand
- * @returns {quat} out
- * @function
- */
- quat.add = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].add;
- /**
- * Multiplies two quat's
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a the first operand
- * @param {quat} b the second operand
- * @returns {quat} out
- */
- quat.multiply = function (out, a, b) {
- var ax = a[0], ay = a[1], az = a[2], aw = a[3],
- bx = b[0], by = b[1], bz = b[2], bw = b[3];
- out[0] = ax * bw + aw * bx + ay * bz - az * by;
- out[1] = ay * bw + aw * by + az * bx - ax * bz;
- out[2] = az * bw + aw * bz + ax * by - ay * bx;
- out[3] = aw * bw - ax * bx - ay * by - az * bz;
- return out;
- };
- /**
- * Alias for {@link quat.multiply}
- * @function
- */
- quat.mul = quat.multiply;
- /**
- * Scales a quat by a scalar number
- *
- * @param {quat} out the receiving vector
- * @param {quat} a the vector to scale
- * @param {Number} b amount to scale the vector by
- * @returns {quat} out
- * @function
- */
- quat.scale = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].scale;
- /**
- * Rotates a quaternion by the given angle about the X axis
- *
- * @param {quat} out quat receiving operation result
- * @param {quat} a quat to rotate
- * @param {number} rad angle (in radians) to rotate
- * @returns {quat} out
- */
- quat.rotateX = function (out, a, rad) {
- rad *= 0.5;
- var ax = a[0], ay = a[1], az = a[2], aw = a[3],
- bx = Math.sin(rad), bw = Math.cos(rad);
- out[0] = ax * bw + aw * bx;
- out[1] = ay * bw + az * bx;
- out[2] = az * bw - ay * bx;
- out[3] = aw * bw - ax * bx;
- return out;
- };
- /**
- * Rotates a quaternion by the given angle about the Y axis
- *
- * @param {quat} out quat receiving operation result
- * @param {quat} a quat to rotate
- * @param {number} rad angle (in radians) to rotate
- * @returns {quat} out
- */
- quat.rotateY = function (out, a, rad) {
- rad *= 0.5;
- var ax = a[0], ay = a[1], az = a[2], aw = a[3],
- by = Math.sin(rad), bw = Math.cos(rad);
- out[0] = ax * bw - az * by;
- out[1] = ay * bw + aw * by;
- out[2] = az * bw + ax * by;
- out[3] = aw * bw - ay * by;
- return out;
- };
- /**
- * Rotates a quaternion by the given angle about the Z axis
- *
- * @param {quat} out quat receiving operation result
- * @param {quat} a quat to rotate
- * @param {number} rad angle (in radians) to rotate
- * @returns {quat} out
- */
- quat.rotateZ = function (out, a, rad) {
- rad *= 0.5;
- var ax = a[0], ay = a[1], az = a[2], aw = a[3],
- bz = Math.sin(rad), bw = Math.cos(rad);
- out[0] = ax * bw + ay * bz;
- out[1] = ay * bw - ax * bz;
- out[2] = az * bw + aw * bz;
- out[3] = aw * bw - az * bz;
- return out;
- };
- /**
- * Calculates the W component of a quat from the X, Y, and Z components.
- * Assumes that quaternion is 1 unit in length.
- * Any existing W component will be ignored.
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a quat to calculate W component of
- * @returns {quat} out
- */
- quat.calculateW = function (out, a) {
- var x = a[0], y = a[1], z = a[2];
- out[0] = x;
- out[1] = y;
- out[2] = z;
- out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z));
- return out;
- };
- /**
- * Calculates the dot product of two quat's
- *
- * @param {quat} a the first operand
- * @param {quat} b the second operand
- * @returns {Number} dot product of a and b
- * @function
- */
- quat.dot = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].dot;
- /**
- * Performs a linear interpolation between two quat's
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a the first operand
- * @param {quat} b the second operand
- * @param {Number} t interpolation amount between the two inputs
- * @returns {quat} out
- * @function
- */
- quat.lerp = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].lerp;
- /**
- * Performs a spherical linear interpolation between two quat
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a the first operand
- * @param {quat} b the second operand
- * @param {Number} t interpolation amount between the two inputs
- * @returns {quat} out
- */
- quat.slerp = function (out, a, b, t) {
- // benchmarks:
- // http://jsperf.com/quaternion-slerp-implementations
- var ax = a[0], ay = a[1], az = a[2], aw = a[3],
- bx = b[0], by = b[1], bz = b[2], bw = b[3];
- var omega, cosom, sinom, scale0, scale1;
- // calc cosine
- cosom = ax * bx + ay * by + az * bz + aw * bw;
- // adjust signs (if necessary)
- if (cosom < 0.0) {
- cosom = -cosom;
- bx = - bx;
- by = - by;
- bz = - bz;
- bw = - bw;
- }
- // calculate coefficients
- if ((1.0 - cosom) > 0.000001) {
- // standard case (slerp)
- omega = Math.acos(cosom);
- sinom = Math.sin(omega);
- scale0 = Math.sin((1.0 - t) * omega) / sinom;
- scale1 = Math.sin(t * omega) / sinom;
- } else {
- // "from" and "to" quaternions are very close
- // ... so we can do a linear interpolation
- scale0 = 1.0 - t;
- scale1 = t;
- }
- // calculate final values
- out[0] = scale0 * ax + scale1 * bx;
- out[1] = scale0 * ay + scale1 * by;
- out[2] = scale0 * az + scale1 * bz;
- out[3] = scale0 * aw + scale1 * bw;
- return out;
- };
- /**
- * Calculates the inverse of a quat
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a quat to calculate inverse of
- * @returns {quat} out
- */
- quat.invert = function (out, a) {
- var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
- dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3,
- invDot = dot ? 1.0 / dot : 0;
- // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0
- out[0] = -a0 * invDot;
- out[1] = -a1 * invDot;
- out[2] = -a2 * invDot;
- out[3] = a3 * invDot;
- return out;
- };
- /**
- * Calculates the conjugate of a quat
- * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a quat to calculate conjugate of
- * @returns {quat} out
- */
- quat.conjugate = function (out, a) {
- out[0] = -a[0];
- out[1] = -a[1];
- out[2] = -a[2];
- out[3] = a[3];
- return out;
- };
- /**
- * Calculates the length of a quat
- *
- * @param {quat} a vector to calculate length of
- * @returns {Number} length of a
- * @function
- */
- quat.length = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].length;
- /**
- * Alias for {@link quat.length}
- * @function
- */
- quat.len = quat.length;
- /**
- * Calculates the squared length of a quat
- *
- * @param {quat} a vector to calculate squared length of
- * @returns {Number} squared length of a
- * @function
- */
- quat.squaredLength = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].squaredLength;
- /**
- * Alias for {@link quat.squaredLength}
- * @function
- */
- quat.sqrLen = quat.squaredLength;
- /**
- * Normalize a quat
- *
- * @param {quat} out the receiving quaternion
- * @param {quat} a quaternion to normalize
- * @returns {quat} out
- * @function
- */
- quat.normalize = __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */].normalize;
- /**
- * Creates a quaternion from the given 3x3 rotation matrix.
- *
- * NOTE: The resultant quaternion is not normalized, so you should be sure
- * to renormalize the quaternion yourself where necessary.
- *
- * @param {quat} out the receiving quaternion
- * @param {mat3} m rotation matrix
- * @returns {quat} out
- * @function
- */
- quat.fromMat3 = function (out, m) {
- // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
- // article "Quaternion Calculus and Fast Animation".
- var fTrace = m[0] + m[4] + m[8];
- var fRoot;
- if (fTrace > 0.0) {
- // |w| > 1/2, may as well choose w > 1/2
- fRoot = Math.sqrt(fTrace + 1.0); // 2w
- out[3] = 0.5 * fRoot;
- fRoot = 0.5 / fRoot; // 1/(4w)
- out[0] = (m[5] - m[7]) * fRoot;
- out[1] = (m[6] - m[2]) * fRoot;
- out[2] = (m[1] - m[3]) * fRoot;
- } else {
- // |w| <= 1/2
- var i = 0;
- if (m[4] > m[0])
- i = 1;
- if (m[8] > m[i * 3 + i])
- i = 2;
- var j = (i + 1) % 3;
- var k = (i + 2) % 3;
- fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0);
- out[i] = 0.5 * fRoot;
- fRoot = 0.5 / fRoot;
- out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot;
- out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot;
- out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot;
- }
- return out;
- };
- /* harmony default export */ __webpack_exports__["a"] = (quat);
- /***/
- }),
- /* 56 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__ = __webpack_require__(55);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat3__ = __webpack_require__(34);
- /**
- * @constructor
- * @alias clay.Quaternion
- * @param {number} x
- * @param {number} y
- * @param {number} z
- * @param {number} w
- */
- var Quaternion = function (x, y, z, w) {
- x = x || 0;
- y = y || 0;
- z = z || 0;
- w = w === undefined ? 1 : w;
- /**
- * Storage of Quaternion, read and write of x, y, z, w will change the values in array
- * All methods also operate on the array instead of x, y, z, w components
- * @name array
- * @type {Float32Array}
- * @memberOf clay.Quaternion#
- */
- this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].fromValues(x, y, z, w);
- /**
- * Dirty flag is used by the Node to determine
- * if the matrix is updated to latest
- * @name _dirty
- * @type {boolean}
- * @memberOf clay.Quaternion#
- */
- this._dirty = true;
- };
- Quaternion.prototype = {
- constructor: Quaternion,
- /**
- * Add b to self
- * @param {clay.Quaternion} b
- * @return {clay.Quaternion}
- */
- add: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].add(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Calculate the w component from x, y, z component
- * @return {clay.Quaternion}
- */
- calculateW: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].calculateW(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Set x, y and z components
- * @param {number} x
- * @param {number} y
- * @param {number} z
- * @param {number} w
- * @return {clay.Quaternion}
- */
- set: function (x, y, z, w) {
- this.array[0] = x;
- this.array[1] = y;
- this.array[2] = z;
- this.array[3] = w;
- this._dirty = true;
- return this;
- },
- /**
- * Set x, y, z and w components from array
- * @param {Float32Array|number[]} arr
- * @return {clay.Quaternion}
- */
- setArray: function (arr) {
- this.array[0] = arr[0];
- this.array[1] = arr[1];
- this.array[2] = arr[2];
- this.array[3] = arr[3];
- this._dirty = true;
- return this;
- },
- /**
- * Clone a new Quaternion
- * @return {clay.Quaternion}
- */
- clone: function () {
- return new Quaternion(this.x, this.y, this.z, this.w);
- },
- /**
- * Calculates the conjugate of self If the quaternion is normalized,
- * this function is faster than invert and produces the same result.
- *
- * @return {clay.Quaternion}
- */
- conjugate: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].conjugate(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Copy from b
- * @param {clay.Quaternion} b
- * @return {clay.Quaternion}
- */
- copy: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].copy(this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Dot product of self and b
- * @param {clay.Quaternion} b
- * @return {number}
- */
- dot: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].dot(this.array, b.array);
- },
- /**
- * Set from the given 3x3 rotation matrix
- * @param {clay.Matrix3} m
- * @return {clay.Quaternion}
- */
- fromMat3: function (m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].fromMat3(this.array, m.array);
- this._dirty = true;
- return this;
- },
- /**
- * Set from the given 4x4 rotation matrix
- * The 4th column and 4th row will be droped
- * @param {clay.Matrix4} m
- * @return {clay.Quaternion}
- */
- fromMat4: (function () {
- var m3 = __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat3__["a" /* default */].create();
- return function (m) {
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat3__["a" /* default */].fromMat4(m3, m.array);
- // TODO Not like mat4, mat3 in glmatrix seems to be row-based
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat3__["a" /* default */].transpose(m3, m3);
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].fromMat3(this.array, m3);
- this._dirty = true;
- return this;
- };
- })(),
- /**
- * Set to identity quaternion
- * @return {clay.Quaternion}
- */
- identity: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].identity(this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Invert self
- * @return {clay.Quaternion}
- */
- invert: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].invert(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias of length
- * @return {number}
- */
- len: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].len(this.array);
- },
- /**
- * Calculate the length
- * @return {number}
- */
- length: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].length(this.array);
- },
- /**
- * Linear interpolation between a and b
- * @param {clay.Quaternion} a
- * @param {clay.Quaternion} b
- * @param {number} t
- * @return {clay.Quaternion}
- */
- lerp: function (a, b, t) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].lerp(this.array, a.array, b.array, t);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for multiply
- * @param {clay.Quaternion} b
- * @return {clay.Quaternion}
- */
- mul: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].mul(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for multiplyLeft
- * @param {clay.Quaternion} a
- * @return {clay.Quaternion}
- */
- mulLeft: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].multiply(this.array, a.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Mutiply self and b
- * @param {clay.Quaternion} b
- * @return {clay.Quaternion}
- */
- multiply: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].multiply(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Mutiply a and self
- * Quaternion mutiply is not commutative, so the result of mutiplyLeft is different with multiply.
- * @param {clay.Quaternion} a
- * @return {clay.Quaternion}
- */
- multiplyLeft: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].multiply(this.array, a.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Normalize self
- * @return {clay.Quaternion}
- */
- normalize: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].normalize(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Rotate self by a given radian about X axis
- * @param {number} rad
- * @return {clay.Quaternion}
- */
- rotateX: function (rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateX(this.array, this.array, rad);
- this._dirty = true;
- return this;
- },
- /**
- * Rotate self by a given radian about Y axis
- * @param {number} rad
- * @return {clay.Quaternion}
- */
- rotateY: function (rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateY(this.array, this.array, rad);
- this._dirty = true;
- return this;
- },
- /**
- * Rotate self by a given radian about Z axis
- * @param {number} rad
- * @return {clay.Quaternion}
- */
- rotateZ: function (rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateZ(this.array, this.array, rad);
- this._dirty = true;
- return this;
- },
- /**
- * Sets self to represent the shortest rotation from Vector3 a to Vector3 b.
- * a and b needs to be normalized
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Quaternion}
- */
- rotationTo: function (a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotationTo(this.array, a.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Sets self with values corresponding to the given axes
- * @param {clay.Vector3} view
- * @param {clay.Vector3} right
- * @param {clay.Vector3} up
- * @return {clay.Quaternion}
- */
- setAxes: function (view, right, up) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].setAxes(this.array, view.array, right.array, up.array);
- this._dirty = true;
- return this;
- },
- /**
- * Sets self with a rotation axis and rotation angle
- * @param {clay.Vector3} axis
- * @param {number} rad
- * @return {clay.Quaternion}
- */
- setAxisAngle: function (axis, rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].setAxisAngle(this.array, axis.array, rad);
- this._dirty = true;
- return this;
- },
- /**
- * Perform spherical linear interpolation between a and b
- * @param {clay.Quaternion} a
- * @param {clay.Quaternion} b
- * @param {number} t
- * @return {clay.Quaternion}
- */
- slerp: function (a, b, t) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].slerp(this.array, a.array, b.array, t);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for squaredLength
- * @return {number}
- */
- sqrLen: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].sqrLen(this.array);
- },
- /**
- * Squared length of self
- * @return {number}
- */
- squaredLength: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].squaredLength(this.array);
- },
- /**
- * Set from euler
- * @param {clay.Vector3} v
- * @param {String} order
- */
- fromEuler: function (v, order) {
- return Quaternion.fromEuler(this, v, order);
- },
- toString: function () {
- return '[' + Array.prototype.join.call(this.array, ',') + ']';
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array);
- }
- };
- var defineProperty = Object.defineProperty;
- // Getter and Setter
- if (defineProperty) {
- var proto = Quaternion.prototype;
- /**
- * @name x
- * @type {number}
- * @memberOf clay.Quaternion
- * @instance
- */
- defineProperty(proto, 'x', {
- get: function () {
- return this.array[0];
- },
- set: function (value) {
- this.array[0] = value;
- this._dirty = true;
- }
- });
- /**
- * @name y
- * @type {number}
- * @memberOf clay.Quaternion
- * @instance
- */
- defineProperty(proto, 'y', {
- get: function () {
- return this.array[1];
- },
- set: function (value) {
- this.array[1] = value;
- this._dirty = true;
- }
- });
- /**
- * @name z
- * @type {number}
- * @memberOf clay.Quaternion
- * @instance
- */
- defineProperty(proto, 'z', {
- get: function () {
- return this.array[2];
- },
- set: function (value) {
- this.array[2] = value;
- this._dirty = true;
- }
- });
- /**
- * @name w
- * @type {number}
- * @memberOf clay.Quaternion
- * @instance
- */
- defineProperty(proto, 'w', {
- get: function () {
- return this.array[3];
- },
- set: function (value) {
- this.array[3] = value;
- this._dirty = true;
- }
- });
- }
- // Supply methods that are not in place
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @param {clay.Quaternion} b
- * @return {clay.Quaternion}
- */
- Quaternion.add = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].add(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {number} x
- * @param {number} y
- * @param {number} z
- * @param {number} w
- * @return {clay.Quaternion}
- */
- Quaternion.set = function (out, x, y, z, w) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].set(out.array, x, y, z, w);
- out._dirty = true;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} b
- * @return {clay.Quaternion}
- */
- Quaternion.copy = function (out, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].copy(out.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @return {clay.Quaternion}
- */
- Quaternion.calculateW = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].calculateW(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @return {clay.Quaternion}
- */
- Quaternion.conjugate = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].conjugate(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @return {clay.Quaternion}
- */
- Quaternion.identity = function (out) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].identity(out.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @return {clay.Quaternion}
- */
- Quaternion.invert = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].invert(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} a
- * @param {clay.Quaternion} b
- * @return {number}
- */
- Quaternion.dot = function (a, b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].dot(a.array, b.array);
- };
- /**
- * @param {clay.Quaternion} a
- * @return {number}
- */
- Quaternion.len = function (a) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].length(a.array);
- };
- // Quaternion.length = Quaternion.len;
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @param {clay.Quaternion} b
- * @param {number} t
- * @return {clay.Quaternion}
- */
- Quaternion.lerp = function (out, a, b, t) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].lerp(out.array, a.array, b.array, t);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @param {clay.Quaternion} b
- * @param {number} t
- * @return {clay.Quaternion}
- */
- Quaternion.slerp = function (out, a, b, t) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].slerp(out.array, a.array, b.array, t);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @param {clay.Quaternion} b
- * @return {clay.Quaternion}
- */
- Quaternion.mul = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].multiply(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @param {clay.Quaternion} b
- * @return {clay.Quaternion}
- */
- Quaternion.multiply = Quaternion.mul;
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @param {number} rad
- * @return {clay.Quaternion}
- */
- Quaternion.rotateX = function (out, a, rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateX(out.array, a.array, rad);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @param {number} rad
- * @return {clay.Quaternion}
- */
- Quaternion.rotateY = function (out, a, rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateY(out.array, a.array, rad);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @param {number} rad
- * @return {clay.Quaternion}
- */
- Quaternion.rotateZ = function (out, a, rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotateZ(out.array, a.array, rad);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Vector3} axis
- * @param {number} rad
- * @return {clay.Quaternion}
- */
- Quaternion.setAxisAngle = function (out, axis, rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].setAxisAngle(out.array, axis.array, rad);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Quaternion} a
- * @return {clay.Quaternion}
- */
- Quaternion.normalize = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].normalize(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} a
- * @return {number}
- */
- Quaternion.sqrLen = function (a) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].sqrLen(a.array);
- };
- /**
- * @function
- * @param {clay.Quaternion} a
- * @return {number}
- */
- Quaternion.squaredLength = Quaternion.sqrLen;
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Matrix3} m
- * @return {clay.Quaternion}
- */
- Quaternion.fromMat3 = function (out, m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].fromMat3(out.array, m.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Vector3} view
- * @param {clay.Vector3} right
- * @param {clay.Vector3} up
- * @return {clay.Quaternion}
- */
- Quaternion.setAxes = function (out, view, right, up) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].setAxes(out.array, view.array, right.array, up.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Quaternion} out
- * @param {clay.Vector3} a
- * @param {clay.Vector3} b
- * @return {clay.Quaternion}
- */
- Quaternion.rotationTo = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_quat__["a" /* default */].rotationTo(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * Set quaternion from euler
- * @param {clay.Quaternion} out
- * @param {clay.Vector3} v
- * @param {String} order
- */
- Quaternion.fromEuler = function (out, v, order) {
- out._dirty = true;
- v = v.array;
- var target = out.array;
- var c1 = Math.cos(v[0] / 2);
- var c2 = Math.cos(v[1] / 2);
- var c3 = Math.cos(v[2] / 2);
- var s1 = Math.sin(v[0] / 2);
- var s2 = Math.sin(v[1] / 2);
- var s3 = Math.sin(v[2] / 2);
- var order = (order || 'XYZ').toUpperCase();
- // http://www.mathworks.com/matlabcentral/fileexchange/
- // 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
- // content/SpinCalc.m
- switch (order) {
- case 'XYZ':
- target[0] = s1 * c2 * c3 + c1 * s2 * s3;
- target[1] = c1 * s2 * c3 - s1 * c2 * s3;
- target[2] = c1 * c2 * s3 + s1 * s2 * c3;
- target[3] = c1 * c2 * c3 - s1 * s2 * s3;
- break;
- case 'YXZ':
- target[0] = s1 * c2 * c3 + c1 * s2 * s3;
- target[1] = c1 * s2 * c3 - s1 * c2 * s3;
- target[2] = c1 * c2 * s3 - s1 * s2 * c3;
- target[3] = c1 * c2 * c3 + s1 * s2 * s3;
- break;
- case 'ZXY':
- target[0] = s1 * c2 * c3 - c1 * s2 * s3;
- target[1] = c1 * s2 * c3 + s1 * c2 * s3;
- target[2] = c1 * c2 * s3 + s1 * s2 * c3;
- target[3] = c1 * c2 * c3 - s1 * s2 * s3;
- break;
- case 'ZYX':
- target[0] = s1 * c2 * c3 - c1 * s2 * s3;
- target[1] = c1 * s2 * c3 + s1 * c2 * s3;
- target[2] = c1 * c2 * s3 - s1 * s2 * c3;
- target[3] = c1 * c2 * c3 + s1 * s2 * s3;
- break;
- case 'YZX':
- target[0] = s1 * c2 * c3 + c1 * s2 * s3;
- target[1] = c1 * s2 * c3 + s1 * c2 * s3;
- target[2] = c1 * c2 * s3 - s1 * s2 * c3;
- target[3] = c1 * c2 * c3 - s1 * s2 * s3;
- break;
- case 'XZY':
- target[0] = s1 * c2 * c3 - c1 * s2 * s3;
- target[1] = c1 * s2 * c3 - s1 * c2 * s3;
- target[2] = c1 * c2 * s3 + s1 * s2 * c3;
- target[3] = c1 * c2 * c3 + s1 * s2 * s3;
- break;
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (Quaternion);
- /***/
- }),
- /* 57 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var DIRTY_PREFIX = '__dt__';
- var Cache = function () {
- this._contextId = 0;
- this._caches = [];
- this._context = {};
- };
- Cache.prototype = {
- use: function (contextId, documentSchema) {
- var caches = this._caches;
- if (!caches[contextId]) {
- caches[contextId] = {};
- if (documentSchema) {
- caches[contextId] = documentSchema();
- }
- }
- this._contextId = contextId;
- this._context = caches[contextId];
- },
- put: function (key, value) {
- this._context[key] = value;
- },
- get: function (key) {
- return this._context[key];
- },
- dirty: function (field) {
- field = field || '';
- var key = DIRTY_PREFIX + field;
- this.put(key, true);
- },
- dirtyAll: function (field) {
- field = field || '';
- var key = DIRTY_PREFIX + field;
- var caches = this._caches;
- for (var i = 0; i < caches.length; i++) {
- if (caches[i]) {
- caches[i][key] = true;
- }
- }
- },
- fresh: function (field) {
- field = field || '';
- var key = DIRTY_PREFIX + field;
- this.put(key, false);
- },
- freshAll: function (field) {
- field = field || '';
- var key = DIRTY_PREFIX + field;
- var caches = this._caches;
- for (var i = 0; i < caches.length; i++) {
- if (caches[i]) {
- caches[i][key] = false;
- }
- }
- },
- isDirty: function (field) {
- field = field || '';
- var key = DIRTY_PREFIX + field;
- var context = this._context;
- return !context.hasOwnProperty(key)
- || context[key] === true;
- },
- deleteContext: function (contextId) {
- delete this._caches[contextId];
- this._context = {};
- },
- delete: function (key) {
- delete this._context[key];
- },
- clearAll: function () {
- this._caches = {};
- },
- getContext: function () {
- return this._context;
- },
- eachContext: function (cb, context) {
- var keys = Object.keys(this._caches);
- keys.forEach(function (key) {
- cb && cb.call(context, key);
- });
- },
- miss: function (key) {
- return !this._context.hasOwnProperty(key);
- }
- };
- Cache.prototype.constructor = Cache;
- /* harmony default export */ __webpack_exports__["a"] = (Cache);
- /***/
- }),
- /* 58 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(35);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Frustum__ = __webpack_require__(59);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Ray__ = __webpack_require__(54);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__ = __webpack_require__(33);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__glmatrix_vec3__ = __webpack_require__(12);
- /**
- * @constructor clay.Camera
- * @extends clay.Node
- */
- var Camera = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(function () {
- return /** @lends clay.Camera# */ {
- /**
- * Camera projection matrix
- * @type {clay.Matrix4}
- */
- projectionMatrix: new __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__["a" /* default */](),
- /**
- * Inverse of camera projection matrix
- * @type {clay.Matrix4}
- */
- invProjectionMatrix: new __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__["a" /* default */](),
- /**
- * View matrix, equal to inverse of camera's world matrix
- * @type {clay.Matrix4}
- */
- viewMatrix: new __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__["a" /* default */](),
- /**
- * Camera frustum in view space
- * @type {clay.Frustum}
- */
- frustum: new __WEBPACK_IMPORTED_MODULE_2__math_Frustum__["a" /* default */]()
- };
- }, function () {
- this.update(true);
- },
- /** @lends clay.Camera.prototype */
- {
- update: function (force) {
- __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].prototype.update.call(this, force);
- __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__["a" /* default */].invert(this.viewMatrix, this.worldTransform);
- this.updateProjectionMatrix();
- __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__["a" /* default */].invert(this.invProjectionMatrix, this.projectionMatrix);
- this.frustum.setFromProjection(this.projectionMatrix);
- },
- /**
- * Set camera view matrix
- */
- setViewMatrix: function (viewMatrix) {
- __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__["a" /* default */].copy(this.viewMatrix, viewMatrix);
- __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__["a" /* default */].invert(this.worldTransform, viewMatrix);
- this.decomposeWorldTransform();
- },
- /**
- * Decompose camera projection matrix
- */
- decomposeProjectionMatrix: function () { },
- /**
- * Set camera projection matrix
- * @param {clay.Matrix4} projectionMatrix
- */
- setProjectionMatrix: function (projectionMatrix) {
- __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__["a" /* default */].copy(this.projectionMatrix, projectionMatrix);
- __WEBPACK_IMPORTED_MODULE_1__math_Matrix4__["a" /* default */].invert(this.invProjectionMatrix, projectionMatrix);
- this.decomposeProjectionMatrix();
- },
- /**
- * Update projection matrix, called after update
- */
- updateProjectionMatrix: function () { },
- /**
- * Cast a picking ray from camera near plane to far plane
- * @function
- * @param {clay.Vector2} ndc
- * @param {clay.Ray} [out]
- * @return {clay.Ray}
- */
- castRay: (function () {
- var v4 = __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].create();
- return function (ndc, out) {
- var ray = out !== undefined ? out : new __WEBPACK_IMPORTED_MODULE_3__math_Ray__["a" /* default */]();
- var x = ndc.array[0];
- var y = ndc.array[1];
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].set(v4, x, y, -1, 1);
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].transformMat4(v4, v4, this.invProjectionMatrix.array);
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].transformMat4(v4, v4, this.worldTransform.array);
- __WEBPACK_IMPORTED_MODULE_5__glmatrix_vec3__["a" /* default */].scale(ray.origin.array, v4, 1 / v4[3]);
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].set(v4, x, y, 1, 1);
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].transformMat4(v4, v4, this.invProjectionMatrix.array);
- __WEBPACK_IMPORTED_MODULE_4__glmatrix_vec4__["a" /* default */].transformMat4(v4, v4, this.worldTransform.array);
- __WEBPACK_IMPORTED_MODULE_5__glmatrix_vec3__["a" /* default */].scale(v4, v4, 1 / v4[3]);
- __WEBPACK_IMPORTED_MODULE_5__glmatrix_vec3__["a" /* default */].sub(ray.direction.array, v4, ray.origin.array);
- __WEBPACK_IMPORTED_MODULE_5__glmatrix_vec3__["a" /* default */].normalize(ray.direction.array, ray.direction.array);
- ray.direction._dirty = true;
- ray.origin._dirty = true;
- return ray;
- };
- })(),
- /**
- * @function
- * @name clone
- * @return {clay.Camera}
- * @memberOf clay.Camera.prototype
- */
- });
- /* harmony default export */ __webpack_exports__["a"] = (Camera);
- /***/
- }),
- /* 59 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__BoundingBox__ = __webpack_require__(18);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Plane__ = __webpack_require__(74);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__ = __webpack_require__(12);
- var vec3Set = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].set;
- var vec3Copy = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].copy;
- var vec3TranformMat4 = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].transformMat4;
- var mathMin = Math.min;
- var mathMax = Math.max;
- /**
- * @constructor
- * @alias clay.Frustum
- */
- var Frustum = function () {
- /**
- * Eight planes to enclose the frustum
- * @type {clay.Plane[]}
- */
- this.planes = [];
- for (var i = 0; i < 6; i++) {
- this.planes.push(new __WEBPACK_IMPORTED_MODULE_1__Plane__["a" /* default */]());
- }
- /**
- * Bounding box of frustum
- * @type {clay.BoundingBox}
- */
- this.boundingBox = new __WEBPACK_IMPORTED_MODULE_0__BoundingBox__["a" /* default */]();
- /**
- * Eight vertices of frustum
- * @type {Float32Array[]}
- */
- this.vertices = [];
- for (var i = 0; i < 8; i++) {
- this.vertices[i] = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].fromValues(0, 0, 0);
- }
- };
- Frustum.prototype = {
- // http://web.archive.org/web/20120531231005/http://crazyjoke.free.fr/doc/3D/plane%20extraction.pdf
- /**
- * Set frustum from a projection matrix
- * @param {clay.Matrix4} projectionMatrix
- */
- setFromProjection: function (projectionMatrix) {
- var planes = this.planes;
- var m = projectionMatrix.array;
- var m0 = m[0], m1 = m[1], m2 = m[2], m3 = m[3];
- var m4 = m[4], m5 = m[5], m6 = m[6], m7 = m[7];
- var m8 = m[8], m9 = m[9], m10 = m[10], m11 = m[11];
- var m12 = m[12], m13 = m[13], m14 = m[14], m15 = m[15];
- // Update planes
- vec3Set(planes[0].normal.array, m3 - m0, m7 - m4, m11 - m8);
- planes[0].distance = -(m15 - m12);
- planes[0].normalize();
- vec3Set(planes[1].normal.array, m3 + m0, m7 + m4, m11 + m8);
- planes[1].distance = -(m15 + m12);
- planes[1].normalize();
- vec3Set(planes[2].normal.array, m3 + m1, m7 + m5, m11 + m9);
- planes[2].distance = -(m15 + m13);
- planes[2].normalize();
- vec3Set(planes[3].normal.array, m3 - m1, m7 - m5, m11 - m9);
- planes[3].distance = -(m15 - m13);
- planes[3].normalize();
- vec3Set(planes[4].normal.array, m3 - m2, m7 - m6, m11 - m10);
- planes[4].distance = -(m15 - m14);
- planes[4].normalize();
- vec3Set(planes[5].normal.array, m3 + m2, m7 + m6, m11 + m10);
- planes[5].distance = -(m15 + m14);
- planes[5].normalize();
- // Perspective projection
- var boundingBox = this.boundingBox;
- var vertices = this.vertices;
- if (m15 === 0) {
- var aspect = m5 / m0;
- var zNear = -m14 / (m10 - 1);
- var zFar = -m14 / (m10 + 1);
- var farY = -zFar / m5;
- var nearY = -zNear / m5;
- // Update bounding box
- boundingBox.min.set(-farY * aspect, -farY, zFar);
- boundingBox.max.set(farY * aspect, farY, zNear);
- // update vertices
- //--- min z
- // min x
- vec3Set(vertices[0], -farY * aspect, -farY, zFar);
- vec3Set(vertices[1], -farY * aspect, farY, zFar);
- // max x
- vec3Set(vertices[2], farY * aspect, -farY, zFar);
- vec3Set(vertices[3], farY * aspect, farY, zFar);
- //-- max z
- vec3Set(vertices[4], -nearY * aspect, -nearY, zNear);
- vec3Set(vertices[5], -nearY * aspect, nearY, zNear);
- vec3Set(vertices[6], nearY * aspect, -nearY, zNear);
- vec3Set(vertices[7], nearY * aspect, nearY, zNear);
- }
- else { // Orthographic projection
- var left = (-1 - m12) / m0;
- var right = (1 - m12) / m0;
- var top = (1 - m13) / m5;
- var bottom = (-1 - m13) / m5;
- var near = (-1 - m14) / m10;
- var far = (1 - m14) / m10;
- boundingBox.min.set(Math.min(left, right), Math.min(bottom, top), Math.min(far, near));
- boundingBox.max.set(Math.max(right, left), Math.max(top, bottom), Math.max(near, far));
- var min = boundingBox.min.array;
- var max = boundingBox.max.array;
- //--- min z
- // min x
- vec3Set(vertices[0], min[0], min[1], min[2]);
- vec3Set(vertices[1], min[0], max[1], min[2]);
- // max x
- vec3Set(vertices[2], max[0], min[1], min[2]);
- vec3Set(vertices[3], max[0], max[1], min[2]);
- //-- max z
- vec3Set(vertices[4], min[0], min[1], max[2]);
- vec3Set(vertices[5], min[0], max[1], max[2]);
- vec3Set(vertices[6], max[0], min[1], max[2]);
- vec3Set(vertices[7], max[0], max[1], max[2]);
- }
- },
- /**
- * Apply a affine transform matrix and set to the given bounding box
- * @function
- * @param {clay.BoundingBox}
- * @param {clay.Matrix4}
- * @return {clay.BoundingBox}
- */
- getTransformedBoundingBox: (function () {
- var tmpVec3 = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].create();
- return function (bbox, matrix) {
- var vertices = this.vertices;
- var m4 = matrix.array;
- var min = bbox.min;
- var max = bbox.max;
- var minArr = min.array;
- var maxArr = max.array;
- var v = vertices[0];
- vec3TranformMat4(tmpVec3, v, m4);
- vec3Copy(minArr, tmpVec3);
- vec3Copy(maxArr, tmpVec3);
- for (var i = 1; i < 8; i++) {
- v = vertices[i];
- vec3TranformMat4(tmpVec3, v, m4);
- minArr[0] = mathMin(tmpVec3[0], minArr[0]);
- minArr[1] = mathMin(tmpVec3[1], minArr[1]);
- minArr[2] = mathMin(tmpVec3[2], minArr[2]);
- maxArr[0] = mathMax(tmpVec3[0], maxArr[0]);
- maxArr[1] = mathMax(tmpVec3[1], maxArr[1]);
- maxArr[2] = mathMax(tmpVec3[2], maxArr[2]);
- }
- min._dirty = true;
- max._dirty = true;
- return bbox;
- };
- })()
- };
- /* harmony default export */ __webpack_exports__["a"] = (Frustum);
- /***/
- }),
- /* 60 */
- /***/ (function (module, exports) {
- // Simple LRU cache use doubly linked list
- // @module zrender/core/LRU
- /**
- * Simple double linked list. Compared with array, it has O(1) remove operation.
- * @constructor
- */
- var LinkedList = function () {
- /**
- * @type {module:zrender/core/LRU~Entry}
- */
- this.head = null;
- /**
- * @type {module:zrender/core/LRU~Entry}
- */
- this.tail = null;
- this._len = 0;
- };
- var linkedListProto = LinkedList.prototype;
- /**
- * Insert a new value at the tail
- * @param {} val
- * @return {module:zrender/core/LRU~Entry}
- */
- linkedListProto.insert = function (val) {
- var entry = new Entry(val);
- this.insertEntry(entry);
- return entry;
- };
- /**
- * Insert an entry at the tail
- * @param {module:zrender/core/LRU~Entry} entry
- */
- linkedListProto.insertEntry = function (entry) {
- if (!this.head) {
- this.head = this.tail = entry;
- } else {
- this.tail.next = entry;
- entry.prev = this.tail;
- entry.next = null;
- this.tail = entry;
- }
- this._len++;
- };
- /**
- * Remove entry.
- * @param {module:zrender/core/LRU~Entry} entry
- */
- linkedListProto.remove = function (entry) {
- var prev = entry.prev;
- var next = entry.next;
- if (prev) {
- prev.next = next;
- } else {
- // Is head
- this.head = next;
- }
- if (next) {
- next.prev = prev;
- } else {
- // Is tail
- this.tail = prev;
- }
- entry.next = entry.prev = null;
- this._len--;
- };
- /**
- * @return {number}
- */
- linkedListProto.len = function () {
- return this._len;
- };
- /**
- * Clear list
- */
- linkedListProto.clear = function () {
- this.head = this.tail = null;
- this._len = 0;
- };
- /**
- * @constructor
- * @param {} val
- */
- var Entry = function (val) {
- /**
- * @type {}
- */
- this.value = val;
- /**
- * @type {module:zrender/core/LRU~Entry}
- */
- this.next;
- /**
- * @type {module:zrender/core/LRU~Entry}
- */
- this.prev;
- };
- /**
- * LRU Cache
- * @constructor
- * @alias module:zrender/core/LRU
- */
- var LRU = function (maxSize) {
- this._list = new LinkedList();
- this._map = {};
- this._maxSize = maxSize || 10;
- this._lastRemovedEntry = null;
- };
- var LRUProto = LRU.prototype;
- /**
- * @param {string} key
- * @param {} value
- * @return {} Removed value
- */
- LRUProto.put = function (key, value) {
- var list = this._list;
- var map = this._map;
- var removed = null;
- if (map[key] == null) {
- var len = list.len(); // Reuse last removed entry
- var entry = this._lastRemovedEntry;
- if (len >= this._maxSize && len > 0) {
- // Remove the least recently used
- var leastUsedEntry = list.head;
- list.remove(leastUsedEntry);
- delete map[leastUsedEntry.key];
- removed = leastUsedEntry.value;
- this._lastRemovedEntry = leastUsedEntry;
- }
- if (entry) {
- entry.value = value;
- } else {
- entry = new Entry(value);
- }
- entry.key = key;
- list.insertEntry(entry);
- map[key] = entry;
- }
- return removed;
- };
- /**
- * @param {string} key
- * @return {}
- */
- LRUProto.get = function (key) {
- var entry = this._map[key];
- var list = this._list;
- if (entry != null) {
- // Put the latest used entry in the tail
- if (entry !== list.tail) {
- list.remove(entry);
- list.insertEntry(entry);
- }
- return entry.value;
- }
- };
- /**
- * Clear the cache
- */
- LRUProto.clear = function () {
- this._list.clear();
- this._map = {};
- };
- var _default = LRU;
- module.exports = _default;
- /***/
- }),
- /* 61 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TextureCube__ = __webpack_require__(27);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_vendor__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__prePass_EnvironmentMap__ = __webpack_require__(62);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__plugin_Skydome__ = __webpack_require__(75);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Scene__ = __webpack_require__(36);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__dds__ = __webpack_require__(122);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__hdr__ = __webpack_require__(123);
- /**
- * @alias clay.util.texture
- */
- var textureUtil = {
- /**
- * @param {string|object} path
- * @param {object} [option]
- * @param {Function} [onsuccess]
- * @param {Function} [onerror]
- * @return {clay.Texture}
- */
- loadTexture: function (path, option, onsuccess, onerror) {
- var texture;
- if (typeof (option) === 'function') {
- onsuccess = option;
- onerror = onsuccess;
- option = {};
- }
- else {
- option = option || {};
- }
- if (typeof (path) === 'string') {
- if (path.match(/.hdr$/) || option.fileType === 'hdr') {
- texture = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({
- width: 0,
- height: 0,
- sRGB: false
- });
- textureUtil._fetchTexture(
- path,
- function (data) {
- __WEBPACK_IMPORTED_MODULE_7__hdr__["a" /* default */].parseRGBE(data, texture, option.exposure);
- texture.dirty();
- onsuccess && onsuccess(texture);
- },
- onerror
- );
- return texture;
- }
- else if (path.match(/.dds$/) || option.fileType === 'dds') {
- texture = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({
- width: 0,
- height: 0
- });
- textureUtil._fetchTexture(
- path,
- function (data) {
- __WEBPACK_IMPORTED_MODULE_6__dds__["a" /* default */].parse(data, texture);
- texture.dirty();
- onsuccess && onsuccess(texture);
- },
- onerror
- );
- }
- else {
- texture = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]();
- texture.load(path);
- texture.success(onsuccess);
- texture.error(onerror);
- }
- }
- else if (typeof path === 'object' && typeof (path.px) !== 'undefined') {
- texture = new __WEBPACK_IMPORTED_MODULE_1__TextureCube__["a" /* default */]();
- texture.load(path);
- texture.success(onsuccess);
- texture.error(onerror);
- }
- return texture;
- },
- /**
- * Load a panorama texture and render it to a cube map
- * @param {clay.Renderer} renderer
- * @param {string} path
- * @param {clay.TextureCube} cubeMap
- * @param {object} [option]
- * @param {boolean} [option.encodeRGBM]
- * @param {number} [option.exposure]
- * @param {Function} [onsuccess]
- * @param {Function} [onerror]
- */
- loadPanorama: function (renderer, path, cubeMap, option, onsuccess, onerror) {
- var self = this;
- if (typeof (option) === 'function') {
- onsuccess = option;
- onerror = onsuccess;
- option = {};
- }
- else {
- option = option || {};
- }
- textureUtil.loadTexture(path, option, function (texture) {
- // PENDING
- texture.flipY = option.flipY || false;
- self.panoramaToCubeMap(renderer, texture, cubeMap, option);
- texture.dispose(renderer);
- onsuccess && onsuccess(cubeMap);
- }, onerror);
- },
- /**
- * Render a panorama texture to a cube map
- * @param {clay.Renderer} renderer
- * @param {clay.Texture2D} panoramaMap
- * @param {clay.TextureCube} cubeMap
- * @param {Object} option
- * @param {boolean} [option.encodeRGBM]
- */
- panoramaToCubeMap: function (renderer, panoramaMap, cubeMap, option) {
- var environmentMapPass = new __WEBPACK_IMPORTED_MODULE_3__prePass_EnvironmentMap__["a" /* default */]();
- var skydome = new __WEBPACK_IMPORTED_MODULE_4__plugin_Skydome__["a" /* default */]({
- scene: new __WEBPACK_IMPORTED_MODULE_5__Scene__["a" /* default */]()
- });
- skydome.setEnvironmentMap(panoramaMap);
- option = option || {};
- if (option.encodeRGBM) {
- skydome.material.define('fragment', 'RGBM_ENCODE');
- }
- // Share sRGB
- cubeMap.sRGB = panoramaMap.sRGB;
- environmentMapPass.texture = cubeMap;
- environmentMapPass.render(renderer, skydome.scene);
- environmentMapPass.texture = null;
- environmentMapPass.dispose(renderer);
- return cubeMap;
- },
- /**
- * Convert height map to normal map
- * @param {HTMLImageElement|HTMLCanvasElement} image
- * @param {boolean} [checkBump=false]
- * @return {HTMLCanvasElement}
- */
- heightToNormal: function (image, checkBump) {
- var canvas = document.createElement('canvas');
- var width = canvas.width = image.width;
- var height = canvas.height = image.height;
- var ctx = canvas.getContext('2d');
- ctx.drawImage(image, 0, 0, width, height);
- checkBump = checkBump || false;
- var srcData = ctx.getImageData(0, 0, width, height);
- var dstData = ctx.createImageData(width, height);
- for (var i = 0; i < srcData.data.length; i += 4) {
- if (checkBump) {
- var r = srcData.data[i];
- var g = srcData.data[i + 1];
- var b = srcData.data[i + 2];
- var diff = Math.abs(r - g) + Math.abs(g - b);
- if (diff > 20) {
- console.warn('Given image is not a height map');
- return image;
- }
- }
- // Modified from http://mrdoob.com/lab/javascript/height2normal/
- var x1, y1, x2, y2;
- if (i % (width * 4) === 0) {
- // left edge
- x1 = srcData.data[i];
- x2 = srcData.data[i + 4];
- }
- else if (i % (width * 4) === (width - 1) * 4) {
- // right edge
- x1 = srcData.data[i - 4];
- x2 = srcData.data[i];
- }
- else {
- x1 = srcData.data[i - 4];
- x2 = srcData.data[i + 4];
- }
- if (i < width * 4) {
- // top edge
- y1 = srcData.data[i];
- y2 = srcData.data[i + width * 4];
- }
- else if (i > width * (height - 1) * 4) {
- // bottom edge
- y1 = srcData.data[i - width * 4];
- y2 = srcData.data[i];
- }
- else {
- y1 = srcData.data[i - width * 4];
- y2 = srcData.data[i + width * 4];
- }
- dstData.data[i] = (x1 - x2) + 127;
- dstData.data[i + 1] = (y1 - y2) + 127;
- dstData.data[i + 2] = 255;
- dstData.data[i + 3] = 255;
- }
- ctx.putImageData(dstData, 0, 0);
- return canvas;
- },
- /**
- * Convert height map to normal map
- * @param {HTMLImageElement|HTMLCanvasElement} image
- * @param {boolean} [checkBump=false]
- * @param {number} [threshold=20]
- * @return {HTMLCanvasElement}
- */
- isHeightImage: function (img, downScaleSize, threshold) {
- if (!img || !img.width || !img.height) {
- return false;
- }
- var canvas = document.createElement('canvas');
- var ctx = canvas.getContext('2d');
- var size = downScaleSize || 32;
- threshold = threshold || 20;
- canvas.width = canvas.height = size;
- ctx.drawImage(img, 0, 0, size, size);
- var srcData = ctx.getImageData(0, 0, size, size);
- for (var i = 0; i < srcData.data.length; i += 4) {
- var r = srcData.data[i];
- var g = srcData.data[i + 1];
- var b = srcData.data[i + 2];
- var diff = Math.abs(r - g) + Math.abs(g - b);
- if (diff > threshold) {
- return false;
- }
- }
- return true;
- },
- _fetchTexture: function (path, onsuccess, onerror) {
- __WEBPACK_IMPORTED_MODULE_2__core_vendor__["a" /* default */].request.get({
- url: path,
- responseType: 'arraybuffer',
- onload: onsuccess,
- onerror: onerror
- });
- },
- /**
- * Create a chessboard texture
- * @param {number} [size]
- * @param {number} [unitSize]
- * @param {string} [color1]
- * @param {string} [color2]
- * @return {clay.Texture2D}
- */
- createChessboard: function (size, unitSize, color1, color2) {
- size = size || 512;
- unitSize = unitSize || 64;
- color1 = color1 || 'black';
- color2 = color2 || 'white';
- var repeat = Math.ceil(size / unitSize);
- var canvas = document.createElement('canvas');
- canvas.width = size;
- canvas.height = size;
- var ctx = canvas.getContext('2d');
- ctx.fillStyle = color2;
- ctx.fillRect(0, 0, size, size);
- ctx.fillStyle = color1;
- for (var i = 0; i < repeat; i++) {
- for (var j = 0; j < repeat; j++) {
- var isFill = j % 2 ? (i % 2) : (i % 2 - 1);
- if (isFill) {
- ctx.fillRect(i * unitSize, j * unitSize, unitSize, unitSize);
- }
- }
- }
- var texture = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({
- image: canvas,
- anisotropic: 8
- });
- return texture;
- },
- /**
- * Create a blank pure color 1x1 texture
- * @param {string} color
- * @return {clay.Texture2D}
- */
- createBlank: function (color) {
- var canvas = document.createElement('canvas');
- canvas.width = 1;
- canvas.height = 1;
- var ctx = canvas.getContext('2d');
- ctx.fillStyle = color;
- ctx.fillRect(0, 0, 1, 1);
- var texture = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({
- image: canvas
- });
- return texture;
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (textureUtil);
- /***/
- }),
- /* 62 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__camera_Perspective__ = __webpack_require__(41);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__ = __webpack_require__(10);
- var targets = ['px', 'nx', 'py', 'ny', 'pz', 'nz'];
- /**
- * Pass rendering scene to a environment cube map
- *
- * @constructor clay.prePass.EnvironmentMap
- * @extends clay.core.Base
- * @example
- * // Example of car reflection
- * var envMap = new clay.TextureCube({
- * width: 256,
- * height: 256
- * });
- * var envPass = new clay.prePass.EnvironmentMap({
- * position: car.position,
- * texture: envMap
- * });
- * var carBody = car.getChildByName('body');
- * carBody.material.enableTexture('environmentMap');
- * carBody.material.set('environmentMap', envMap);
- * ...
- * animation.on('frame', function(frameTime) {
- * envPass.render(renderer, scene);
- * renderer.render(scene, camera);
- * });
- */
- var EnvironmentMapPass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () {
- var ret = /** @lends clay.prePass.EnvironmentMap# */ {
- /**
- * Camera position
- * @type {clay.Vector3}
- * @memberOf clay.prePass.EnvironmentMap#
- */
- position: new __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */](),
- /**
- * Camera far plane
- * @type {number}
- * @memberOf clay.prePass.EnvironmentMap#
- */
- far: 1000,
- /**
- * Camera near plane
- * @type {number}
- * @memberOf clay.prePass.EnvironmentMap#
- */
- near: 0.1,
- /**
- * Environment cube map
- * @type {clay.TextureCube}
- * @memberOf clay.prePass.EnvironmentMap#
- */
- texture: null,
- /**
- * Used if you wan't have shadow in environment map
- * @type {clay.prePass.ShadowMap}
- */
- shadowMapPass: null,
- };
- var cameras = ret._cameras = {
- px: new __WEBPACK_IMPORTED_MODULE_2__camera_Perspective__["a" /* default */]({ fov: 90 }),
- nx: new __WEBPACK_IMPORTED_MODULE_2__camera_Perspective__["a" /* default */]({ fov: 90 }),
- py: new __WEBPACK_IMPORTED_MODULE_2__camera_Perspective__["a" /* default */]({ fov: 90 }),
- ny: new __WEBPACK_IMPORTED_MODULE_2__camera_Perspective__["a" /* default */]({ fov: 90 }),
- pz: new __WEBPACK_IMPORTED_MODULE_2__camera_Perspective__["a" /* default */]({ fov: 90 }),
- nz: new __WEBPACK_IMPORTED_MODULE_2__camera_Perspective__["a" /* default */]({ fov: 90 })
- };
- cameras.px.lookAt(__WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].POSITIVE_X, __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].NEGATIVE_Y);
- cameras.nx.lookAt(__WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].NEGATIVE_X, __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].NEGATIVE_Y);
- cameras.py.lookAt(__WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].POSITIVE_Y, __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].POSITIVE_Z);
- cameras.ny.lookAt(__WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].NEGATIVE_Y, __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].NEGATIVE_Z);
- cameras.pz.lookAt(__WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].POSITIVE_Z, __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].NEGATIVE_Y);
- cameras.nz.lookAt(__WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].NEGATIVE_Z, __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].NEGATIVE_Y);
- // FIXME In windows, use one framebuffer only renders one side of cubemap
- ret._frameBuffer = new __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__["a" /* default */]();
- return ret;
- }, /** @lends clay.prePass.EnvironmentMap# */ {
- /**
- * @param {string} target
- * @return {clay.Camera}
- */
- getCamera: function (target) {
- return this._cameras[target];
- },
- /**
- * @param {clay.Renderer} renderer
- * @param {clay.Scene} scene
- * @param {boolean} [notUpdateScene=false]
- */
- render: function (renderer, scene, notUpdateScene) {
- var _gl = renderer.gl;
- if (!notUpdateScene) {
- scene.update();
- }
- // Tweak fov
- // http://the-witness.net/news/2012/02/seamless-cube-map-filtering/
- var n = this.texture.width;
- var fov = 2 * Math.atan(n / (n - 0.5)) / Math.PI * 180;
- for (var i = 0; i < 6; i++) {
- var target = targets[i];
- var camera = this._cameras[target];
- __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */].copy(camera.position, this.position);
- camera.far = this.far;
- camera.near = this.near;
- camera.fov = fov;
- if (this.shadowMapPass) {
- camera.update();
- // update boundingBoxLastFrame
- var bbox = scene.getBoundingBox();
- bbox.applyTransform(camera.viewMatrix);
- scene.viewBoundingBoxLastFrame.copy(bbox);
- this.shadowMapPass.render(renderer, scene, camera, true);
- }
- this._frameBuffer.attach(
- this.texture, _gl.COLOR_ATTACHMENT0,
- _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i
- );
- this._frameBuffer.bind(renderer);
- renderer.render(scene, camera, true);
- this._frameBuffer.unbind(renderer);
- }
- },
- /**
- * @param {clay.Renderer} renderer
- */
- dispose: function (renderer) {
- this._frameBuffer.dispose(renderer);
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (EnvironmentMapPass);
- /***/
- }),
- /* 63 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geometry_Sprites__ = __webpack_require__(165);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__shader_labels_glsl_js__ = __webpack_require__(166);
- __WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_2__shader_labels_glsl_js__["a" /* default */]);
- /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].Mesh.extend(function () {
- var geometry = new __WEBPACK_IMPORTED_MODULE_1__geometry_Sprites__["a" /* default */]({
- dynamic: true
- });
- var material = new __WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].Material({
- shader: __WEBPACK_IMPORTED_MODULE_0__graphicGL__["a" /* default */].createShader('ecgl.labels'),
- transparent: true,
- depthMask: false
- });
- return {
- geometry: geometry,
- material: material,
- culling: false,
- castShadow: false,
- ignorePicking: true
- };
- }));
- /***/
- }),
- /* 64 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_earcut__ = __webpack_require__(204);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(25);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_geometry_trianglesSortMixin__ = __webpack_require__(65);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__LabelsBuilder__ = __webpack_require__(66);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_shader_lines3D_glsl_js__ = __webpack_require__(46);
- var vec3 = __WEBPACK_IMPORTED_MODULE_5_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_8__util_shader_lines3D_glsl_js__["a" /* default */]);
- function Geo3DBuilder(api) {
- this.rootNode = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- // Cache triangulation result
- this._triangulationResults = {};
- this._shadersMap = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].COMMON_SHADERS.reduce(function (obj, shaderName) {
- obj[shaderName] = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.' + shaderName);
- return obj;
- }, {});
- this._linesShader = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.meshLines3D');
- var groundMaterials = {};
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].COMMON_SHADERS.forEach(function (shading) {
- groundMaterials[shading] = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.' + shading)
- });
- });
- this._groundMaterials = groundMaterials;
- this._groundMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].PlaneGeometry({ dynamic: true }),
- castShadow: false,
- renderNormal: true,
- $ignorePicking: true
- });
- this._groundMesh.rotation.rotateX(-Math.PI / 2);
- this._labelsBuilder = new __WEBPACK_IMPORTED_MODULE_7__LabelsBuilder__["a" /* default */](512, 512, api);
- // Give a large render order.
- this._labelsBuilder.getMesh().renderOrder = 100;
- this._labelsBuilder.getMesh().material.depthTest = false;
- this.rootNode.add(this._labelsBuilder.getMesh());
- this._initMeshes();
- this._api = api;
- }
- Geo3DBuilder.prototype = {
- constructor: Geo3DBuilder,
- // Which dimension to extrude. Y or Z
- extrudeY: true,
- update: function (componentModel, ecModel, api, start, end) {
- var data = componentModel.getData();
- if (start == null) {
- start = 0;
- }
- if (end == null) {
- end = data.count();
- }
- this._startIndex = start;
- this._endIndex = end - 1;
- this._triangulation(componentModel, start, end);
- var shader = this._getShader(componentModel.get('shading'));
- this._prepareMesh(componentModel, shader, api, start, end);
- this.rootNode.updateWorldTransform();
- this._updateRegionMesh(componentModel, api, start, end);
- var coordSys = componentModel.coordinateSystem;
- // PENDING
- if (coordSys.type === 'geo3D') {
- this._updateGroundPlane(componentModel, coordSys, api);
- }
- var self = this;
- this._labelsBuilder.updateData(data, start, end);
- this._labelsBuilder.getLabelPosition = function (dataIndex, positionDesc, distance) {
- var name = data.getName(dataIndex);
- var center;
- var height = distance;
- if (coordSys.type === 'geo3D') {
- var region = coordSys.getRegion(name);
- if (!region) {
- return [NaN, NaN, NaN];
- }
- center = region.center;
- var pos = coordSys.dataToPoint([center[0], center[1], height]);
- return pos;
- }
- else {
- var tmp = self._triangulationResults[dataIndex - self._startIndex];
- var center = self.extrudeY ? [
- (tmp.max[0] + tmp.min[0]) / 2,
- tmp.max[1] + height,
- (tmp.max[2] + tmp.min[2]) / 2
- ] : [
- (tmp.max[0] + tmp.min[0]) / 2,
- (tmp.max[1] + tmp.min[1]) / 2,
- tmp.max[2] + height
- ];
- }
- };
- this._data = data;
- this._labelsBuilder.updateLabels();
- this._updateDebugWireframe(componentModel);
- // Reset some state.
- this._lastHoverDataIndex = 0;
- },
- _initMeshes: function () {
- var self = this;
- function createPolygonMesh() {
- var mesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- name: 'Polygon',
- material: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- shader: self._shadersMap.lambert
- }),
- geometry: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Geometry({
- sortTriangles: true,
- dynamic: true
- }),
- // TODO Disable culling
- culling: false,
- ignorePicking: true,
- // Render normal in normal pass
- renderNormal: true
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend(mesh.geometry, __WEBPACK_IMPORTED_MODULE_6__util_geometry_trianglesSortMixin__["a" /* default */]);
- return mesh;
- }
- var polygonMesh = createPolygonMesh();
- var linesMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- material: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- shader: this._linesShader
- }),
- castShadow: false,
- ignorePicking: true,
- $ignorePicking: true,
- geometry: new __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__["a" /* default */]({
- useNativeLine: false
- })
- });
- this.rootNode.add(polygonMesh);
- this.rootNode.add(linesMesh);
- polygonMesh.material.define('both', 'VERTEX_COLOR');
- polygonMesh.material.define('fragment', 'DOUBLE_SIDED');
- this._polygonMesh = polygonMesh;
- this._linesMesh = linesMesh;
- this.rootNode.add(this._groundMesh);
- },
- _getShader: function (shading) {
- var shader = this._shadersMap[shading];
- if (!shader) {
- if (true) {
- console.warn('Unkown shading ' + shading);
- }
- // Default use lambert shader.
- shader = this._shadersMap.lambert;
- }
- shader.__shading = shading;
- return shader;
- },
- _prepareMesh: function (componentModel, shader, api, start, end) {
- var polygonVertexCount = 0;
- var polygonTriangleCount = 0;
- var linesVertexCount = 0;
- var linesTriangleCount = 0;
- // TODO Lines
- for (var idx = start; idx < end; idx++) {
- var polyInfo = this._getRegionPolygonInfo(idx);
- var lineInfo = this._getRegionLinesInfo(idx, componentModel, this._linesMesh.geometry);
- polygonVertexCount += polyInfo.vertexCount;
- polygonTriangleCount += polyInfo.triangleCount;
- linesVertexCount += lineInfo.vertexCount;
- linesTriangleCount += lineInfo.triangleCount;
- }
- var polygonMesh = this._polygonMesh;
- var polygonGeo = polygonMesh.geometry;
- ['position', 'normal', 'texcoord0', 'color'].forEach(function (attrName) {
- polygonGeo.attributes[attrName].init(polygonVertexCount);
- });
- polygonGeo.indices = polygonVertexCount > 0xffff ? new Uint32Array(polygonTriangleCount * 3) : new Uint16Array(polygonTriangleCount * 3);
- if (polygonMesh.material.shader !== shader) {
- polygonMesh.material.attachShader(shader, true);
- }
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].setMaterialFromModel(shader.__shading, polygonMesh.material, componentModel, api);
- if (linesVertexCount > 0) {
- this._linesMesh.geometry.resetOffset();
- this._linesMesh.geometry.setVertexCount(linesVertexCount);
- this._linesMesh.geometry.setTriangleCount(linesTriangleCount);
- }
- // Indexing data index from vertex index.
- this._dataIndexOfVertex = new Uint32Array(polygonVertexCount);
- // Indexing vertex index range from data index
- this._vertexRangeOfDataIndex = new Uint32Array((end - start) * 2);
- },
- _updateRegionMesh: function (componentModel, api, start, end) {
- var data = componentModel.getData();
- var vertexOffset = 0;
- var triangleOffset = 0;
- // Materials configurations.
- var hasTranparentRegion = false;
- var polygonMesh = this._polygonMesh;
- var linesMesh = this._linesMesh;
- for (var dataIndex = start; dataIndex < end; dataIndex++) {
- // Get bunch of visual properties.
- var regionModel = componentModel.getRegionModel(dataIndex);
- var itemStyleModel = regionModel.getModel('itemStyle');
- var color = itemStyleModel.get('color');
- var opacity = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(itemStyleModel.get('opacity'), 1.0);
- // Use visual color if it is encoded by visualMap component
- var visualColor = data.getItemVisual(dataIndex, 'color', true);
- if (visualColor != null && data.hasValue(dataIndex)) {
- color = visualColor;
- }
- // Set color, opacity to visual for label usage.
- data.setItemVisual(dataIndex, 'color', color);
- data.setItemVisual(dataIndex, 'opacity', opacity);
- color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color);
- var borderColor = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(itemStyleModel.get('borderColor'));
- color[3] *= opacity;
- borderColor[3] *= opacity;
- var isTransparent = color[3] < 0.99;
- polygonMesh.material.set('color', [1, 1, 1, 1]);
- hasTranparentRegion = hasTranparentRegion || isTransparent;
- var regionHeight = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(regionModel.get('height', true), componentModel.get('regionHeight'));
- var newOffsets = this._updatePolygonGeometry(
- componentModel, polygonMesh.geometry, dataIndex, regionHeight,
- vertexOffset, triangleOffset, color
- );
- for (var i = vertexOffset; i < newOffsets.vertexOffset; i++) {
- this._dataIndexOfVertex[i] = dataIndex;
- }
- this._vertexRangeOfDataIndex[(dataIndex - start) * 2] = vertexOffset;
- this._vertexRangeOfDataIndex[(dataIndex - start) * 2 + 1] = newOffsets.vertexOffset;
- vertexOffset = newOffsets.vertexOffset;
- triangleOffset = newOffsets.triangleOffset;
- // Update lines.
- var lineWidth = itemStyleModel.get('borderWidth');
- var hasLine = lineWidth > 0;
- if (hasLine) {
- lineWidth *= api.getDevicePixelRatio();
- this._updateLinesGeometry(
- linesMesh.geometry, componentModel, dataIndex, regionHeight, lineWidth,
- componentModel.coordinateSystem.transform
- );
- }
- linesMesh.invisible = !hasLine;
- linesMesh.material.set({
- color: borderColor
- });
- }
- var polygonMesh = this._polygonMesh;
- polygonMesh.material.transparent = hasTranparentRegion;
- polygonMesh.material.depthMask = !hasTranparentRegion;
- polygonMesh.geometry.updateBoundingBox();
- polygonMesh.frontFace = this.extrudeY ? __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.CCW : __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.CW;
- // Update tangents
- if (polygonMesh.material.get('normalMap')) {
- polygonMesh.geometry.generateTangents();
- }
- polygonMesh.seriesIndex = componentModel.seriesIndex;
- polygonMesh.on('mousemove', this._onmousemove, this);
- polygonMesh.on('mouseout', this._onmouseout, this);
- },
- _updateDebugWireframe: function (componentModel) {
- var debugWireframeModel = componentModel.getModel('debug.wireframe');
- // TODO Unshow
- if (debugWireframeModel.get('show')) {
- var color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(
- debugWireframeModel.get('lineStyle.color') || 'rgba(0,0,0,0.5)'
- );
- var width = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(
- debugWireframeModel.get('lineStyle.width'), 1
- );
- // TODO Will cause highlight wrong
- var mesh = this._polygonMesh;
- mesh.geometry.generateBarycentric();
- mesh.material.define('both', 'WIREFRAME_TRIANGLE');
- mesh.material.set('wireframeLineColor', color);
- mesh.material.set('wireframeLineWidth', width);
- }
- },
- _onmousemove: function (e) {
- var dataIndex = this._dataIndexOfVertex[e.triangle[0]];
- if (dataIndex == null) {
- dataIndex = -1;
- }
- if (dataIndex !== this._lastHoverDataIndex) {
- this.downplay(this._lastHoverDataIndex);
- this.highlight(dataIndex);
- this._labelsBuilder.updateLabels([dataIndex]);
- }
- this._lastHoverDataIndex = dataIndex;
- this._polygonMesh.dataIndex = dataIndex;
- },
- _onmouseout: function (e) {
- if (e.target) {
- this.downplay(this._lastHoverDataIndex);
- this._lastHoverDataIndex = -1;
- this._polygonMesh.dataIndex = -1;
- }
- this._labelsBuilder.updateLabels([]);
- },
- _updateGroundPlane: function (componentModel, geo3D, api) {
- var groundModel = componentModel.getModel('groundPlane', componentModel);
- this._groundMesh.invisible = !groundModel.get('show', true);
- if (this._groundMesh.invisible) {
- return;
- }
- var shading = componentModel.get('shading');
- var material = this._groundMaterials[shading];
- if (!material) {
- if (true) {
- console.warn('Unkown shading ' + shading);
- }
- material = this._groundMaterials.lambert;
- }
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].setMaterialFromModel(shading, material, groundModel, api);
- if (material.get('normalMap')) {
- this._groundMesh.geometry.generateTangents();
- }
- this._groundMesh.material = material;
- this._groundMesh.material.set('color', __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(groundModel.get('color')));
- this._groundMesh.scale.set(geo3D.size[0], geo3D.size[2], 1);
- },
- _triangulation: function (componentModel, start, end) {
- this._triangulationResults = [];
- var minAll = [Infinity, Infinity, Infinity];
- var maxAll = [-Infinity, -Infinity, -Infinity];
- var coordSys = componentModel.coordinateSystem;
- for (var idx = start; idx < end; idx++) {
- var polygons = [];
- var polygonCoords = componentModel.getRegionPolygonCoords(idx);
- for (var i = 0; i < polygonCoords.length; i++) {
- var exterior = polygonCoords[i].exterior;
- var interiors = polygonCoords[i].interiors;
- var points = [];
- var holes = [];
- if (exterior.length < 3) {
- continue;
- }
- var offset = 0;
- for (var j = 0; j < exterior.length; j++) {
- var p = exterior[j];
- points[offset++] = p[0];
- points[offset++] = p[1];
- }
- for (var j = 0; j < interiors.length; j++) {
- if (interiors[j].length < 3) {
- continue;
- }
- var startIdx = points.length / 2;
- for (var k = 0; k < interiors[j].length; k++) {
- var p = interiors[j][k];
- points.push(p[0]);
- points.push(p[1]);
- }
- holes.push(startIdx);
- }
- var triangles = Object(__WEBPACK_IMPORTED_MODULE_2__util_earcut__["a" /* default */])(points, holes);
- var points3 = new Float64Array(points.length / 2 * 3);
- var pos = [];
- var min = [Infinity, Infinity, Infinity];
- var max = [-Infinity, -Infinity, -Infinity];
- var off3 = 0;
- for (var j = 0; j < points.length;) {
- vec3.set(pos, points[j++], 0, points[j++]);
- if (coordSys && coordSys.transform) {
- vec3.transformMat4(pos, pos, coordSys.transform);
- }
- vec3.min(min, min, pos);
- vec3.max(max, max, pos);
- points3[off3++] = pos[0];
- points3[off3++] = pos[1];
- points3[off3++] = pos[2];
- }
- vec3.min(minAll, minAll, min);
- vec3.max(maxAll, maxAll, max);
- polygons.push({
- points: points3,
- indices: triangles,
- min: min,
- max: max
- });
- }
- this._triangulationResults.push(polygons);
- }
- this._geoBoundingBox = [minAll, maxAll];
- },
- /**
- * Get region vertex and triangle count
- */
- _getRegionPolygonInfo: function (idx) {
- var polygons = this._triangulationResults[idx - this._startIndex];
- var sideVertexCount = 0;
- var sideTriangleCount = 0;
- for (var i = 0; i < polygons.length; i++) {
- sideVertexCount += polygons[i].points.length / 3;
- sideTriangleCount += polygons[i].indices.length / 3;
- }
- var vertexCount = sideVertexCount * 2 + sideVertexCount * 4;
- var triangleCount = sideTriangleCount * 2 + sideVertexCount * 2;
- return {
- vertexCount: vertexCount,
- triangleCount: triangleCount
- };
- },
- _updatePolygonGeometry: function (
- componentModel, geometry, dataIndex, regionHeight,
- vertexOffset, triangleOffset, color
- ) {
- // FIXME
- var projectUVOnGround = componentModel.get('projectUVOnGround');
- var positionAttr = geometry.attributes.position;
- var normalAttr = geometry.attributes.normal;
- var texcoordAttr = geometry.attributes.texcoord0;
- var colorAttr = geometry.attributes.color;
- var polygons = this._triangulationResults[dataIndex - this._startIndex];
- var hasColor = colorAttr.value && color;
- var indices = geometry.indices;
- var extrudeCoordIndex = this.extrudeY ? 1 : 2;
- var sideCoordIndex = this.extrudeY ? 2 : 1;
- var scale = [
- this.rootNode.worldTransform.x.len(),
- this.rootNode.worldTransform.y.len(),
- this.rootNode.worldTransform.z.len()
- ];
- var min = vec3.mul([], this._geoBoundingBox[0], scale);
- var max = vec3.mul([], this._geoBoundingBox[1], scale);
- var maxDimSize = Math.max(max[0] - min[0], max[2] - min[2]);
- function addVertices(polygon, y, insideOffset) {
- var points = polygon.points;
- var pointsLen = points.length;
- var currentPosition = [];
- var uv = [];
- for (var k = 0; k < pointsLen; k += 3) {
- currentPosition[0] = points[k];
- currentPosition[extrudeCoordIndex] = y;
- currentPosition[sideCoordIndex] = points[k + 2];
- uv[0] = (points[k] * scale[0] - min[0]) / maxDimSize;
- uv[1] = (points[k + 2] * scale[sideCoordIndex] - min[2]) / maxDimSize;
- positionAttr.set(vertexOffset, currentPosition);
- if (hasColor) {
- colorAttr.set(vertexOffset, color);
- }
- texcoordAttr.set(vertexOffset++, uv);
- }
- }
- function buildTopBottom(polygon, y, insideOffset) {
- var startVertexOffset = vertexOffset;
- addVertices(polygon, y, insideOffset);
- var len = polygon.indices.length;
- for (var k = 0; k < len; k++) {
- indices[triangleOffset * 3 + k] = polygon.indices[k] + startVertexOffset;
- }
- triangleOffset += polygon.indices.length / 3;
- }
- var normalTop = this.extrudeY ? [0, 1, 0] : [0, 0, 1];
- var normalBottom = vec3.negate([], normalTop);
- for (var p = 0; p < polygons.length; p++) {
- var startVertexOffset = vertexOffset;
- var polygon = polygons[p];
- // BOTTOM
- buildTopBottom(polygon, 0, 0);
- // TOP
- buildTopBottom(polygon, regionHeight, 0);
- var ringVertexCount = polygon.points.length / 3;
- for (var v = 0; v < ringVertexCount; v++) {
- normalAttr.set(startVertexOffset + v, normalBottom);
- normalAttr.set(startVertexOffset + v + ringVertexCount, normalTop);
- }
- var quadToTriangle = [0, 3, 1, 1, 3, 2];
- var quadPos = [[], [], [], []];
- var a = [];
- var b = [];
- var normal = [];
- var uv = [];
- var len = 0;
- for (var v = 0; v < ringVertexCount; v++) {
- var next = (v + 1) % ringVertexCount;
- var dx = (polygon.points[next * 3] - polygon.points[v * 3]) * scale[0];
- var dy = (polygon.points[next * 3 + 2] - polygon.points[v * 3 + 2]) * scale[sideCoordIndex];
- var sideLen = Math.sqrt(dx * dx + dy * dy);
- // 0----1
- // 3----2
- for (var k = 0; k < 4; k++) {
- var isCurrent = (k === 0 || k === 3);
- var idx3 = (isCurrent ? v : next) * 3;
- quadPos[k][0] = polygon.points[idx3];
- quadPos[k][extrudeCoordIndex] = k > 1 ? regionHeight : 0;
- quadPos[k][sideCoordIndex] = polygon.points[idx3 + 2];
- positionAttr.set(vertexOffset + k, quadPos[k]);
- if (projectUVOnGround) {
- uv[0] = (polygon.points[idx3] * scale[0] - min[0]) / maxDimSize;
- uv[1] = (polygon.points[idx3 + 2] * scale[sideCoordIndex] - min[sideCoordIndex]) / maxDimSize;
- }
- else {
- uv[0] = (isCurrent ? len : (len + sideLen)) / maxDimSize;
- uv[1] = (quadPos[k][extrudeCoordIndex] * scale[extrudeCoordIndex] - min[extrudeCoordIndex]) / maxDimSize;
- }
- texcoordAttr.set(vertexOffset + k, uv);
- }
- vec3.sub(a, quadPos[1], quadPos[0]);
- vec3.sub(b, quadPos[3], quadPos[0]);
- vec3.cross(normal, a, b);
- vec3.normalize(normal, normal);
- for (var k = 0; k < 4; k++) {
- normalAttr.set(vertexOffset + k, normal);
- if (hasColor) {
- colorAttr.set(vertexOffset + k, color);
- }
- }
- for (var k = 0; k < 6; k++) {
- indices[triangleOffset * 3 + k] = quadToTriangle[k] + vertexOffset;
- }
- vertexOffset += 4;
- triangleOffset += 2;
- len += sideLen;
- }
- }
- geometry.dirty();
- return {
- vertexOffset: vertexOffset,
- triangleOffset: triangleOffset
- };
- },
- _getRegionLinesInfo: function (idx, componentModel, geometry) {
- var vertexCount = 0;
- var triangleCount = 0;
- var regionModel = componentModel.getRegionModel(idx);
- var itemStyleModel = regionModel.getModel('itemStyle');
- var lineWidth = itemStyleModel.get('borderWidth');
- if (lineWidth > 0) {
- var polygonCoords = componentModel.getRegionPolygonCoords(idx);
- polygonCoords.forEach(function (coords) {
- var exterior = coords.exterior;
- var interiors = coords.interiors;
- vertexCount += geometry.getPolylineVertexCount(exterior);
- triangleCount += geometry.getPolylineTriangleCount(exterior);
- for (var i = 0; i < interiors.length; i++) {
- vertexCount += geometry.getPolylineVertexCount(interiors[i]);
- triangleCount += geometry.getPolylineTriangleCount(interiors[i]);
- }
- }, this);
- }
- return {
- vertexCount: vertexCount,
- triangleCount: triangleCount
- };
- },
- _updateLinesGeometry: function (geometry, componentModel, dataIndex, regionHeight, lineWidth, transform) {
- function convertToPoints3(polygon) {
- var points = new Float64Array(polygon.length * 3);
- var offset = 0;
- var pos = [];
- for (var i = 0; i < polygon.length; i++) {
- pos[0] = polygon[i][0];
- // Add a offset to avoid z-fighting
- pos[1] = regionHeight + 0.1;
- pos[2] = polygon[i][1];
- if (transform) {
- vec3.transformMat4(pos, pos, transform);
- }
- points[offset++] = pos[0];
- points[offset++] = pos[1];
- points[offset++] = pos[2];
- }
- return points;
- }
- var whiteColor = [1, 1, 1, 1];
- var coords = componentModel.getRegionPolygonCoords(dataIndex);
- coords.forEach(function (geo) {
- var exterior = geo.exterior;
- var interiors = geo.interiors;
- geometry.addPolyline(convertToPoints3(exterior), whiteColor, lineWidth);
- for (var i = 0; i < interiors.length; i++) {
- geometry.addPolyline(convertToPoints3(interiors[i]), whiteColor, lineWidth);
- }
- });
- },
- highlight: function (dataIndex) {
- var data = this._data;
- if (!data) {
- return;
- }
- var itemModel = data.getItemModel(dataIndex);
- var emphasisItemStyleModel = itemModel.getModel('emphasis.itemStyle');
- var emphasisColor = emphasisItemStyleModel.get('color');
- var emphasisOpacity = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(
- emphasisItemStyleModel.get('opacity'),
- data.getItemVisual(dataIndex, 'opacity'),
- 1
- );
- if (emphasisColor == null) {
- var color = data.getItemVisual(dataIndex, 'color');
- emphasisColor = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.color.lift(color, -0.4);
- }
- if (emphasisOpacity == null) {
- emphasisOpacity = data.getItemVisual(dataIndex, 'opacity');
- }
- var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(emphasisColor);
- colorArr[3] *= emphasisOpacity;
- this._setColorOfDataIndex(data, dataIndex, colorArr);
- },
- downplay: function (dataIndex) {
- var data = this._data;
- if (!data) {
- return;
- }
- var color = data.getItemVisual(dataIndex, 'color');
- var opacity = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(data.getItemVisual(dataIndex, 'opacity'), 1);
- var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color);
- colorArr[3] *= opacity;
- this._setColorOfDataIndex(data, dataIndex, colorArr);
- },
- _setColorOfDataIndex: function (data, dataIndex, colorArr) {
- if (dataIndex < this._startIndex && dataIndex > this._endIndex) {
- return;
- }
- dataIndex -= this._startIndex;
- for (var i = this._vertexRangeOfDataIndex[dataIndex * 2]; i < this._vertexRangeOfDataIndex[dataIndex * 2 + 1]; i++) {
- this._polygonMesh.geometry.attributes.color.set(i, colorArr);
- }
- this._polygonMesh.geometry.dirty();
- this._api.getZr().refresh();
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (Geo3DBuilder);
- /***/
- }),
- /* 65 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__ = __webpack_require__(97);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- var p0 = vec3.create();
- var p1 = vec3.create();
- var p2 = vec3.create();
- // var cp = vec3.create();
- /* harmony default export */ __webpack_exports__["a"] = ({
- needsSortTriangles: function () {
- return this.indices && this.sortTriangles;
- },
- needsSortTrianglesProgressively: function () {
- return this.needsSortTriangles() && this.triangleCount >= 2e4;
- },
- doSortTriangles: function (cameraPos, frame) {
- var indices = this.indices;
- // Do progressive quick sort.
- if (frame === 0) {
- var posAttr = this.attributes.position;
- var cameraPos = cameraPos.array;
- if (!this._triangleZList || this._triangleZList.length !== this.triangleCount) {
- this._triangleZList = new Float32Array(this.triangleCount);
- this._sortedTriangleIndices = new Uint32Array(this.triangleCount);
- this._indicesTmp = new indices.constructor(indices.length);
- this._triangleZListTmp = new Float32Array(this.triangleCount);
- }
- var cursor = 0;
- var firstZ;
- for (var i = 0; i < indices.length;) {
- posAttr.get(indices[i++], p0);
- posAttr.get(indices[i++], p1);
- posAttr.get(indices[i++], p2);
- // FIXME If use center ?
- // cp[0] = (p0[0] + p1[0] + p2[0]) / 3;
- // cp[1] = (p0[1] + p1[1] + p2[1]) / 3;
- // cp[2] = (p0[2] + p1[2] + p2[2]) / 3;
- // Camera position is in object space
- // Use max of three points, PENDING
- var z0 = vec3.sqrDist(p0, cameraPos);
- var z1 = vec3.sqrDist(p1, cameraPos);
- var z2 = vec3.sqrDist(p2, cameraPos);
- var zMax = Math.min(z0, z1);
- zMax = Math.min(zMax, z2);
- if (i === 3) {
- firstZ = zMax;
- zMax = 0;
- }
- else {
- // Only store the difference to avoid the precision issue.
- zMax = zMax - firstZ;
- }
- this._triangleZList[cursor++] = zMax;
- }
- }
- var sortedTriangleIndices = this._sortedTriangleIndices;
- for (var i = 0; i < sortedTriangleIndices.length; i++) {
- sortedTriangleIndices[i] = i;
- }
- if (this.triangleCount < 2e4) {
- // Use simple timsort for simple geometries.
- if (frame === 0) {
- // Use native sort temporary.
- this._simpleSort(true);
- }
- }
- else {
- for (var i = 0; i < 3; i++) {
- this._progressiveQuickSort(frame * 3 + i);
- }
- }
- var targetIndices = this._indicesTmp;
- var targetTriangleZList = this._triangleZListTmp;
- var faceZList = this._triangleZList;
- for (var i = 0; i < this.triangleCount; i++) {
- var fromIdx3 = sortedTriangleIndices[i] * 3;
- var toIdx3 = i * 3;
- targetIndices[toIdx3++] = indices[fromIdx3++];
- targetIndices[toIdx3++] = indices[fromIdx3++];
- targetIndices[toIdx3] = indices[fromIdx3];
- targetTriangleZList[i] = faceZList[sortedTriangleIndices[i]];
- }
- // Swap indices.
- var tmp = this._indicesTmp;
- this._indicesTmp = this.indices;
- this.indices = tmp;
- var tmp = this._triangleZListTmp;
- this._triangleZListTmp = this._triangleZList;
- this._triangleZList = tmp;
- this.dirtyIndices();
- },
- _simpleSort: function (useNativeQuickSort) {
- var faceZList = this._triangleZList;
- var sortedTriangleIndices = this._sortedTriangleIndices;
- function compare(a, b) {
- // Sort from far to near. which is descending order
- return faceZList[b] - faceZList[a];
- }
- if (useNativeQuickSort) {
- Array.prototype.sort.call(sortedTriangleIndices, compare);
- }
- else {
- __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__["a" /* default */].sort(sortedTriangleIndices, compare, 0, sortedTriangleIndices.length - 1);
- }
- },
- _progressiveQuickSort: function (frame) {
- var faceZList = this._triangleZList;
- var sortedTriangleIndices = this._sortedTriangleIndices;
- this._quickSort = this._quickSort || new __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__["a" /* default */]();
- this._quickSort.step(sortedTriangleIndices, function (a, b) {
- return faceZList[b] - faceZList[a];
- }, frame);
- }
- });
- /***/
- }),
- /* 66 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_ZRTextureAtlasSurface__ = __webpack_require__(81);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_mesh_LabelsMesh__ = __webpack_require__(63);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_retrieve__ = __webpack_require__(2);
- var LABEL_NORMAL_SHOW_BIT = 1;
- var LABEL_EMPHASIS_SHOW_BIT = 2;
- function LabelsBuilder(width, height, api) {
- this._labelsMesh = new __WEBPACK_IMPORTED_MODULE_2__util_mesh_LabelsMesh__["a" /* default */]();
- this._labelTextureSurface = new __WEBPACK_IMPORTED_MODULE_1__util_ZRTextureAtlasSurface__["a" /* default */]({
- width: 512,
- height: 512,
- devicePixelRatio: api.getDevicePixelRatio(),
- onupdate: function () {
- api.getZr().refresh();
- }
- });
- this._api = api;
- this._labelsMesh.material.set('textureAtlas', this._labelTextureSurface.getTexture());
- }
- LabelsBuilder.prototype.getLabelPosition = function (dataIndex, positionDesc, distance) {
- return [0, 0, 0];
- };
- LabelsBuilder.prototype.getLabelDistance = function (dataIndex, positionDesc, distance) {
- return 0;
- };
- LabelsBuilder.prototype.getMesh = function () {
- return this._labelsMesh;
- };
- LabelsBuilder.prototype.updateData = function (data, start, end) {
- if (start == null) {
- start = 0;
- }
- if (end == null) {
- end = data.count();
- }
- if (!this._labelsVisibilitiesBits || this._labelsVisibilitiesBits.length !== (end - start)) {
- this._labelsVisibilitiesBits = new Uint8Array(end - start);
- }
- var normalLabelVisibilityQuery = ['label', 'show'];
- var emphasisLabelVisibilityQuery = ['emphasis', 'label', 'show'];
- for (var idx = start; idx < end; idx++) {
- var itemModel = data.getItemModel(idx);
- var normalVisibility = itemModel.get(normalLabelVisibilityQuery);
- var emphasisVisibility = itemModel.get(emphasisLabelVisibilityQuery);
- if (emphasisVisibility == null) {
- emphasisVisibility = normalVisibility;
- }
- var bit = (normalVisibility ? LABEL_NORMAL_SHOW_BIT : 0)
- | (emphasisVisibility ? LABEL_EMPHASIS_SHOW_BIT : 0);
- this._labelsVisibilitiesBits[idx - start] = bit;
- }
- this._start = start;
- this._end = end;
- this._data = data;
- };
- LabelsBuilder.prototype.updateLabels = function (highlightDataIndices) {
- if (!this._data) {
- return;
- }
- highlightDataIndices = highlightDataIndices || [];
- var hasHighlightData = highlightDataIndices.length > 0;
- var highlightDataIndicesMap = {};
- for (var i = 0; i < highlightDataIndices.length; i++) {
- highlightDataIndicesMap[highlightDataIndices[i]] = true;
- }
- this._labelsMesh.geometry.convertToDynamicArray(true);
- this._labelTextureSurface.clear();
- var normalLabelQuery = ['label'];
- var emphasisLabelQuery = ['emphasis', 'label'];
- var seriesModel = this._data.hostModel;
- var data = this._data;
- var seriesLabelModel = seriesModel.getModel(normalLabelQuery);
- var seriesLabelEmphasisModel = seriesModel.getModel(emphasisLabelQuery, seriesLabelModel);
- var textAlignMap = {
- left: 'right',
- right: 'left',
- top: 'center',
- bottom: 'center'
- };
- var textVerticalAlignMap = {
- left: 'middle',
- right: 'middle',
- top: 'bottom',
- bottom: 'top'
- };
- for (var dataIndex = this._start; dataIndex < this._end; dataIndex++) {
- var isEmphasis = false;
- if (hasHighlightData && highlightDataIndicesMap[dataIndex]) {
- isEmphasis = true;
- }
- var ifShow = this._labelsVisibilitiesBits[dataIndex - this._start]
- & (isEmphasis ? LABEL_EMPHASIS_SHOW_BIT : LABEL_NORMAL_SHOW_BIT);
- if (!ifShow) {
- continue;
- }
- var itemModel = data.getItemModel(dataIndex);
- var labelModel = itemModel.getModel(
- isEmphasis ? emphasisLabelQuery : normalLabelQuery,
- isEmphasis ? seriesLabelEmphasisModel : seriesLabelModel
- );
- var distance = labelModel.get('distance') || 0;
- var position = labelModel.get('position');
- var textStyleModel = labelModel.getModel('textStyle');
- var dpr = this._api.getDevicePixelRatio();
- var text = seriesModel.getFormattedLabel(dataIndex, isEmphasis ? 'emphasis' : 'normal');
- if (text == null || text === '') {
- return;
- }
- // TODO Background.
- var textEl = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Text();
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.setTextStyle(textEl.style, textStyleModel, {
- text: text,
- textFill: textStyleModel.get('color') || data.getItemVisual(dataIndex, 'color') || '#000',
- textAlign: 'left',
- textVerticalAlign: 'top',
- opacity: __WEBPACK_IMPORTED_MODULE_3__util_retrieve__["a" /* default */].firstNotNull(textStyleModel.get('opacity'), data.getItemVisual(dataIndex, 'opacity'), 1)
- });
- var rect = textEl.getBoundingRect();
- var lineHeight = 1.2;
- rect.height *= lineHeight;
- var coords = this._labelTextureSurface.add(textEl);
- var textAlign = textAlignMap[position] || 'center';
- var textVerticalAlign = textVerticalAlignMap[position] || 'bottom';
- this._labelsMesh.geometry.addSprite(
- this.getLabelPosition(dataIndex, position, distance),
- [rect.width * dpr, rect.height * dpr], coords,
- textAlign, textVerticalAlign,
- this.getLabelDistance(dataIndex, position, distance) * dpr
- );
- }
- this._labelsMesh.material.set('uvScale', this._labelTextureSurface.getCoordsScale());
- // var canvas = this._labelTextureSurface.getTexture().image;
- // document.body.appendChild(canvas);
- // canvas.style.cssText = 'position:absolute;z-index: 1000';
- // Update image.
- this._labelTextureSurface.getZr().refreshImmediately();
- this._labelsMesh.geometry.convertToTypedArray();
- this._labelsMesh.geometry.dirty();
- };
- /* harmony default export */ __webpack_exports__["a"] = (LabelsBuilder);
- /***/
- }),
- /* 67 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_sprite__ = __webpack_require__(239);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__PointsMesh__ = __webpack_require__(240);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__component_common_LabelsBuilder__ = __webpack_require__(66);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_retrieve__ = __webpack_require__(2);
- var SDF_RANGE = 20;
- var Z_2D = -10;
- function isSymbolSizeSame(a, b) {
- return a && b && a[0] === b[0] && a[1] === b[1];
- }
- // TODO gl_PointSize has max value.
- function PointsBuilder(is2D, api) {
- this.rootNode = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- /**
- * @type {boolean}
- */
- this.is2D = is2D;
- this._labelsBuilder = new __WEBPACK_IMPORTED_MODULE_4__component_common_LabelsBuilder__["a" /* default */](256, 256, api);
- // Give a large render order.
- this._labelsBuilder.getMesh().renderOrder = 100;
- this.rootNode.add(this._labelsBuilder.getMesh());
- this._api = api;
- this._spriteImageCanvas = document.createElement('canvas');
- this._startDataIndex = 0;
- this._endDataIndex = 0;
- this._sizeScale = 1;
- }
- PointsBuilder.prototype = {
- constructor: PointsBuilder,
- /**
- * If highlight on over
- */
- highlightOnMouseover: true,
- update: function (seriesModel, ecModel, api, start, end) {
- // Swap barMesh
- var tmp = this._prevMesh;
- this._prevMesh = this._mesh;
- this._mesh = tmp;
- var data = seriesModel.getData();
- if (start == null) {
- start = 0;
- }
- if (end == null) {
- end = data.count();
- }
- this._startDataIndex = start;
- this._endDataIndex = end - 1;
- if (!this._mesh) {
- var material = this._prevMesh && this._prevMesh.material;
- this._mesh = new __WEBPACK_IMPORTED_MODULE_3__PointsMesh__["a" /* default */]({
- // Render after axes
- renderOrder: 10,
- // FIXME
- frustumCulling: false
- });
- if (material) {
- this._mesh.material = material;
- }
- }
- var material = this._mesh.material;
- var geometry = this._mesh.geometry;
- var attributes = geometry.attributes;
- this.rootNode.remove(this._prevMesh);
- this.rootNode.add(this._mesh);
- this._setPositionTextureToMesh(this._mesh, this._positionTexture);
- var symbolInfo = this._getSymbolInfo(seriesModel, start, end);
- var dpr = api.getDevicePixelRatio();
- // TODO image symbol
- var itemStyle = seriesModel.getModel('itemStyle').getItemStyle();
- var largeMode = seriesModel.get('large');
- var pointSizeScale = 1;
- if (symbolInfo.maxSize > 2) {
- pointSizeScale = this._updateSymbolSprite(seriesModel, itemStyle, symbolInfo, dpr);
- material.enableTexture('sprite');
- }
- else {
- material.disableTexture('sprite');
- }
- attributes.position.init(end - start);
- var rgbaArr = [];
- if (largeMode) {
- material.undefine('VERTEX_SIZE');
- material.undefine('VERTEX_COLOR');
- var color = data.getVisual('color');
- var opacity = data.getVisual('opacity');
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color, rgbaArr);
- rgbaArr[3] *= opacity;
- material.set({
- color: rgbaArr,
- 'u_Size': symbolInfo.maxSize * this._sizeScale
- });
- }
- else {
- material.set({
- color: [1, 1, 1, 1]
- });
- material.define('VERTEX_SIZE');
- material.define('VERTEX_COLOR');
- attributes.size.init(end - start);
- attributes.color.init(end - start);
- this._originalOpacity = new Float32Array(end - start);
- }
- var points = data.getLayout('points');
- var positionArr = attributes.position.value;
- var hasTransparentPoint = false;
- for (var i = 0; i < end - start; i++) {
- var i3 = i * 3;
- var i2 = i * 2;
- if (this.is2D) {
- positionArr[i3] = points[i2];
- positionArr[i3 + 1] = points[i2 + 1];
- positionArr[i3 + 2] = Z_2D;
- }
- else {
- positionArr[i3] = points[i3];
- positionArr[i3 + 1] = points[i3 + 1];
- positionArr[i3 + 2] = points[i3 + 2];
- }
- if (!largeMode) {
- var color = data.getItemVisual(i, 'color');
- var opacity = data.getItemVisual(i, 'opacity');
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color, rgbaArr);
- rgbaArr[3] *= opacity;
- attributes.color.set(i, rgbaArr);
- if (rgbaArr[3] < 0.99) {
- hasTransparentPoint = true;
- }
- var symbolSize = data.getItemVisual(i, 'symbolSize');
- symbolSize = (symbolSize instanceof Array
- ? Math.max(symbolSize[0], symbolSize[1]) : symbolSize);
- // NaN pointSize may have strange result.
- if (isNaN(symbolSize)) {
- symbolSize = 0;
- }
- // Scale point size because canvas has margin.
- attributes.size.value[i] = symbolSize * pointSizeScale * this._sizeScale;
- // Save the original opacity for recover from fadeIn.
- this._originalOpacity[i] = rgbaArr[3];
- }
- }
- this._mesh.sizeScale = pointSizeScale;
- geometry.updateBoundingBox();
- geometry.dirty();
- // Update material.
- this._updateMaterial(seriesModel, itemStyle);
- var coordSys = seriesModel.coordinateSystem;
- if (coordSys && coordSys.viewGL) {
- var methodName = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine';
- material[methodName]('fragment', 'SRGB_DECODE');
- }
- if (!largeMode) {
- this._updateLabelBuilder(seriesModel, start, end);
- }
- this._updateHandler(seriesModel, ecModel, api);
- this._updateAnimation(seriesModel);
- this._api = api;
- },
- getPointsMesh: function () {
- return this._mesh;
- },
- updateLabels: function (highlightDataIndices) {
- this._labelsBuilder.updateLabels(highlightDataIndices);
- },
- hideLabels: function () {
- this.rootNode.remove(this._labelsBuilder.getMesh());
- },
- showLabels: function () {
- this.rootNode.add(this._labelsBuilder.getMesh());
- },
- _updateSymbolSprite: function (seriesModel, itemStyle, symbolInfo, dpr) {
- symbolInfo.maxSize = Math.min(symbolInfo.maxSize * 2, 200);
- var symbolSize = [];
- if (symbolInfo.aspect > 1) {
- symbolSize[0] = symbolInfo.maxSize;
- symbolSize[1] = symbolInfo.maxSize / symbolInfo.aspect;
- }
- else {
- symbolSize[1] = symbolInfo.maxSize;
- symbolSize[0] = symbolInfo.maxSize * symbolInfo.aspect;
- }
- // In case invalid data.
- symbolSize[0] = symbolSize[0] || 1;
- symbolSize[1] = symbolSize[1] || 1;
- if (this._symbolType !== symbolInfo.type
- || !isSymbolSizeSame(this._symbolSize, symbolSize)
- || this._lineWidth !== itemStyle.lineWidth
- ) {
- __WEBPACK_IMPORTED_MODULE_2__util_sprite__["a" /* default */].createSymbolSprite(symbolInfo.type, symbolSize, {
- fill: '#fff',
- lineWidth: itemStyle.lineWidth,
- stroke: 'transparent',
- shadowColor: 'transparent',
- minMargin: Math.min(symbolSize[0] / 2, 10)
- }, this._spriteImageCanvas);
- __WEBPACK_IMPORTED_MODULE_2__util_sprite__["a" /* default */].createSDFFromCanvas(
- this._spriteImageCanvas, Math.min(this._spriteImageCanvas.width, 32), SDF_RANGE,
- this._mesh.material.get('sprite').image
- );
- this._symbolType = symbolInfo.type;
- this._symbolSize = symbolSize;
- this._lineWidth = itemStyle.lineWidth;
- }
- return this._spriteImageCanvas.width / symbolInfo.maxSize * dpr;
- },
- _updateMaterial: function (seriesModel, itemStyle) {
- var blendFunc = seriesModel.get('blendMode') === 'lighter'
- ? __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].additiveBlend : null;
- var material = this._mesh.material;
- material.blend = blendFunc;
- material.set('lineWidth', itemStyle.lineWidth / SDF_RANGE);
- var strokeColor = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(itemStyle.stroke);
- material.set('strokeColor', strokeColor);
- // Because of symbol texture, we always needs it be transparent.
- material.transparent = true;
- material.depthMask = false;
- material.depthTest = !this.is2D;
- material.sortVertices = !this.is2D;
- },
- _updateLabelBuilder: function (seriesModel, start, end) {
- var data = seriesModel.getData();
- var geometry = this._mesh.geometry;
- var positionArr = geometry.attributes.position.value;
- var start = this._startDataIndex;
- var pointSizeScale = this._mesh.sizeScale;
- this._labelsBuilder.updateData(data, start, end);
- this._labelsBuilder.getLabelPosition = function (dataIndex, positionDesc, distance) {
- var idx3 = (dataIndex - start) * 3;
- return [positionArr[idx3], positionArr[idx3 + 1], positionArr[idx3 + 2]];
- };
- this._labelsBuilder.getLabelDistance = function (dataIndex, positionDesc, distance) {
- var size = geometry.attributes.size.get(dataIndex - start) / pointSizeScale;
- return size / 2 + distance;
- };
- this._labelsBuilder.updateLabels();
- },
- _updateAnimation: function (seriesModel) {
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].updateVertexAnimation(
- [['prevPosition', 'position'],
- ['prevSize', 'size']],
- this._prevMesh,
- this._mesh,
- seriesModel
- );
- },
- _updateHandler: function (seriesModel, ecModel, api) {
- var data = seriesModel.getData();
- var pointsMesh = this._mesh;
- var self = this;
- var lastDataIndex = -1;
- var isCartesian3D = seriesModel.coordinateSystem
- && seriesModel.coordinateSystem.type === 'cartesian3D';
- var grid3DModel;
- if (isCartesian3D) {
- grid3DModel = seriesModel.coordinateSystem.model;
- }
- pointsMesh.seriesIndex = seriesModel.seriesIndex;
- pointsMesh.off('mousemove');
- pointsMesh.off('mouseout');
- pointsMesh.on('mousemove', function (e) {
- var dataIndex = e.vertexIndex + self._startDataIndex;
- if (dataIndex !== lastDataIndex) {
- if (this.highlightOnMouseover) {
- this.downplay(data, lastDataIndex);
- this.highlight(data, dataIndex);
- this._labelsBuilder.updateLabels([dataIndex]);
- }
- if (isCartesian3D) {
- api.dispatchAction({
- type: 'grid3DShowAxisPointer',
- value: [
- data.get(seriesModel.coordDimToDataDim('x')[0], dataIndex),
- data.get(seriesModel.coordDimToDataDim('y')[0], dataIndex),
- data.get(seriesModel.coordDimToDataDim('z')[0], dataIndex)
- ],
- grid3DIndex: grid3DModel.componentIndex
- });
- }
- }
- pointsMesh.dataIndex = dataIndex;
- lastDataIndex = dataIndex;
- }, this);
- pointsMesh.on('mouseout', function (e) {
- var dataIndex = e.vertexIndex + self._startDataIndex;
- if (this.highlightOnMouseover) {
- this.downplay(data, dataIndex);
- this._labelsBuilder.updateLabels();
- }
- lastDataIndex = -1;
- pointsMesh.dataIndex = -1;
- if (isCartesian3D) {
- api.dispatchAction({
- type: 'grid3DHideAxisPointer',
- grid3DIndex: grid3DModel.componentIndex
- });
- }
- }, this);
- },
- updateLayout: function (seriesModel, ecModel, api) {
- var data = seriesModel.getData();
- if (!this._mesh) {
- return;
- }
- var positionArr = this._mesh.geometry.attributes.position.value;
- var points = data.getLayout('points');
- if (this.is2D) {
- for (var i = 0; i < points.length / 2; i++) {
- var i3 = i * 3;
- var i2 = i * 2;
- positionArr[i3] = points[i2];
- positionArr[i3 + 1] = points[i2 + 1];
- positionArr[i3 + 2] = Z_2D;
- }
- }
- else {
- for (var i = 0; i < points.length; i++) {
- positionArr[i] = points[i];
- }
- }
- this._mesh.geometry.dirty();
- api.getZr().refresh();
- },
- updateView: function (camera) {
- if (!this._mesh) {
- return;
- }
- var worldViewProjection = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */]();
- __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */].mul(worldViewProjection, camera.viewMatrix, this._mesh.worldTransform);
- __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */].mul(worldViewProjection, camera.projectionMatrix, worldViewProjection);
- this._mesh.updateNDCPosition(worldViewProjection, this.is2D, this._api);
- },
- highlight: function (data, dataIndex) {
- if (dataIndex > this._endDataIndex || dataIndex < this._startDataIndex) {
- return;
- }
- var itemModel = data.getItemModel(dataIndex);
- var emphasisItemStyleModel = itemModel.getModel('emphasis.itemStyle');
- var emphasisColor = emphasisItemStyleModel.get('color');
- var emphasisOpacity = emphasisItemStyleModel.get('opacity');
- if (emphasisColor == null) {
- var color = data.getItemVisual(dataIndex, 'color');
- emphasisColor = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.color.lift(color, -0.4);
- }
- if (emphasisOpacity == null) {
- emphasisOpacity = data.getItemVisual(dataIndex, 'opacity');
- }
- var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(emphasisColor);
- colorArr[3] *= emphasisOpacity;
- this._mesh.geometry.attributes.color.set(dataIndex - this._startDataIndex, colorArr);
- this._mesh.geometry.dirtyAttribute('color');
- this._api.getZr().refresh();
- },
- downplay: function (data, dataIndex) {
- if (dataIndex > this._endDataIndex || dataIndex < this._startDataIndex) {
- return;
- }
- var color = data.getItemVisual(dataIndex, 'color');
- var opacity = data.getItemVisual(dataIndex, 'opacity');
- var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color);
- colorArr[3] *= opacity;
- this._mesh.geometry.attributes.color.set(dataIndex - this._startDataIndex, colorArr);
- this._mesh.geometry.dirtyAttribute('color');
- this._api.getZr().refresh();
- },
- fadeOutAll: function (fadeOutPercent) {
- if (this._originalOpacity) {
- var geo = this._mesh.geometry;
- for (var i = 0; i < geo.vertexCount; i++) {
- var fadeOutOpacity = this._originalOpacity[i] * fadeOutPercent;
- geo.attributes.color.value[i * 4 + 3] = fadeOutOpacity;
- }
- geo.dirtyAttribute('color');
- this._api.getZr().refresh();
- }
- },
- fadeInAll: function () {
- this.fadeOutAll(1);
- },
- setPositionTexture: function (texture) {
- if (this._mesh) {
- this._setPositionTextureToMesh(this._mesh, texture);
- }
- this._positionTexture = texture;
- },
- removePositionTexture: function () {
- this._positionTexture = null;
- if (this._mesh) {
- this._setPositionTextureToMesh(this._mesh, null);
- }
- },
- setSizeScale: function (sizeScale) {
- if (sizeScale !== this._sizeScale) {
- if (this._mesh) {
- var originalSize = this._mesh.material.get('u_Size');
- this._mesh.material.set('u_Size', originalSize / this._sizeScale * sizeScale);
- var attributes = this._mesh.geometry.attributes;
- if (attributes.size.value) {
- for (var i = 0; i < attributes.size.value.length; i++) {
- attributes.size.value[i] = attributes.size.value[i] / this._sizeScale * sizeScale;
- }
- }
- }
- this._sizeScale = sizeScale;
- }
- },
- _setPositionTextureToMesh: function (mesh, texture) {
- if (texture) {
- mesh.material.set('positionTexture', texture);
- }
- mesh.material[
- texture ? 'enableTexture' : 'disableTexture'
- ]('positionTexture');
- },
- _getSymbolInfo: function (seriesModel, start, end) {
- if (seriesModel.get('large')) {
- var symbolSize = __WEBPACK_IMPORTED_MODULE_6__util_retrieve__["a" /* default */].firstNotNull(seriesModel.get('symbolSize'), 1);
- var maxSymbolSize;
- var symbolAspect;
- if (symbolSize instanceof Array) {
- maxSymbolSize = Math.max(symbolSize[0], symbolSize[1]);
- symbolAspect = symbolSize[0] / symbolSize[1];
- }
- else {
- maxSymbolSize = symbolSize;
- symbolAspect = 1;
- }
- return {
- maxSize: symbolSize,
- type: seriesModel.get('symbol'),
- aspect: symbolAspect
- }
- }
- var data = seriesModel.getData();
- var symbolAspect;
- var differentSymbolAspect = false;
- var symbolType = data.getItemVisual(0, 'symbol') || 'circle';
- var differentSymbolType = false;
- var maxSymbolSize = 0;
- for (var idx = start; idx < end; idx++) {
- var symbolSize = data.getItemVisual(idx, 'symbolSize');
- var currentSymbolType = data.getItemVisual(idx, 'symbol');
- var currentSymbolAspect;
- if (!(symbolSize instanceof Array)) {
- // Ignore NaN value.
- if (isNaN(symbolSize)) {
- return;
- }
- currentSymbolAspect = 1;
- maxSymbolSize = Math.max(symbolSize, maxSymbolSize);
- }
- else {
- currentSymbolAspect = symbolSize[0] / symbolSize[1];
- maxSymbolSize = Math.max(Math.max(symbolSize[0], symbolSize[1]), maxSymbolSize);
- }
- if (true) {
- if (symbolAspect != null && Math.abs(currentSymbolAspect - symbolAspect) > 0.05) {
- differentSymbolAspect = true;
- }
- if (currentSymbolType !== symbolType) {
- differentSymbolType = true;
- }
- }
- symbolType = currentSymbolType;
- symbolAspect = currentSymbolAspect;
- }
- if (true) {
- if (differentSymbolAspect) {
- console.warn('Different symbol width / height ratio will be ignored.');
- }
- if (differentSymbolType) {
- console.warn('Different symbol type will be ignored.');
- }
- }
- return {
- maxSize: maxSymbolSize,
- type: symbolType,
- aspect: symbolAspect
- };
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (PointsBuilder);
- /***/
- }),
- /* 68 */
- /***/ (function (module, exports) {
- var g;
- // This works in non-strict mode
- g = (function () {
- return this;
- })();
- try {
- // This works if eval is allowed (see CSP)
- g = g || Function("return this")() || (1, eval)("this");
- } catch (e) {
- // This works if the window reference is available
- if (typeof window === "object")
- g = window;
- }
- // g can still be undefined, but nothing to do about it...
- // We return undefined, instead of nothing here, so it's
- // easier to handle this case. if(!global) { ...}
- module.exports = g;
- /***/
- }),
- /* 69 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__LinkedList__ = __webpack_require__(114);
- /**
- * LRU Cache
- * @constructor
- * @alias clay.core.LRU
- */
- var LRU = function (maxSize) {
- this._list = new __WEBPACK_IMPORTED_MODULE_0__LinkedList__["a" /* default */]();
- this._map = {};
- this._maxSize = maxSize || 10;
- };
- /**
- * Set cache max size
- * @param {number} size
- */
- LRU.prototype.setMaxSize = function (size) {
- this._maxSize = size;
- };
- /**
- * @param {string} key
- * @param {} value
- */
- LRU.prototype.put = function (key, value) {
- if (!this._map.hasOwnProperty(key)) {
- var len = this._list.length();
- if (len >= this._maxSize && len > 0) {
- // Remove the least recently used
- var leastUsedEntry = this._list.head;
- this._list.remove(leastUsedEntry);
- delete this._map[leastUsedEntry.key];
- }
- var entry = this._list.insert(value);
- entry.key = key;
- this._map[key] = entry;
- }
- };
- /**
- * @param {string} key
- * @return {}
- */
- LRU.prototype.get = function (key) {
- var entry = this._map[key];
- if (this._map.hasOwnProperty(key)) {
- // Put the latest used entry in the tail
- if (entry !== this._list.tail) {
- this._list.remove(entry);
- this._list.insertEntry(entry);
- }
- return entry.value;
- }
- };
- /**
- * @param {string} key
- */
- LRU.prototype.remove = function (key) {
- var entry = this._map[key];
- if (typeof (entry) !== 'undefined') {
- delete this._map[key];
- this._list.remove(entry);
- }
- };
- /**
- * Clear the cache
- */
- LRU.prototype.clear = function () {
- this._list.clear();
- this._map = {};
- };
- /* harmony default export */ __webpack_exports__["a"] = (LRU);
- /***/
- }),
- /* 70 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20);
- /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
- /**
- * @class 2 Dimensional Vector
- * @name vec2
- */
- var vec2 = {};
- /**
- * Creates a new, empty vec2
- *
- * @returns {vec2} a new 2D vector
- */
- vec2.create = function () {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](2);
- out[0] = 0;
- out[1] = 0;
- return out;
- };
- /**
- * Creates a new vec2 initialized with values from an existing vector
- *
- * @param {vec2} a vector to clone
- * @returns {vec2} a new 2D vector
- */
- vec2.clone = function (a) {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](2);
- out[0] = a[0];
- out[1] = a[1];
- return out;
- };
- /**
- * Creates a new vec2 initialized with the given values
- *
- * @param {Number} x X component
- * @param {Number} y Y component
- * @returns {vec2} a new 2D vector
- */
- vec2.fromValues = function (x, y) {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](2);
- out[0] = x;
- out[1] = y;
- return out;
- };
- /**
- * Copy the values from one vec2 to another
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the source vector
- * @returns {vec2} out
- */
- vec2.copy = function (out, a) {
- out[0] = a[0];
- out[1] = a[1];
- return out;
- };
- /**
- * Set the components of a vec2 to the given values
- *
- * @param {vec2} out the receiving vector
- * @param {Number} x X component
- * @param {Number} y Y component
- * @returns {vec2} out
- */
- vec2.set = function (out, x, y) {
- out[0] = x;
- out[1] = y;
- return out;
- };
- /**
- * Adds two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- vec2.add = function (out, a, b) {
- out[0] = a[0] + b[0];
- out[1] = a[1] + b[1];
- return out;
- };
- /**
- * Subtracts vector b from vector a
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- vec2.subtract = function (out, a, b) {
- out[0] = a[0] - b[0];
- out[1] = a[1] - b[1];
- return out;
- };
- /**
- * Alias for {@link vec2.subtract}
- * @function
- */
- vec2.sub = vec2.subtract;
- /**
- * Multiplies two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- vec2.multiply = function (out, a, b) {
- out[0] = a[0] * b[0];
- out[1] = a[1] * b[1];
- return out;
- };
- /**
- * Alias for {@link vec2.multiply}
- * @function
- */
- vec2.mul = vec2.multiply;
- /**
- * Divides two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- vec2.divide = function (out, a, b) {
- out[0] = a[0] / b[0];
- out[1] = a[1] / b[1];
- return out;
- };
- /**
- * Alias for {@link vec2.divide}
- * @function
- */
- vec2.div = vec2.divide;
- /**
- * Returns the minimum of two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- vec2.min = function (out, a, b) {
- out[0] = Math.min(a[0], b[0]);
- out[1] = Math.min(a[1], b[1]);
- return out;
- };
- /**
- * Returns the maximum of two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec2} out
- */
- vec2.max = function (out, a, b) {
- out[0] = Math.max(a[0], b[0]);
- out[1] = Math.max(a[1], b[1]);
- return out;
- };
- /**
- * Scales a vec2 by a scalar number
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the vector to scale
- * @param {Number} b amount to scale the vector by
- * @returns {vec2} out
- */
- vec2.scale = function (out, a, b) {
- out[0] = a[0] * b;
- out[1] = a[1] * b;
- return out;
- };
- /**
- * Adds two vec2's after scaling the second operand by a scalar value
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @param {Number} scale the amount to scale b by before adding
- * @returns {vec2} out
- */
- vec2.scaleAndAdd = function (out, a, b, scale) {
- out[0] = a[0] + (b[0] * scale);
- out[1] = a[1] + (b[1] * scale);
- return out;
- };
- /**
- * Calculates the euclidian distance between two vec2's
- *
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {Number} distance between a and b
- */
- vec2.distance = function (a, b) {
- var x = b[0] - a[0],
- y = b[1] - a[1];
- return Math.sqrt(x * x + y * y);
- };
- /**
- * Alias for {@link vec2.distance}
- * @function
- */
- vec2.dist = vec2.distance;
- /**
- * Calculates the squared euclidian distance between two vec2's
- *
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {Number} squared distance between a and b
- */
- vec2.squaredDistance = function (a, b) {
- var x = b[0] - a[0],
- y = b[1] - a[1];
- return x * x + y * y;
- };
- /**
- * Alias for {@link vec2.squaredDistance}
- * @function
- */
- vec2.sqrDist = vec2.squaredDistance;
- /**
- * Calculates the length of a vec2
- *
- * @param {vec2} a vector to calculate length of
- * @returns {Number} length of a
- */
- vec2.length = function (a) {
- var x = a[0],
- y = a[1];
- return Math.sqrt(x * x + y * y);
- };
- /**
- * Alias for {@link vec2.length}
- * @function
- */
- vec2.len = vec2.length;
- /**
- * Calculates the squared length of a vec2
- *
- * @param {vec2} a vector to calculate squared length of
- * @returns {Number} squared length of a
- */
- vec2.squaredLength = function (a) {
- var x = a[0],
- y = a[1];
- return x * x + y * y;
- };
- /**
- * Alias for {@link vec2.squaredLength}
- * @function
- */
- vec2.sqrLen = vec2.squaredLength;
- /**
- * Negates the components of a vec2
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a vector to negate
- * @returns {vec2} out
- */
- vec2.negate = function (out, a) {
- out[0] = -a[0];
- out[1] = -a[1];
- return out;
- };
- /**
- * Returns the inverse of the components of a vec2
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a vector to invert
- * @returns {vec2} out
- */
- vec2.inverse = function (out, a) {
- out[0] = 1.0 / a[0];
- out[1] = 1.0 / a[1];
- return out;
- };
- /**
- * Normalize a vec2
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a vector to normalize
- * @returns {vec2} out
- */
- vec2.normalize = function (out, a) {
- var x = a[0],
- y = a[1];
- var len = x * x + y * y;
- if (len > 0) {
- //TODO: evaluate use of glm_invsqrt here?
- len = 1 / Math.sqrt(len);
- out[0] = a[0] * len;
- out[1] = a[1] * len;
- }
- return out;
- };
- /**
- * Calculates the dot product of two vec2's
- *
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {Number} dot product of a and b
- */
- vec2.dot = function (a, b) {
- return a[0] * b[0] + a[1] * b[1];
- };
- /**
- * Computes the cross product of two vec2's
- * Note that the cross product must by definition produce a 3D vector
- *
- * @param {vec3} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @returns {vec3} out
- */
- vec2.cross = function (out, a, b) {
- var z = a[0] * b[1] - a[1] * b[0];
- out[0] = out[1] = 0;
- out[2] = z;
- return out;
- };
- /**
- * Performs a linear interpolation between two vec2's
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the first operand
- * @param {vec2} b the second operand
- * @param {Number} t interpolation amount between the two inputs
- * @returns {vec2} out
- */
- vec2.lerp = function (out, a, b, t) {
- var ax = a[0],
- ay = a[1];
- out[0] = ax + t * (b[0] - ax);
- out[1] = ay + t * (b[1] - ay);
- return out;
- };
- /**
- * Generates a random vector with the given scale
- *
- * @param {vec2} out the receiving vector
- * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
- * @returns {vec2} out
- */
- vec2.random = function (out, scale) {
- scale = scale || 1.0;
- var r = GLMAT_RANDOM() * 2.0 * Math.PI;
- out[0] = Math.cos(r) * scale;
- out[1] = Math.sin(r) * scale;
- return out;
- };
- /**
- * Transforms the vec2 with a mat2
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the vector to transform
- * @param {mat2} m matrix to transform with
- * @returns {vec2} out
- */
- vec2.transformMat2 = function (out, a, m) {
- var x = a[0],
- y = a[1];
- out[0] = m[0] * x + m[2] * y;
- out[1] = m[1] * x + m[3] * y;
- return out;
- };
- /**
- * Transforms the vec2 with a mat2d
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the vector to transform
- * @param {mat2d} m matrix to transform with
- * @returns {vec2} out
- */
- vec2.transformMat2d = function (out, a, m) {
- var x = a[0],
- y = a[1];
- out[0] = m[0] * x + m[2] * y + m[4];
- out[1] = m[1] * x + m[3] * y + m[5];
- return out;
- };
- /**
- * Transforms the vec2 with a mat3
- * 3rd vector component is implicitly '1'
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the vector to transform
- * @param {mat3} m matrix to transform with
- * @returns {vec2} out
- */
- vec2.transformMat3 = function (out, a, m) {
- var x = a[0],
- y = a[1];
- out[0] = m[0] * x + m[3] * y + m[6];
- out[1] = m[1] * x + m[4] * y + m[7];
- return out;
- };
- /**
- * Transforms the vec2 with a mat4
- * 3rd vector component is implicitly '0'
- * 4th vector component is implicitly '1'
- *
- * @param {vec2} out the receiving vector
- * @param {vec2} a the vector to transform
- * @param {mat4} m matrix to transform with
- * @returns {vec2} out
- */
- vec2.transformMat4 = function (out, a, m) {
- var x = a[0],
- y = a[1];
- out[0] = m[0] * x + m[4] * y + m[12];
- out[1] = m[1] * x + m[5] * y + m[13];
- return out;
- };
- /**
- * Perform some operation over an array of vec2s.
- *
- * @param {Array} a the array of vectors to iterate over
- * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
- * @param {Number} offset Number of elements to skip at the beginning of the array
- * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
- * @param {Function} fn Function to call for each vector in the array
- * @param {Object} [arg] additional argument to pass to fn
- * @returns {Array} a
- * @function
- */
- vec2.forEach = (function () {
- var vec = vec2.create();
- return function (a, stride, offset, count, fn, arg) {
- var i, l;
- if (!stride) {
- stride = 2;
- }
- if (!offset) {
- offset = 0;
- }
- if (count) {
- l = Math.min((count * stride) + offset, a.length);
- } else {
- l = a.length;
- }
- for (i = offset; i < l; i += stride) {
- vec[0] = a[i]; vec[1] = a[i + 1];
- fn(vec, vec, arg);
- a[i] = vec[0]; a[i + 1] = vec[1];
- }
- return a;
- };
- })();
- /* harmony default export */ __webpack_exports__["a"] = (vec2);
- /***/
- }),
- /* 71 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.prez.vertex\nuniform mat4 WVP : WORLDVIEWPROJECTION;\nattribute vec3 pos : POSITION;\nattribute vec2 uv : TEXCOORD_0;\n@import clay.chunk.skinning_header\nvarying vec2 v_Texcoord;\nvoid main()\n{\n vec3 P = pos;\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n P = (skinMatrixWS * vec4(pos, 1.0)).xyz;\n#endif\n gl_Position = WVP * vec4(P, 1.0);\n v_Texcoord = uv;\n}\n@end\n@export clay.prez.fragment\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n gl_FragColor = vec4(0.0,0.0,0.0,1.0);\n}\n@end");
- /***/
- }),
- /* 72 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Node__ = __webpack_require__(35);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11);
- /**
- * @constructor
- * @alias clay.Renderable
- * @extends clay.Node
- */
- var Renderable = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].extend(/** @lends clay.Renderable# */ {
- /**
- * @type {clay.Material}
- */
- material: null,
- /**
- * @type {clay.Geometry}
- */
- geometry: null,
- /**
- * @type {number}
- */
- mode: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLES,
- _renderInfo: null
- },
- /** @lends clay.Renderable.prototype */
- {
- __program: null,
- /**
- * Group of received light.
- */
- lightGroup: 0,
- /**
- * Render order, Nodes with smaller value renders before nodes with larger values.
- * @type {Number}
- */
- renderOrder: 0,
- /**
- * Used when mode is LINES, LINE_STRIP or LINE_LOOP
- * @type {number}
- */
- // lineWidth: 1,
- /**
- * If enable culling
- * @type {boolean}
- */
- culling: true,
- /**
- * Specify which side of polygon will be culled.
- * Possible values:
- * + {@link clay.Renderable.BACK}
- * + {@link clay.Renderable.FRONT}
- * + {@link clay.Renderable.FRONT_AND_BACK}
- * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/cullFace
- * @type {number}
- */
- cullFace: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BACK,
- /**
- * Specify which side is front face.
- * Possible values:
- * + {@link clay.Renderable.CW}
- * + {@link clay.Renderable.CCW}
- * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/frontFace
- * @type {number}
- */
- frontFace: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CCW,
- /**
- * If enable software frustum culling
- * @type {boolean}
- */
- frustumCulling: true,
- /**
- * @type {boolean}
- */
- receiveShadow: true,
- /**
- * @type {boolean}
- */
- castShadow: true,
- /**
- * @type {boolean}
- */
- ignorePicking: false,
- /**
- * @type {boolean}
- */
- ignorePreZ: false,
- /**
- * @type {boolean}
- */
- ignoreGBuffer: false,
- /**
- * @return {boolean}
- */
- isRenderable: function () {
- // TODO Shader ?
- return this.geometry && this.material && this.material.shader && !this.invisible
- && this.geometry.vertexCount > 0;
- },
- /**
- * Before render hook
- * @type {Function}
- */
- beforeRender: function (_gl) { },
- /**
- * Before render hook
- * @type {Function}
- */
- afterRender: function (_gl, renderStat) { },
- getBoundingBox: function (filter, out) {
- out = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].prototype.getBoundingBox.call(this, filter, out);
- if (this.geometry && this.geometry.boundingBox) {
- out.union(this.geometry.boundingBox);
- }
- return out;
- },
- /**
- * Clone a new renderable
- * @function
- * @return {clay.Renderable}
- */
- clone: (function () {
- var properties = [
- 'castShadow', 'receiveShadow',
- 'mode', 'culling', 'cullFace', 'frontFace',
- 'frustumCulling',
- 'renderOrder', 'lineWidth',
- 'ignorePicking', 'ignorePreZ', 'ignoreGBuffer'
- ];
- return function () {
- var renderable = __WEBPACK_IMPORTED_MODULE_0__Node__["a" /* default */].prototype.clone.call(this);
- renderable.geometry = this.geometry;
- renderable.material = this.material;
- for (var i = 0; i < properties.length; i++) {
- var name = properties[i];
- // Try not to overwrite the prototype property
- if (renderable[name] !== this[name]) {
- renderable[name] = this[name];
- }
- }
- return renderable;
- };
- })()
- });
- /**
- * @type {number}
- */
- Renderable.POINTS = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].POINTS;
- /**
- * @type {number}
- */
- Renderable.LINES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINES;
- /**
- * @type {number}
- */
- Renderable.LINE_LOOP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_LOOP;
- /**
- * @type {number}
- */
- Renderable.LINE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINE_STRIP;
- /**
- * @type {number}
- */
- Renderable.TRIANGLES = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLES;
- /**
- * @type {number}
- */
- Renderable.TRIANGLE_STRIP = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_STRIP;
- /**
- * @type {number}
- */
- Renderable.TRIANGLE_FAN = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].TRIANGLE_FAN;
- /**
- * @type {number}
- */
- Renderable.BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].BACK;
- /**
- * @type {number}
- */
- Renderable.FRONT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT;
- /**
- * @type {number}
- */
- Renderable.FRONT_AND_BACK = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].FRONT_AND_BACK;
- /**
- * @type {number}
- */
- Renderable.CW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CW;
- /**
- * @type {number}
- */
- Renderable.CCW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CCW;
- /* harmony default export */ __webpack_exports__["a"] = (Renderable);
- /***/
- }),
- /* 73 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var mathUtil = {};
- mathUtil.isPowerOfTwo = function (value) {
- return (value & (value - 1)) === 0;
- };
- mathUtil.nextPowerOfTwo = function (value) {
- value--;
- value |= value >> 1;
- value |= value >> 2;
- value |= value >> 4;
- value |= value >> 8;
- value |= value >> 16;
- value++;
- return value;
- };
- mathUtil.nearestPowerOfTwo = function (value) {
- return Math.pow(2, Math.round(Math.log(value) / Math.LN2));
- };
- /* harmony default export */ __webpack_exports__["a"] = (mathUtil);
- /***/
- }),
- /* 74 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat4__ = __webpack_require__(21);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__ = __webpack_require__(12);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__glmatrix_vec4__ = __webpack_require__(33);
- /**
- * @constructor
- * @alias clay.Plane
- * @param {clay.Vector3} [normal]
- * @param {number} [distance]
- */
- var Plane = function (normal, distance) {
- /**
- * Normal of the plane
- * @type {clay.Vector3}
- */
- this.normal = normal || new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */](0, 1, 0);
- /**
- * Constant of the plane equation, used as distance to the origin
- * @type {number}
- */
- this.distance = distance || 0;
- };
- Plane.prototype = {
- constructor: Plane,
- /**
- * Distance from a given point to the plane
- * @param {clay.Vector3} point
- * @return {number}
- */
- distanceToPoint: function (point) {
- return __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(point.array, this.normal.array) - this.distance;
- },
- /**
- * Calculate the projection point on the plane
- * @param {clay.Vector3} point
- * @param {clay.Vector3} out
- * @return {clay.Vector3}
- */
- projectPoint: function (point, out) {
- if (!out) {
- out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */]();
- }
- var d = this.distanceToPoint(point);
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, point.array, this.normal.array, -d);
- out._dirty = true;
- return out;
- },
- /**
- * Normalize the plane's normal and calculate the distance
- */
- normalize: function () {
- var invLen = 1 / __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].len(this.normal.array);
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].scale(this.normal.array, invLen);
- this.distance *= invLen;
- },
- /**
- * If the plane intersect a frustum
- * @param {clay.Frustum} Frustum
- * @return {boolean}
- */
- intersectFrustum: function (frustum) {
- // Check if all coords of frustum is on plane all under plane
- var coords = frustum.vertices;
- var normal = this.normal.array;
- var onPlane = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(coords[0].array, normal) > this.distance;
- for (var i = 1; i < 8; i++) {
- if ((__WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(coords[i].array, normal) > this.distance) != onPlane) {
- return true;
- }
- }
- },
- /**
- * Calculate the intersection point between plane and a given line
- * @function
- * @param {clay.Vector3} start start point of line
- * @param {clay.Vector3} end end point of line
- * @param {clay.Vector3} [out]
- * @return {clay.Vector3}
- */
- intersectLine: (function () {
- var rd = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].create();
- return function (start, end, out) {
- var d0 = this.distanceToPoint(start);
- var d1 = this.distanceToPoint(end);
- if ((d0 > 0 && d1 > 0) || (d0 < 0 && d1 < 0)) {
- return null;
- }
- // Ray intersection
- var pn = this.normal.array;
- var d = this.distance;
- var ro = start.array;
- // direction
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].sub(rd, end.array, start.array);
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].normalize(rd, rd);
- var divider = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(pn, rd);
- // ray is parallel to the plane
- if (divider === 0) {
- return null;
- }
- if (!out) {
- out = new __WEBPACK_IMPORTED_MODULE_0__Vector3__["a" /* default */]();
- }
- var t = (__WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(pn, ro) - d) / divider;
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].scaleAndAdd(out.array, ro, rd, -t);
- out._dirty = true;
- return out;
- };
- })(),
- /**
- * Apply an affine transform matrix to plane
- * @function
- * @return {clay.Matrix4}
- */
- applyTransform: (function () {
- var inverseTranspose = __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat4__["a" /* default */].create();
- var normalv4 = __WEBPACK_IMPORTED_MODULE_3__glmatrix_vec4__["a" /* default */].create();
- var pointv4 = __WEBPACK_IMPORTED_MODULE_3__glmatrix_vec4__["a" /* default */].create();
- pointv4[3] = 1;
- return function (m4) {
- m4 = m4.array;
- // Transform point on plane
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].scale(pointv4, this.normal.array, this.distance);
- __WEBPACK_IMPORTED_MODULE_3__glmatrix_vec4__["a" /* default */].transformMat4(pointv4, pointv4, m4);
- this.distance = __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].dot(pointv4, this.normal.array);
- // Transform plane normal
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat4__["a" /* default */].invert(inverseTranspose, m4);
- __WEBPACK_IMPORTED_MODULE_1__glmatrix_mat4__["a" /* default */].transpose(inverseTranspose, inverseTranspose);
- normalv4[3] = 0;
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].copy(normalv4, this.normal.array);
- __WEBPACK_IMPORTED_MODULE_3__glmatrix_vec4__["a" /* default */].transformMat4(normalv4, normalv4, inverseTranspose);
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].copy(this.normal.array, normalv4);
- };
- })(),
- /**
- * Copy from another plane
- * @param {clay.Vector3} plane
- */
- copy: function (plane) {
- __WEBPACK_IMPORTED_MODULE_2__glmatrix_vec3__["a" /* default */].copy(this.normal.array, plane.normal.array);
- this.normal._dirty = true;
- this.distance = plane.distance;
- },
- /**
- * Clone a new plane
- * @return {clay.Plane}
- */
- clone: function () {
- var plane = new Plane();
- plane.copy(this);
- return plane;
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (Plane);
- /***/
- }),
- /* 75 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Skybox__ = __webpack_require__(42);
- /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__Skybox__["a" /* default */]);
- /***/
- }),
- /* 76 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(15);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Plane__ = __webpack_require__(43);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__math_BoundingBox__ = __webpack_require__(18);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__core_vendor__ = __webpack_require__(14);
- var planeMatrix = new __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */]();
- /**
- * @constructor clay.geometry.Cube
- * @extends clay.Geometry
- * @param {Object} [opt]
- * @param {number} [opt.widthSegments]
- * @param {number} [opt.heightSegments]
- * @param {number} [opt.depthSegments]
- * @param {boolean} [opt.inside]
- */
- var Cube = __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].extend(
- /**@lends clay.geometry.Cube# */
- {
- dynamic: false,
- /**
- * @type {number}
- */
- widthSegments: 1,
- /**
- * @type {number}
- */
- heightSegments: 1,
- /**
- * @type {number}
- */
- depthSegments: 1,
- /**
- * @type {boolean}
- */
- inside: false
- }, function () {
- this.build();
- },
- /** @lends clay.geometry.Cube.prototype */
- {
- /**
- * Build cube geometry
- */
- build: function () {
- var planes = {
- 'px': createPlane('px', this.depthSegments, this.heightSegments),
- 'nx': createPlane('nx', this.depthSegments, this.heightSegments),
- 'py': createPlane('py', this.widthSegments, this.depthSegments),
- 'ny': createPlane('ny', this.widthSegments, this.depthSegments),
- 'pz': createPlane('pz', this.widthSegments, this.heightSegments),
- 'nz': createPlane('nz', this.widthSegments, this.heightSegments),
- };
- var attrList = ['position', 'texcoord0', 'normal'];
- var vertexNumber = 0;
- var faceNumber = 0;
- for (var pos in planes) {
- vertexNumber += planes[pos].vertexCount;
- faceNumber += planes[pos].indices.length;
- }
- for (var k = 0; k < attrList.length; k++) {
- this.attributes[attrList[k]].init(vertexNumber);
- }
- this.indices = new __WEBPACK_IMPORTED_MODULE_5__core_vendor__["a" /* default */].Uint16Array(faceNumber);
- var faceOffset = 0;
- var vertexOffset = 0;
- for (var pos in planes) {
- var plane = planes[pos];
- for (var k = 0; k < attrList.length; k++) {
- var attrName = attrList[k];
- var attrArray = plane.attributes[attrName].value;
- var attrSize = plane.attributes[attrName].size;
- var isNormal = attrName === 'normal';
- for (var i = 0; i < attrArray.length; i++) {
- var value = attrArray[i];
- if (this.inside && isNormal) {
- value = -value;
- }
- this.attributes[attrName].value[i + attrSize * vertexOffset] = value;
- }
- }
- var len = plane.indices.length;
- for (var i = 0; i < plane.indices.length; i++) {
- this.indices[i + faceOffset] = vertexOffset + plane.indices[this.inside ? (len - i - 1) : i];
- }
- faceOffset += plane.indices.length;
- vertexOffset += plane.vertexCount;
- }
- this.boundingBox = new __WEBPACK_IMPORTED_MODULE_4__math_BoundingBox__["a" /* default */]();
- this.boundingBox.max.set(1, 1, 1);
- this.boundingBox.min.set(-1, -1, -1);
- }
- });
- function createPlane(pos, widthSegments, heightSegments) {
- planeMatrix.identity();
- var plane = new __WEBPACK_IMPORTED_MODULE_1__Plane__["a" /* default */]({
- widthSegments: widthSegments,
- heightSegments: heightSegments
- });
- switch (pos) {
- case 'px':
- __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].POSITIVE_X);
- __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateY(planeMatrix, planeMatrix, Math.PI / 2);
- break;
- case 'nx':
- __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].NEGATIVE_X);
- __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateY(planeMatrix, planeMatrix, -Math.PI / 2);
- break;
- case 'py':
- __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].POSITIVE_Y);
- __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateX(planeMatrix, planeMatrix, -Math.PI / 2);
- break;
- case 'ny':
- __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].NEGATIVE_Y);
- __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateX(planeMatrix, planeMatrix, Math.PI / 2);
- break;
- case 'pz':
- __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].POSITIVE_Z);
- break;
- case 'nz':
- __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].translate(planeMatrix, planeMatrix, __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].NEGATIVE_Z);
- __WEBPACK_IMPORTED_MODULE_2__math_Matrix4__["a" /* default */].rotateY(planeMatrix, planeMatrix, Math.PI);
- break;
- }
- plane.applyTransform(planeMatrix);
- return plane;
- }
- /* harmony default export */ __webpack_exports__["a"] = (Cube);
- /***/
- }),
- /* 77 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TextureCube__ = __webpack_require__(27);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__ = __webpack_require__(10);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__compositor_Pass__ = __webpack_require__(16);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Material__ = __webpack_require__(19);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__plugin_Skybox__ = __webpack_require__(42);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Scene__ = __webpack_require__(36);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__prePass_EnvironmentMap__ = __webpack_require__(62);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__core_vendor__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__texture__ = __webpack_require__(61);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__shader_integrateBRDF_glsl_js__ = __webpack_require__(127);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__shader_prefilter_glsl_js__ = __webpack_require__(128);
- // Cubemap prefilter utility
- // http://www.unrealengine.com/files/downloads/2013SiggraphPresentationsNotes.pdf
- // http://http.developer.nvidia.com/GPUGems3/gpugems3_ch20.html
- var cubemapUtil = {};
- var targets = ['px', 'nx', 'py', 'ny', 'pz', 'nz'];
- // TODO Downsample
- /**
- * @name clay.util.cubemap.prefilterEnvironmentMap
- * @param {clay.Renderer} renderer
- * @param {clay.Texture} envMap
- * @param {Object} [textureOpts]
- * @param {number} [textureOpts.width=64]
- * @param {number} [textureOpts.height=64]
- * @param {number} [textureOpts.type]
- * @param {boolean} [textureOpts.encodeRGBM=false]
- * @param {boolean} [textureOpts.decodeRGBM=false]
- * @param {clay.Texture2D} [normalDistribution]
- * @param {clay.Texture2D} [brdfLookup]
- */
- cubemapUtil.prefilterEnvironmentMap = function (
- renderer, envMap, textureOpts, normalDistribution, brdfLookup
- ) {
- // Not create other renderer, it is easy having issue of cross reference of resources like framebuffer
- // PENDING preserveDrawingBuffer?
- if (!brdfLookup || !normalDistribution) {
- normalDistribution = cubemapUtil.generateNormalDistribution();
- brdfLookup = cubemapUtil.integrateBRDF(renderer, normalDistribution);
- }
- textureOpts = textureOpts || {};
- var width = textureOpts.width || 64;
- var height = textureOpts.height || 64;
- var textureType = textureOpts.type || envMap.type;
- // Use same type with given envMap
- var prefilteredCubeMap = new __WEBPACK_IMPORTED_MODULE_1__TextureCube__["a" /* default */]({
- width: width,
- height: height,
- type: textureType,
- flipY: false,
- mipmaps: []
- });
- if (!prefilteredCubeMap.isPowerOfTwo()) {
- console.warn('Width and height must be power of two to enable mipmap.');
- }
- var size = Math.min(width, height);
- var mipmapNum = Math.log(size) / Math.log(2) + 1;
- var prefilterMaterial = new __WEBPACK_IMPORTED_MODULE_5__Material__["a" /* default */]({
- shader: new __WEBPACK_IMPORTED_MODULE_6__Shader__["a" /* default */]({
- vertex: __WEBPACK_IMPORTED_MODULE_6__Shader__["a" /* default */].source('clay.skybox.vertex'),
- fragment: __WEBPACK_IMPORTED_MODULE_13__shader_prefilter_glsl_js__["a" /* default */]
- })
- });
- prefilterMaterial.set('normalDistribution', normalDistribution);
- textureOpts.encodeRGBM && prefilterMaterial.define('fragment', 'RGBM_ENCODE');
- textureOpts.decodeRGBM && prefilterMaterial.define('fragment', 'RGBM_DECODE');
- var dummyScene = new __WEBPACK_IMPORTED_MODULE_8__Scene__["a" /* default */]();
- var skyEnv;
- if (envMap.textureType === 'texture2D') {
- // Convert panorama to cubemap
- var envCubemap = new __WEBPACK_IMPORTED_MODULE_1__TextureCube__["a" /* default */]({
- width: width,
- height: height,
- // FIXME FLOAT type will cause GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT error on iOS
- type: textureType === __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].FLOAT ?
- __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].HALF_FLOAT : textureType
- });
- __WEBPACK_IMPORTED_MODULE_11__texture__["a" /* default */].panoramaToCubeMap(renderer, envMap, envCubemap, {
- // PENDING encodeRGBM so it can be decoded as RGBM
- encodeRGBM: textureOpts.decodeRGBM
- });
- envMap = envCubemap;
- }
- skyEnv = new __WEBPACK_IMPORTED_MODULE_7__plugin_Skybox__["a" /* default */]({
- scene: dummyScene,
- material: prefilterMaterial
- });
- skyEnv.material.set('environmentMap', envMap);
- var envMapPass = new __WEBPACK_IMPORTED_MODULE_9__prePass_EnvironmentMap__["a" /* default */]({
- texture: prefilteredCubeMap
- });
- // Force to be UNSIGNED_BYTE
- if (textureOpts.encodeRGBM) {
- textureType = prefilteredCubeMap.type = __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].UNSIGNED_BYTE;
- }
- var renderTargetTmp = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({
- width: width,
- height: height,
- type: textureType
- });
- var frameBuffer = new __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__["a" /* default */]({
- depthBuffer: false
- });
- var ArrayCtor = __WEBPACK_IMPORTED_MODULE_10__core_vendor__["a" /* default */][textureType === __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].UNSIGNED_BYTE ? 'Uint8Array' : 'Float32Array'];
- for (var i = 0; i < mipmapNum; i++) {
- // console.time('prefilter');
- prefilteredCubeMap.mipmaps[i] = {
- pixels: {}
- };
- skyEnv.material.set('roughness', i / (mipmapNum - 1));
- // Tweak fov
- // http://the-witness.net/news/2012/02/seamless-cube-map-filtering/
- var n = renderTargetTmp.width;
- var fov = 2 * Math.atan(n / (n - 0.5)) / Math.PI * 180;
- for (var j = 0; j < targets.length; j++) {
- var pixels = new ArrayCtor(renderTargetTmp.width * renderTargetTmp.height * 4);
- frameBuffer.attach(renderTargetTmp);
- frameBuffer.bind(renderer);
- var camera = envMapPass.getCamera(targets[j]);
- camera.fov = fov;
- renderer.render(dummyScene, camera);
- renderer.gl.readPixels(
- 0, 0, renderTargetTmp.width, renderTargetTmp.height,
- __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].RGBA, textureType, pixels
- );
- // var canvas = document.createElement('canvas');
- // var ctx = canvas.getContext('2d');
- // canvas.width = renderTargetTmp.width;
- // canvas.height = renderTargetTmp.height;
- // var imageData = ctx.createImageData(renderTargetTmp.width, renderTargetTmp.height);
- // for (var k = 0; k < pixels.length; k++) {
- // imageData.data[k] = pixels[k];
- // }
- // ctx.putImageData(imageData, 0, 0);
- // document.body.appendChild(canvas);
- frameBuffer.unbind(renderer);
- prefilteredCubeMap.mipmaps[i].pixels[targets[j]] = pixels;
- }
- renderTargetTmp.width /= 2;
- renderTargetTmp.height /= 2;
- renderTargetTmp.dirty();
- // console.timeEnd('prefilter');
- }
- frameBuffer.dispose(renderer);
- renderTargetTmp.dispose(renderer);
- skyEnv.dispose(renderer);
- // Remove gpu resource allucated in renderer
- normalDistribution.dispose(renderer);
- // renderer.dispose();
- return {
- environmentMap: prefilteredCubeMap,
- brdfLookup: brdfLookup,
- normalDistribution: normalDistribution,
- maxMipmapLevel: mipmapNum
- };
- };
- cubemapUtil.integrateBRDF = function (renderer, normalDistribution) {
- normalDistribution = normalDistribution || cubemapUtil.generateNormalDistribution();
- var framebuffer = new __WEBPACK_IMPORTED_MODULE_3__FrameBuffer__["a" /* default */]({
- depthBuffer: false
- });
- var pass = new __WEBPACK_IMPORTED_MODULE_4__compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_12__shader_integrateBRDF_glsl_js__["a" /* default */]
- });
- var texture = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({
- width: 512,
- height: 256,
- type: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].HALF_FLOAT,
- wrapS: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].CLAMP_TO_EDGE,
- wrapT: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].CLAMP_TO_EDGE,
- minFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST,
- magFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST,
- useMipmap: false
- });
- pass.setUniform('normalDistribution', normalDistribution);
- pass.setUniform('viewportSize', [512, 256]);
- pass.attachOutput(texture);
- pass.render(renderer, framebuffer);
- // FIXME Only chrome and firefox can readPixels with float type.
- // framebuffer.bind(renderer);
- // var pixels = new Float32Array(512 * 256 * 4);
- // renderer.gl.readPixels(
- // 0, 0, texture.width, texture.height,
- // Texture.RGBA, Texture.FLOAT, pixels
- // );
- // texture.pixels = pixels;
- // texture.flipY = false;
- // texture.dirty();
- // framebuffer.unbind(renderer);
- framebuffer.dispose(renderer);
- return texture;
- };
- cubemapUtil.generateNormalDistribution = function (roughnessLevels, sampleSize) {
- // http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
- // GLSL not support bit operation, use lookup instead
- // V -> i / N, U -> roughness
- var roughnessLevels = roughnessLevels || 256;
- var sampleSize = sampleSize || 1024;
- var normalDistribution = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */]({
- width: roughnessLevels,
- height: sampleSize,
- type: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].FLOAT,
- minFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST,
- magFilter: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].NEAREST,
- wrapS: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].CLAMP_TO_EDGE,
- wrapT: __WEBPACK_IMPORTED_MODULE_2__Texture__["a" /* default */].CLAMP_TO_EDGE,
- useMipmap: false
- });
- var pixels = new Float32Array(sampleSize * roughnessLevels * 4);
- var tmp = [];
- // function sortFunc(a, b) {
- // return Math.abs(b) - Math.abs(a);
- // }
- for (var j = 0; j < roughnessLevels; j++) {
- var roughness = j / roughnessLevels;
- var a = roughness * roughness;
- for (var i = 0; i < sampleSize; i++) {
- // http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators
- // http://stackoverflow.com/questions/1908492/unsigned-integer-in-javascript
- // http://stackoverflow.com/questions/1822350/what-is-the-javascript-operator-and-how-do-you-use-it
- var y = (i << 16 | i >>> 16) >>> 0;
- y = ((y & 1431655765) << 1 | (y & 2863311530) >>> 1) >>> 0;
- y = ((y & 858993459) << 2 | (y & 3435973836) >>> 2) >>> 0;
- y = ((y & 252645135) << 4 | (y & 4042322160) >>> 4) >>> 0;
- y = (((y & 16711935) << 8 | (y & 4278255360) >>> 8) >>> 0) / 4294967296;
- // CDF
- var cosTheta = Math.sqrt((1 - y) / (1 + (a * a - 1.0) * y));
- tmp[i] = cosTheta;
- }
- for (var i = 0; i < sampleSize; i++) {
- var offset = (i * roughnessLevels + j) * 4;
- var cosTheta = tmp[i];
- var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
- var x = i / sampleSize;
- var phi = 2.0 * Math.PI * x;
- pixels[offset] = sinTheta * Math.cos(phi);
- pixels[offset + 1] = cosTheta;
- pixels[offset + 2] = sinTheta * Math.sin(phi);
- pixels[offset + 3] = 1.0;
- }
- }
- normalDistribution.pixels = pixels;
- return normalDistribution;
- };
- /* harmony default export */ __webpack_exports__["a"] = (cubemapUtil);
- /***/
- }),
- /* 78 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20);
- /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
- /**
- * @class 2x2 Matrix
- * @name mat2
- */
- var mat2 = {};
- /**
- * Creates a new identity mat2
- *
- * @returns {mat2} a new 2x2 matrix
- */
- mat2.create = function () {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4);
- out[0] = 1;
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
- return out;
- };
- /**
- * Creates a new mat2 initialized with values from an existing matrix
- *
- * @param {mat2} a matrix to clone
- * @returns {mat2} a new 2x2 matrix
- */
- mat2.clone = function (a) {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](4);
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- return out;
- };
- /**
- * Copy the values from one mat2 to another
- *
- * @param {mat2} out the receiving matrix
- * @param {mat2} a the source matrix
- * @returns {mat2} out
- */
- mat2.copy = function (out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- return out;
- };
- /**
- * Set a mat2 to the identity matrix
- *
- * @param {mat2} out the receiving matrix
- * @returns {mat2} out
- */
- mat2.identity = function (out) {
- out[0] = 1;
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
- return out;
- };
- /**
- * Transpose the values of a mat2
- *
- * @param {mat2} out the receiving matrix
- * @param {mat2} a the source matrix
- * @returns {mat2} out
- */
- mat2.transpose = function (out, a) {
- // If we are transposing ourselves we can skip a few steps but have to cache some values
- if (out === a) {
- var a1 = a[1];
- out[1] = a[2];
- out[2] = a1;
- } else {
- out[0] = a[0];
- out[1] = a[2];
- out[2] = a[1];
- out[3] = a[3];
- }
- return out;
- };
- /**
- * Inverts a mat2
- *
- * @param {mat2} out the receiving matrix
- * @param {mat2} a the source matrix
- * @returns {mat2} out
- */
- mat2.invert = function (out, a) {
- var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
- // Calculate the determinant
- det = a0 * a3 - a2 * a1;
- if (!det) {
- return null;
- }
- det = 1.0 / det;
- out[0] = a3 * det;
- out[1] = -a1 * det;
- out[2] = -a2 * det;
- out[3] = a0 * det;
- return out;
- };
- /**
- * Calculates the adjugate of a mat2
- *
- * @param {mat2} out the receiving matrix
- * @param {mat2} a the source matrix
- * @returns {mat2} out
- */
- mat2.adjoint = function (out, a) {
- // Caching this value is nessecary if out == a
- var a0 = a[0];
- out[0] = a[3];
- out[1] = -a[1];
- out[2] = -a[2];
- out[3] = a0;
- return out;
- };
- /**
- * Calculates the determinant of a mat2
- *
- * @param {mat2} a the source matrix
- * @returns {Number} determinant of a
- */
- mat2.determinant = function (a) {
- return a[0] * a[3] - a[2] * a[1];
- };
- /**
- * Multiplies two mat2's
- *
- * @param {mat2} out the receiving matrix
- * @param {mat2} a the first operand
- * @param {mat2} b the second operand
- * @returns {mat2} out
- */
- mat2.multiply = function (out, a, b) {
- var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
- var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
- out[0] = a0 * b0 + a2 * b1;
- out[1] = a1 * b0 + a3 * b1;
- out[2] = a0 * b2 + a2 * b3;
- out[3] = a1 * b2 + a3 * b3;
- return out;
- };
- /**
- * Alias for {@link mat2.multiply}
- * @function
- */
- mat2.mul = mat2.multiply;
- /**
- * Rotates a mat2 by the given angle
- *
- * @param {mat2} out the receiving matrix
- * @param {mat2} a the matrix to rotate
- * @param {Number} rad the angle to rotate the matrix by
- * @returns {mat2} out
- */
- mat2.rotate = function (out, a, rad) {
- var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
- s = Math.sin(rad),
- c = Math.cos(rad);
- out[0] = a0 * c + a2 * s;
- out[1] = a1 * c + a3 * s;
- out[2] = a0 * -s + a2 * c;
- out[3] = a1 * -s + a3 * c;
- return out;
- };
- /**
- * Scales the mat2 by the dimensions in the given vec2
- *
- * @param {mat2} out the receiving matrix
- * @param {mat2} a the matrix to rotate
- * @param {vec2} v the vec2 to scale the matrix by
- * @returns {mat2} out
- **/
- mat2.scale = function (out, a, v) {
- var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
- v0 = v[0], v1 = v[1];
- out[0] = a0 * v0;
- out[1] = a1 * v0;
- out[2] = a2 * v1;
- out[3] = a3 * v1;
- return out;
- };
- /**
- * Returns Frobenius norm of a mat2
- *
- * @param {mat2} a the matrix to calculate Frobenius norm of
- * @returns {Number} Frobenius norm
- */
- mat2.frob = function (a) {
- return (Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2)))
- };
- /**
- * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix
- * @param {mat2} L the lower triangular matrix
- * @param {mat2} D the diagonal matrix
- * @param {mat2} U the upper triangular matrix
- * @param {mat2} a the input matrix to factorize
- */
- mat2.LDU = function (L, D, U, a) {
- L[2] = a[2] / a[0];
- U[0] = a[0];
- U[1] = a[1];
- U[3] = a[3] - L[2] * U[1];
- return [L, D, U];
- };
- /* harmony default export */ __webpack_exports__["a"] = (mat2);
- /***/
- }),
- /* 79 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common__ = __webpack_require__(20);
- /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
- /**
- * @class 2x3 Matrix
- * @name mat2d
- *
- * @description
- * A mat2d contains six elements defined as:
- * <pre>
- * [a, c, tx,
- * b, d, ty]
- * </pre>
- * This is a short form for the 3x3 matrix:
- * <pre>
- * [a, c, tx,
- * b, d, ty,
- * 0, 0, 1]
- * </pre>
- * The last row is ignored so the array is shorter and operations are faster.
- */
- var mat2d = {};
- /**
- * Creates a new identity mat2d
- *
- * @returns {mat2d} a new 2x3 matrix
- */
- mat2d.create = function () {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](6);
- out[0] = 1;
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
- out[4] = 0;
- out[5] = 0;
- return out;
- };
- /**
- * Creates a new mat2d initialized with values from an existing matrix
- *
- * @param {mat2d} a matrix to clone
- * @returns {mat2d} a new 2x3 matrix
- */
- mat2d.clone = function (a) {
- var out = new __WEBPACK_IMPORTED_MODULE_0__common__["a" /* GLMAT_ARRAY_TYPE */](6);
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- out[4] = a[4];
- out[5] = a[5];
- return out;
- };
- /**
- * Copy the values from one mat2d to another
- *
- * @param {mat2d} out the receiving matrix
- * @param {mat2d} a the source matrix
- * @returns {mat2d} out
- */
- mat2d.copy = function (out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- out[4] = a[4];
- out[5] = a[5];
- return out;
- };
- /**
- * Set a mat2d to the identity matrix
- *
- * @param {mat2d} out the receiving matrix
- * @returns {mat2d} out
- */
- mat2d.identity = function (out) {
- out[0] = 1;
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
- out[4] = 0;
- out[5] = 0;
- return out;
- };
- /**
- * Inverts a mat2d
- *
- * @param {mat2d} out the receiving matrix
- * @param {mat2d} a the source matrix
- * @returns {mat2d} out
- */
- mat2d.invert = function (out, a) {
- var aa = a[0], ab = a[1], ac = a[2], ad = a[3],
- atx = a[4], aty = a[5];
- var det = aa * ad - ab * ac;
- if (!det) {
- return null;
- }
- det = 1.0 / det;
- out[0] = ad * det;
- out[1] = -ab * det;
- out[2] = -ac * det;
- out[3] = aa * det;
- out[4] = (ac * aty - ad * atx) * det;
- out[5] = (ab * atx - aa * aty) * det;
- return out;
- };
- /**
- * Calculates the determinant of a mat2d
- *
- * @param {mat2d} a the source matrix
- * @returns {Number} determinant of a
- */
- mat2d.determinant = function (a) {
- return a[0] * a[3] - a[1] * a[2];
- };
- /**
- * Multiplies two mat2d's
- *
- * @param {mat2d} out the receiving matrix
- * @param {mat2d} a the first operand
- * @param {mat2d} b the second operand
- * @returns {mat2d} out
- */
- mat2d.multiply = function (out, a, b) {
- var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],
- b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];
- out[0] = a0 * b0 + a2 * b1;
- out[1] = a1 * b0 + a3 * b1;
- out[2] = a0 * b2 + a2 * b3;
- out[3] = a1 * b2 + a3 * b3;
- out[4] = a0 * b4 + a2 * b5 + a4;
- out[5] = a1 * b4 + a3 * b5 + a5;
- return out;
- };
- /**
- * Alias for {@link mat2d.multiply}
- * @function
- */
- mat2d.mul = mat2d.multiply;
- /**
- * Rotates a mat2d by the given angle
- *
- * @param {mat2d} out the receiving matrix
- * @param {mat2d} a the matrix to rotate
- * @param {Number} rad the angle to rotate the matrix by
- * @returns {mat2d} out
- */
- mat2d.rotate = function (out, a, rad) {
- var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],
- s = Math.sin(rad),
- c = Math.cos(rad);
- out[0] = a0 * c + a2 * s;
- out[1] = a1 * c + a3 * s;
- out[2] = a0 * -s + a2 * c;
- out[3] = a1 * -s + a3 * c;
- out[4] = a4;
- out[5] = a5;
- return out;
- };
- /**
- * Scales the mat2d by the dimensions in the given vec2
- *
- * @param {mat2d} out the receiving matrix
- * @param {mat2d} a the matrix to translate
- * @param {vec2} v the vec2 to scale the matrix by
- * @returns {mat2d} out
- **/
- mat2d.scale = function (out, a, v) {
- var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],
- v0 = v[0], v1 = v[1];
- out[0] = a0 * v0;
- out[1] = a1 * v0;
- out[2] = a2 * v1;
- out[3] = a3 * v1;
- out[4] = a4;
- out[5] = a5;
- return out;
- };
- /**
- * Translates the mat2d by the dimensions in the given vec2
- *
- * @param {mat2d} out the receiving matrix
- * @param {mat2d} a the matrix to translate
- * @param {vec2} v the vec2 to translate the matrix by
- * @returns {mat2d} out
- **/
- mat2d.translate = function (out, a, v) {
- var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],
- v0 = v[0], v1 = v[1];
- out[0] = a0;
- out[1] = a1;
- out[2] = a2;
- out[3] = a3;
- out[4] = a0 * v0 + a2 * v1 + a4;
- out[5] = a1 * v0 + a3 * v1 + a5;
- return out;
- };
- /**
- * Returns Frobenius norm of a mat2d
- *
- * @param {mat2d} a the matrix to calculate Frobenius norm of
- * @returns {Number} Frobenius norm
- */
- mat2d.frob = function (a) {
- return (Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + 1))
- };
- /* harmony default export */ __webpack_exports__["a"] = (mat2d);
- /***/
- }),
- /* 80 */
- /***/ (function (module, exports) {
- var _default = typeof window !== 'undefined' && (window.requestAnimationFrame && window.requestAnimationFrame.bind(window) || // https://github.com/ecomfe/zrender/issues/189#issuecomment-224919809
- window.msRequestAnimationFrame && window.msRequestAnimationFrame.bind(window) || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame) || function (func) {
- setTimeout(func, 16);
- };
- module.exports = _default;
- /***/
- }),
- /* 81 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture2D__ = __webpack_require__(5);
- /**
- * Texture Atlas for the sprites.
- * It uses zrender for 2d element management and rendering
- * @module echarts-gl/util/ZRTextureAtlasSurface
- */
- // TODO Expand.
- function ZRTextureAtlasSurfaceNode(zr, offsetX, offsetY, width, height, gap, dpr) {
- this._zr = zr;
- /**
- * Current cursor x
- * @type {number}
- * @private
- */
- this._x = 0;
- /**
- * Current cursor y
- * @type {number}
- */
- this._y = 0;
- this._rowHeight = 0;
- /**
- * width without dpr.
- * @type {number}
- * @private
- */
- this.width = width;
- /**
- * height without dpr.
- * @type {number}
- * @private
- */
- this.height = height;
- /**
- * offsetX without dpr
- * @type {number}
- */
- this.offsetX = offsetX;
- /**
- * offsetY without dpr
- * @type {number}
- */
- this.offsetY = offsetY;
- this.dpr = dpr;
- this.gap = gap;
- }
- ZRTextureAtlasSurfaceNode.prototype = {
- constructor: ZRTextureAtlasSurfaceNode,
- clear: function () {
- this._x = 0;
- this._y = 0;
- this._rowHeight = 0;
- },
- /**
- * Add shape to atlas
- * @param {module:zrender/graphic/Displayable} shape
- * @param {number} width
- * @param {number} height
- * @return {Array}
- */
- add: function (el, width, height) {
- // FIXME Text element not consider textAlign and textVerticalAlign.
- // TODO, inner text, shadow
- var rect = el.getBoundingRect();
- // FIXME aspect ratio
- if (width == null) {
- width = rect.width;
- }
- if (height == null) {
- height = rect.height;
- }
- width *= this.dpr;
- height *= this.dpr;
- this._fitElement(el, width, height);
- // var aspect = el.scale[1] / el.scale[0];
- // Adjust aspect ratio to make the text more clearly
- // FIXME If height > width, width is useless ?
- // width = height * aspect;
- // el.position[0] *= aspect;
- // el.scale[0] = el.scale[1];
- var x = this._x;
- var y = this._y;
- var canvasWidth = this.width * this.dpr;
- var canvasHeight = this.height * this.dpr;
- var gap = this.gap;
- if (x + width + gap > canvasWidth) {
- // Change a new row
- x = this._x = 0;
- y += this._rowHeight + gap;
- this._y = y;
- // Reset row height
- this._rowHeight = 0;
- }
- this._x += width + gap;
- this._rowHeight = Math.max(this._rowHeight, height);
- if (y + height + gap > canvasHeight) {
- // There is no space anymore
- return null;
- }
- // Shift the el
- el.position[0] += this.offsetX * this.dpr + x;
- el.position[1] += this.offsetY * this.dpr + y;
- this._zr.add(el);
- var coordsOffset = [
- this.offsetX / this.width,
- this.offsetY / this.height
- ];
- var coords = [
- [x / canvasWidth + coordsOffset[0], y / canvasHeight + coordsOffset[1]],
- [(x + width) / canvasWidth + coordsOffset[0], (y + height) / canvasHeight + coordsOffset[1]]
- ];
- return coords;
- },
- /**
- * Fit element size by correct its position and scaling
- * @param {module:zrender/graphic/Displayable} el
- * @param {number} spriteWidth
- * @param {number} spriteHeight
- */
- _fitElement: function (el, spriteWidth, spriteHeight) {
- // TODO, inner text, shadow
- var rect = el.getBoundingRect();
- var scaleX = spriteWidth / rect.width;
- var scaleY = spriteHeight / rect.height;
- el.position = [-rect.x * scaleX, -rect.y * scaleY];
- el.scale = [scaleX, scaleY];
- el.update();
- }
- }
- /**
- * constructor
- * @alias module:echarts-gl/util/ZRTextureAtlasSurface
- * @param {number} opt.width
- * @param {number} opt.height
- * @param {number} opt.devicePixelRatio
- * @param {number} opt.gap Gap for safe.
- * @param {Function} opt.onupdate
- */
- function ZRTextureAtlasSurface(opt) {
- opt = opt || {};
- opt.width = opt.width || 512;
- opt.height = opt.height || 512;
- opt.devicePixelRatio = opt.devicePixelRatio || 1;
- opt.gap = opt.gap == null ? 2 : opt.gap;
- var canvas = document.createElement('canvas');
- canvas.width = opt.width * opt.devicePixelRatio;
- canvas.height = opt.height * opt.devicePixelRatio;
- this._canvas = canvas;
- this._texture = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture2D__["a" /* default */]({
- image: canvas,
- flipY: false
- });
- var self = this;
- /**
- * zrender instance in the Chart
- * @type {zrender~ZRender}
- */
- this._zr = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.zrender.init(canvas);
- var oldRefreshImmediately = this._zr.refreshImmediately;
- this._zr.refreshImmediately = function () {
- oldRefreshImmediately.call(this);
- self._texture.dirty();
- self.onupdate && self.onupdate();
- };
- this._dpr = opt.devicePixelRatio;
- /**
- * Texture coords map for each sprite image
- * @type {Object}
- */
- this._coords = {};
- this.onupdate = opt.onupdate;
- this._gap = opt.gap;
- // Left sub atlas.
- this._textureAtlasNodes = [new ZRTextureAtlasSurfaceNode(
- this._zr, 0, 0, opt.width, opt.height, this._gap, this._dpr
- )];
- this._nodeWidth = opt.width;
- this._nodeHeight = opt.height;
- this._currentNodeIdx = 0;
- }
- ZRTextureAtlasSurface.prototype = {
- /**
- * Clear the texture atlas
- */
- clear: function () {
- for (var i = 0; i < this._textureAtlasNodes.length; i++) {
- this._textureAtlasNodes[i].clear();
- }
- this._currentNodeIdx = 0;
- this._zr.clear();
- this._coords = {};
- },
- /**
- * @return {number}
- */
- getWidth: function () {
- return this._width;
- },
- /**
- * @return {number}
- */
- getHeight: function () {
- return this._height;
- },
- /**
- * @return {number}
- */
- getTexture: function () {
- return this._texture;
- },
- /**
- * @return {number}
- */
- getDevicePixelRatio: function () {
- return this._dpr;
- },
- getZr: function () {
- return this._zr;
- },
- _getCurrentNode: function () {
- return this._textureAtlasNodes[this._currentNodeIdx];
- },
- _expand: function () {
- this._currentNodeIdx++;
- if (this._textureAtlasNodes[this._currentNodeIdx]) {
- // Use the node created previously.
- return this._textureAtlasNodes[this._currentNodeIdx];
- }
- var maxSize = 4096 / this._dpr;
- var textureAtlasNodes = this._textureAtlasNodes;
- var nodeLen = textureAtlasNodes.length;
- var offsetX = (nodeLen * this._nodeWidth) % maxSize;
- var offsetY = Math.floor(nodeLen * this._nodeWidth / maxSize) * this._nodeHeight;
- if (offsetY >= maxSize) {
- // Failed if image is too large.
- if (true) {
- console.error('Too much labels. Some will be ignored.');
- }
- return;
- }
- var width = (offsetX + this._nodeWidth) * this._dpr;
- var height = (offsetY + this._nodeHeight) * this._dpr;
- try {
- // Resize will error in node.
- this._zr.resize({
- width: width,
- height: height
- });
- }
- catch (e) {
- this._canvas.width = width;
- this._canvas.height = height;
- }
- var newNode = new ZRTextureAtlasSurfaceNode(
- this._zr, offsetX, offsetY, this._nodeWidth, this._nodeHeight, this._gap, this._dpr
- );
- this._textureAtlasNodes.push(newNode);
- return newNode;
- },
- add: function (el, width, height) {
- if (this._coords[el.id]) {
- if (true) {
- console.warn('Element already been add');
- }
- return this._coords[el.id];
- }
- var coords = this._getCurrentNode().add(el, width, height);
- if (!coords) {
- var newNode = this._expand();
- if (!newNode) {
- // To maximum
- return;
- }
- coords = newNode.add(el, width, height);
- }
- this._coords[el.id] = coords;
- return coords;
- },
- /**
- * Get coord scale after texture atlas is expanded.
- * @return {Array.<number>}
- */
- getCoordsScale: function () {
- var dpr = this._dpr;
- return [this._nodeWidth / this._canvas.width * dpr, this._nodeHeight / this._canvas.height * dpr];
- },
- /**
- * Get texture coords of sprite image
- * @param {string} id Image id
- * @return {Array}
- */
- getCoords: function (id) {
- return this._coords[id];
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (ZRTextureAtlasSurface);
- /***/
- }),
- /* 82 */
- /***/ (function (module, exports, __webpack_require__) {
- var vec2 = __webpack_require__(83);
- var matrix = __webpack_require__(84);
- /**
- * @module echarts/core/BoundingRect
- */
- var v2ApplyTransform = vec2.applyTransform;
- var mathMin = Math.min;
- var mathMax = Math.max;
- /**
- * @alias module:echarts/core/BoundingRect
- */
- function BoundingRect(x, y, width, height) {
- if (width < 0) {
- x = x + width;
- width = -width;
- }
- if (height < 0) {
- y = y + height;
- height = -height;
- }
- /**
- * @type {number}
- */
- this.x = x;
- /**
- * @type {number}
- */
- this.y = y;
- /**
- * @type {number}
- */
- this.width = width;
- /**
- * @type {number}
- */
- this.height = height;
- }
- BoundingRect.prototype = {
- constructor: BoundingRect,
- /**
- * @param {module:echarts/core/BoundingRect} other
- */
- union: function (other) {
- var x = mathMin(other.x, this.x);
- var y = mathMin(other.y, this.y);
- this.width = mathMax(other.x + other.width, this.x + this.width) - x;
- this.height = mathMax(other.y + other.height, this.y + this.height) - y;
- this.x = x;
- this.y = y;
- },
- /**
- * @param {Array.<number>} m
- * @methods
- */
- applyTransform: function () {
- var lt = [];
- var rb = [];
- var lb = [];
- var rt = [];
- return function (m) {
- // In case usage like this
- // el.getBoundingRect().applyTransform(el.transform)
- // And element has no transform
- if (!m) {
- return;
- }
- lt[0] = lb[0] = this.x;
- lt[1] = rt[1] = this.y;
- rb[0] = rt[0] = this.x + this.width;
- rb[1] = lb[1] = this.y + this.height;
- v2ApplyTransform(lt, lt, m);
- v2ApplyTransform(rb, rb, m);
- v2ApplyTransform(lb, lb, m);
- v2ApplyTransform(rt, rt, m);
- this.x = mathMin(lt[0], rb[0], lb[0], rt[0]);
- this.y = mathMin(lt[1], rb[1], lb[1], rt[1]);
- var maxX = mathMax(lt[0], rb[0], lb[0], rt[0]);
- var maxY = mathMax(lt[1], rb[1], lb[1], rt[1]);
- this.width = maxX - this.x;
- this.height = maxY - this.y;
- };
- }(),
- /**
- * Calculate matrix of transforming from self to target rect
- * @param {module:zrender/core/BoundingRect} b
- * @return {Array.<number>}
- */
- calculateTransform: function (b) {
- var a = this;
- var sx = b.width / a.width;
- var sy = b.height / a.height;
- var m = matrix.create(); // 矩阵å³ä¹˜
- matrix.translate(m, m, [-a.x, -a.y]);
- matrix.scale(m, m, [sx, sy]);
- matrix.translate(m, m, [b.x, b.y]);
- return m;
- },
- /**
- * @param {(module:echarts/core/BoundingRect|Object)} b
- * @return {boolean}
- */
- intersect: function (b) {
- if (!b) {
- return false;
- }
- if (!(b instanceof BoundingRect)) {
- // Normalize negative width/height.
- b = BoundingRect.create(b);
- }
- var a = this;
- var ax0 = a.x;
- var ax1 = a.x + a.width;
- var ay0 = a.y;
- var ay1 = a.y + a.height;
- var bx0 = b.x;
- var bx1 = b.x + b.width;
- var by0 = b.y;
- var by1 = b.y + b.height;
- return !(ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);
- },
- contain: function (x, y) {
- var rect = this;
- return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
- },
- /**
- * @return {module:echarts/core/BoundingRect}
- */
- clone: function () {
- return new BoundingRect(this.x, this.y, this.width, this.height);
- },
- /**
- * Copy from another rect
- */
- copy: function (other) {
- this.x = other.x;
- this.y = other.y;
- this.width = other.width;
- this.height = other.height;
- },
- plain: function () {
- return {
- x: this.x,
- y: this.y,
- width: this.width,
- height: this.height
- };
- }
- };
- /**
- * @param {Object|module:zrender/core/BoundingRect} rect
- * @param {number} rect.x
- * @param {number} rect.y
- * @param {number} rect.width
- * @param {number} rect.height
- * @return {module:zrender/core/BoundingRect}
- */
- BoundingRect.create = function (rect) {
- return new BoundingRect(rect.x, rect.y, rect.width, rect.height);
- };
- var _default = BoundingRect;
- module.exports = _default;
- /***/
- }),
- /* 83 */
- /***/ (function (module, exports) {
- var ArrayCtor = typeof Float32Array === 'undefined' ? Array : Float32Array;
- /**
- * 创建一个å‘é‡
- * @param {number} [x=0]
- * @param {number} [y=0]
- * @return {Vector2}
- */
- function create(x, y) {
- var out = new ArrayCtor(2);
- if (x == null) {
- x = 0;
- }
- if (y == null) {
- y = 0;
- }
- out[0] = x;
- out[1] = y;
- return out;
- }
- /**
- * å¤åˆ¶å‘釿•°æ®
- * @param {Vector2} out
- * @param {Vector2} v
- * @return {Vector2}
- */
- function copy(out, v) {
- out[0] = v[0];
- out[1] = v[1];
- return out;
- }
- /**
- * 克隆一个å‘é‡
- * @param {Vector2} v
- * @return {Vector2}
- */
- function clone(v) {
- var out = new ArrayCtor(2);
- out[0] = v[0];
- out[1] = v[1];
- return out;
- }
- /**
- * 设置å‘é‡çš„两个项
- * @param {Vector2} out
- * @param {number} a
- * @param {number} b
- * @return {Vector2} 结果
- */
- function set(out, a, b) {
- out[0] = a;
- out[1] = b;
- return out;
- }
- /**
- * å‘é‡ç›¸åŠ
- * @param {Vector2} out
- * @param {Vector2} v1
- * @param {Vector2} v2
- */
- function add(out, v1, v2) {
- out[0] = v1[0] + v2[0];
- out[1] = v1[1] + v2[1];
- return out;
- }
- /**
- * å‘é‡ç¼©æ”¾åŽç›¸åŠ
- * @param {Vector2} out
- * @param {Vector2} v1
- * @param {Vector2} v2
- * @param {number} a
- */
- function scaleAndAdd(out, v1, v2, a) {
- out[0] = v1[0] + v2[0] * a;
- out[1] = v1[1] + v2[1] * a;
- return out;
- }
- /**
- * å‘é‡ç›¸å‡
- * @param {Vector2} out
- * @param {Vector2} v1
- * @param {Vector2} v2
- */
- function sub(out, v1, v2) {
- out[0] = v1[0] - v2[0];
- out[1] = v1[1] - v2[1];
- return out;
- }
- /**
- * å‘é‡é•¿åº¦
- * @param {Vector2} v
- * @return {number}
- */
- function len(v) {
- return Math.sqrt(lenSquare(v));
- }
- var length = len; // jshint ignore:line
- /**
- * å‘é‡é•¿åº¦å¹³æ–¹
- * @param {Vector2} v
- * @return {number}
- */
- function lenSquare(v) {
- return v[0] * v[0] + v[1] * v[1];
- }
- var lengthSquare = lenSquare;
- /**
- * å‘é‡ä¹˜æ³•
- * @param {Vector2} out
- * @param {Vector2} v1
- * @param {Vector2} v2
- */
- function mul(out, v1, v2) {
- out[0] = v1[0] * v2[0];
- out[1] = v1[1] * v2[1];
- return out;
- }
- /**
- * å‘é‡é™¤æ³•
- * @param {Vector2} out
- * @param {Vector2} v1
- * @param {Vector2} v2
- */
- function div(out, v1, v2) {
- out[0] = v1[0] / v2[0];
- out[1] = v1[1] / v2[1];
- return out;
- }
- /**
- * å‘é‡ç‚¹ä¹˜
- * @param {Vector2} v1
- * @param {Vector2} v2
- * @return {number}
- */
- function dot(v1, v2) {
- return v1[0] * v2[0] + v1[1] * v2[1];
- }
- /**
- * å‘é‡ç¼©æ”¾
- * @param {Vector2} out
- * @param {Vector2} v
- * @param {number} s
- */
- function scale(out, v, s) {
- out[0] = v[0] * s;
- out[1] = v[1] * s;
- return out;
- }
- /**
- * å‘é‡å½’一化
- * @param {Vector2} out
- * @param {Vector2} v
- */
- function normalize(out, v) {
- var d = len(v);
- if (d === 0) {
- out[0] = 0;
- out[1] = 0;
- } else {
- out[0] = v[0] / d;
- out[1] = v[1] / d;
- }
- return out;
- }
- /**
- * 计算å‘é‡é—´è·ç¦»
- * @param {Vector2} v1
- * @param {Vector2} v2
- * @return {number}
- */
- function distance(v1, v2) {
- return Math.sqrt((v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]));
- }
- var dist = distance;
- /**
- * å‘é‡è·ç¦»å¹³æ–¹
- * @param {Vector2} v1
- * @param {Vector2} v2
- * @return {number}
- */
- function distanceSquare(v1, v2) {
- return (v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]);
- }
- var distSquare = distanceSquare;
- /**
- * 求负å‘é‡
- * @param {Vector2} out
- * @param {Vector2} v
- */
- function negate(out, v) {
- out[0] = -v[0];
- out[1] = -v[1];
- return out;
- }
- /**
- * æ’值两个点
- * @param {Vector2} out
- * @param {Vector2} v1
- * @param {Vector2} v2
- * @param {number} t
- */
- function lerp(out, v1, v2, t) {
- out[0] = v1[0] + t * (v2[0] - v1[0]);
- out[1] = v1[1] + t * (v2[1] - v1[1]);
- return out;
- }
- /**
- * 矩阵左乘å‘é‡
- * @param {Vector2} out
- * @param {Vector2} v
- * @param {Vector2} m
- */
- function applyTransform(out, v, m) {
- var x = v[0];
- var y = v[1];
- out[0] = m[0] * x + m[2] * y + m[4];
- out[1] = m[1] * x + m[3] * y + m[5];
- return out;
- }
- /**
- * 求两个å‘釿œ€å°å€¼
- * @param {Vector2} out
- * @param {Vector2} v1
- * @param {Vector2} v2
- */
- function min(out, v1, v2) {
- out[0] = Math.min(v1[0], v2[0]);
- out[1] = Math.min(v1[1], v2[1]);
- return out;
- }
- /**
- * 求两个å‘釿œ€å¤§å€¼
- * @param {Vector2} out
- * @param {Vector2} v1
- * @param {Vector2} v2
- */
- function max(out, v1, v2) {
- out[0] = Math.max(v1[0], v2[0]);
- out[1] = Math.max(v1[1], v2[1]);
- return out;
- }
- exports.create = create;
- exports.copy = copy;
- exports.clone = clone;
- exports.set = set;
- exports.add = add;
- exports.scaleAndAdd = scaleAndAdd;
- exports.sub = sub;
- exports.len = len;
- exports.length = length;
- exports.lenSquare = lenSquare;
- exports.lengthSquare = lengthSquare;
- exports.mul = mul;
- exports.div = div;
- exports.dot = dot;
- exports.scale = scale;
- exports.normalize = normalize;
- exports.distance = distance;
- exports.dist = dist;
- exports.distanceSquare = distanceSquare;
- exports.distSquare = distSquare;
- exports.negate = negate;
- exports.lerp = lerp;
- exports.applyTransform = applyTransform;
- exports.min = min;
- exports.max = max;
- /***/
- }),
- /* 84 */
- /***/ (function (module, exports) {
- /**
- * 3x2矩阵æ“作类
- * @exports zrender/tool/matrix
- */
- var ArrayCtor = typeof Float32Array === 'undefined' ? Array : Float32Array;
- /**
- * Create a identity matrix.
- * @return {Float32Array|Array.<number>}
- */
- function create() {
- var out = new ArrayCtor(6);
- identity(out);
- return out;
- }
- /**
- * 设置矩阵为å•ä½çŸ©é˜µ
- * @param {Float32Array|Array.<number>} out
- */
- function identity(out) {
- out[0] = 1;
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
- out[4] = 0;
- out[5] = 0;
- return out;
- }
- /**
- * å¤åˆ¶çŸ©é˜µ
- * @param {Float32Array|Array.<number>} out
- * @param {Float32Array|Array.<number>} m
- */
- function copy(out, m) {
- out[0] = m[0];
- out[1] = m[1];
- out[2] = m[2];
- out[3] = m[3];
- out[4] = m[4];
- out[5] = m[5];
- return out;
- }
- /**
- * 矩阵相乘
- * @param {Float32Array|Array.<number>} out
- * @param {Float32Array|Array.<number>} m1
- * @param {Float32Array|Array.<number>} m2
- */
- function mul(out, m1, m2) {
- // Consider matrix.mul(m, m2, m);
- // where out is the same as m2.
- // So use temp variable to escape error.
- var out0 = m1[0] * m2[0] + m1[2] * m2[1];
- var out1 = m1[1] * m2[0] + m1[3] * m2[1];
- var out2 = m1[0] * m2[2] + m1[2] * m2[3];
- var out3 = m1[1] * m2[2] + m1[3] * m2[3];
- var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
- var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
- out[0] = out0;
- out[1] = out1;
- out[2] = out2;
- out[3] = out3;
- out[4] = out4;
- out[5] = out5;
- return out;
- }
- /**
- * å¹³ç§»å˜æ¢
- * @param {Float32Array|Array.<number>} out
- * @param {Float32Array|Array.<number>} a
- * @param {Float32Array|Array.<number>} v
- */
- function translate(out, a, v) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- out[4] = a[4] + v[0];
- out[5] = a[5] + v[1];
- return out;
- }
- /**
- * æ—‹è½¬å˜æ¢
- * @param {Float32Array|Array.<number>} out
- * @param {Float32Array|Array.<number>} a
- * @param {number} rad
- */
- function rotate(out, a, rad) {
- var aa = a[0];
- var ac = a[2];
- var atx = a[4];
- var ab = a[1];
- var ad = a[3];
- var aty = a[5];
- var st = Math.sin(rad);
- var ct = Math.cos(rad);
- out[0] = aa * ct + ab * st;
- out[1] = -aa * st + ab * ct;
- out[2] = ac * ct + ad * st;
- out[3] = -ac * st + ct * ad;
- out[4] = ct * atx + st * aty;
- out[5] = ct * aty - st * atx;
- return out;
- }
- /**
- * ç¼©æ”¾å˜æ¢
- * @param {Float32Array|Array.<number>} out
- * @param {Float32Array|Array.<number>} a
- * @param {Float32Array|Array.<number>} v
- */
- function scale(out, a, v) {
- var vx = v[0];
- var vy = v[1];
- out[0] = a[0] * vx;
- out[1] = a[1] * vy;
- out[2] = a[2] * vx;
- out[3] = a[3] * vy;
- out[4] = a[4] * vx;
- out[5] = a[5] * vy;
- return out;
- }
- /**
- * 求逆矩阵
- * @param {Float32Array|Array.<number>} out
- * @param {Float32Array|Array.<number>} a
- */
- function invert(out, a) {
- var aa = a[0];
- var ac = a[2];
- var atx = a[4];
- var ab = a[1];
- var ad = a[3];
- var aty = a[5];
- var det = aa * ad - ab * ac;
- if (!det) {
- return null;
- }
- det = 1.0 / det;
- out[0] = ad * det;
- out[1] = -ab * det;
- out[2] = -ac * det;
- out[3] = aa * det;
- out[4] = (ac * aty - ad * atx) * det;
- out[5] = (ab * atx - aa * aty) * det;
- return out;
- }
- /**
- * Clone a new matrix.
- * @param {Float32Array|Array.<number>} a
- */
- function clone(a) {
- var b = create();
- copy(b, a);
- return b;
- }
- exports.create = create;
- exports.identity = identity;
- exports.copy = copy;
- exports.mul = mul;
- exports.translate = translate;
- exports.rotate = rotate;
- exports.scale = scale;
- exports.invert = invert;
- exports.clone = clone;
- /***/
- }),
- /* 85 */
- /***/ (function (module, exports, __webpack_require__) {
- var zrUtil = __webpack_require__(13);
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- var RADIAN_EPSILON = 1e-4;
- function _trim(str) {
- return str.replace(/^\s+/, '').replace(/\s+$/, '');
- }
- /**
- * Linear mapping a value from domain to range
- * @memberOf module:echarts/util/number
- * @param {(number|Array.<number>)} val
- * @param {Array.<number>} domain Domain extent domain[0] can be bigger than domain[1]
- * @param {Array.<number>} range Range extent range[0] can be bigger than range[1]
- * @param {boolean} clamp
- * @return {(number|Array.<number>}
- */
- function linearMap(val, domain, range, clamp) {
- var subDomain = domain[1] - domain[0];
- var subRange = range[1] - range[0];
- if (subDomain === 0) {
- return subRange === 0 ? range[0] : (range[0] + range[1]) / 2;
- } // Avoid accuracy problem in edge, such as
- // 146.39 - 62.83 === 83.55999999999999.
- // See echarts/test/ut/spec/util/number.js#linearMap#accuracyError
- // It is a little verbose for efficiency considering this method
- // is a hotspot.
- if (clamp) {
- if (subDomain > 0) {
- if (val <= domain[0]) {
- return range[0];
- } else if (val >= domain[1]) {
- return range[1];
- }
- } else {
- if (val >= domain[0]) {
- return range[0];
- } else if (val <= domain[1]) {
- return range[1];
- }
- }
- } else {
- if (val === domain[0]) {
- return range[0];
- }
- if (val === domain[1]) {
- return range[1];
- }
- }
- return (val - domain[0]) / subDomain * subRange + range[0];
- }
- /**
- * Convert a percent string to absolute number.
- * Returns NaN if percent is not a valid string or number
- * @memberOf module:echarts/util/number
- * @param {string|number} percent
- * @param {number} all
- * @return {number}
- */
- function parsePercent(percent, all) {
- switch (percent) {
- case 'center':
- case 'middle':
- percent = '50%';
- break;
- case 'left':
- case 'top':
- percent = '0%';
- break;
- case 'right':
- case 'bottom':
- percent = '100%';
- break;
- }
- if (typeof percent === 'string') {
- if (_trim(percent).match(/%$/)) {
- return parseFloat(percent) / 100 * all;
- }
- return parseFloat(percent);
- }
- return percent == null ? NaN : +percent;
- }
- /**
- * (1) Fix rounding error of float numbers.
- * (2) Support return string to avoid scientific notation like '3.5e-7'.
- *
- * @param {number} x
- * @param {number} [precision]
- * @param {boolean} [returnStr]
- * @return {number|string}
- */
- function round(x, precision, returnStr) {
- if (precision == null) {
- precision = 10;
- } // Avoid range error
- precision = Math.min(Math.max(0, precision), 20);
- x = (+x).toFixed(precision);
- return returnStr ? x : +x;
- }
- function asc(arr) {
- arr.sort(function (a, b) {
- return a - b;
- });
- return arr;
- }
- /**
- * Get precision
- * @param {number} val
- */
- function getPrecision(val) {
- val = +val;
- if (isNaN(val)) {
- return 0;
- } // It is much faster than methods converting number to string as follows
- // var tmp = val.toString();
- // return tmp.length - 1 - tmp.indexOf('.');
- // especially when precision is low
- var e = 1;
- var count = 0;
- while (Math.round(val * e) / e !== val) {
- e *= 10;
- count++;
- }
- return count;
- }
- /**
- * @param {string|number} val
- * @return {number}
- */
- function getPrecisionSafe(val) {
- var str = val.toString(); // Consider scientific notation: '3.4e-12' '3.4e+12'
- var eIndex = str.indexOf('e');
- if (eIndex > 0) {
- var precision = +str.slice(eIndex + 1);
- return precision < 0 ? -precision : 0;
- } else {
- var dotIndex = str.indexOf('.');
- return dotIndex < 0 ? 0 : str.length - 1 - dotIndex;
- }
- }
- /**
- * Minimal dicernible data precisioin according to a single pixel.
- *
- * @param {Array.<number>} dataExtent
- * @param {Array.<number>} pixelExtent
- * @return {number} precision
- */
- function getPixelPrecision(dataExtent, pixelExtent) {
- var log = Math.log;
- var LN10 = Math.LN10;
- var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10);
- var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10); // toFixed() digits argument must be between 0 and 20.
- var precision = Math.min(Math.max(-dataQuantity + sizeQuantity, 0), 20);
- return !isFinite(precision) ? 20 : precision;
- }
- /**
- * Get a data of given precision, assuring the sum of percentages
- * in valueList is 1.
- * The largest remainer method is used.
- * https://en.wikipedia.org/wiki/Largest_remainder_method
- *
- * @param {Array.<number>} valueList a list of all data
- * @param {number} idx index of the data to be processed in valueList
- * @param {number} precision integer number showing digits of precision
- * @return {number} percent ranging from 0 to 100
- */
- function getPercentWithPrecision(valueList, idx, precision) {
- if (!valueList[idx]) {
- return 0;
- }
- var sum = zrUtil.reduce(valueList, function (acc, val) {
- return acc + (isNaN(val) ? 0 : val);
- }, 0);
- if (sum === 0) {
- return 0;
- }
- var digits = Math.pow(10, precision);
- var votesPerQuota = zrUtil.map(valueList, function (val) {
- return (isNaN(val) ? 0 : val) / sum * digits * 100;
- });
- var targetSeats = digits * 100;
- var seats = zrUtil.map(votesPerQuota, function (votes) {
- // Assign automatic seats.
- return Math.floor(votes);
- });
- var currentSum = zrUtil.reduce(seats, function (acc, val) {
- return acc + val;
- }, 0);
- var remainder = zrUtil.map(votesPerQuota, function (votes, idx) {
- return votes - seats[idx];
- }); // Has remainding votes.
- while (currentSum < targetSeats) {
- // Find next largest remainder.
- var max = Number.NEGATIVE_INFINITY;
- var maxId = null;
- for (var i = 0, len = remainder.length; i < len; ++i) {
- if (remainder[i] > max) {
- max = remainder[i];
- maxId = i;
- }
- } // Add a vote to max remainder.
- ++seats[maxId];
- remainder[maxId] = 0;
- ++currentSum;
- }
- return seats[idx] / digits;
- } // Number.MAX_SAFE_INTEGER, ie do not support.
- var MAX_SAFE_INTEGER = 9007199254740991;
- /**
- * To 0 - 2 * PI, considering negative radian.
- * @param {number} radian
- * @return {number}
- */
- function remRadian(radian) {
- var pi2 = Math.PI * 2;
- return (radian % pi2 + pi2) % pi2;
- }
- /**
- * @param {type} radian
- * @return {boolean}
- */
- function isRadianAroundZero(val) {
- return val > -RADIAN_EPSILON && val < RADIAN_EPSILON;
- }
- var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d\d)(?::(\d\d)(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/; // jshint ignore:line
- /**
- * @param {string|Date|number} value These values can be accepted:
- * + An instance of Date, represent a time in its own time zone.
- * + Or string in a subset of ISO 8601, only including:
- * + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06',
- * + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123',
- * + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00',
- * all of which will be treated as local time if time zone is not specified
- * (see <https://momentjs.com/>).
- * + Or other string format, including (all of which will be treated as loacal time):
- * '2012', '2012-3-1', '2012/3/1', '2012/03/01',
- * '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123'
- * + a timestamp, which represent a time in UTC.
- * @return {Date} date
- */
- function parseDate(value) {
- if (value instanceof Date) {
- return value;
- } else if (typeof value === 'string') {
- // Different browsers parse date in different way, so we parse it manually.
- // Some other issues:
- // new Date('1970-01-01') is UTC,
- // new Date('1970/01/01') and new Date('1970-1-01') is local.
- // See issue #3623
- var match = TIME_REG.exec(value);
- if (!match) {
- // return Invalid Date.
- return new Date(NaN);
- } // Use local time when no timezone offset specifed.
- if (!match[8]) {
- // match[n] can only be string or undefined.
- // But take care of '12' + 1 => '121'.
- return new Date(+match[1], +(match[2] || 1) - 1, +match[3] || 1, +match[4] || 0, +(match[5] || 0), +match[6] || 0, +match[7] || 0);
- } // Timezoneoffset of Javascript Date has considered DST (Daylight Saving Time,
- // https://tc39.github.io/ecma262/#sec-daylight-saving-time-adjustment).
- // For example, system timezone is set as "Time Zone: America/Toronto",
- // then these code will get different result:
- // `new Date(1478411999999).getTimezoneOffset(); // get 240`
- // `new Date(1478412000000).getTimezoneOffset(); // get 300`
- // So we should not use `new Date`, but use `Date.UTC`.
- else {
- var hour = +match[4] || 0;
- if (match[8].toUpperCase() !== 'Z') {
- hour -= match[8].slice(0, 3);
- }
- return new Date(Date.UTC(+match[1], +(match[2] || 1) - 1, +match[3] || 1, hour, +(match[5] || 0), +match[6] || 0, +match[7] || 0));
- }
- } else if (value == null) {
- return new Date(NaN);
- }
- return new Date(Math.round(value));
- }
- /**
- * Quantity of a number. e.g. 0.1, 1, 10, 100
- *
- * @param {number} val
- * @return {number}
- */
- function quantity(val) {
- return Math.pow(10, quantityExponent(val));
- }
- function quantityExponent(val) {
- return Math.floor(Math.log(val) / Math.LN10);
- }
- /**
- * find a “nice†number approximately equal to x. Round the number if round = true,
- * take ceiling if round = false. The primary observation is that the “nicestâ€
- * numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
- *
- * See "Nice Numbers for Graph Labels" of Graphic Gems.
- *
- * @param {number} val Non-negative value.
- * @param {boolean} round
- * @return {number}
- */
- function nice(val, round) {
- var exponent = quantityExponent(val);
- var exp10 = Math.pow(10, exponent);
- var f = val / exp10; // 1 <= f < 10
- var nf;
- if (round) {
- if (f < 1.5) {
- nf = 1;
- } else if (f < 2.5) {
- nf = 2;
- } else if (f < 4) {
- nf = 3;
- } else if (f < 7) {
- nf = 5;
- } else {
- nf = 10;
- }
- } else {
- if (f < 1) {
- nf = 1;
- } else if (f < 2) {
- nf = 2;
- } else if (f < 3) {
- nf = 3;
- } else if (f < 5) {
- nf = 5;
- } else {
- nf = 10;
- }
- }
- val = nf * exp10; // Fix 3 * 0.1 === 0.30000000000000004 issue (see IEEE 754).
- // 20 is the uppper bound of toFixed.
- return exponent >= -20 ? +val.toFixed(exponent < 0 ? -exponent : 0) : val;
- }
- /**
- * Order intervals asc, and split them when overlap.
- * expect(numberUtil.reformIntervals([
- * {interval: [18, 62], close: [1, 1]},
- * {interval: [-Infinity, -70], close: [0, 0]},
- * {interval: [-70, -26], close: [1, 1]},
- * {interval: [-26, 18], close: [1, 1]},
- * {interval: [62, 150], close: [1, 1]},
- * {interval: [106, 150], close: [1, 1]},
- * {interval: [150, Infinity], close: [0, 0]}
- * ])).toEqual([
- * {interval: [-Infinity, -70], close: [0, 0]},
- * {interval: [-70, -26], close: [1, 1]},
- * {interval: [-26, 18], close: [0, 1]},
- * {interval: [18, 62], close: [0, 1]},
- * {interval: [62, 150], close: [0, 1]},
- * {interval: [150, Infinity], close: [0, 0]}
- * ]);
- * @param {Array.<Object>} list, where `close` mean open or close
- * of the interval, and Infinity can be used.
- * @return {Array.<Object>} The origin list, which has been reformed.
- */
- function reformIntervals(list) {
- list.sort(function (a, b) {
- return littleThan(a, b, 0) ? -1 : 1;
- });
- var curr = -Infinity;
- var currClose = 1;
- for (var i = 0; i < list.length;) {
- var interval = list[i].interval;
- var close = list[i].close;
- for (var lg = 0; lg < 2; lg++) {
- if (interval[lg] <= curr) {
- interval[lg] = curr;
- close[lg] = !lg ? 1 - currClose : 1;
- }
- curr = interval[lg];
- currClose = close[lg];
- }
- if (interval[0] === interval[1] && close[0] * close[1] !== 1) {
- list.splice(i, 1);
- } else {
- i++;
- }
- }
- return list;
- function littleThan(a, b, lg) {
- return a.interval[lg] < b.interval[lg] || a.interval[lg] === b.interval[lg] && (a.close[lg] - b.close[lg] === (!lg ? 1 : -1) || !lg && littleThan(a, b, 1));
- }
- }
- /**
- * parseFloat NaNs numeric-cast false positives (null|true|false|"")
- * ...but misinterprets leading-number strings, particularly hex literals ("0x...")
- * subtraction forces infinities to NaN
- *
- * @param {*} v
- * @return {boolean}
- */
- function isNumeric(v) {
- return v - parseFloat(v) >= 0;
- }
- exports.linearMap = linearMap;
- exports.parsePercent = parsePercent;
- exports.round = round;
- exports.asc = asc;
- exports.getPrecision = getPrecision;
- exports.getPrecisionSafe = getPrecisionSafe;
- exports.getPixelPrecision = getPixelPrecision;
- exports.getPercentWithPrecision = getPercentWithPrecision;
- exports.MAX_SAFE_INTEGER = MAX_SAFE_INTEGER;
- exports.remRadian = remRadian;
- exports.isRadianAroundZero = isRadianAroundZero;
- exports.parseDate = parseDate;
- exports.quantity = quantity;
- exports.nice = nice;
- exports.reformIntervals = reformIntervals;
- exports.isNumeric = isNumeric;
- /***/
- }),
- /* 86 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_util__ = __webpack_require__(23);
- var TexturePool = function () {
- this._pool = {};
- this._allocatedTextures = [];
- };
- TexturePool.prototype = {
- constructor: TexturePool,
- get: function (parameters) {
- var key = generateKey(parameters);
- if (!this._pool.hasOwnProperty(key)) {
- this._pool[key] = [];
- }
- var list = this._pool[key];
- if (!list.length) {
- var texture = new __WEBPACK_IMPORTED_MODULE_0__Texture2D__["a" /* default */](parameters);
- this._allocatedTextures.push(texture);
- return texture;
- }
- return list.pop();
- },
- put: function (texture) {
- var key = generateKey(texture);
- if (!this._pool.hasOwnProperty(key)) {
- this._pool[key] = [];
- }
- var list = this._pool[key];
- list.push(texture);
- },
- clear: function (renderer) {
- for (var i = 0; i < this._allocatedTextures.length; i++) {
- this._allocatedTextures[i].dispose(renderer);
- }
- this._pool = {};
- this._allocatedTextures = [];
- }
- };
- var defaultParams = {
- width: 512,
- height: 512,
- type: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].UNSIGNED_BYTE,
- format: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].RGBA,
- wrapS: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE,
- wrapT: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE,
- minFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR,
- magFilter: __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR,
- useMipmap: true,
- anisotropic: 1,
- flipY: true,
- unpackAlignment: 4,
- premultiplyAlpha: false
- };
- var defaultParamPropList = Object.keys(defaultParams);
- function generateKey(parameters) {
- __WEBPACK_IMPORTED_MODULE_2__core_util__["a" /* default */].defaultsWithPropList(parameters, defaultParams, defaultParamPropList);
- fallBack(parameters);
- var key = '';
- for (var i = 0; i < defaultParamPropList.length; i++) {
- var name = defaultParamPropList[i];
- var chunk = parameters[name].toString();
- key += chunk;
- }
- return key;
- }
- function fallBack(target) {
- var IPOT = isPowerOfTwo(target.width, target.height);
- if (target.format === __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_COMPONENT) {
- target.useMipmap = false;
- }
- if (!IPOT || !target.useMipmap) {
- if (target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_NEAREST ||
- target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST_MIPMAP_LINEAR) {
- target.minFilter = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST;
- } else if (
- target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_LINEAR ||
- target.minFilter == __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR_MIPMAP_NEAREST
- ) {
- target.minFilter = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].LINEAR;
- }
- }
- if (!IPOT) {
- target.wrapS = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE;
- target.wrapT = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].CLAMP_TO_EDGE;
- }
- }
- function isPowerOfTwo(width, height) {
- return (width & (width - 1)) === 0 &&
- (height & (height - 1)) === 0;
- }
- /* harmony default export */ __webpack_exports__["a"] = (TexturePool);
- /***/
- }),
- /* 87 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export clay.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export clay.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main (void)\n{\n @import clay.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n");
- /***/
- }),
- /* 88 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("\n@export clay.compositor.lut\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform sampler2D lookup;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n float blueColor = tex.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * tex.g);\n vec4 newColor1 = texture2D(lookup, texPos1);\n vec4 newColor2 = texture2D(lookup, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n gl_FragColor = vec4(newColor.rgb, tex.w);\n}\n@end");
- /***/
- }),
- /* 89 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end");
- /***/
- }),
- /* 90 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n");
- /***/
- }),
- /* 91 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import clay.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end");
- /***/
- }),
- /* 92 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("\n@export clay.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\n@import clay.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end");
- /***/
- }),
- /* 93 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.hdr.composite\n#define TONEMAPPING\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import clay.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n#ifdef TONEMAPPING\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01 && gl_FragColor.a > 1e-5) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end");
- /***/
- }),
- /* 94 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.blend\n#define SHADER_NAME blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end");
- /***/
- }),
- /* 95 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import clay.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end");
- /***/
- }),
- /* 96 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony default export */ __webpack_exports__["a"] = ({
- getFilledRegions: function (regions, mapData) {
- var regionsArr = (regions || []).slice();
- var geoJson;
- if (typeof mapData === 'string') {
- mapData = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.getMap(mapData);
- geoJson = mapData && mapData.geoJson;
- }
- else {
- if (mapData && mapData.features) {
- geoJson = mapData;
- }
- }
- if (!geoJson) {
- if (true) {
- console.error('Map ' + mapData + ' not exists. You can download map file on http://echarts.baidu.com/download-map.html');
- if (!geoJson.features) {
- console.error('Invalid GeoJSON for map3D');
- }
- }
- return [];
- }
- var dataNameMap = {};
- var features = geoJson.features;
- for (var i = 0; i < regionsArr.length; i++) {
- dataNameMap[regionsArr[i].name] = regionsArr[i];
- }
- for (var i = 0; i < features.length; i++) {
- var name = features[i].properties.name;
- if (!dataNameMap[name]) {
- regionsArr.push({
- name: name
- });
- }
- }
- return regionsArr;
- },
- defaultOption: {
- show: true,
- zlevel: -10,
- // geoJson used by geo3D
- map: '',
- // Layout used for viewport
- left: 0,
- top: 0,
- width: '100%',
- height: '100%',
- boxWidth: 100,
- boxHeight: 10,
- boxDepth: 'auto',
- regionHeight: 3,
- environment: 'auto',
- groundPlane: {
- show: false,
- color: '#aaa'
- },
- shading: 'lambert',
- light: {
- main: {
- alpha: 40,
- beta: 30
- }
- },
- viewControl: {
- alpha: 40,
- beta: 0,
- distance: 100,
- orthographicSize: 60,
- minAlpha: 5,
- minBeta: -80,
- maxBeta: 80
- },
- label: {
- show: false,
- // Distance in 3d space.
- distance: 2,
- textStyle: {
- fontSize: 20,
- color: '#000',
- backgroundColor: 'rgba(255,255,255,0.7)',
- padding: 3,
- borderRadius: 4
- }
- },
- // TODO
- // altitude: {
- // min: 'auto',
- // max: 'auto',
- // height: []
- // },
- // labelLine
- // light
- // postEffect
- // temporalSuperSampling
- itemStyle: {
- color: '#fff',
- borderWidth: 0,
- borderColor: '#333'
- },
- emphasis: {
- itemStyle: {
- // color: '#f94b59'
- color: '#639fc0'
- },
- label: {
- show: true
- }
- }
- }
- });
- /***/
- }),
- /* 97 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- function swap(arr, a, b) {
- var tmp = arr[a];
- arr[a] = arr[b];
- arr[b] = tmp;
- }
- function partition(arr, pivot, left, right, compare) {
- var storeIndex = left;
- var pivotValue = arr[pivot];
- // put the pivot on the right
- swap(arr, pivot, right);
- // go through the rest
- for (var v = left; v < right; v++) {
- if (compare(arr[v], pivotValue) < 0) {
- swap(arr, v, storeIndex);
- storeIndex++;
- }
- }
- // finally put the pivot in the correct place
- swap(arr, right, storeIndex);
- return storeIndex;
- }
- function quickSort(array, compare, left, right) {
- if (left < right) {
- var pivot = Math.floor((left + right) / 2);
- var newPivot = partition(array, pivot, left, right, compare);
- quickSort(array, compare, left, newPivot - 1);
- quickSort(array, compare, newPivot + 1, right);
- }
- }
- // TODO Test.
- function ProgressiveQuickSort() {
- // this._pivotList = new LinkedList();
- this._parts = [];
- }
- ProgressiveQuickSort.prototype.step = function (arr, compare, frame) {
- var len = arr.length;
- if (frame === 0) {
- this._parts = [];
- this._sorted = false;
- // Pick a start pivot;
- var pivot = Math.floor(len / 2);
- this._parts.push({
- pivot: pivot,
- left: 0,
- right: len - 1
- });
- this._currentSortPartIdx = 0;
- }
- if (this._sorted) {
- return;
- }
- var parts = this._parts;
- if (parts.length === 0) {
- this._sorted = true;
- // Already finished.
- return true;
- }
- else if (parts.length < 512) {
- // Sort large parts in about 10 frames.
- for (var i = 0; i < parts.length; i++) {
- // Partition and Modify the pivot index.
- parts[i].pivot = partition(
- arr, parts[i].pivot, parts[i].left, parts[i].right, compare
- );
- }
- var subdividedParts = [];
- for (var i = 0; i < parts.length; i++) {
- // Subdivide left
- var left = parts[i].left;
- var right = parts[i].pivot - 1;
- if (right > left) {
- subdividedParts.push({
- pivot: Math.floor((right + left) / 2),
- left: left, right: right
- });
- }
- // Subdivide right
- var left = parts[i].pivot + 1;
- var right = parts[i].right;
- if (right > left) {
- subdividedParts.push({
- pivot: Math.floor((right + left) / 2),
- left: left, right: right
- });
- }
- }
- parts = this._parts = subdividedParts;
- }
- else {
- // console.time('sort');
- // Finally quick sort each parts in 10 frames.
- for (var i = 0; i < Math.floor(parts.length / 10); i++) {
- // Sort near parts first.
- var idx = parts.length - 1 - this._currentSortPartIdx;
- quickSort(arr, compare, parts[idx].left, parts[idx].right);
- this._currentSortPartIdx++;
- // Finish sort
- if (this._currentSortPartIdx === parts.length) {
- this._sorted = true;
- return true;
- }
- }
- // console.timeEnd('sort');
- }
- return false;
- };
- ProgressiveQuickSort.sort = quickSort;
- /* harmony default export */ __webpack_exports__["a"] = (ProgressiveQuickSort);
- /***/
- }),
- /* 98 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__geo3D_Geo3D__ = __webpack_require__(99);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout__ = __webpack_require__(47);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(22);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(2);
- function resizeGeo3D(geo3DModel, api) {
- // Use left/top/width/height
- var boxLayoutOption = geo3DModel.getBoxLayoutParams();
- var viewport = __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout___default.a.getLayoutRect(boxLayoutOption, {
- width: api.getWidth(),
- height: api.getHeight()
- });
- // Flip Y
- viewport.y = api.getHeight() - viewport.y - viewport.height;
- this.viewGL.setViewport(viewport.x, viewport.y, viewport.width, viewport.height, api.getDevicePixelRatio());
- var geoRect = this.getGeoBoundingRect();
- var aspect = geoRect.width / geoRect.height * (geo3DModel.get('aspectScale') || 0.75);
- var width = geo3DModel.get('boxWidth');
- var depth = geo3DModel.get('boxDepth');
- var height = geo3DModel.get('boxHeight');
- if (height == null) {
- height = 5;
- }
- if (isNaN(width) && isNaN(depth)) {
- // Default to have 100 width
- width = 100;
- }
- if (isNaN(depth)) {
- depth = width / aspect;
- }
- else if (isNaN(width)) {
- width = depth / aspect;
- }
- this.setSize(width, height, depth);
- this.regionHeight = geo3DModel.get('regionHeight');
- if (this.altitudeAxis) {
- this.altitudeAxis.setExtent(0, Math.max(height - this.regionHeight, 0));
- }
- }
- function updateGeo3D(ecModel, api) {
- var altitudeDataExtent = [Infinity, -Infinity];
- ecModel.eachSeries(function (seriesModel) {
- if (seriesModel.coordinateSystem !== this) {
- return;
- }
- if (seriesModel.type === 'series.map3D') {
- return;
- }
- // Get altitude data extent.
- var data = seriesModel.getData();
- var altDims = seriesModel.coordDimToDataDim('alt');
- var altDim = altDims && altDims[0];
- if (altDim) {
- // TODO altitiude is in coords of lines.
- var dataExtent = data.getDataExtent(altDim, true);
- altitudeDataExtent[0] = Math.min(
- altitudeDataExtent[0], dataExtent[0]
- );
- altitudeDataExtent[1] = Math.max(
- altitudeDataExtent[1], dataExtent[1]
- );
- }
- }, this);
- // Create altitude axis
- if (altitudeDataExtent && isFinite(altitudeDataExtent[1] - altitudeDataExtent[0])) {
- var scale = __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.helper.createScale(
- altitudeDataExtent, {
- type: 'value',
- // PENDING
- min: 'dataMin',
- max: 'dataMax'
- }
- );
- this.altitudeAxis = new __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.Axis('altitude', scale);
- // Resize again
- this.resize(this.model, api);
- }
- }
- if (true) {
- var mapNotExistsError = function (name) {
- console.error('Map ' + name + ' not exists. You can download map file on http://echarts.baidu.com/download-map.html');
- };
- }
- var idStart = 0;
- var geo3DCreator = {
- dimensions: __WEBPACK_IMPORTED_MODULE_0__geo3D_Geo3D__["a" /* default */].prototype.dimensions,
- create: function (ecModel, api) {
- var geo3DList = [];
- if (!__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.getMap) {
- throw new Error('geo3D component depends on geo component');
- }
- function createGeo3D(componentModel, idx) {
- var geo3D = geo3DCreator.createGeo3D(componentModel);
- // FIXME
- componentModel.__viewGL = componentModel.__viewGL || new __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__["a" /* default */]();
- geo3D.viewGL = componentModel.__viewGL;
- componentModel.coordinateSystem = geo3D;
- geo3D.model = componentModel;
- geo3DList.push(geo3D);
- // Inject resize
- geo3D.resize = resizeGeo3D;
- geo3D.resize(componentModel, api);
- geo3D.update = updateGeo3D;
- }
- ecModel.eachComponent('geo3D', function (geo3DModel, idx) {
- createGeo3D(geo3DModel, idx);
- });
- ecModel.eachSeriesByType('map3D', function (map3DModel, idx) {
- var coordSys = map3DModel.get('coordinateSystem');
- if (coordSys == null) {
- coordSys = 'geo3D';
- }
- if (coordSys === 'geo3D') {
- createGeo3D(map3DModel, idx);
- }
- });
- ecModel.eachSeries(function (seriesModel) {
- if (seriesModel.get('coordinateSystem') === 'geo3D') {
- if (seriesModel.type === 'series.map3D') {
- return;
- }
- var geo3DModel = seriesModel.getReferringComponents('geo3D')[0];
- if (!geo3DModel) {
- geo3DModel = ecModel.getComponent('geo3D');
- }
- if (!geo3DModel) {
- throw new Error('geo "' + __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(
- seriesModel.get('geo3DIndex'),
- seriesModel.get('geo3DId'),
- 0
- ) + '" not found');
- }
- seriesModel.coordinateSystem = geo3DModel.coordinateSystem;
- }
- });
- return geo3DList;
- },
- createGeo3D: function (componentModel) {
- var mapData = componentModel.get('map');
- var name;
- if (typeof mapData === 'string') {
- name = mapData;
- mapData = __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.getMap(mapData);
- }
- else {
- if (mapData && mapData.features) {
- mapData = {
- geoJson: mapData
- };
- }
- }
- if (true) {
- if (!mapData) {
- mapNotExistsError(mapData);
- }
- if (!mapData.geoJson.features) {
- throw new Error('Invalid GeoJSON for map3D');
- }
- }
- if (name == null) {
- name = 'GEO_ANONYMOUS_' + idStart++;
- }
- return new __WEBPACK_IMPORTED_MODULE_0__geo3D_Geo3D__["a" /* default */](
- name + idStart++, name,
- mapData && mapData.geoJson, mapData && mapData.specialAreas,
- componentModel.get('nameMap')
- );
- }
- };
- __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.registerCoordinateSystem('geo3D', geo3DCreator);
- /* harmony default export */ __webpack_exports__["a"] = (geo3DCreator);
- /***/
- }),
- /* 99 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord__ = __webpack_require__(205);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord__ = __webpack_require__(206);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord__);
- var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- var mat4 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].mat4;
- // Geo fix functions
- var geoFixFuncs = [__WEBPACK_IMPORTED_MODULE_2_echarts_lib_coord_geo_fix_textCoord___default.a, __WEBPACK_IMPORTED_MODULE_3_echarts_lib_coord_geo_fix_geoCoord___default.a];
- function Geo3D(name, map, geoJson, specialAreas, nameMap) {
- this.name = name;
- this.map = map;
- this.regionHeight = 0;
- this.regions = [];
- this._nameCoordMap = {};
- this.loadGeoJson(geoJson, specialAreas, nameMap);
- this.transform = mat4.identity(new Float64Array(16));
- this.invTransform = mat4.identity(new Float64Array(16));
- // Which dimension to extrude. Y or Z
- this.extrudeY = true;
- this.altitudeAxis;
- }
- Geo3D.prototype = {
- constructor: Geo3D,
- type: 'geo3D',
- dimensions: ['lng', 'lat', 'alt'],
- containPoint: function () { },
- loadGeoJson: function (geoJson, specialAreas, nameMap) {
- var parseGeoJSON = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.parseGeoJSON || __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.parseGeoJson;
- try {
- this.regions = geoJson ? parseGeoJSON(geoJson) : [];
- }
- catch (e) {
- throw 'Invalid geoJson format\n' + e;
- }
- specialAreas = specialAreas || {};
- nameMap = nameMap || {};
- var regions = this.regions;
- var regionsMap = {};
- for (var i = 0; i < regions.length; i++) {
- var regionName = regions[i].name;
- // Try use the alias in nameMap
- regionName = nameMap[regionName] || regionName;
- regions[i].name = regionName;
- regionsMap[regionName] = regions[i];
- // Add geoJson
- this.addGeoCoord(regionName, regions[i].center);
- // Some area like Alaska in USA map needs to be tansformed
- // to look better
- var specialArea = specialAreas[regionName];
- if (specialArea) {
- regions[i].transformTo(
- specialArea.left, specialArea.top, specialArea.width, specialArea.height
- );
- }
- }
- this._regionsMap = regionsMap;
- this._geoRect = null;
- geoFixFuncs.forEach(function (fixFunc) {
- fixFunc(this);
- }, this);
- },
- getGeoBoundingRect: function () {
- if (this._geoRect) {
- return this._geoRect;
- }
- var rect;
- var regions = this.regions;
- for (var i = 0; i < regions.length; i++) {
- var regionRect = regions[i].getBoundingRect();
- rect = rect || regionRect.clone();
- rect.union(regionRect);
- }
- // FIXME Always return new ?
- return (this._geoRect = rect || new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.BoundingRect(0, 0, 0, 0));
- },
- /**
- * Add geoCoord for indexing by name
- * @param {string} name
- * @param {Array.<number>} geoCoord
- */
- addGeoCoord: function (name, geoCoord) {
- this._nameCoordMap[name] = geoCoord;
- },
- /**
- * @param {string} name
- * @return {module:echarts/coord/geo/Region}
- */
- getRegion: function (name) {
- return this._regionsMap[name];
- },
- getRegionByCoord: function (coord) {
- var regions = this.regions;
- for (var i = 0; i < regions.length; i++) {
- if (regions[i].contain(coord)) {
- return regions[i];
- }
- }
- },
- setSize: function (width, height, depth) {
- this.size = [width, height, depth];
- var rect = this.getGeoBoundingRect();
- var scaleX = width / rect.width;
- var scaleZ = -depth / rect.height;
- var translateX = -width / 2 - rect.x * scaleX;
- var translateZ = depth / 2 - rect.y * scaleZ;
- var position = this.extrudeY ? [translateX, 0, translateZ] : [translateX, translateZ, 0];
- var scale = this.extrudeY ? [scaleX, 1, scaleZ] : [scaleX, scaleZ, 1];
- var m = this.transform;
- mat4.identity(m);
- mat4.translate(m, m, position);
- mat4.scale(m, m, scale);
- mat4.invert(this.invTransform, m);
- },
- dataToPoint: function (data, out) {
- out = out || [];
- var extrudeCoordIndex = this.extrudeY ? 1 : 2;
- var sideCoordIndex = this.extrudeY ? 2 : 1;
- var altitudeVal = data[2];
- // PENDING.
- if (isNaN(altitudeVal)) {
- altitudeVal = 0;
- }
- // lng
- out[0] = data[0];
- // lat
- out[sideCoordIndex] = data[1];
- if (this.altitudeAxis) {
- out[extrudeCoordIndex] = this.altitudeAxis.dataToCoord(altitudeVal);
- }
- else {
- out[extrudeCoordIndex] = 0;
- }
- // PENDING different region height.
- out[extrudeCoordIndex] += this.regionHeight;
- vec3.transformMat4(out, out, this.transform);
- return out;
- },
- pointToData: function (point, out) {
- // TODO
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (Geo3D);
- /***/
- }),
- /* 100 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- var mat4 = __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__["a" /* default */].mat4;
- var TILE_SIZE = 512;
- var FOV = 0.6435011087932844;
- var PI = Math.PI;
- var WORLD_SCALE = 1 / 10;
- function MapServiceCoordSys3D() {
- /**
- * Width of mapbox viewport
- */
- this.width = 0;
- /**
- * Height of mapbox viewport
- */
- this.height = 0;
- this.altitudeScale = 1;
- // TODO Change boxHeight won't have animation.
- this.boxHeight = 'auto';
- // Set by mapbox creator
- this.altitudeExtent;
- this.bearing = 0;
- this.pitch = 0;
- this.center = [0, 0];
- this._origin;
- this.zoom = 0;
- this._initialZoom;
- // Some parameters for different map services.
- this.maxPitch = 60;
- this.zoomOffset = 0;
- }
- MapServiceCoordSys3D.prototype = {
- constructor: MapServiceCoordSys3D,
- dimensions: ['lng', 'lat', 'alt'],
- containPoint: function () { },
- setCameraOption: function (option) {
- this.bearing = option.bearing;
- this.pitch = option.pitch;
- this.center = option.center;
- this.zoom = option.zoom;
- if (!this._origin) {
- this._origin = this.projectOnTileWithScale(this.center, TILE_SIZE);
- }
- if (this._initialZoom == null) {
- this._initialZoom = this.zoom;
- }
- this.updateTransform();
- },
- // https://github.com/mapbox/mapbox-gl-js/blob/master/src/geo/transform.js#L479
- updateTransform: function () {
- if (!this.height) { return; }
- var cameraToCenterDistance = 0.5 / Math.tan(FOV / 2) * this.height * WORLD_SCALE;
- // Convert to radian.
- var pitch = Math.max(Math.min(this.pitch, this.maxPitch), 0) / 180 * Math.PI;
- // Find the distance from the center point [width/2, height/2] to the
- // center top point [width/2, 0] in Z units, using the law of sines.
- // 1 Z unit is equivalent to 1 horizontal px at the center of the map
- // (the distance between[width/2, height/2] and [width/2 + 1, height/2])
- var halfFov = FOV / 2;
- var groundAngle = Math.PI / 2 + pitch;
- var topHalfSurfaceDistance = Math.sin(halfFov) * cameraToCenterDistance / Math.sin(Math.PI - groundAngle - halfFov);
- // Calculate z distance of the farthest fragment that should be rendered.
- var furthestDistance = Math.cos(Math.PI / 2 - pitch) * topHalfSurfaceDistance + cameraToCenterDistance;
- // Add a bit extra to avoid precision problems when a fragment's distance is exactly `furthestDistance`
- var farZ = furthestDistance * 1.1;
- // Forced to be 1000
- if (this.pitch > 50) {
- farZ = 1000;
- }
- // matrix for conversion from location to GL coordinates (-1 .. 1)
- var m = [];
- mat4.perspective(m, FOV, this.width / this.height, 1, farZ);
- this.viewGL.camera.projectionMatrix.setArray(m);
- this.viewGL.camera.decomposeProjectionMatrix();
- var m = mat4.identity([]);
- var pt = this.dataToPoint(this.center);
- // Inverse
- mat4.scale(m, m, [1, -1, 1]);
- // Translate to altitude
- mat4.translate(m, m, [0, 0, -cameraToCenterDistance]);
- mat4.rotateX(m, m, pitch);
- mat4.rotateZ(m, m, -this.bearing / 180 * Math.PI);
- // Translate to center.
- mat4.translate(m, m, [-pt[0] * this.getScale() * WORLD_SCALE, -pt[1] * this.getScale() * WORLD_SCALE, 0]);
- this.viewGL.camera.viewMatrix.array = m;
- var invertM = [];
- mat4.invert(invertM, m);
- this.viewGL.camera.worldTransform.array = invertM;
- this.viewGL.camera.decomposeWorldTransform();
- // scale vertically to meters per pixel (inverse of ground resolution):
- // worldSize / (circumferenceOfEarth * cos(lat * π / 180))
- var worldSize = TILE_SIZE * this.getScale();
- var verticalScale;
- if (this.altitudeExtent && !isNaN(this.boxHeight)) {
- var range = this.altitudeExtent[1] - this.altitudeExtent[0];
- verticalScale = this.boxHeight / range * this.getScale() / Math.pow(2, this._initialZoom - this.zoomOffset);
- }
- else {
- verticalScale = worldSize / (2 * Math.PI * 6378000 * Math.abs(Math.cos(this.center[1] * (Math.PI / 180))))
- * this.altitudeScale * WORLD_SCALE;
- }
- // Include scale to avoid relayout when zooming
- // FIXME Camera scale may have problem in shadow
- this.viewGL.rootNode.scale.set(
- this.getScale() * WORLD_SCALE, this.getScale() * WORLD_SCALE, verticalScale
- );
- },
- getScale: function () {
- return Math.pow(2, this.zoom - this.zoomOffset);
- },
- projectOnTile: function (data, out) {
- return this.projectOnTileWithScale(data, this.getScale() * TILE_SIZE, out);
- },
- projectOnTileWithScale: function (data, scale, out) {
- var lng = data[0];
- var lat = data[1];
- var lambda2 = lng * PI / 180;
- var phi2 = lat * PI / 180;
- var x = scale * (lambda2 + PI) / (2 * PI);
- var y = scale * (PI - Math.log(Math.tan(PI / 4 + phi2 * 0.5))) / (2 * PI);
- out = out || [];
- out[0] = x;
- out[1] = y;
- return out;
- },
- unprojectFromTile: function (point, out) {
- return this.unprojectOnTileWithScale(point, this.getScale() * TILE_SIZE, out);
- },
- unprojectOnTileWithScale: function (point, scale, out) {
- var x = point[0];
- var y = point[1];
- var lambda2 = (x / scale) * (2 * PI) - PI;
- var phi2 = 2 * (Math.atan(Math.exp(PI - (y / scale) * (2 * PI))) - PI / 4);
- out = out || [];
- out[0] = lambda2 * 180 / PI;
- out[1] = phi2 * 180 / PI;
- return out;
- },
- dataToPoint: function (data, out) {
- out = this.projectOnTileWithScale(data, TILE_SIZE, out);
- // Add a origin to avoid precision issue in WebGL.
- out[0] -= this._origin[0];
- out[1] -= this._origin[1];
- // PENDING
- out[2] = !isNaN(data[2]) ? data[2] : 0;
- if (!isNaN(data[2])) {
- out[2] = data[2];
- if (this.altitudeExtent) {
- out[2] -= this.altitudeExtent[0];
- }
- }
- return out;
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (MapServiceCoordSys3D);
- /***/
- }),
- /* 101 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__ = __webpack_require__(22);
- /* harmony default export */ __webpack_exports__["a"] = (function (serviceComponentType, ServiceCtor, afterCreate) {
- function resizeMapService3D(mapService3DModel, api) {
- var width = api.getWidth();
- var height = api.getHeight();
- var dpr = api.getDevicePixelRatio();
- this.viewGL.setViewport(0, 0, width, height, dpr);
- this.width = width;
- this.height = height;
- this.altitudeScale = mapService3DModel.get('altitudeScale');
- this.boxHeight = mapService3DModel.get('boxHeight');
- // this.updateTransform();
- }
- function updateService3D(ecModel, api) {
- if (this.model.get('boxHeight') === 'auto') {
- return;
- }
- var altitudeDataExtent = [Infinity, -Infinity]
- ecModel.eachSeries(function (seriesModel) {
- if (seriesModel.coordinateSystem !== this) {
- return;
- }
- // Get altitude data extent.
- var data = seriesModel.getData();
- var altDim = seriesModel.coordDimToDataDim('alt')[0];
- if (altDim) {
- // TODO altitiude is in coords of lines.
- var dataExtent = data.getDataExtent(altDim, true);
- altitudeDataExtent[0] = Math.min(
- altitudeDataExtent[0], dataExtent[0]
- );
- altitudeDataExtent[1] = Math.max(
- altitudeDataExtent[1], dataExtent[1]
- );
- }
- }, this);
- if (altitudeDataExtent && isFinite(altitudeDataExtent[1] - altitudeDataExtent[0])) {
- this.altitudeExtent = altitudeDataExtent;
- }
- }
- return {
- dimensions: ServiceCtor.prototype.dimensions,
- create: function (ecModel, api) {
- var mapService3DList = [];
- ecModel.eachComponent(serviceComponentType, function (mapService3DModel) {
- var viewGL = mapService3DModel.__viewGL;
- if (!viewGL) {
- viewGL = mapService3DModel.__viewGL = new __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__["a" /* default */]();
- viewGL.setRootNode(new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node());
- }
- var mapService3DCoordSys = new ServiceCtor();
- mapService3DCoordSys.viewGL = mapService3DModel.__viewGL;
- // Inject resize
- mapService3DCoordSys.resize = resizeMapService3D;
- mapService3DCoordSys.resize(mapService3DModel, api);
- mapService3DList.push(mapService3DCoordSys);
- mapService3DModel.coordinateSystem = mapService3DCoordSys;
- mapService3DCoordSys.model = mapService3DModel;
- mapService3DCoordSys.update = updateService3D;
- });
- ecModel.eachSeries(function (seriesModel) {
- if (seriesModel.get('coordinateSystem') === serviceComponentType) {
- var mapService3DModel = seriesModel.getReferringComponents(serviceComponentType)[0];
- if (!mapService3DModel) {
- mapService3DModel = ecModel.getComponent(serviceComponentType);
- }
- if (!mapService3DModel) {
- throw new Error(serviceComponentType + ' "' + __WEBPACK_IMPORTED_MODULE_0__util_retrieve__["a" /* default */].firstNotNull(
- seriesModel.get(serviceComponentType + 'Index'),
- seriesModel.get(serviceComponentType + 'Id'),
- 0
- ) + '" not found');
- }
- seriesModel.coordinateSystem = mapService3DModel.coordinateSystem;
- }
- });
- afterCreate && afterCreate(mapService3DList, ecModel, api);
- return mapService3DList;
- }
- };
- });
- /***/
- }),
- /* 102 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("\n@export ecgl.displayShadow.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_WorldPosition;\n\nvarying vec3 v_Normal;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n\n@end\n\n\n@export ecgl.displayShadow.fragment\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform float roughness: 0.2;\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.ssaoMap.header\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n float shadow = 1.0;\n\n @import ecgl.common.ssaoMap.main\n\n#if defined(DIRECTIONAL_LIGHT_COUNT) && defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++) {\n shadow = min(shadow, shadowContribsDir[i] * 0.5 + 0.5);\n }\n#endif\n\n shadow *= 0.5 + ao * 0.5;\n shadow = clamp(shadow, 0.0, 1.0);\n\n gl_FragColor = vec4(vec3(0.0), 1.0 - shadow);\n}\n\n@end");
- /***/
- }),
- /* 103 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix__ = __webpack_require__(84);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector__ = __webpack_require__(83);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector__);
- function GLViewHelper(viewGL) {
- this.viewGL = viewGL;
- }
- GLViewHelper.prototype.reset = function (seriesModel, api) {
- this._updateCamera(api.getWidth(), api.getHeight(), api.getDevicePixelRatio());
- this._viewTransform = __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix___default.a.create();
- this.updateTransform(seriesModel, api);
- };
- GLViewHelper.prototype.updateTransform = function (seriesModel, api) {
- var coordinateSystem = seriesModel.coordinateSystem;
- if (coordinateSystem.getRoamTransform) {
- __WEBPACK_IMPORTED_MODULE_0_zrender_lib_core_matrix___default.a.invert(this._viewTransform, coordinateSystem.getRoamTransform());
- this._setCameraTransform(this._viewTransform);
- api.getZr().refresh();
- }
- };
- // Reimplement the dataToPoint of coordinate system.
- // Remove the effect of pan/zoom transform
- GLViewHelper.prototype.dataToPoint = function (coordSys, data, pt) {
- pt = coordSys.dataToPoint(data, null, pt);
- var viewTransform = this._viewTransform;
- if (viewTransform) {
- __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector___default.a.applyTransform(pt, pt, viewTransform);
- }
- };
- /**
- * Remove transform info in point.
- */
- GLViewHelper.prototype.removeTransformInPoint = function (pt) {
- if (this._viewTransform) {
- __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_vector___default.a.applyTransform(pt, pt, this._viewTransform);
- }
- return pt;
- };
- /**
- * Return number
- */
- GLViewHelper.prototype.getZoom = function () {
- if (this._viewTransform) {
- var m = this._viewTransform;
- return 1 / Math.max(
- Math.sqrt(m[0] * m[0] + m[1] * m[1]),
- Math.sqrt(m[2] * m[2] + m[3] * m[3])
- );
- }
- return 1;
- };
- GLViewHelper.prototype._setCameraTransform = function (m) {
- var camera = this.viewGL.camera;
- camera.position.set(m[4], m[5], 0);
- camera.scale.set(
- Math.sqrt(m[0] * m[0] + m[1] * m[1]),
- Math.sqrt(m[2] * m[2] + m[3] * m[3]),
- 1
- );
- };
- GLViewHelper.prototype._updateCamera = function (width, height, dpr) {
- // TODO, left, top, right, bottom
- this.viewGL.setViewport(0, 0, width, height, dpr);
- var camera = this.viewGL.camera;
- camera.left = camera.top = 0;
- camera.bottom = height;
- camera.right = width;
- camera.near = 0;
- camera.far = 100;
- };
- /* harmony default export */ __webpack_exports__["a"] = (GLViewHelper);
- /***/
- }),
- /* 104 */
- /***/ (function (module, exports, __webpack_require__) {
- /* WEBPACK VAR INJECTION */(function (global) {/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- // (1) The code `if (__DEV__) ...` can be removed by build tool.
- // (2) If intend to use `__DEV__`, this module should be imported. Use a global
- // variable `__DEV__` may cause that miss the declaration (see #6535), or the
- // declaration is behind of the using position (for example in `Model.extent`,
- // And tools like rollup can not analysis the dependency if not import).
- var dev; // In browser
- if (typeof window !== 'undefined') {
- dev = window.__DEV__;
- } // In node
- else if (typeof global !== 'undefined') {
- dev = global.__DEV__;
- }
- if (typeof dev === 'undefined') {
- dev = true;
- }
- var __DEV__ = dev;
- exports.__DEV__ = __DEV__;
- /* WEBPACK VAR INJECTION */
- }.call(exports, __webpack_require__(68)))
- /***/
- }),
- /* 105 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(15);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(38);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /**
- * Lines geometry
- * Use screen space projected lines lineWidth > MAX_LINE_WIDTH
- * https://mattdesl.svbtle.com/drawing-lines-is-hard
- * @module echarts-gl/util/geometry/LinesGeometry
- * @author Yi Shen(http://github.com/pissang)
- */
- var vec2 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__["a" /* default */].vec2;
- // var CURVE_RECURSION_LIMIT = 8;
- // var CURVE_COLLINEAR_EPSILON = 40;
- var sampleLinePoints = [[0, 0], [1, 1]];
- /**
- * @constructor
- * @alias module:echarts-gl/util/geometry/LinesGeometry
- * @extends clay.Geometry
- */
- var LinesGeometry = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].extend(function () {
- return {
- segmentScale: 4,
- dynamic: true,
- /**
- * Need to use mesh to expand lines if lineWidth > MAX_LINE_WIDTH
- */
- useNativeLine: true,
- attributes: {
- position: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('position', 'float', 2, 'POSITION'),
- normal: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('normal', 'float', 2),
- offset: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('offset', 'float', 1),
- color: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('color', 'float', 4, 'COLOR')
- }
- };
- },
- /** @lends module: echarts-gl/util/geometry/LinesGeometry.prototype */
- {
- /**
- * Reset offset
- */
- resetOffset: function () {
- this._vertexOffset = 0;
- this._faceOffset = 0;
- this._itemVertexOffsets = [];
- },
- /**
- * @param {number} nVertex
- */
- setVertexCount: function (nVertex) {
- var attributes = this.attributes;
- if (this.vertexCount !== nVertex) {
- attributes.position.init(nVertex);
- attributes.color.init(nVertex);
- if (!this.useNativeLine) {
- attributes.offset.init(nVertex);
- attributes.normal.init(nVertex);
- }
- if (nVertex > 0xffff) {
- if (this.indices instanceof Uint16Array) {
- this.indices = new Uint32Array(this.indices);
- }
- }
- else {
- if (this.indices instanceof Uint32Array) {
- this.indices = new Uint16Array(this.indices);
- }
- }
- }
- },
- /**
- * @param {number} nTriangle
- */
- setTriangleCount: function (nTriangle) {
- if (this.triangleCount !== nTriangle) {
- if (nTriangle === 0) {
- this.indices = null;
- }
- else {
- this.indices = this.vertexCount > 0xffff ? new Uint32Array(nTriangle * 3) : new Uint16Array(nTriangle * 3);
- }
- }
- },
- _getCubicCurveApproxStep: function (p0, p1, p2, p3) {
- var len = vec2.dist(p0, p1) + vec2.dist(p2, p1) + vec2.dist(p3, p2);
- var step = 1 / (len + 1) * this.segmentScale;
- return step;
- },
- /**
- * Get vertex count of cubic curve
- * @param {Array.<number>} p0
- * @param {Array.<number>} p1
- * @param {Array.<number>} p2
- * @param {Array.<number>} p3
- * @return number
- */
- getCubicCurveVertexCount: function (p0, p1, p2, p3) {
- var step = this._getCubicCurveApproxStep(p0, p1, p2, p3);
- var segCount = Math.ceil(1 / step);
- if (!this.useNativeLine) {
- return segCount * 2 + 2;
- }
- else {
- return segCount * 2;
- }
- },
- /**
- * Get face count of cubic curve
- * @param {Array.<number>} p0
- * @param {Array.<number>} p1
- * @param {Array.<number>} p2
- * @param {Array.<number>} p3
- * @return number
- */
- getCubicCurveTriangleCount: function (p0, p1, p2, p3) {
- var step = this._getCubicCurveApproxStep(p0, p1, p2, p3);
- var segCount = Math.ceil(1 / step);
- if (!this.useNativeLine) {
- return segCount * 2;
- }
- else {
- return 0;
- }
- },
- /**
- * Get vertex count of line
- * @return {number}
- */
- getLineVertexCount: function () {
- return this.getPolylineVertexCount(sampleLinePoints);
- },
- /**
- * Get face count of line
- * @return {number}
- */
- getLineTriangleCount: function () {
- return this.getPolylineTriangleCount(sampleLinePoints);
- },
- /**
- * Get how many vertices will polyline take.
- * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount.
- * @return {number}
- */
- getPolylineVertexCount: function (points) {
- var pointsLen;
- if (typeof points === 'number') {
- pointsLen = points;
- }
- else {
- var is2DArray = typeof points[0] !== 'number';
- pointsLen = is2DArray ? points.length : (points.length / 2);
- }
- return !this.useNativeLine ? ((pointsLen - 1) * 2 + 2) : (pointsLen - 1) * 2;
- },
- /**
- * Get how many triangles will polyline take.
- * @type {number|Array} points Can be a 1d/2d list of points, or a number of points amount.
- * @return {number}
- */
- getPolylineTriangleCount: function (points) {
- var pointsLen;
- if (typeof points === 'number') {
- pointsLen = points;
- }
- else {
- var is2DArray = typeof points[0] !== 'number';
- pointsLen = is2DArray ? points.length : (points.length / 2);
- }
- return !this.useNativeLine ? (pointsLen - 1) * 2 : 0;
- },
- /**
- * Add a cubic curve
- * @param {Array.<number>} p0
- * @param {Array.<number>} p1
- * @param {Array.<number>} p2
- * @param {Array.<number>} p3
- * @param {Array.<number>} color
- * @param {number} [lineWidth=1]
- */
- addCubicCurve: function (p0, p1, p2, p3, color, lineWidth) {
- if (lineWidth == null) {
- lineWidth = 1;
- }
- // incremental interpolation
- // http://antigrain.com/research/bezier_interpolation/index.html#PAGE_BEZIER_INTERPOLATION
- var x0 = p0[0], y0 = p0[1];
- var x1 = p1[0], y1 = p1[1];
- var x2 = p2[0], y2 = p2[1];
- var x3 = p3[0], y3 = p3[1];
- var step = this._getCubicCurveApproxStep(p0, p1, p2, p3);
- var step2 = step * step;
- var step3 = step2 * step;
- var pre1 = 3.0 * step;
- var pre2 = 3.0 * step2;
- var pre4 = 6.0 * step2;
- var pre5 = 6.0 * step3;
- var tmp1x = x0 - x1 * 2.0 + x2;
- var tmp1y = y0 - y1 * 2.0 + y2;
- var tmp2x = (x1 - x2) * 3.0 - x0 + x3;
- var tmp2y = (y1 - y2) * 3.0 - y0 + y3;
- var fx = x0;
- var fy = y0;
- var dfx = (x1 - x0) * pre1 + tmp1x * pre2 + tmp2x * step3;
- var dfy = (y1 - y0) * pre1 + tmp1y * pre2 + tmp2y * step3;
- var ddfx = tmp1x * pre4 + tmp2x * pre5;
- var ddfy = tmp1y * pre4 + tmp2y * pre5;
- var dddfx = tmp2x * pre5;
- var dddfy = tmp2y * pre5;
- var t = 0;
- var k = 0;
- var segCount = Math.ceil(1 / step);
- var points = new Float32Array((segCount + 1) * 3);
- var points = [];
- var offset = 0;
- for (var k = 0; k < segCount + 1; k++) {
- points[offset++] = fx;
- points[offset++] = fy;
- fx += dfx; fy += dfy;
- dfx += ddfx; dfy += ddfy;
- ddfx += dddfx; ddfy += dddfy;
- t += step;
- if (t > 1) {
- fx = dfx > 0 ? Math.min(fx, x3) : Math.max(fx, x3);
- fy = dfy > 0 ? Math.min(fy, y3) : Math.max(fy, y3);
- }
- }
- this.addPolyline(points, color, lineWidth);
- },
- /**
- * Add a straight line
- * @param {Array.<number>} p0
- * @param {Array.<number>} p1
- * @param {Array.<number>} color
- * @param {number} [lineWidth=1]
- */
- addLine: function (p0, p1, color, lineWidth) {
- this.addPolyline([p0, p1], color, lineWidth);
- },
- /**
- * Add a straight line
- * @param {Array.<Array> | Array.<number>} points
- * @param {Array.<number> | Array.<Array>} color
- * @param {number} [lineWidth=1]
- * @param {number} [arrayOffset=0]
- * @param {number} [pointsCount] Default to be amount of points in the first argument
- */
- addPolyline: (function () {
- var dirA = vec2.create();
- var dirB = vec2.create();
- var normal = vec2.create();
- var tangent = vec2.create();
- var point = [], nextPoint = [], prevPoint = [];
- return function (points, color, lineWidth, arrayOffset, pointsCount) {
- if (!points.length) {
- return;
- }
- var is2DArray = typeof points[0] !== 'number';
- if (pointsCount == null) {
- pointsCount = is2DArray ? points.length : points.length / 2;
- }
- if (pointsCount < 2) {
- return;
- }
- if (arrayOffset == null) {
- arrayOffset = 0;
- }
- if (lineWidth == null) {
- lineWidth = 1;
- }
- this._itemVertexOffsets.push(this._vertexOffset);
- var notSharingColor = is2DArray
- ? typeof color[0] !== 'number'
- : color.length / 4 === pointsCount;
- var positionAttr = this.attributes.position;
- var colorAttr = this.attributes.color;
- var offsetAttr = this.attributes.offset;
- var normalAttr = this.attributes.normal;
- var indices = this.indices;
- var vertexOffset = this._vertexOffset;
- var pointColor;
- for (var k = 0; k < pointsCount; k++) {
- if (is2DArray) {
- point = points[k + arrayOffset];
- if (notSharingColor) {
- pointColor = color[k + arrayOffset];
- }
- else {
- pointColor = color;
- }
- }
- else {
- var k2 = k * 2 + arrayOffset;
- point = point || [];
- point[0] = points[k2];
- point[1] = points[k2 + 1];
- if (notSharingColor) {
- var k4 = k * 4 + arrayOffset;
- pointColor = pointColor || [];
- pointColor[0] = color[k4];
- pointColor[1] = color[k4 + 1];
- pointColor[2] = color[k4 + 2];
- pointColor[3] = color[k4 + 3];
- }
- else {
- pointColor = color;
- }
- }
- if (!this.useNativeLine) {
- var offset;
- if (k < pointsCount - 1) {
- if (is2DArray) {
- vec2.copy(nextPoint, points[k + 1]);
- }
- else {
- var k2 = (k + 1) * 2 + arrayOffset;
- nextPoint = nextPoint || [];
- nextPoint[0] = points[k2];
- nextPoint[1] = points[k2 + 1];
- }
- // TODO In case dir is (0, 0)
- // TODO miterLimit
- if (k > 0) {
- vec2.sub(dirA, point, prevPoint);
- vec2.sub(dirB, nextPoint, point);
- vec2.normalize(dirA, dirA);
- vec2.normalize(dirB, dirB);
- vec2.add(tangent, dirA, dirB);
- vec2.normalize(tangent, tangent);
- var miter = lineWidth / 2 * Math.min(1 / vec2.dot(dirA, tangent), 2);
- normal[0] = -tangent[1];
- normal[1] = tangent[0];
- offset = miter;
- }
- else {
- vec2.sub(dirA, nextPoint, point);
- vec2.normalize(dirA, dirA);
- normal[0] = -dirA[1];
- normal[1] = dirA[0];
- offset = lineWidth / 2;
- }
- }
- else {
- vec2.sub(dirA, point, prevPoint);
- vec2.normalize(dirA, dirA);
- normal[0] = -dirA[1];
- normal[1] = dirA[0];
- offset = lineWidth / 2;
- }
- normalAttr.set(vertexOffset, normal);
- normalAttr.set(vertexOffset + 1, normal);
- offsetAttr.set(vertexOffset, offset);
- offsetAttr.set(vertexOffset + 1, -offset);
- vec2.copy(prevPoint, point);
- positionAttr.set(vertexOffset, point);
- positionAttr.set(vertexOffset + 1, point);
- colorAttr.set(vertexOffset, pointColor);
- colorAttr.set(vertexOffset + 1, pointColor);
- vertexOffset += 2;
- }
- else {
- if (k > 1) {
- positionAttr.copy(vertexOffset, vertexOffset - 1);
- colorAttr.copy(vertexOffset, vertexOffset - 1);
- vertexOffset++;
- }
- }
- if (!this.useNativeLine) {
- if (k > 0) {
- var idx3 = this._faceOffset * 3;
- var indices = this.indices;
- // 0-----2
- // 1-----3
- // 0->1->2, 1->3->2
- indices[idx3] = vertexOffset - 4;
- indices[idx3 + 1] = vertexOffset - 3;
- indices[idx3 + 2] = vertexOffset - 2;
- indices[idx3 + 3] = vertexOffset - 3;
- indices[idx3 + 4] = vertexOffset - 1;
- indices[idx3 + 5] = vertexOffset - 2;
- this._faceOffset += 2;
- }
- }
- else {
- colorAttr.set(vertexOffset, pointColor);
- positionAttr.set(vertexOffset, point);
- vertexOffset++;
- }
- }
- this._vertexOffset = vertexOffset;
- };
- })(),
- /**
- * Set color of single line.
- */
- setItemColor: function (idx, color) {
- var startOffset = this._itemVertexOffsets[idx];
- var endOffset = idx < this._itemVertexOffsets.length - 1 ? this._itemVertexOffsets[idx + 1] : this._vertexOffset;
- for (var i = startOffset; i < endOffset; i++) {
- this.attributes.color.set(i, color);
- }
- this.dirty('color');
- }
- });
- __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.util.defaults(LinesGeometry.prototype, __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__["a" /* default */]);
- /* harmony default export */ __webpack_exports__["a"] = (LinesGeometry);
- /***/
- }),
- /* 106 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_echarts_gl__ = __webpack_require__(107);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_component_grid3D__ = __webpack_require__(154);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_component_geo3D__ = __webpack_require__(201);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_component_globe__ = __webpack_require__(207);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_component_mapbox3D__ = __webpack_require__(213);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_component_maptalks3D__ = __webpack_require__(219);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_chart_bar3D__ = __webpack_require__(225);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_chart_line3D__ = __webpack_require__(232);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_chart_scatter3D__ = __webpack_require__(236);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_chart_lines3D__ = __webpack_require__(243);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__src_chart_polygons3D__ = __webpack_require__(249);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__src_chart_surface__ = __webpack_require__(252);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__src_chart_map3D__ = __webpack_require__(256);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__src_chart_scatterGL__ = __webpack_require__(259);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__src_chart_graphGL__ = __webpack_require__(262);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__src_chart_flowGL__ = __webpack_require__(275);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__src_chart_linesGL__ = __webpack_require__(281);
- /***/
- }),
- /* 107 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_version__ = __webpack_require__(108);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_LayerGL__ = __webpack_require__(109);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__preprocessor_backwardCompat__ = __webpack_require__(153);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__ = __webpack_require__(1);
- /**
- * echarts-gl
- * Extension pack of ECharts providing 3d plots and globe visualization
- *
- * Copyright (c) 2014, echarts-gl
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- /**
- * @module echarts-gl
- * @author Yi Shen(http://github.com/pissang)
- */
- // PENDING Use a single canvas as layer or use image element?
- var echartsGl = {
- version: '1.1.1',
- dependencies: {
- echarts: '4.1.0',
- claygl: '1.2.1'
- }
- };
- // Version checking
- var deps = echartsGl.dependencies;
- function versionTooOldMsg(name) {
- throw new Error(
- name + ' version is too old, needs ' + deps[name] + ' or higher'
- );
- }
- function checkVersion(version, name) {
- if ((version.replace('.', '') - 0) < (deps[name].replace('.', '') - 0)) {
- versionTooOldMsg(name);
- }
- console.log('Loaded ' + name + ', version ' + version);
- }
- checkVersion(__WEBPACK_IMPORTED_MODULE_1_claygl_src_version__["a" /* default */], 'claygl');
- checkVersion(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.version, 'echarts');
- function EChartsGL(zr) {
- this._layers = {};
- this._zr = zr;
- }
- EChartsGL.prototype.update = function (ecModel, api) {
- var self = this;
- var zr = api.getZr();
- if (!zr.getWidth() || !zr.getHeight()) {
- console.warn('Dom has no width or height');
- return;
- }
- function getLayerGL(model) {
- var zlevel;
- // Host on coordinate system.
- if (model.coordinateSystem && model.coordinateSystem.model) {
- zlevel = model.get('zlevel');
- }
- else {
- zlevel = model.get('zlevel');
- }
- var layers = self._layers;
- var layerGL = layers[zlevel];
- if (!layerGL) {
- layerGL = layers[zlevel] = new __WEBPACK_IMPORTED_MODULE_2__core_LayerGL__["a" /* default */]('gl-' + zlevel, zr);
- if (zr.painter.isSingleCanvas()) {
- layerGL.virtual = true;
- // If container is canvas, use image to represent LayerGL
- // FIXME Performance
- var img = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Image({
- z: 1e4,
- style: {
- image: layerGL.renderer.canvas
- },
- silent: true
- });
- layerGL.__hostImage = img;
- zr.add(img);
- }
- zr.painter.insertLayer(zlevel, layerGL);
- }
- if (layerGL.__hostImage) {
- layerGL.__hostImage.setStyle({
- width: layerGL.renderer.getWidth(),
- height: layerGL.renderer.getHeight()
- });
- }
- return layerGL;
- }
- function setSilent(groupGL, silent) {
- if (groupGL) {
- groupGL.traverse(function (mesh) {
- if (mesh.isRenderable && mesh.isRenderable()) {
- mesh.ignorePicking = mesh.$ignorePicking != null
- ? mesh.$ignorePicking : silent;
- }
- });
- }
- }
- for (var zlevel in this._layers) {
- this._layers[zlevel].removeViewsAll();
- }
- ecModel.eachComponent(function (componentType, componentModel) {
- if (componentType !== 'series') {
- var view = api.getViewOfComponentModel(componentModel);
- var coordSys = componentModel.coordinateSystem;
- // View with __ecgl__ flag is a echarts-gl component.
- if (view.__ecgl__) {
- var viewGL;
- if (coordSys) {
- if (!coordSys.viewGL) {
- console.error('Can\'t find viewGL in coordinateSystem of component ' + componentModel.id);
- return;
- }
- viewGL = coordSys.viewGL;
- }
- else {
- if (!componentModel.viewGL) {
- console.error('Can\'t find viewGL of component ' + componentModel.id);
- return;
- }
- viewGL = coordSys.viewGL;
- }
- var viewGL = coordSys.viewGL;
- var layerGL = getLayerGL(componentModel);
- layerGL.addView(viewGL);
- view.afterRender && view.afterRender(
- componentModel, ecModel, api, layerGL
- );
- setSilent(view.groupGL, componentModel.get('silent'));
- }
- }
- });
- ecModel.eachSeries(function (seriesModel) {
- var chartView = api.getViewOfSeriesModel(seriesModel);
- var coordSys = seriesModel.coordinateSystem;
- if (chartView.__ecgl__) {
- if ((coordSys && !coordSys.viewGL) && !chartView.viewGL) {
- console.error('Can\'t find viewGL of series ' + chartView.id);
- return;
- }
- var viewGL = (coordSys && coordSys.viewGL) || chartView.viewGL;
- // TODO Check zlevel not same with component of coordinate system ?
- var layerGL = getLayerGL(seriesModel);
- layerGL.addView(viewGL);
- chartView.afterRender && chartView.afterRender(
- seriesModel, ecModel, api, layerGL
- );
- setSilent(chartView.groupGL, seriesModel.get('silent'));
- }
- });
- };
- // Hack original getRenderedCanvas. Will removed after new echarts released
- // TODO
- var oldInit = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.init;
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.init = function () {
- var chart = oldInit.apply(this, arguments);
- chart.getZr().painter.getRenderedCanvas = function (opts) {
- opts = opts || {};
- if (this._singleCanvas) {
- return this._layers[0].dom;
- }
- var canvas = document.createElement('canvas');
- var dpr = opts.pixelRatio || this.dpr;
- canvas.width = this.getWidth() * dpr;
- canvas.height = this.getHeight() * dpr;
- var ctx = canvas.getContext('2d');
- ctx.dpr = dpr;
- ctx.clearRect(0, 0, canvas.width, canvas.height);
- if (opts.backgroundColor) {
- ctx.fillStyle = opts.backgroundColor;
- ctx.fillRect(0, 0, canvas.width, canvas.height);
- }
- var displayList = this.storage.getDisplayList(true);
- var scope = {};
- var zlevel;
- var self = this;
- function findAndDrawOtherLayer(smaller, larger) {
- var zlevelList = self._zlevelList;
- if (smaller == null) {
- smaller = -Infinity;
- }
- var intermediateLayer;
- for (var i = 0; i < zlevelList.length; i++) {
- var z = zlevelList[i];
- var layer = self._layers[z];
- if (!layer.__builtin__ && z > smaller && z < larger) {
- intermediateLayer = layer;
- break;
- }
- }
- if (intermediateLayer && intermediateLayer.renderToCanvas) {
- ctx.save();
- intermediateLayer.renderToCanvas(ctx);
- ctx.restore();
- }
- }
- var layer = {
- ctx: ctx
- };
- for (var i = 0; i < displayList.length; i++) {
- var el = displayList[i];
- if (el.zlevel !== zlevel) {
- findAndDrawOtherLayer(zlevel, el.zlevel);
- zlevel = el.zlevel;
- }
- this._doPaintEl(el, layer, true, scope);
- }
- findAndDrawOtherLayer(zlevel, Infinity);
- return canvas;
- };
- return chart;
- };
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerPostUpdate(function (ecModel, api) {
- var zr = api.getZr();
- var egl = zr.__egl = zr.__egl || new EChartsGL(zr);
- egl.update(ecModel, api);
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerPreprocessor(__WEBPACK_IMPORTED_MODULE_3__preprocessor_backwardCompat__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphicGL = __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__["a" /* default */];
- /* unused harmony default export */ var _unused_webpack_default_export = (EChartsGL);
- /***/
- }),
- /* 108 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * @name clay.version
- */
- /* harmony default export */ __webpack_exports__["a"] = ('1.2.1');
- /***/
- }),
- /* 109 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__ = __webpack_require__(52);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_picking_RayPicking__ = __webpack_require__(117);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_core_mixin_notifier__ = __webpack_require__(53);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame__ = __webpack_require__(80);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame__);
- /**
- * Provide WebGL layer to zrender. Which is rendered on top of clay.
- *
- *
- * Relationship between zrender, LayerGL(renderer) and ViewGL(Scene, Camera, Viewport)
- * zrender
- * / \
- * LayerGL LayerGL
- * (renderer) (renderer)
- * / \
- * ViewGL ViewGL
- *
- * @module echarts-gl/core/LayerGL
- * @author Yi Shen(http://github.com/pissang)
- */
- // PENDING, clay. notifier is same with zrender Eventful
- /**
- * @constructor
- * @alias module:echarts-gl/core/LayerGL
- * @param {string} id Layer ID
- * @param {module:zrender/ZRender} zr
- */
- var LayerGL = function (id, zr) {
- /**
- * Layer ID
- * @type {string}
- */
- this.id = id;
- /**
- * @type {module:zrender/ZRender}
- */
- this.zr = zr;
- /**
- * @type {clay.Renderer}
- */
- try {
- this.renderer = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Renderer__["a" /* default */]({
- clearBit: 0,
- devicePixelRatio: zr.painter.dpr,
- preserveDrawingBuffer: true,
- // PENDING
- premultipliedAlpha: true
- });
- this.renderer.resize(zr.painter.getWidth(), zr.painter.getHeight());
- }
- catch (e) {
- this.renderer = null;
- this.dom = document.createElement('div');
- this.dom.style.cssText = 'position:absolute; left: 0; top: 0; right: 0; bottom: 0;';
- this.dom.className = 'ecgl-nowebgl';
- this.dom.innerHTML = 'Sorry, your browser does not support WebGL';
- console.error(e);
- return;
- }
- this.onglobalout = this.onglobalout.bind(this);
- zr.on('globalout', this.onglobalout);
- /**
- * Canvas dom for webgl rendering
- * @type {HTMLCanvasElement}
- */
- this.dom = this.renderer.canvas;
- var style = this.dom.style;
- style.position = 'absolute';
- style.left = '0';
- style.top = '0';
- /**
- * @type {Array.<clay.Scene>}
- */
- this.views = [];
- this._picking = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_picking_RayPicking__["a" /* default */]({
- renderer: this.renderer
- });
- this._viewsToDispose = [];
- /**
- * Current accumulating id.
- */
- this._accumulatingId = 0;
- this._zrEventProxy = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Rect({
- shape: { x: -1, y: -1, width: 2, height: 2 },
- // FIXME Better solution.
- __isGLToZRProxy: true
- });
- this._backgroundColor = null;
- };
- /**
- * @param {module:echarts-gl/core/ViewGL} view
- */
- LayerGL.prototype.addView = function (view) {
- if (view.layer === this) {
- return;
- }
- // If needs to dispose in this layer. unmark it.
- var idx = this._viewsToDispose.indexOf(view);
- if (idx >= 0) {
- this._viewsToDispose.splice(idx, 1);
- }
- this.views.push(view);
- view.layer = this;
- var zr = this.zr;
- view.scene.traverse(function (node) {
- node.__zr = zr;
- if (node.addAnimatorsToZr) {
- node.addAnimatorsToZr(zr);
- }
- });
- };
- function removeFromZr(node) {
- var zr = node.__zr;
- node.__zr = null;
- if (zr && node.removeAnimatorsFromZr) {
- node.removeAnimatorsFromZr(zr);
- }
- }
- /**
- * @param {module:echarts-gl/core/ViewGL} view
- */
- LayerGL.prototype.removeView = function (view) {
- if (view.layer !== this) {
- return;
- }
- var idx = this.views.indexOf(view);
- if (idx >= 0) {
- this.views.splice(idx, 1);
- view.scene.traverse(removeFromZr, this);
- view.layer = null;
- // Mark to dispose in this layer.
- this._viewsToDispose.push(view);
- }
- };
- /**
- * Remove all views
- */
- LayerGL.prototype.removeViewsAll = function () {
- this.views.forEach(function (view) {
- view.scene.traverse(removeFromZr, this);
- view.layer = null;
- // Mark to dispose in this layer.
- this._viewsToDispose.push(view);
- }, this);
- this.views.length = 0;
- };
- /**
- * Resize the canvas and viewport, will be invoked by zrender
- * @param {number} width
- * @param {number} height
- */
- LayerGL.prototype.resize = function (width, height) {
- var renderer = this.renderer;
- renderer.resize(width, height);
- };
- /**
- * Clear color and depth
- * @return {[type]} [description]
- */
- LayerGL.prototype.clear = function () {
- var gl = this.renderer.gl;
- var clearColor = this._backgroundColor || [0, 0, 0, 0];
- gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
- gl.depthMask(true);
- gl.colorMask(true, true, true, true);
- gl.clear(gl.DEPTH_BUFFER_BIT | gl.COLOR_BUFFER_BIT);
- };
- /**
- * Clear depth
- */
- LayerGL.prototype.clearDepth = function () {
- var gl = this.renderer.gl;
- gl.clear(gl.DEPTH_BUFFER_BIT);
- };
- /**
- * Clear color
- */
- LayerGL.prototype.clearColor = function () {
- var gl = this.renderer.gl;
- gl.clearColor(0, 0, 0, 0);
- gl.clear(gl.COLOR_BUFFER_BIT);
- };
- /**
- * Mark layer to refresh next tick
- */
- LayerGL.prototype.needsRefresh = function () {
- this.zr.refresh();
- };
- /**
- * Refresh the layer, will be invoked by zrender
- */
- LayerGL.prototype.refresh = function (bgColor) {
- this._backgroundColor = bgColor ? __WEBPACK_IMPORTED_MODULE_4__util_graphicGL__["a" /* default */].parseColor(bgColor) : [0, 0, 0, 0];
- this.renderer.clearColor = this._backgroundColor;
- for (var i = 0; i < this.views.length; i++) {
- this.views[i].prepareRender(this.renderer);
- }
- this._doRender(false);
- // Auto dispose unused resources on GPU, like program(shader), texture, geometry(buffers)
- this._trackAndClean();
- // Dispose trashed views
- for (var i = 0; i < this._viewsToDispose.length; i++) {
- this._viewsToDispose[i].dispose(this.renderer);
- }
- this._viewsToDispose.length = 0;
- this._startAccumulating();
- };
- LayerGL.prototype.renderToCanvas = function (ctx) {
- // PENDING will block the page
- this._startAccumulating(true);
- ctx.drawImage(this.dom, 0, 0, ctx.canvas.width, ctx.canvas.height);
- };
- LayerGL.prototype._doRender = function (accumulating) {
- this.clear();
- this.renderer.saveViewport();
- for (var i = 0; i < this.views.length; i++) {
- this.views[i].render(this.renderer, accumulating);
- }
- this.renderer.restoreViewport();
- };
- /**
- * Stop accumulating
- */
- LayerGL.prototype._stopAccumulating = function () {
- this._accumulatingId = 0;
- clearTimeout(this._accumulatingTimeout);
- };
- var accumulatingId = 1;
- /**
- * Start accumulating all the views.
- * Accumulating is for antialising and have more sampling in SSAO
- * @private
- */
- LayerGL.prototype._startAccumulating = function (immediate) {
- var self = this;
- this._stopAccumulating();
- var needsAccumulate = false;
- for (var i = 0; i < this.views.length; i++) {
- needsAccumulate = this.views[i].needsAccumulate() || needsAccumulate;
- }
- if (!needsAccumulate) {
- return;
- }
- function accumulate(id) {
- if (!self._accumulatingId || id !== self._accumulatingId) {
- return;
- }
- var isFinished = true;
- for (var i = 0; i < self.views.length; i++) {
- isFinished = self.views[i].isAccumulateFinished() && needsAccumulate;
- }
- if (!isFinished) {
- self._doRender(true);
- if (immediate) {
- accumulate(id);
- }
- else {
- __WEBPACK_IMPORTED_MODULE_6_zrender_lib_animation_requestAnimationFrame___default()(function () {
- accumulate(id);
- });
- }
- }
- }
- this._accumulatingId = accumulatingId++;
- if (immediate) {
- accumulate(self._accumulatingId);
- }
- else {
- this._accumulatingTimeout = setTimeout(function () {
- accumulate(self._accumulatingId);
- }, 50);
- }
- };
- LayerGL.prototype._trackAndClean = function () {
- var textureList = [];
- var geometriesList = [];
- // Mark all resources unused;
- if (this._textureList) {
- markUnused(this._textureList);
- markUnused(this._geometriesList);
- }
- for (var i = 0; i < this.views.length; i++) {
- collectResources(this.views[i].scene, textureList, geometriesList);
- }
- // Dispose those unsed resources.
- if (this._textureList) {
- checkAndDispose(this.renderer, this._textureList);
- checkAndDispose(this.renderer, this._geometriesList);
- }
- this._textureList = textureList;
- this._geometriesList = geometriesList;
- };
- function markUnused(resourceList) {
- for (var i = 0; i < resourceList.length; i++) {
- resourceList[i].__used__ = 0;
- }
- }
- function checkAndDispose(renderer, resourceList) {
- for (var i = 0; i < resourceList.length; i++) {
- if (!resourceList[i].__used__) {
- resourceList[i].dispose(renderer);
- }
- }
- }
- function updateUsed(resource, list) {
- resource.__used__ = resource.__used__ || 0;
- resource.__used__++;
- if (resource.__used__ === 1) {
- // Don't push to the list twice.
- list.push(resource);
- }
- }
- function collectResources(scene, textureResourceList, geometryResourceList) {
- var prevMaterial;
- var prevGeometry;
- scene.traverse(function (renderable) {
- if (renderable.isRenderable()) {
- var geometry = renderable.geometry;
- var material = renderable.material;
- // TODO optimize!!
- if (material !== prevMaterial) {
- var textureUniforms = material.getTextureUniforms();
- for (var u = 0; u < textureUniforms.length; u++) {
- var uniformName = textureUniforms[u];
- var val = material.uniforms[uniformName].value;
- if (!val) {
- continue;
- }
- if (val instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */]) {
- updateUsed(val, textureResourceList);
- }
- else if (val instanceof Array) {
- for (var k = 0; k < val.length; k++) {
- if (val[k] instanceof __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */]) {
- updateUsed(val[k], textureResourceList);
- }
- }
- }
- }
- }
- if (geometry !== prevGeometry) {
- updateUsed(geometry, geometryResourceList);
- }
- prevMaterial = material;
- prevGeometry = geometry;
- }
- });
- for (var k = 0; k < scene.lights.length; k++) {
- // Track AmbientCubemap
- if (scene.lights[k].cubemap) {
- updateUsed(scene.lights[k].cubemap, textureResourceList);
- }
- }
- }
- /**
- * Dispose the layer
- */
- LayerGL.prototype.dispose = function () {
- this._stopAccumulating();
- this.renderer.disposeScene(this.scene);
- this.zr.off('globalout', this.onglobalout);
- };
- // Event handlers
- LayerGL.prototype.onmousedown = function (e) {
- if (e.target && e.target.__isGLToZRProxy) {
- return;
- }
- e = e.event;
- var obj = this.pickObject(e.offsetX, e.offsetY);
- if (obj) {
- this._dispatchEvent('mousedown', e, obj);
- this._dispatchDataEvent('mousedown', e, obj);
- }
- this._downX = e.offsetX;
- this._downY = e.offsetY;
- };
- LayerGL.prototype.onmousemove = function (e) {
- if (e.target && e.target.__isGLToZRProxy) {
- return;
- }
- e = e.event;
- var obj = this.pickObject(e.offsetX, e.offsetY);
- var target = obj && obj.target;
- var lastHovered = this._hovered;
- this._hovered = obj;
- if (lastHovered && target !== lastHovered.target) {
- lastHovered.relatedTarget = target;
- this._dispatchEvent('mouseout', e, lastHovered);
- // this._dispatchDataEvent('mouseout', e, lastHovered);
- this.zr.setCursorStyle('default');
- }
- this._dispatchEvent('mousemove', e, obj);
- if (obj) {
- this.zr.setCursorStyle('pointer');
- if (!lastHovered || (target !== lastHovered.target)) {
- this._dispatchEvent('mouseover', e, obj);
- // this._dispatchDataEvent('mouseover', e, obj);
- }
- }
- this._dispatchDataEvent('mousemove', e, obj);
- };
- LayerGL.prototype.onmouseup = function (e) {
- if (e.target && e.target.__isGLToZRProxy) {
- return;
- }
- e = e.event;
- var obj = this.pickObject(e.offsetX, e.offsetY);
- if (obj) {
- this._dispatchEvent('mouseup', e, obj);
- this._dispatchDataEvent('mouseup', e, obj);
- }
- this._upX = e.offsetX;
- this._upY = e.offsetY;
- };
- LayerGL.prototype.onclick = LayerGL.prototype.dblclick = function (e) {
- if (e.target && e.target.__isGLToZRProxy) {
- return;
- }
- // Ignore click event if mouse moved
- var dx = this._upX - this._downX;
- var dy = this._upY - this._downY;
- if (Math.sqrt(dx * dx + dy * dy) > 20) {
- return;
- }
- e = e.event;
- var obj = this.pickObject(e.offsetX, e.offsetY);
- if (obj) {
- this._dispatchEvent(e.type, e, obj);
- this._dispatchDataEvent(e.type, e, obj);
- }
- // Try set depth of field onclick
- var result = this._clickToSetFocusPoint(e);
- if (result) {
- var success = result.view.setDOFFocusOnPoint(result.distance);
- if (success) {
- this.zr.refresh();
- }
- }
- };
- LayerGL.prototype._clickToSetFocusPoint = function (e) {
- var renderer = this.renderer;
- var oldViewport = renderer.viewport;
- for (var i = this.views.length - 1; i >= 0; i--) {
- var viewGL = this.views[i];
- if (viewGL.hasDOF() && viewGL.containPoint(e.offsetX, e.offsetY)) {
- this._picking.scene = viewGL.scene;
- this._picking.camera = viewGL.camera;
- // Only used for picking, renderer.setViewport will also invoke gl.viewport.
- // Set directly, PENDING.
- renderer.viewport = viewGL.viewport;
- var result = this._picking.pick(e.offsetX, e.offsetY, true);
- if (result) {
- result.view = viewGL;
- return result;
- }
- }
- }
- renderer.viewport = oldViewport;
- };
- LayerGL.prototype.onglobalout = function (e) {
- var lastHovered = this._hovered;
- if (lastHovered) {
- this._dispatchEvent('mouseout', e, {
- target: lastHovered.target
- });
- }
- };
- LayerGL.prototype.pickObject = function (x, y) {
- var output = [];
- var renderer = this.renderer;
- var oldViewport = renderer.viewport;
- for (var i = 0; i < this.views.length; i++) {
- var viewGL = this.views[i];
- if (viewGL.containPoint(x, y)) {
- this._picking.scene = viewGL.scene;
- this._picking.camera = viewGL.camera;
- // Only used for picking, renderer.setViewport will also invoke gl.viewport.
- // Set directly, PENDING.
- renderer.viewport = viewGL.viewport;
- this._picking.pickAll(x, y, output);
- }
- }
- renderer.viewport = oldViewport;
- output.sort(function (a, b) {
- return a.distance - b.distance;
- });
- return output[0];
- };
- LayerGL.prototype._dispatchEvent = function (eveName, originalEvent, newEvent) {
- if (!newEvent) {
- newEvent = {};
- }
- var current = newEvent.target;
- newEvent.cancelBubble = false;
- newEvent.event = originalEvent;
- newEvent.type = eveName;
- newEvent.offsetX = originalEvent.offsetX;
- newEvent.offsetY = originalEvent.offsetY;
- while (current) {
- current.trigger(eveName, newEvent);
- current = current.getParent();
- if (newEvent.cancelBubble) {
- break;
- }
- }
- this._dispatchToView(eveName, newEvent);
- };
- LayerGL.prototype._dispatchDataEvent = function (eveName, originalEvent, newEvent) {
- var mesh = newEvent && newEvent.target;
- var dataIndex = mesh && mesh.dataIndex;
- var seriesIndex = mesh && mesh.seriesIndex;
- // Custom event data
- var eventData = mesh && mesh.eventData;
- var elChangedInMouseMove = false;
- var eventProxy = this._zrEventProxy;
- eventProxy.position = [originalEvent.offsetX, originalEvent.offsetY];
- eventProxy.update();
- var targetInfo = {
- target: eventProxy
- };
- if (eveName === 'mousemove') {
- if (dataIndex != null) {
- if (dataIndex !== this._lastDataIndex) {
- if (parseInt(this._lastDataIndex, 10) >= 0) {
- eventProxy.dataIndex = this._lastDataIndex;
- eventProxy.seriesIndex = this._lastSeriesIndex;
- // FIXME May cause double events.
- this.zr.handler.dispatchToElement(targetInfo, 'mouseout', originalEvent);
- }
- elChangedInMouseMove = true;
- }
- }
- else if (eventData != null) {
- if (eventData !== this._lastEventData) {
- if (this._lastEventData != null) {
- eventProxy.eventData = this._lastEventData;
- // FIXME May cause double events.
- this.zr.handler.dispatchToElement(targetInfo, 'mouseout', originalEvent);
- }
- elChangedInMouseMove = true;
- }
- }
- this._lastEventData = eventData;
- this._lastDataIndex = dataIndex;
- this._lastSeriesIndex = seriesIndex;
- }
- eventProxy.eventData = eventData;
- eventProxy.dataIndex = dataIndex;
- eventProxy.seriesIndex = seriesIndex;
- if (eventData != null || (parseInt(dataIndex, 10) >= 0 && parseInt(seriesIndex, 10) >= 0)) {
- this.zr.handler.dispatchToElement(targetInfo, eveName, originalEvent);
- if (elChangedInMouseMove) {
- this.zr.handler.dispatchToElement(targetInfo, 'mouseover', originalEvent);
- }
- }
- };
- LayerGL.prototype._dispatchToView = function (eventName, e) {
- for (var i = 0; i < this.views.length; i++) {
- if (this.views[i].containPoint(e.offsetX, e.offsetY)) {
- this.views[i].trigger(eventName, e);
- }
- }
- };
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend(LayerGL.prototype, __WEBPACK_IMPORTED_MODULE_5_claygl_src_core_mixin_notifier__["a" /* default */]);
- /* harmony default export */ __webpack_exports__["a"] = (LayerGL);
- /***/
- }),
- /* 110 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * Extend a sub class from base class
- * @param {object|Function} makeDefaultOpt default option of this sub class, method of the sub can use this.xxx to access this option
- * @param {Function} [initialize] Initialize after the sub class is instantiated
- * @param {Object} [proto] Prototype methods/properties of the sub class
- * @memberOf clay.core.mixin.extend
- * @return {Function}
- */
- function derive(makeDefaultOpt, initialize/*optional*/, proto/*optional*/) {
- if (typeof initialize == 'object') {
- proto = initialize;
- initialize = null;
- }
- var _super = this;
- var propList;
- if (!(makeDefaultOpt instanceof Function)) {
- // Optimize the property iterate if it have been fixed
- propList = [];
- for (var propName in makeDefaultOpt) {
- if (makeDefaultOpt.hasOwnProperty(propName)) {
- propList.push(propName);
- }
- }
- }
- var sub = function (options) {
- // call super constructor
- _super.apply(this, arguments);
- if (makeDefaultOpt instanceof Function) {
- // Invoke makeDefaultOpt each time if it is a function, So we can make sure each
- // property in the object will not be shared by mutiple instances
- extend(this, makeDefaultOpt.call(this, options));
- }
- else {
- extendWithPropList(this, makeDefaultOpt, propList);
- }
- if (this.constructor === sub) {
- // Initialize function will be called in the order of inherit
- var initializers = sub.__initializers__;
- for (var i = 0; i < initializers.length; i++) {
- initializers[i].apply(this, arguments);
- }
- }
- };
- // save super constructor
- sub.__super__ = _super;
- // Initialize function will be called after all the super constructor is called
- if (!_super.__initializers__) {
- sub.__initializers__ = [];
- } else {
- sub.__initializers__ = _super.__initializers__.slice();
- }
- if (initialize) {
- sub.__initializers__.push(initialize);
- }
- var Ctor = function () { };
- Ctor.prototype = _super.prototype;
- sub.prototype = new Ctor();
- sub.prototype.constructor = sub;
- extend(sub.prototype, proto);
- // extend the derive method as a static method;
- sub.extend = _super.extend;
- // DEPCRATED
- sub.derive = _super.extend;
- return sub;
- }
- function extend(target, source) {
- if (!source) {
- return;
- }
- for (var name in source) {
- if (source.hasOwnProperty(name)) {
- target[name] = source[name];
- }
- }
- }
- function extendWithPropList(target, source, propList) {
- for (var i = 0; i < propList.length; i++) {
- var propName = propList[i];
- target[propName] = source[propName];
- }
- }
- /**
- * @alias clay.core.mixin.extend
- * @mixin
- */
- /* harmony default export */ __webpack_exports__["a"] = ({
- extend: derive,
- // DEPCRATED
- derive: derive
- });
- /***/
- }),
- /* 111 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- var EXTENSION_LIST = [
- 'OES_texture_float',
- 'OES_texture_half_float',
- 'OES_texture_float_linear',
- 'OES_texture_half_float_linear',
- 'OES_standard_derivatives',
- 'OES_vertex_array_object',
- 'OES_element_index_uint',
- 'WEBGL_compressed_texture_s3tc',
- 'WEBGL_depth_texture',
- 'EXT_texture_filter_anisotropic',
- 'EXT_shader_texture_lod',
- 'WEBGL_draw_buffers',
- 'EXT_frag_depth',
- 'EXT_sRGB'
- ];
- var PARAMETER_NAMES = [
- 'MAX_TEXTURE_SIZE',
- 'MAX_CUBE_MAP_TEXTURE_SIZE'
- ];
- function GLInfo(_gl) {
- var extensions = {};
- var parameters = {};
- // Get webgl extension
- for (var i = 0; i < EXTENSION_LIST.length; i++) {
- var extName = EXTENSION_LIST[i];
- createExtension(extName);
- }
- // Get parameters
- for (var i = 0; i < PARAMETER_NAMES.length; i++) {
- var name = PARAMETER_NAMES[i];
- parameters[name] = _gl.getParameter(_gl[name]);
- }
- this.getExtension = function (name) {
- if (!(name in extensions)) {
- createExtension(name);
- }
- return extensions[name];
- };
- this.getParameter = function (name) {
- return parameters[name];
- };
- this.getMaxJointNumber = function () {
- return 15;
- };
- function createExtension(name) {
- var ext = _gl.getExtension(name);
- if (!ext) {
- ext = _gl.getExtension('MOZ_' + name);
- }
- if (!ext) {
- ext = _gl.getExtension('WEBKIT_' + name);
- }
- extensions[name] = ext;
- }
- }
- /* harmony default export */ __webpack_exports__["a"] = (GLInfo);
- /***/
- }),
- /* 112 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- function get(options) {
- var xhr = new XMLHttpRequest();
- xhr.open('get', options.url);
- // With response type set browser can get and put binary data
- // https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Sending_and_Receiving_Binary_Data
- // Default is text, and it can be set
- // arraybuffer, blob, document, json, text
- xhr.responseType = options.responseType || 'text';
- if (options.onprogress) {
- //https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest/Using_XMLHttpRequest
- xhr.onprogress = function (e) {
- if (e.lengthComputable) {
- var percent = e.loaded / e.total;
- options.onprogress(percent, e.loaded, e.total);
- }
- else {
- options.onprogress(null);
- }
- };
- }
- xhr.onload = function (e) {
- if (xhr.status >= 400) {
- options.onerror && options.onerror();
- }
- else {
- options.onload && options.onload(xhr.response);
- }
- };
- if (options.onerror) {
- xhr.onerror = options.onerror;
- }
- xhr.send(null);
- }
- /* harmony default export */ __webpack_exports__["a"] = ({
- get: get
- });
- /***/
- }),
- /* 113 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_LRU__ = __webpack_require__(69);
- /**
- * @namespace clay.core.color
- */
- var colorUtil = {};
- var kCSSColorTable = {
- 'transparent': [0, 0, 0, 0], 'aliceblue': [240, 248, 255, 1],
- 'antiquewhite': [250, 235, 215, 1], 'aqua': [0, 255, 255, 1],
- 'aquamarine': [127, 255, 212, 1], 'azure': [240, 255, 255, 1],
- 'beige': [245, 245, 220, 1], 'bisque': [255, 228, 196, 1],
- 'black': [0, 0, 0, 1], 'blanchedalmond': [255, 235, 205, 1],
- 'blue': [0, 0, 255, 1], 'blueviolet': [138, 43, 226, 1],
- 'brown': [165, 42, 42, 1], 'burlywood': [222, 184, 135, 1],
- 'cadetblue': [95, 158, 160, 1], 'chartreuse': [127, 255, 0, 1],
- 'chocolate': [210, 105, 30, 1], 'coral': [255, 127, 80, 1],
- 'cornflowerblue': [100, 149, 237, 1], 'cornsilk': [255, 248, 220, 1],
- 'crimson': [220, 20, 60, 1], 'cyan': [0, 255, 255, 1],
- 'darkblue': [0, 0, 139, 1], 'darkcyan': [0, 139, 139, 1],
- 'darkgoldenrod': [184, 134, 11, 1], 'darkgray': [169, 169, 169, 1],
- 'darkgreen': [0, 100, 0, 1], 'darkgrey': [169, 169, 169, 1],
- 'darkkhaki': [189, 183, 107, 1], 'darkmagenta': [139, 0, 139, 1],
- 'darkolivegreen': [85, 107, 47, 1], 'darkorange': [255, 140, 0, 1],
- 'darkorchid': [153, 50, 204, 1], 'darkred': [139, 0, 0, 1],
- 'darksalmon': [233, 150, 122, 1], 'darkseagreen': [143, 188, 143, 1],
- 'darkslateblue': [72, 61, 139, 1], 'darkslategray': [47, 79, 79, 1],
- 'darkslategrey': [47, 79, 79, 1], 'darkturquoise': [0, 206, 209, 1],
- 'darkviolet': [148, 0, 211, 1], 'deeppink': [255, 20, 147, 1],
- 'deepskyblue': [0, 191, 255, 1], 'dimgray': [105, 105, 105, 1],
- 'dimgrey': [105, 105, 105, 1], 'dodgerblue': [30, 144, 255, 1],
- 'firebrick': [178, 34, 34, 1], 'floralwhite': [255, 250, 240, 1],
- 'forestgreen': [34, 139, 34, 1], 'fuchsia': [255, 0, 255, 1],
- 'gainsboro': [220, 220, 220, 1], 'ghostwhite': [248, 248, 255, 1],
- 'gold': [255, 215, 0, 1], 'goldenrod': [218, 165, 32, 1],
- 'gray': [128, 128, 128, 1], 'green': [0, 128, 0, 1],
- 'greenyellow': [173, 255, 47, 1], 'grey': [128, 128, 128, 1],
- 'honeydew': [240, 255, 240, 1], 'hotpink': [255, 105, 180, 1],
- 'indianred': [205, 92, 92, 1], 'indigo': [75, 0, 130, 1],
- 'ivory': [255, 255, 240, 1], 'khaki': [240, 230, 140, 1],
- 'lavender': [230, 230, 250, 1], 'lavenderblush': [255, 240, 245, 1],
- 'lawngreen': [124, 252, 0, 1], 'lemonchiffon': [255, 250, 205, 1],
- 'lightblue': [173, 216, 230, 1], 'lightcoral': [240, 128, 128, 1],
- 'lightcyan': [224, 255, 255, 1], 'lightgoldenrodyellow': [250, 250, 210, 1],
- 'lightgray': [211, 211, 211, 1], 'lightgreen': [144, 238, 144, 1],
- 'lightgrey': [211, 211, 211, 1], 'lightpink': [255, 182, 193, 1],
- 'lightsalmon': [255, 160, 122, 1], 'lightseagreen': [32, 178, 170, 1],
- 'lightskyblue': [135, 206, 250, 1], 'lightslategray': [119, 136, 153, 1],
- 'lightslategrey': [119, 136, 153, 1], 'lightsteelblue': [176, 196, 222, 1],
- 'lightyellow': [255, 255, 224, 1], 'lime': [0, 255, 0, 1],
- 'limegreen': [50, 205, 50, 1], 'linen': [250, 240, 230, 1],
- 'magenta': [255, 0, 255, 1], 'maroon': [128, 0, 0, 1],
- 'mediumaquamarine': [102, 205, 170, 1], 'mediumblue': [0, 0, 205, 1],
- 'mediumorchid': [186, 85, 211, 1], 'mediumpurple': [147, 112, 219, 1],
- 'mediumseagreen': [60, 179, 113, 1], 'mediumslateblue': [123, 104, 238, 1],
- 'mediumspringgreen': [0, 250, 154, 1], 'mediumturquoise': [72, 209, 204, 1],
- 'mediumvioletred': [199, 21, 133, 1], 'midnightblue': [25, 25, 112, 1],
- 'mintcream': [245, 255, 250, 1], 'mistyrose': [255, 228, 225, 1],
- 'moccasin': [255, 228, 181, 1], 'navajowhite': [255, 222, 173, 1],
- 'navy': [0, 0, 128, 1], 'oldlace': [253, 245, 230, 1],
- 'olive': [128, 128, 0, 1], 'olivedrab': [107, 142, 35, 1],
- 'orange': [255, 165, 0, 1], 'orangered': [255, 69, 0, 1],
- 'orchid': [218, 112, 214, 1], 'palegoldenrod': [238, 232, 170, 1],
- 'palegreen': [152, 251, 152, 1], 'paleturquoise': [175, 238, 238, 1],
- 'palevioletred': [219, 112, 147, 1], 'papayawhip': [255, 239, 213, 1],
- 'peachpuff': [255, 218, 185, 1], 'peru': [205, 133, 63, 1],
- 'pink': [255, 192, 203, 1], 'plum': [221, 160, 221, 1],
- 'powderblue': [176, 224, 230, 1], 'purple': [128, 0, 128, 1],
- 'red': [255, 0, 0, 1], 'rosybrown': [188, 143, 143, 1],
- 'royalblue': [65, 105, 225, 1], 'saddlebrown': [139, 69, 19, 1],
- 'salmon': [250, 128, 114, 1], 'sandybrown': [244, 164, 96, 1],
- 'seagreen': [46, 139, 87, 1], 'seashell': [255, 245, 238, 1],
- 'sienna': [160, 82, 45, 1], 'silver': [192, 192, 192, 1],
- 'skyblue': [135, 206, 235, 1], 'slateblue': [106, 90, 205, 1],
- 'slategray': [112, 128, 144, 1], 'slategrey': [112, 128, 144, 1],
- 'snow': [255, 250, 250, 1], 'springgreen': [0, 255, 127, 1],
- 'steelblue': [70, 130, 180, 1], 'tan': [210, 180, 140, 1],
- 'teal': [0, 128, 128, 1], 'thistle': [216, 191, 216, 1],
- 'tomato': [255, 99, 71, 1], 'turquoise': [64, 224, 208, 1],
- 'violet': [238, 130, 238, 1], 'wheat': [245, 222, 179, 1],
- 'white': [255, 255, 255, 1], 'whitesmoke': [245, 245, 245, 1],
- 'yellow': [255, 255, 0, 1], 'yellowgreen': [154, 205, 50, 1]
- };
- function clampCssByte(i) { // Clamp to integer 0 .. 255.
- i = Math.round(i); // Seems to be what Chrome does (vs truncation).
- return i < 0 ? 0 : i > 255 ? 255 : i;
- }
- function clampCssAngle(i) { // Clamp to integer 0 .. 360.
- i = Math.round(i); // Seems to be what Chrome does (vs truncation).
- return i < 0 ? 0 : i > 360 ? 360 : i;
- }
- function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0.
- return f < 0 ? 0 : f > 1 ? 1 : f;
- }
- function parseCssInt(str) { // int or percentage.
- if (str.length && str.charAt(str.length - 1) === '%') {
- return clampCssByte(parseFloat(str) / 100 * 255);
- }
- return clampCssByte(parseInt(str, 10));
- }
- function parseCssFloat(str) { // float or percentage.
- if (str.length && str.charAt(str.length - 1) === '%') {
- return clampCssFloat(parseFloat(str) / 100);
- }
- return clampCssFloat(parseFloat(str));
- }
- function cssHueToRgb(m1, m2, h) {
- if (h < 0) {
- h += 1;
- }
- else if (h > 1) {
- h -= 1;
- }
- if (h * 6 < 1) {
- return m1 + (m2 - m1) * h * 6;
- }
- if (h * 2 < 1) {
- return m2;
- }
- if (h * 3 < 2) {
- return m1 + (m2 - m1) * (2 / 3 - h) * 6;
- }
- return m1;
- }
- function lerpNumber(a, b, p) {
- return a + (b - a) * p;
- }
- function setRgba(out, r, g, b, a) {
- out[0] = r; out[1] = g; out[2] = b; out[3] = a;
- return out;
- }
- function copyRgba(out, a) {
- out[0] = a[0]; out[1] = a[1]; out[2] = a[2]; out[3] = a[3];
- return out;
- }
- var colorCache = new __WEBPACK_IMPORTED_MODULE_0__core_LRU__["a" /* default */](20);
- var lastRemovedArr = null;
- function putToCache(colorStr, rgbaArr) {
- // Reuse removed array
- if (lastRemovedArr) {
- copyRgba(lastRemovedArr, rgbaArr);
- }
- lastRemovedArr = colorCache.put(colorStr, lastRemovedArr || (rgbaArr.slice()));
- }
- /**
- * @name clay.core.color.parse
- * @param {string} colorStr
- * @param {Array.<number>} out
- * @return {Array.<number>}
- */
- colorUtil.parse = function (colorStr, rgbaArr) {
- if (!colorStr) {
- return;
- }
- rgbaArr = rgbaArr || [];
- var cached = colorCache.get(colorStr);
- if (cached) {
- return copyRgba(rgbaArr, cached);
- }
- // colorStr may be not string
- colorStr = colorStr + '';
- // Remove all whitespace, not compliant, but should just be more accepting.
- var str = colorStr.replace(/ /g, '').toLowerCase();
- // Color keywords (and transparent) lookup.
- if (str in kCSSColorTable) {
- copyRgba(rgbaArr, kCSSColorTable[str]);
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- }
- // #abc and #abc123 syntax.
- if (str.charAt(0) === '#') {
- if (str.length === 4) {
- var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
- if (!(iv >= 0 && iv <= 0xfff)) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return; // Covers NaN.
- }
- setRgba(rgbaArr,
- ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8),
- (iv & 0xf0) | ((iv & 0xf0) >> 4),
- (iv & 0xf) | ((iv & 0xf) << 4),
- 1
- );
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- }
- else if (str.length === 7) {
- var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
- if (!(iv >= 0 && iv <= 0xffffff)) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return; // Covers NaN.
- }
- setRgba(rgbaArr,
- (iv & 0xff0000) >> 16,
- (iv & 0xff00) >> 8,
- iv & 0xff,
- 1
- );
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- }
- return;
- }
- var op = str.indexOf('('), ep = str.indexOf(')');
- if (op !== -1 && ep + 1 === str.length) {
- var fname = str.substr(0, op);
- var params = str.substr(op + 1, ep - (op + 1)).split(',');
- var alpha = 1; // To allow case fallthrough.
- switch (fname) {
- case 'rgba':
- if (params.length !== 4) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return;
- }
- alpha = parseCssFloat(params.pop()); // jshint ignore:line
- // Fall through.
- case 'rgb':
- if (params.length !== 3) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return;
- }
- setRgba(rgbaArr,
- parseCssInt(params[0]),
- parseCssInt(params[1]),
- parseCssInt(params[2]),
- alpha
- );
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- case 'hsla':
- if (params.length !== 4) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return;
- }
- params[3] = parseCssFloat(params[3]);
- hsla2rgba(params, rgbaArr);
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- case 'hsl':
- if (params.length !== 3) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return;
- }
- hsla2rgba(params, rgbaArr);
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- default:
- return;
- }
- }
- setRgba(rgbaArr, 0, 0, 0, 1);
- return;
- };
- colorUtil.parseToFloat = function (colorStr, rgbaArr) {
- rgbaArr = colorUtil.parse(colorStr, rgbaArr);
- if (!rgbaArr) {
- return;
- }
- rgbaArr[0] /= 255;
- rgbaArr[1] /= 255;
- rgbaArr[2] /= 255;
- return rgbaArr;
- }
- /**
- * @name clay.core.color.hsla2rgba
- * @param {Array.<number>} hsla
- * @param {Array.<number>} rgba
- * @return {Array.<number>} rgba
- */
- function hsla2rgba(hsla, rgba) {
- var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1
- // NOTE(deanm): According to the CSS spec s/l should only be
- // percentages, but we don't bother and let float or percentage.
- var s = parseCssFloat(hsla[1]);
- var l = parseCssFloat(hsla[2]);
- var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
- var m1 = l * 2 - m2;
- rgba = rgba || [];
- setRgba(rgba,
- clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255),
- clampCssByte(cssHueToRgb(m1, m2, h) * 255),
- clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255),
- 1
- );
- if (hsla.length === 4) {
- rgba[3] = hsla[3];
- }
- return rgba;
- }
- /**
- * @name clay.core.color.rgba2hsla
- * @param {Array.<number>} rgba
- * @return {Array.<number>} hsla
- */
- function rgba2hsla(rgba) {
- if (!rgba) {
- return;
- }
- // RGB from 0 to 255
- var R = rgba[0] / 255;
- var G = rgba[1] / 255;
- var B = rgba[2] / 255;
- var vMin = Math.min(R, G, B); // Min. value of RGB
- var vMax = Math.max(R, G, B); // Max. value of RGB
- var delta = vMax - vMin; // Delta RGB value
- var L = (vMax + vMin) / 2;
- var H;
- var S;
- // HSL results from 0 to 1
- if (delta === 0) {
- H = 0;
- S = 0;
- }
- else {
- if (L < 0.5) {
- S = delta / (vMax + vMin);
- }
- else {
- S = delta / (2 - vMax - vMin);
- }
- var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta;
- var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta;
- var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta;
- if (R === vMax) {
- H = deltaB - deltaG;
- }
- else if (G === vMax) {
- H = (1 / 3) + deltaR - deltaB;
- }
- else if (B === vMax) {
- H = (2 / 3) + deltaG - deltaR;
- }
- if (H < 0) {
- H += 1;
- }
- if (H > 1) {
- H -= 1;
- }
- }
- var hsla = [H * 360, S, L];
- if (rgba[3] != null) {
- hsla.push(rgba[3]);
- }
- return hsla;
- }
- /**
- * @name clay.core.color.lift
- * @param {string} color
- * @param {number} level
- * @return {string}
- */
- colorUtil.lift = function (color, level) {
- var colorArr = colorUtil.parse(color);
- if (colorArr) {
- for (var i = 0; i < 3; i++) {
- if (level < 0) {
- colorArr[i] = colorArr[i] * (1 - level) | 0;
- }
- else {
- colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0;
- }
- }
- return colorUtil.stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb');
- }
- }
- /**
- * @name clay.core.color.toHex
- * @param {string} color
- * @return {string}
- */
- colorUtil.toHex = function (color) {
- var colorArr = colorUtil.parse(color);
- if (colorArr) {
- return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1);
- }
- };
- /**
- * Map value to color. Faster than lerp methods because color is represented by rgba array.
- * @name clay.core.color
- * @param {number} normalizedValue A float between 0 and 1.
- * @param {Array.<Array.<number>>} colors List of rgba color array
- * @param {Array.<number>} [out] Mapped gba color array
- * @return {Array.<number>} will be null/undefined if input illegal.
- */
- colorUtil.fastLerp = function (normalizedValue, colors, out) {
- if (!(colors && colors.length)
- || !(normalizedValue >= 0 && normalizedValue <= 1)
- ) {
- return;
- }
- out = out || [];
- var value = normalizedValue * (colors.length - 1);
- var leftIndex = Math.floor(value);
- var rightIndex = Math.ceil(value);
- var leftColor = colors[leftIndex];
- var rightColor = colors[rightIndex];
- var dv = value - leftIndex;
- out[0] = clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv));
- out[1] = clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv));
- out[2] = clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv));
- out[3] = clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv));
- return out;
- }
- colorUtil.fastMapToColor = colorUtil.fastLerp;
- /**
- * @param {number} normalizedValue A float between 0 and 1.
- * @param {Array.<string>} colors Color list.
- * @param {boolean=} fullOutput Default false.
- * @return {(string|Object)} Result color. If fullOutput,
- * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...},
- */
- colorUtil.lerp = function (normalizedValue, colors, fullOutput) {
- if (!(colors && colors.length)
- || !(normalizedValue >= 0 && normalizedValue <= 1)
- ) {
- return;
- }
- var value = normalizedValue * (colors.length - 1);
- var leftIndex = Math.floor(value);
- var rightIndex = Math.ceil(value);
- var leftColor = colorUtil.parse(colors[leftIndex]);
- var rightColor = colorUtil.parse(colors[rightIndex]);
- var dv = value - leftIndex;
- var color = colorUtil.stringify(
- [
- clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)),
- clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)),
- clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)),
- clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv))
- ],
- 'rgba'
- );
- return fullOutput
- ? {
- color: color,
- leftIndex: leftIndex,
- rightIndex: rightIndex,
- value: value
- }
- : color;
- }
- /**
- * @deprecated
- */
- colorUtil.mapToColor = colorUtil.lerp;
- /**
- * @name clay.core.color
- * @param {string} color
- * @param {number=} h 0 ~ 360, ignore when null.
- * @param {number=} s 0 ~ 1, ignore when null.
- * @param {number=} l 0 ~ 1, ignore when null.
- * @return {string} Color string in rgba format.
- */
- colorUtil.modifyHSL = function (color, h, s, l) {
- color = colorUtil.parse(color);
- if (color) {
- color = rgba2hsla(color);
- h != null && (color[0] = clampCssAngle(h));
- s != null && (color[1] = parseCssFloat(s));
- l != null && (color[2] = parseCssFloat(l));
- return colorUtil.stringify(hsla2rgba(color), 'rgba');
- }
- }
- /**
- * @param {string} color
- * @param {number=} alpha 0 ~ 1
- * @return {string} Color string in rgba format.
- */
- colorUtil.modifyAlpha = function (color, alpha) {
- color = colorUtil.parse(color);
- if (color && alpha != null) {
- color[3] = clampCssFloat(alpha);
- return colorUtil.stringify(color, 'rgba');
- }
- }
- /**
- * @param {Array.<number>} arrColor like [12,33,44,0.4]
- * @param {string} type 'rgba', 'hsva', ...
- * @return {string} Result color. (If input illegal, return undefined).
- */
- colorUtil.stringify = function (arrColor, type) {
- if (!arrColor || !arrColor.length) {
- return;
- }
- var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2];
- if (type === 'rgba' || type === 'hsva' || type === 'hsla') {
- colorStr += ',' + arrColor[3];
- }
- return type + '(' + colorStr + ')';
- };
- /* harmony default export */ __webpack_exports__["a"] = (colorUtil);
- /***/
- }),
- /* 114 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * Simple double linked list. Compared with array, it has O(1) remove operation.
- * @constructor
- * @alias clay.core.LinkedList
- */
- var LinkedList = function () {
- /**
- * @type {clay.core.LinkedList.Entry}
- */
- this.head = null;
- /**
- * @type {clay.core.LinkedList.Entry}
- */
- this.tail = null;
- this._length = 0;
- };
- /**
- * Insert a new value at the tail
- * @param {} val
- * @return {clay.core.LinkedList.Entry}
- */
- LinkedList.prototype.insert = function (val) {
- var entry = new LinkedList.Entry(val);
- this.insertEntry(entry);
- return entry;
- };
- /**
- * Insert a new value at idx
- * @param {number} idx
- * @param {} val
- * @return {clay.core.LinkedList.Entry}
- */
- LinkedList.prototype.insertAt = function (idx, val) {
- if (idx < 0) {
- return;
- }
- var next = this.head;
- var cursor = 0;
- while (next && cursor != idx) {
- next = next.next;
- cursor++;
- }
- if (next) {
- var entry = new LinkedList.Entry(val);
- var prev = next.prev;
- if (!prev) { //next is head
- this.head = entry;
- }
- else {
- prev.next = entry;
- entry.prev = prev;
- }
- entry.next = next;
- next.prev = entry;
- }
- else {
- this.insert(val);
- }
- };
- LinkedList.prototype.insertBeforeEntry = function (val, next) {
- var entry = new LinkedList.Entry(val);
- var prev = next.prev;
- if (!prev) { //next is head
- this.head = entry;
- }
- else {
- prev.next = entry;
- entry.prev = prev;
- }
- entry.next = next;
- next.prev = entry;
- this._length++;
- };
- /**
- * Insert an entry at the tail
- * @param {clay.core.LinkedList.Entry} entry
- */
- LinkedList.prototype.insertEntry = function (entry) {
- if (!this.head) {
- this.head = this.tail = entry;
- }
- else {
- this.tail.next = entry;
- entry.prev = this.tail;
- this.tail = entry;
- }
- this._length++;
- };
- /**
- * Remove entry.
- * @param {clay.core.LinkedList.Entry} entry
- */
- LinkedList.prototype.remove = function (entry) {
- var prev = entry.prev;
- var next = entry.next;
- if (prev) {
- prev.next = next;
- }
- else {
- // Is head
- this.head = next;
- }
- if (next) {
- next.prev = prev;
- }
- else {
- // Is tail
- this.tail = prev;
- }
- entry.next = entry.prev = null;
- this._length--;
- };
- /**
- * Remove entry at index.
- * @param {number} idx
- * @return {}
- */
- LinkedList.prototype.removeAt = function (idx) {
- if (idx < 0) {
- return;
- }
- var curr = this.head;
- var cursor = 0;
- while (curr && cursor != idx) {
- curr = curr.next;
- cursor++;
- }
- if (curr) {
- this.remove(curr);
- return curr.value;
- }
- };
- /**
- * Get head value
- * @return {}
- */
- LinkedList.prototype.getHead = function () {
- if (this.head) {
- return this.head.value;
- }
- };
- /**
- * Get tail value
- * @return {}
- */
- LinkedList.prototype.getTail = function () {
- if (this.tail) {
- return this.tail.value;
- }
- };
- /**
- * Get value at idx
- * @param {number} idx
- * @return {}
- */
- LinkedList.prototype.getAt = function (idx) {
- if (idx < 0) {
- return;
- }
- var curr = this.head;
- var cursor = 0;
- while (curr && cursor != idx) {
- curr = curr.next;
- cursor++;
- }
- return curr.value;
- };
- /**
- * @param {} value
- * @return {number}
- */
- LinkedList.prototype.indexOf = function (value) {
- var curr = this.head;
- var cursor = 0;
- while (curr) {
- if (curr.value === value) {
- return cursor;
- }
- curr = curr.next;
- cursor++;
- }
- };
- /**
- * @return {number}
- */
- LinkedList.prototype.length = function () {
- return this._length;
- };
- /**
- * If list is empty
- */
- LinkedList.prototype.isEmpty = function () {
- return this._length === 0;
- };
- /**
- * @param {Function} cb
- * @param {} context
- */
- LinkedList.prototype.forEach = function (cb, context) {
- var curr = this.head;
- var idx = 0;
- var haveContext = typeof (context) != 'undefined';
- while (curr) {
- if (haveContext) {
- cb.call(context, curr.value, idx);
- }
- else {
- cb(curr.value, idx);
- }
- curr = curr.next;
- idx++;
- }
- };
- /**
- * Clear the list
- */
- LinkedList.prototype.clear = function () {
- this.tail = this.head = null;
- this._length = 0;
- };
- /**
- * @constructor
- * @param {} val
- */
- LinkedList.Entry = function (val) {
- /**
- * @type {}
- */
- this.value = val;
- /**
- * @type {clay.core.LinkedList.Entry}
- */
- this.next = null;
- /**
- * @type {clay.core.LinkedList.Entry}
- */
- this.prev = null;
- };
- /* harmony default export */ __webpack_exports__["a"] = (LinkedList);
- /***/
- }),
- /* 115 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__GLProgram__ = __webpack_require__(116);
- var loopRegex = /for\s*?\(int\s*?_idx_\s*\=\s*([\w-]+)\;\s*_idx_\s*<\s*([\w-]+);\s*_idx_\s*\+\+\s*\)\s*\{\{([\s\S]+?)(?=\}\})\}\}/g;
- function unrollLoop(shaderStr, defines, lightsNumbers) {
- // Loop unroll from three.js, https://github.com/mrdoob/three.js/blob/master/src/renderers/webgl/WebGLProgram.js#L175
- // In some case like shadowMap in loop use 'i' to index value much slower.
- // Loop use _idx_ and increased with _idx_++ will be unrolled
- // Use {{ }} to match the pair so the if statement will not be affected
- // Write like following
- // for (int _idx_ = 0; _idx_ < 4; _idx_++) {{
- // vec3 color = texture2D(textures[_idx_], uv).rgb;
- // }}
- function replace(match, start, end, snippet) {
- var unroll = '';
- // Try to treat as define
- if (isNaN(start)) {
- if (start in defines) {
- start = defines[start];
- }
- else {
- start = lightNumberDefines[start];
- }
- }
- if (isNaN(end)) {
- if (end in defines) {
- end = defines[end];
- }
- else {
- end = lightNumberDefines[end];
- }
- }
- // TODO Error checking
- for (var idx = parseInt(start); idx < parseInt(end); idx++) {
- // PENDING Add scope?
- unroll += '{'
- + snippet
- .replace(/float\s*\(\s*_idx_\s*\)/g, idx.toFixed(1))
- .replace(/_idx_/g, idx)
- + '}';
- }
- return unroll;
- }
- var lightNumberDefines = {};
- for (var lightType in lightsNumbers) {
- lightNumberDefines[lightType + '_COUNT'] = lightsNumbers[lightType];
- }
- return shaderStr.replace(loopRegex, replace);
- }
- function getDefineCode(defines, lightsNumbers, enabledTextures) {
- var defineStr = [];
- if (lightsNumbers) {
- for (var lightType in lightsNumbers) {
- var count = lightsNumbers[lightType];
- if (count > 0) {
- defineStr.push('#define ' + lightType.toUpperCase() + '_COUNT ' + count);
- }
- }
- }
- if (enabledTextures) {
- for (var i = 0; i < enabledTextures.length; i++) {
- var symbol = enabledTextures[i];
- defineStr.push('#define ' + symbol.toUpperCase() + '_ENABLED');
- }
- }
- // Custom Defines
- for (var symbol in defines) {
- var value = defines[symbol];
- if (value === null) {
- defineStr.push('#define ' + symbol);
- }
- else {
- defineStr.push('#define ' + symbol + ' ' + value.toString());
- }
- }
- return defineStr.join('\n');
- }
- function getExtensionCode(exts) {
- // Extension declaration must before all non-preprocessor codes
- // TODO vertex ? extension enum ?
- var extensionStr = [];
- for (var i = 0; i < exts.length; i++) {
- extensionStr.push('#extension GL_' + exts[i] + ' : enable');
- }
- return extensionStr.join('\n');
- }
- function getPrecisionCode(precision) {
- return ['precision', precision, 'float'].join(' ') + ';\n'
- + ['precision', precision, 'int'].join(' ') + ';\n'
- // depth texture may have precision problem on iOS device.
- + ['precision', precision, 'sampler2D'].join(' ') + ';\n';
- }
- function ProgramManager(renderer) {
- this._renderer = renderer;
- this._cache = {};
- }
- ProgramManager.prototype.getProgram = function (renderable, material, scene) {
- var cache = this._cache;
- var isSkinnedMesh = renderable.isSkinnedMesh && renderable.isSkinnedMesh();
- var key = 's' + material.shader.shaderID + 'm' + material.getProgramKey();
- if (scene) {
- key += 'se' + scene.getProgramKey(renderable.lightGroup);
- }
- if (isSkinnedMesh) {
- key += ',' + renderable.joints.length;
- }
- var program = cache[key];
- if (program) {
- return program;
- }
- var lightsNumbers = scene ? scene.getLightsNumbers(renderable.lightGroup) : {};
- var renderer = this._renderer;
- var _gl = renderer.gl;
- var enabledTextures = material.getEnabledTextures();
- var skinDefineCode = '';
- if (isSkinnedMesh) {
- var skinDefines = {
- SKINNING: null,
- JOINT_COUNT: renderable.joints.length
- };
- if (renderable.joints.length > renderer.getMaxJointNumber()) {
- skinDefines.USE_SKIN_MATRICES_TEXTURE = null;
- }
- // TODO Add skinning code?
- skinDefineCode = '\n' + getDefineCode(skinDefines) + '\n';
- }
- // TODO Optimize key generation
- // VERTEX
- var vertexDefineStr = skinDefineCode + getDefineCode(material.vertexDefines, lightsNumbers, enabledTextures);
- // FRAGMENT
- var fragmentDefineStr = skinDefineCode + getDefineCode(material.fragmentDefines, lightsNumbers, enabledTextures);
- var vertexCode = vertexDefineStr + '\n' + material.shader.vertex;
- var extensions = [
- 'OES_standard_derivatives',
- 'EXT_shader_texture_lod'
- ].filter(function (ext) {
- return renderer.getGLExtension(ext) != null;
- });
- if (extensions.indexOf('EXT_shader_texture_lod') >= 0) {
- fragmentDefineStr += '\n#define SUPPORT_TEXTURE_LOD';
- }
- if (extensions.indexOf('OES_standard_derivatives') >= 0) {
- fragmentDefineStr += '\n#define SUPPORT_STANDARD_DERIVATIVES';
- }
- var fragmentCode = getExtensionCode(extensions) + '\n'
- + getPrecisionCode(material.precision) + '\n'
- + fragmentDefineStr + '\n'
- + material.shader.fragment;
- var finalVertexCode = unrollLoop(vertexCode, material.vertexDefines, lightsNumbers);
- var finalFragmentCode = unrollLoop(fragmentCode, material.fragmentDefines, lightsNumbers);
- var program = new __WEBPACK_IMPORTED_MODULE_0__GLProgram__["a" /* default */]();
- program.uniformSemantics = material.shader.uniformSemantics;
- program.attributes = material.shader.attributes;
- var errorMsg = program.buildProgram(_gl, material.shader, finalVertexCode, finalFragmentCode);
- program.__error = errorMsg;
- cache[key] = program;
- return program;
- };
- /* harmony default export */ __webpack_exports__["a"] = (ProgramManager);
- /***/
- }),
- /* 116 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_vendor__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_Base__ = __webpack_require__(7);
- var SHADER_STATE_TO_ENABLE = 1;
- var SHADER_STATE_KEEP_ENABLE = 2;
- var SHADER_STATE_PENDING = 3;
- // Enable attribute operation is global to all programs
- // Here saved the list of all enabled attribute index
- // http://www.mjbshaw.com/2013/03/webgl-fixing-invalidoperation.html
- var enabledAttributeList = {};
- // some util functions
- function addLineNumbers(string) {
- var chunks = string.split('\n');
- for (var i = 0, il = chunks.length; i < il; i++) {
- // Chrome reports shader errors on lines
- // starting counting from 1
- chunks[i] = (i + 1) + ': ' + chunks[i];
- }
- return chunks.join('\n');
- }
- // Return true or error msg if error happened
- function checkShaderErrorMsg(_gl, shader, shaderString) {
- if (!_gl.getShaderParameter(shader, _gl.COMPILE_STATUS)) {
- return [_gl.getShaderInfoLog(shader), addLineNumbers(shaderString)].join('\n');
- }
- }
- var tmpFloat32Array16 = new __WEBPACK_IMPORTED_MODULE_0__core_vendor__["a" /* default */].Float32Array(16);
- var GLProgram = __WEBPACK_IMPORTED_MODULE_1__core_Base__["a" /* default */].extend({
- uniformSemantics: {},
- attributes: {}
- }, function () {
- this._locations = {};
- this._textureSlot = 0;
- this._program = null;
- }, {
- bind: function (renderer) {
- this._textureSlot = 0;
- renderer.gl.useProgram(this._program);
- },
- hasUniform: function (symbol) {
- var location = this._locations[symbol];
- return location !== null && location !== undefined;
- },
- useTextureSlot: function (renderer, texture, slot) {
- if (texture) {
- renderer.gl.activeTexture(renderer.gl.TEXTURE0 + slot);
- // Maybe texture is not loaded yet;
- if (texture.isRenderable()) {
- texture.bind(renderer);
- }
- else {
- // Bind texture to null
- texture.unbind(renderer);
- }
- }
- },
- currentTextureSlot: function () {
- return this._textureSlot;
- },
- resetTextureSlot: function (slot) {
- this._textureSlot = slot || 0;
- },
- takeCurrentTextureSlot: function (renderer, texture) {
- var textureSlot = this._textureSlot;
- this.useTextureSlot(renderer, texture, textureSlot);
- this._textureSlot++;
- return textureSlot;
- },
- setUniform: function (_gl, type, symbol, value) {
- var locationMap = this._locations;
- var location = locationMap[symbol];
- // Uniform is not existed in the shader
- if (location === null || location === undefined) {
- return false;
- }
- switch (type) {
- case 'm4':
- if (!(value instanceof Float32Array)) {
- // Use Float32Array is much faster than array when uniformMatrix4fv.
- for (var i = 0; i < value.length; i++) {
- tmpFloat32Array16[i] = value[i];
- }
- value = tmpFloat32Array16;
- }
- _gl.uniformMatrix4fv(location, false, value);
- break;
- case '2i':
- _gl.uniform2i(location, value[0], value[1]);
- break;
- case '2f':
- _gl.uniform2f(location, value[0], value[1]);
- break;
- case '3i':
- _gl.uniform3i(location, value[0], value[1], value[2]);
- break;
- case '3f':
- _gl.uniform3f(location, value[0], value[1], value[2]);
- break;
- case '4i':
- _gl.uniform4i(location, value[0], value[1], value[2], value[3]);
- break;
- case '4f':
- _gl.uniform4f(location, value[0], value[1], value[2], value[3]);
- break;
- case '1i':
- _gl.uniform1i(location, value);
- break;
- case '1f':
- _gl.uniform1f(location, value);
- break;
- case '1fv':
- _gl.uniform1fv(location, value);
- break;
- case '1iv':
- _gl.uniform1iv(location, value);
- break;
- case '2iv':
- _gl.uniform2iv(location, value);
- break;
- case '2fv':
- _gl.uniform2fv(location, value);
- break;
- case '3iv':
- _gl.uniform3iv(location, value);
- break;
- case '3fv':
- _gl.uniform3fv(location, value);
- break;
- case '4iv':
- _gl.uniform4iv(location, value);
- break;
- case '4fv':
- _gl.uniform4fv(location, value);
- break;
- case 'm2':
- case 'm2v':
- _gl.uniformMatrix2fv(location, false, value);
- break;
- case 'm3':
- case 'm3v':
- _gl.uniformMatrix3fv(location, false, value);
- break;
- case 'm4v':
- // Raw value
- if (Array.isArray(value) && Array.isArray(value[0])) {
- var array = new __WEBPACK_IMPORTED_MODULE_0__core_vendor__["a" /* default */].Float32Array(value.length * 16);
- var cursor = 0;
- for (var i = 0; i < value.length; i++) {
- var item = value[i];
- for (var j = 0; j < 16; j++) {
- array[cursor++] = item[j];
- }
- }
- _gl.uniformMatrix4fv(location, false, array);
- }
- else { // ArrayBufferView
- _gl.uniformMatrix4fv(location, false, value);
- }
- break;
- }
- return true;
- },
- setUniformOfSemantic: function (_gl, semantic, val) {
- var semanticInfo = this.uniformSemantics[semantic];
- if (semanticInfo) {
- return this.setUniform(_gl, semanticInfo.type, semanticInfo.symbol, val);
- }
- return false;
- },
- // Used for creating VAO
- // Enable the attributes passed in and disable the rest
- // Example Usage:
- // enableAttributes(renderer, ["position", "texcoords"])
- enableAttributes: function (renderer, attribList, vao) {
- var _gl = renderer.gl;
- var program = this._program;
- var locationMap = this._locations;
- var enabledAttributeListInContext;
- if (vao) {
- enabledAttributeListInContext = vao.__enabledAttributeList;
- }
- else {
- enabledAttributeListInContext = enabledAttributeList[renderer.__uid__];
- }
- if (!enabledAttributeListInContext) {
- // In vertex array object context
- // PENDING Each vao object needs to enable attributes again?
- if (vao) {
- enabledAttributeListInContext
- = vao.__enabledAttributeList
- = [];
- }
- else {
- enabledAttributeListInContext
- = enabledAttributeList[renderer.__uid__]
- = [];
- }
- }
- var locationList = [];
- for (var i = 0; i < attribList.length; i++) {
- var symbol = attribList[i];
- if (!this.attributes[symbol]) {
- locationList[i] = -1;
- continue;
- }
- var location = locationMap[symbol];
- if (location == null) {
- location = _gl.getAttribLocation(program, symbol);
- // Attrib location is a number from 0 to ...
- if (location === -1) {
- locationList[i] = -1;
- continue;
- }
- locationMap[symbol] = location;
- }
- locationList[i] = location;
- if (!enabledAttributeListInContext[location]) {
- enabledAttributeListInContext[location] = SHADER_STATE_TO_ENABLE;
- }
- else {
- enabledAttributeListInContext[location] = SHADER_STATE_KEEP_ENABLE;
- }
- }
- for (var i = 0; i < enabledAttributeListInContext.length; i++) {
- switch (enabledAttributeListInContext[i]) {
- case SHADER_STATE_TO_ENABLE:
- _gl.enableVertexAttribArray(i);
- enabledAttributeListInContext[i] = SHADER_STATE_PENDING;
- break;
- case SHADER_STATE_KEEP_ENABLE:
- enabledAttributeListInContext[i] = SHADER_STATE_PENDING;
- break;
- // Expired
- case SHADER_STATE_PENDING:
- _gl.disableVertexAttribArray(i);
- enabledAttributeListInContext[i] = 0;
- break;
- }
- }
- return locationList;
- },
- buildProgram: function (_gl, shader, vertexShaderCode, fragmentShaderCode) {
- var vertexShader = _gl.createShader(_gl.VERTEX_SHADER);
- var program = _gl.createProgram();
- _gl.shaderSource(vertexShader, vertexShaderCode);
- _gl.compileShader(vertexShader);
- var fragmentShader = _gl.createShader(_gl.FRAGMENT_SHADER);
- _gl.shaderSource(fragmentShader, fragmentShaderCode);
- _gl.compileShader(fragmentShader);
- var msg = checkShaderErrorMsg(_gl, vertexShader, vertexShaderCode);
- if (msg) {
- return msg;
- }
- msg = checkShaderErrorMsg(_gl, fragmentShader, fragmentShaderCode);
- if (msg) {
- return msg;
- }
- _gl.attachShader(program, vertexShader);
- _gl.attachShader(program, fragmentShader);
- // Force the position bind to location 0;
- if (shader.attributeSemantics['POSITION']) {
- _gl.bindAttribLocation(program, 0, shader.attributeSemantics['POSITION'].symbol);
- }
- else {
- // Else choose an attribute and bind to location 0;
- var keys = Object.keys(this.attributes);
- _gl.bindAttribLocation(program, 0, keys[0]);
- }
- _gl.linkProgram(program);
- if (!_gl.getProgramParameter(program, _gl.LINK_STATUS)) {
- return 'Could not link program\n' + _gl.getProgramInfoLog(program);
- }
- // Cache uniform locations
- for (var i = 0; i < shader.uniforms.length; i++) {
- var uniformSymbol = shader.uniforms[i];
- this._locations[uniformSymbol] = _gl.getUniformLocation(program, uniformSymbol);
- }
- _gl.deleteShader(vertexShader);
- _gl.deleteShader(fragmentShader);
- this._program = program;
- // Save code.
- this.vertexCode = vertexShaderCode;
- this.fragmentCode = fragmentShaderCode;
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (GLProgram);
- /***/
- }),
- /* 117 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Ray__ = __webpack_require__(54);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Vector2__ = __webpack_require__(26);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Renderable__ = __webpack_require__(72);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__core_glenum__ = __webpack_require__(11);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__glmatrix_vec3__ = __webpack_require__(12);
- /**
- * @constructor clay.picking.RayPicking
- * @extends clay.core.Base
- */
- var RayPicking = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(/** @lends clay.picking.RayPicking# */{
- /**
- * Target scene
- * @type {clay.Scene}
- */
- scene: null,
- /**
- * Target camera
- * @type {clay.Camera}
- */
- camera: null,
- /**
- * Target renderer
- * @type {clay.Renderer}
- */
- renderer: null
- }, function () {
- this._ray = new __WEBPACK_IMPORTED_MODULE_1__math_Ray__["a" /* default */]();
- this._ndc = new __WEBPACK_IMPORTED_MODULE_2__math_Vector2__["a" /* default */]();
- },
- /** @lends clay.picking.RayPicking.prototype */
- {
- /**
- * Pick the nearest intersection object in the scene
- * @param {number} x Mouse position x
- * @param {number} y Mouse position y
- * @param {boolean} [forcePickAll=false] ignore ignorePicking
- * @return {clay.picking.RayPicking~Intersection}
- */
- pick: function (x, y, forcePickAll) {
- var out = this.pickAll(x, y, [], forcePickAll);
- return out[0] || null;
- },
- /**
- * Pick all intersection objects, wich will be sorted from near to far
- * @param {number} x Mouse position x
- * @param {number} y Mouse position y
- * @param {Array} [output]
- * @param {boolean} [forcePickAll=false] ignore ignorePicking
- * @return {Array.<clay.picking.RayPicking~Intersection>}
- */
- pickAll: function (x, y, output, forcePickAll) {
- this.renderer.screenToNDC(x, y, this._ndc);
- this.camera.castRay(this._ndc, this._ray);
- output = output || [];
- this._intersectNode(this.scene, output, forcePickAll || false);
- output.sort(this._intersectionCompareFunc);
- return output;
- },
- _intersectNode: function (node, out, forcePickAll) {
- if ((node instanceof __WEBPACK_IMPORTED_MODULE_5__Renderable__["a" /* default */]) && node.isRenderable()) {
- if ((!node.ignorePicking || forcePickAll)
- && (
- // Only triangle mesh support ray picking
- (node.mode === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].TRIANGLES && node.geometry.isUseIndices())
- // Or if geometry has it's own pickByRay, pick, implementation
- || node.geometry.pickByRay
- || node.geometry.pick
- )
- ) {
- this._intersectRenderable(node, out);
- }
- }
- for (var i = 0; i < node._children.length; i++) {
- this._intersectNode(node._children[i], out, forcePickAll);
- }
- },
- _intersectRenderable: (function () {
- var v1 = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */]();
- var v2 = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */]();
- var v3 = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */]();
- var ray = new __WEBPACK_IMPORTED_MODULE_1__math_Ray__["a" /* default */]();
- var worldInverse = new __WEBPACK_IMPORTED_MODULE_4__math_Matrix4__["a" /* default */]();
- return function (renderable, out) {
- var isSkinnedMesh = renderable.isSkinnedMesh();
- ray.copy(this._ray);
- __WEBPACK_IMPORTED_MODULE_4__math_Matrix4__["a" /* default */].invert(worldInverse, renderable.worldTransform);
- // Skinned mesh will ignore the world transform.
- if (!isSkinnedMesh) {
- ray.applyTransform(worldInverse);
- }
- var geometry = renderable.geometry;
- var bbox = isSkinnedMesh ? renderable.skeleton.boundingBox : geometry.boundingBox;
- if (bbox && !ray.intersectBoundingBox(bbox)) {
- return;
- }
- // Use user defined picking algorithm
- if (geometry.pick) {
- geometry.pick(
- this._ndc.x, this._ndc.y,
- this.renderer,
- this.camera,
- renderable, out
- );
- return;
- }
- // Use user defined ray picking algorithm
- else if (geometry.pickByRay) {
- geometry.pickByRay(ray, renderable, out);
- return;
- }
- var cullBack = (renderable.cullFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].BACK && renderable.frontFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].CCW)
- || (renderable.cullFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].FRONT && renderable.frontFace === __WEBPACK_IMPORTED_MODULE_6__core_glenum__["a" /* default */].CW);
- var point;
- var indices = geometry.indices;
- var positionAttr = geometry.attributes.position;
- var weightAttr = geometry.attributes.weight;
- var jointAttr = geometry.attributes.joint;
- var skinMatricesArray;
- var skinMatrices = [];
- // Check if valid.
- if (!positionAttr || !positionAttr.value || !indices) {
- return;
- }
- if (isSkinnedMesh) {
- skinMatricesArray = renderable.skeleton.getSubSkinMatrices(renderable.__uid__, renderable.joints);
- for (var i = 0; i < renderable.joints.length; i++) {
- skinMatrices[i] = skinMatrices[i] || [];
- for (var k = 0; k < 16; k++) {
- skinMatrices[i][k] = skinMatricesArray[i * 16 + k];
- }
- }
- var pos = [];
- var weight = [];
- var joint = [];
- var skinnedPos = [];
- var tmp = [];
- var skinnedPositionAttr = geometry.attributes.skinnedPosition;
- if (!skinnedPositionAttr || !skinnedPositionAttr.value) {
- geometry.createAttribute('skinnedPosition', 'f', 3);
- skinnedPositionAttr = geometry.attributes.skinnedPosition;
- skinnedPositionAttr.init(geometry.vertexCount);
- }
- for (var i = 0; i < geometry.vertexCount; i++) {
- positionAttr.get(i, pos);
- weightAttr.get(i, weight);
- jointAttr.get(i, joint);
- weight[3] = 1 - weight[0] - weight[1] - weight[2];
- __WEBPACK_IMPORTED_MODULE_7__glmatrix_vec3__["a" /* default */].set(skinnedPos, 0, 0, 0);
- for (var k = 0; k < 4; k++) {
- if (joint[k] >= 0 && weight[k] > 1e-4) {
- __WEBPACK_IMPORTED_MODULE_7__glmatrix_vec3__["a" /* default */].transformMat4(tmp, pos, skinMatrices[joint[k]]);
- __WEBPACK_IMPORTED_MODULE_7__glmatrix_vec3__["a" /* default */].scaleAndAdd(skinnedPos, skinnedPos, tmp, weight[k]);
- }
- }
- skinnedPositionAttr.set(i, skinnedPos);
- }
- }
- for (var i = 0; i < indices.length; i += 3) {
- var i1 = indices[i];
- var i2 = indices[i + 1];
- var i3 = indices[i + 2];
- var finalPosAttr = isSkinnedMesh
- ? geometry.attributes.skinnedPosition
- : positionAttr;
- finalPosAttr.get(i1, v1.array);
- finalPosAttr.get(i2, v2.array);
- finalPosAttr.get(i3, v3.array);
- if (cullBack) {
- point = ray.intersectTriangle(v1, v2, v3, renderable.culling);
- }
- else {
- point = ray.intersectTriangle(v1, v3, v2, renderable.culling);
- }
- if (point) {
- var pointW = new __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */]();
- if (!isSkinnedMesh) {
- __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].transformMat4(pointW, point, renderable.worldTransform);
- }
- else {
- // TODO point maybe not right.
- __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].copy(pointW, point);
- }
- out.push(new RayPicking.Intersection(
- point, pointW, renderable, [i1, i2, i3], i / 3,
- __WEBPACK_IMPORTED_MODULE_3__math_Vector3__["a" /* default */].dist(pointW, this._ray.origin)
- ));
- }
- }
- };
- })(),
- _intersectionCompareFunc: function (a, b) {
- return a.distance - b.distance;
- }
- });
- /**
- * @constructor clay.picking.RayPicking~Intersection
- * @param {clay.Vector3} point
- * @param {clay.Vector3} pointWorld
- * @param {clay.Node} target
- * @param {Array.<number>} triangle
- * @param {number} triangleIndex
- * @param {number} distance
- */
- RayPicking.Intersection = function (point, pointWorld, target, triangle, triangleIndex, distance) {
- /**
- * Intersection point in local transform coordinates
- * @type {clay.Vector3}
- */
- this.point = point;
- /**
- * Intersection point in world transform coordinates
- * @type {clay.Vector3}
- */
- this.pointWorld = pointWorld;
- /**
- * Intersection scene node
- * @type {clay.Node}
- */
- this.target = target;
- /**
- * Intersection triangle, which is an array of vertex index
- * @type {Array.<number>}
- */
- this.triangle = triangle;
- /**
- * Index of intersection triangle.
- */
- this.triangleIndex = triangleIndex;
- /**
- * Distance from intersection point to ray origin
- * @type {number}
- */
- this.distance = distance;
- };
- /* harmony default export */ __webpack_exports__["a"] = (RayPicking);
- /***/
- }),
- /* 118 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_Cache__ = __webpack_require__(57);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_vendor__ = __webpack_require__(14);
- function getArrayCtorByType(type) {
- return ({
- 'byte': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Int8Array,
- 'ubyte': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint8Array,
- 'short': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Int16Array,
- 'ushort': __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint16Array
- })[type] || __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Float32Array;
- }
- function makeAttrKey(attrName) {
- return 'attr_' + attrName;
- }
- /**
- * GeometryBase attribute
- * @alias clay.GeometryBase.Attribute
- * @constructor
- */
- function Attribute(name, type, size, semantic) {
- /**
- * Attribute name
- * @type {string}
- */
- this.name = name;
- /**
- * Attribute type
- * Possible values:
- * + `'byte'`
- * + `'ubyte'`
- * + `'short'`
- * + `'ushort'`
- * + `'float'` Most commonly used.
- * @type {string}
- */
- this.type = type;
- /**
- * Size of attribute component. 1 - 4.
- * @type {number}
- */
- this.size = size;
- /**
- * Semantic of this attribute.
- * Possible values:
- * + `'POSITION'`
- * + `'NORMAL'`
- * + `'BINORMAL'`
- * + `'TANGENT'`
- * + `'TEXCOORD'`
- * + `'TEXCOORD_0'`
- * + `'TEXCOORD_1'`
- * + `'COLOR'`
- * + `'JOINT'`
- * + `'WEIGHT'`
- *
- * In shader, attribute with same semantic will be automatically mapped. For example:
- * ```glsl
- * attribute vec3 pos: POSITION
- * ```
- * will use the attribute value with semantic POSITION in geometry, no matter what name it used.
- * @type {string}
- */
- this.semantic = semantic || '';
- /**
- * Value of the attribute.
- * @type {TypedArray}
- */
- this.value = null;
- // Init getter setter
- switch (size) {
- case 1:
- this.get = function (idx) {
- return this.value[idx];
- };
- this.set = function (idx, value) {
- this.value[idx] = value;
- };
- // Copy from source to target
- this.copy = function (target, source) {
- this.value[target] = this.value[target];
- };
- break;
- case 2:
- this.get = function (idx, out) {
- var arr = this.value;
- out[0] = arr[idx * 2];
- out[1] = arr[idx * 2 + 1];
- return out;
- };
- this.set = function (idx, val) {
- var arr = this.value;
- arr[idx * 2] = val[0];
- arr[idx * 2 + 1] = val[1];
- };
- this.copy = function (target, source) {
- var arr = this.value;
- source *= 2;
- target *= 2;
- arr[target] = arr[source];
- arr[target + 1] = arr[source + 1];
- };
- break;
- case 3:
- this.get = function (idx, out) {
- var idx3 = idx * 3;
- var arr = this.value;
- out[0] = arr[idx3];
- out[1] = arr[idx3 + 1];
- out[2] = arr[idx3 + 2];
- return out;
- };
- this.set = function (idx, val) {
- var idx3 = idx * 3;
- var arr = this.value;
- arr[idx3] = val[0];
- arr[idx3 + 1] = val[1];
- arr[idx3 + 2] = val[2];
- };
- this.copy = function (target, source) {
- var arr = this.value;
- source *= 3;
- target *= 3;
- arr[target] = arr[source];
- arr[target + 1] = arr[source + 1];
- arr[target + 2] = arr[source + 2];
- };
- break;
- case 4:
- this.get = function (idx, out) {
- var arr = this.value;
- var idx4 = idx * 4;
- out[0] = arr[idx4];
- out[1] = arr[idx4 + 1];
- out[2] = arr[idx4 + 2];
- out[3] = arr[idx4 + 3];
- return out;
- };
- this.set = function (idx, val) {
- var arr = this.value;
- var idx4 = idx * 4;
- arr[idx4] = val[0];
- arr[idx4 + 1] = val[1];
- arr[idx4 + 2] = val[2];
- arr[idx4 + 3] = val[3];
- };
- this.copy = function (target, source) {
- var arr = this.value;
- source *= 4;
- target *= 4;
- // copyWithin is extremely slow
- arr[target] = arr[source];
- arr[target + 1] = arr[source + 1];
- arr[target + 2] = arr[source + 2];
- arr[target + 3] = arr[source + 3];
- };
- }
- }
- /**
- * Set item value at give index. Second parameter val is number if size is 1
- * @function
- * @name clay.GeometryBase.Attribute#set
- * @param {number} idx
- * @param {number[]|number} val
- * @example
- * geometry.getAttribute('position').set(0, [1, 1, 1]);
- */
- /**
- * Get item value at give index. Second parameter out is no need if size is 1
- * @function
- * @name clay.GeometryBase.Attribute#set
- * @param {number} idx
- * @param {number[]} [out]
- * @example
- * geometry.getAttribute('position').get(0, out);
- */
- /**
- * Initialize attribute with given vertex count
- * @param {number} nVertex
- */
- Attribute.prototype.init = function (nVertex) {
- if (!this.value || this.value.length != nVertex * this.size) {
- var ArrayConstructor = getArrayCtorByType(this.type);
- this.value = new ArrayConstructor(nVertex * this.size);
- }
- };
- /**
- * Initialize attribute with given array. Which can be 1 dimensional or 2 dimensional
- * @param {Array} array
- * @example
- * geometry.getAttribute('position').fromArray(
- * [-1, 0, 0, 1, 0, 0, 0, 1, 0]
- * );
- * geometry.getAttribute('position').fromArray(
- * [ [-1, 0, 0], [1, 0, 0], [0, 1, 0] ]
- * );
- */
- Attribute.prototype.fromArray = function (array) {
- var ArrayConstructor = getArrayCtorByType(this.type);
- var value;
- // Convert 2d array to flat
- if (array[0] && (array[0].length)) {
- var n = 0;
- var size = this.size;
- value = new ArrayConstructor(array.length * size);
- for (var i = 0; i < array.length; i++) {
- for (var j = 0; j < size; j++) {
- value[n++] = array[i][j];
- }
- }
- }
- else {
- value = new ArrayConstructor(array);
- }
- this.value = value;
- };
- Attribute.prototype.clone = function (copyValue) {
- var ret = new Attribute(this.name, this.type, this.size, this.semantic);
- // FIXME
- if (copyValue) {
- console.warn('todo');
- }
- return ret;
- };
- function AttributeBuffer(name, type, buffer, size, semantic) {
- this.name = name;
- this.type = type;
- this.buffer = buffer;
- this.size = size;
- this.semantic = semantic;
- // To be set in mesh
- // symbol in the shader
- this.symbol = '';
- // Needs remove flag
- this.needsRemove = false;
- }
- function IndicesBuffer(buffer) {
- this.buffer = buffer;
- this.count = 0;
- }
- /**
- * Base of all geometry. Use {@link clay.Geometry} for common 3D usage.
- * @constructor clay.GeometryBase
- * @extends clay.core.Base
- */
- var GeometryBase = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () {
- return /** @lends clay.GeometryBase# */ {
- /**
- * Attributes of geometry.
- * @type {Object.<string, clay.GeometryBase.Attribute>}
- */
- attributes: {},
- /**
- * Indices of geometry.
- * @type {Uint16Array|Uint32Array}
- */
- indices: null,
- /**
- * Is vertices data dynamically updated.
- * Attributes value can't be changed after first render if dyanmic is false.
- * @type {boolean}
- */
- dynamic: true,
- _enabledAttributes: null,
- // PENDING
- // Init it here to avoid deoptimization when it's assigned in application dynamically
- __used: 0
- };
- }, function () {
- // Use cache
- this._cache = new __WEBPACK_IMPORTED_MODULE_2__core_Cache__["a" /* default */]();
- this._attributeList = Object.keys(this.attributes);
- this.__vaoCache = {};
- },
- /** @lends clay.GeometryBase.prototype */
- {
- /**
- * Main attribute will be used to count vertex number
- * @type {string}
- */
- mainAttribute: '',
- /**
- * User defined picking algorithm instead of default
- * triangle ray intersection
- * x, y are NDC.
- * ```typescript
- * (x, y, renderer, camera, renderable, out) => boolean
- * ```
- * @type {?Function}
- */
- pick: null,
- /**
- * User defined ray picking algorithm instead of default
- * triangle ray intersection
- * ```typescript
- * (ray: clay.Ray, renderable: clay.Renderable, out: Array) => boolean
- * ```
- * @type {?Function}
- */
- pickByRay: null,
- /**
- * Mark attributes and indices in geometry needs to update.
- * Usually called after you change the data in attributes.
- */
- dirty: function () {
- var enabledAttributes = this.getEnabledAttributes();
- for (var i = 0; i < enabledAttributes.length; i++) {
- this.dirtyAttribute(enabledAttributes[i]);
- }
- this.dirtyIndices();
- this._enabledAttributes = null;
- this._cache.dirty('any');
- },
- /**
- * Mark the indices needs to update.
- */
- dirtyIndices: function () {
- this._cache.dirtyAll('indices');
- },
- /**
- * Mark the attributes needs to update.
- * @param {string} [attrName]
- */
- dirtyAttribute: function (attrName) {
- this._cache.dirtyAll(makeAttrKey(attrName));
- this._cache.dirtyAll('attributes');
- },
- /**
- * Get indices of triangle at given index.
- * @param {number} idx
- * @param {Array.<number>} out
- * @return {Array.<number>}
- */
- getTriangleIndices: function (idx, out) {
- if (idx < this.triangleCount && idx >= 0) {
- if (!out) {
- out = [];
- }
- var indices = this.indices;
- out[0] = indices[idx * 3];
- out[1] = indices[idx * 3 + 1];
- out[2] = indices[idx * 3 + 2];
- return out;
- }
- },
- /**
- * Set indices of triangle at given index.
- * @param {number} idx
- * @param {Array.<number>} arr
- */
- setTriangleIndices: function (idx, arr) {
- var indices = this.indices;
- indices[idx * 3] = arr[0];
- indices[idx * 3 + 1] = arr[1];
- indices[idx * 3 + 2] = arr[2];
- },
- isUseIndices: function () {
- return !!this.indices;
- },
- /**
- * Initialize indices from an array.
- * @param {Array} array
- */
- initIndicesFromArray: function (array) {
- var value;
- var ArrayConstructor = this.vertexCount > 0xffff
- ? __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint32Array : __WEBPACK_IMPORTED_MODULE_3__core_vendor__["a" /* default */].Uint16Array;
- // Convert 2d array to flat
- if (array[0] && (array[0].length)) {
- var n = 0;
- var size = 3;
- value = new ArrayConstructor(array.length * size);
- for (var i = 0; i < array.length; i++) {
- for (var j = 0; j < size; j++) {
- value[n++] = array[i][j];
- }
- }
- }
- else {
- value = new ArrayConstructor(array);
- }
- this.indices = value;
- },
- /**
- * Create a new attribute
- * @param {string} name
- * @param {string} type
- * @param {number} size
- * @param {string} [semantic]
- */
- createAttribute: function (name, type, size, semantic) {
- var attrib = new Attribute(name, type, size, semantic);
- if (this.attributes[name]) {
- this.removeAttribute(name);
- }
- this.attributes[name] = attrib;
- this._attributeList.push(name);
- return attrib;
- },
- /**
- * Remove attribute
- * @param {string} name
- */
- removeAttribute: function (name) {
- var attributeList = this._attributeList;
- var idx = attributeList.indexOf(name);
- if (idx >= 0) {
- attributeList.splice(idx, 1);
- delete this.attributes[name];
- return true;
- }
- return false;
- },
- /**
- * Get attribute
- * @param {string} name
- * @return {clay.GeometryBase.Attribute}
- */
- getAttribute: function (name) {
- return this.attributes[name];
- },
- /**
- * Get enabled attributes name list
- * Attribute which has the same vertex number with position is treated as a enabled attribute
- * @return {string[]}
- */
- getEnabledAttributes: function () {
- var enabledAttributes = this._enabledAttributes;
- var attributeList = this._attributeList;
- // Cache
- if (enabledAttributes) {
- return enabledAttributes;
- }
- var result = [];
- var nVertex = this.vertexCount;
- for (var i = 0; i < attributeList.length; i++) {
- var name = attributeList[i];
- var attrib = this.attributes[name];
- if (attrib.value) {
- if (attrib.value.length === nVertex * attrib.size) {
- result.push(name);
- }
- }
- }
- this._enabledAttributes = result;
- return result;
- },
- getBufferChunks: function (renderer) {
- var cache = this._cache;
- cache.use(renderer.__uid__);
- var isAttributesDirty = cache.isDirty('attributes');
- var isIndicesDirty = cache.isDirty('indices');
- if (isAttributesDirty || isIndicesDirty) {
- this._updateBuffer(renderer.gl, isAttributesDirty, isIndicesDirty);
- var enabledAttributes = this.getEnabledAttributes();
- for (var i = 0; i < enabledAttributes.length; i++) {
- cache.fresh(makeAttrKey(enabledAttributes[i]));
- }
- cache.fresh('attributes');
- cache.fresh('indices');
- }
- cache.fresh('any');
- return cache.get('chunks');
- },
- _updateBuffer: function (_gl, isAttributesDirty, isIndicesDirty) {
- var cache = this._cache;
- var chunks = cache.get('chunks');
- var firstUpdate = false;
- if (!chunks) {
- chunks = [];
- // Intialize
- chunks[0] = {
- attributeBuffers: [],
- indicesBuffer: null
- };
- cache.put('chunks', chunks);
- firstUpdate = true;
- }
- var chunk = chunks[0];
- var attributeBuffers = chunk.attributeBuffers;
- var indicesBuffer = chunk.indicesBuffer;
- if (isAttributesDirty || firstUpdate) {
- var attributeList = this.getEnabledAttributes();
- var attributeBufferMap = {};
- if (!firstUpdate) {
- for (var i = 0; i < attributeBuffers.length; i++) {
- attributeBufferMap[attributeBuffers[i].name] = attributeBuffers[i];
- }
- }
- // FIXME If some attributes removed
- for (var k = 0; k < attributeList.length; k++) {
- var name = attributeList[k];
- var attribute = this.attributes[name];
- var bufferInfo;
- if (!firstUpdate) {
- bufferInfo = attributeBufferMap[name];
- }
- var buffer;
- if (bufferInfo) {
- buffer = bufferInfo.buffer;
- }
- else {
- buffer = _gl.createBuffer();
- }
- if (cache.isDirty(makeAttrKey(name))) {
- // Only update when they are dirty.
- // TODO: Use BufferSubData?
- _gl.bindBuffer(_gl.ARRAY_BUFFER, buffer);
- _gl.bufferData(_gl.ARRAY_BUFFER, attribute.value, this.dynamic ? __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DYNAMIC_DRAW : __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STATIC_DRAW);
- }
- attributeBuffers[k] = new AttributeBuffer(name, attribute.type, buffer, attribute.size, attribute.semantic);
- }
- // Remove unused attributes buffers.
- // PENDING
- for (var i = k; i < attributeBuffers.length; i++) {
- _gl.deleteBuffer(attributeBuffers[i].buffer);
- }
- attributeBuffers.length = k;
- }
- if (this.isUseIndices() && (isIndicesDirty || firstUpdate)) {
- if (!indicesBuffer) {
- indicesBuffer = new IndicesBuffer(_gl.createBuffer());
- chunk.indicesBuffer = indicesBuffer;
- }
- indicesBuffer.count = this.indices.length;
- _gl.bindBuffer(_gl.ELEMENT_ARRAY_BUFFER, indicesBuffer.buffer);
- _gl.bufferData(_gl.ELEMENT_ARRAY_BUFFER, this.indices, this.dynamic ? __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DYNAMIC_DRAW : __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STATIC_DRAW);
- }
- },
- /**
- * Dispose geometry data in GL context.
- * @param {clay.Renderer} renderer
- */
- dispose: function (renderer) {
- var cache = this._cache;
- cache.use(renderer.__uid__);
- var chunks = cache.get('chunks');
- if (chunks) {
- for (var c = 0; c < chunks.length; c++) {
- var chunk = chunks[c];
- for (var k = 0; k < chunk.attributeBuffers.length; k++) {
- var attribs = chunk.attributeBuffers[k];
- renderer.gl.deleteBuffer(attribs.buffer);
- }
- if (chunk.indicesBuffer) {
- renderer.gl.deleteBuffer(chunk.indicesBuffer.buffer);
- }
- }
- }
- if (this.__vaoCache) {
- var vaoExt = renderer.getGLExtension('OES_vertex_array_object');
- for (var id in this.__vaoCache) {
- var vao = this.__vaoCache[id].vao;
- if (vao) {
- vaoExt.deleteVertexArrayOES(vao);
- }
- }
- }
- this.__vaoCache = {};
- cache.deleteContext(renderer.__uid__);
- }
- });
- if (Object.defineProperty) {
- /**
- * @name clay.GeometryBase#vertexCount
- * @type {number}
- * @readOnly
- */
- Object.defineProperty(GeometryBase.prototype, 'vertexCount', {
- enumerable: false,
- get: function () {
- var mainAttribute = this.attributes[this.mainAttribute];
- if (!mainAttribute) {
- mainAttribute = this.attributes[this._attributeList[0]];
- }
- if (!mainAttribute || !mainAttribute.value) {
- return 0;
- }
- return mainAttribute.value.length / mainAttribute.size;
- }
- });
- /**
- * @name clay.GeometryBase#triangleCount
- * @type {number}
- * @readOnly
- */
- Object.defineProperty(GeometryBase.prototype, 'triangleCount', {
- enumerable: false,
- get: function () {
- var indices = this.indices;
- if (!indices) {
- return 0;
- }
- else {
- return indices.length / 3;
- }
- }
- });
- }
- GeometryBase.STATIC_DRAW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STATIC_DRAW;
- GeometryBase.DYNAMIC_DRAW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DYNAMIC_DRAW;
- GeometryBase.STREAM_DRAW = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].STREAM_DRAW;
- GeometryBase.AttributeBuffer = AttributeBuffer;
- GeometryBase.IndicesBuffer = IndicesBuffer;
- GeometryBase.Attribute = Attribute;
- /* harmony default export */ __webpack_exports__["a"] = (GeometryBase);
- /***/
- }),
- /* 119 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__calcAmbientSHLight_glsl_js__ = __webpack_require__(120);
- var uniformVec3Prefix = 'uniform vec3 ';
- var uniformFloatPrefix = 'uniform float ';
- var exportHeaderPrefix = '@export clay.header.';
- var exportEnd = '@end';
- var unconfigurable = ':unconfigurable;';
- /* harmony default export */ __webpack_exports__["a"] = ([
- exportHeaderPrefix + 'directional_light',
- uniformVec3Prefix + 'directionalLightDirection[DIRECTIONAL_LIGHT_COUNT]' + unconfigurable,
- uniformVec3Prefix + 'directionalLightColor[DIRECTIONAL_LIGHT_COUNT]' + unconfigurable,
- exportEnd,
- exportHeaderPrefix + 'ambient_light',
- uniformVec3Prefix + 'ambientLightColor[AMBIENT_LIGHT_COUNT]' + unconfigurable,
- exportEnd,
- exportHeaderPrefix + 'ambient_sh_light',
- uniformVec3Prefix + 'ambientSHLightColor[AMBIENT_SH_LIGHT_COUNT]' + unconfigurable,
- uniformVec3Prefix + 'ambientSHLightCoefficients[AMBIENT_SH_LIGHT_COUNT * 9]' + unconfigurable,
- __WEBPACK_IMPORTED_MODULE_0__calcAmbientSHLight_glsl_js__["a" /* default */],
- exportEnd,
- exportHeaderPrefix + 'ambient_cubemap_light',
- uniformVec3Prefix + 'ambientCubemapLightColor[AMBIENT_CUBEMAP_LIGHT_COUNT]' + unconfigurable,
- 'uniform samplerCube ambientCubemapLightCubemap[AMBIENT_CUBEMAP_LIGHT_COUNT]' + unconfigurable,
- 'uniform sampler2D ambientCubemapLightBRDFLookup[AMBIENT_CUBEMAP_LIGHT_COUNT]' + unconfigurable,
- exportEnd,
- exportHeaderPrefix + 'point_light',
- uniformVec3Prefix + 'pointLightPosition[POINT_LIGHT_COUNT]' + unconfigurable,
- uniformFloatPrefix + 'pointLightRange[POINT_LIGHT_COUNT]' + unconfigurable,
- uniformVec3Prefix + 'pointLightColor[POINT_LIGHT_COUNT]' + unconfigurable,
- exportEnd,
- exportHeaderPrefix + 'spot_light',
- uniformVec3Prefix + 'spotLightPosition[SPOT_LIGHT_COUNT]' + unconfigurable,
- uniformVec3Prefix + 'spotLightDirection[SPOT_LIGHT_COUNT]' + unconfigurable,
- uniformFloatPrefix + 'spotLightRange[SPOT_LIGHT_COUNT]' + unconfigurable,
- uniformFloatPrefix + 'spotLightUmbraAngleCosine[SPOT_LIGHT_COUNT]' + unconfigurable,
- uniformFloatPrefix + 'spotLightPenumbraAngleCosine[SPOT_LIGHT_COUNT]' + unconfigurable,
- uniformFloatPrefix + 'spotLightFalloffFactor[SPOT_LIGHT_COUNT]' + unconfigurable,
- uniformVec3Prefix + 'spotLightColor[SPOT_LIGHT_COUNT]' + unconfigurable,
- exportEnd
- ].join('\n'));
- /***/
- }),
- /* 120 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("vec3 calcAmbientSHLight(int idx, vec3 N) {\n int offset = 9 * idx;\n return ambientSHLightCoefficients[0]\n + ambientSHLightCoefficients[1] * N.x\n + ambientSHLightCoefficients[2] * N.y\n + ambientSHLightCoefficients[3] * N.z\n + ambientSHLightCoefficients[4] * N.x * N.z\n + ambientSHLightCoefficients[5] * N.z * N.y\n + ambientSHLightCoefficients[6] * N.y * N.x\n + ambientSHLightCoefficients[7] * (3.0 * N.z * N.z - 1.0)\n + ambientSHLightCoefficients[8] * (N.x * N.x - N.y * N.y);\n}");
- /***/
- }),
- /* 121 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.skybox.vertex\n#define SHADER_NAME skybox\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export clay.skybox.fragment\n#define PI 3.1415926\nuniform mat4 viewInverse : VIEWINVERSE;\n#ifdef EQUIRECTANGULAR\nuniform sampler2D environmentMap;\n#else\nuniform samplerCube environmentMap;\n#endif\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\n@import clay.util.srgb\n@import clay.util.ACES\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n#ifdef EQUIRECTANGULAR\n float phi = acos(V.y);\n float theta = atan(-V.x, V.z) + PI * 0.5;\n vec2 uv = vec2(theta / 2.0 / PI, phi / PI);\n vec4 texel = decodeHDR(texture2D(environmentMap, fract(uv)));\n#else\n #if defined(LOD) || defined(SUPPORT_TEXTURE_LOD)\n vec4 texel = decodeHDR(textureCubeLodEXT(environmentMap, V, lod));\n #else\n vec4 texel = decodeHDR(textureCube(environmentMap, V));\n #endif\n#endif\n#ifdef SRGB_DECODE\n texel = sRGBToLinear(texel);\n#endif\n#ifdef TONEMAPPING\n texel.rgb = ACESToneMapping(texel.rgb);\n#endif\n#ifdef SRGB_ENCODE\n texel = linearTosRGB(texel);\n#endif\n gl_FragColor = encodeHDR(vec4(texel.rgb, 1.0));\n}\n@end");
- /***/
- }),
- /* 122 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__TextureCube__ = __webpack_require__(27);
- // http://msdn.microsoft.com/en-us/library/windows/desktop/bb943991(v=vs.85).aspx
- // https://github.com/toji/webgl-texture-utils/blob/master/texture-util/dds.js
- var DDS_MAGIC = 0x20534444;
- var DDSD_CAPS = 0x1;
- var DDSD_HEIGHT = 0x2;
- var DDSD_WIDTH = 0x4;
- var DDSD_PITCH = 0x8;
- var DDSD_PIXELFORMAT = 0x1000;
- var DDSD_MIPMAPCOUNT = 0x20000;
- var DDSD_LINEARSIZE = 0x80000;
- var DDSD_DEPTH = 0x800000;
- var DDSCAPS_COMPLEX = 0x8;
- var DDSCAPS_MIPMAP = 0x400000;
- var DDSCAPS_TEXTURE = 0x1000;
- var DDSCAPS2_CUBEMAP = 0x200;
- var DDSCAPS2_CUBEMAP_POSITIVEX = 0x400;
- var DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800;
- var DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000;
- var DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000;
- var DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000;
- var DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000;
- var DDSCAPS2_VOLUME = 0x200000;
- var DDPF_ALPHAPIXELS = 0x1;
- var DDPF_ALPHA = 0x2;
- var DDPF_FOURCC = 0x4;
- var DDPF_RGB = 0x40;
- var DDPF_YUV = 0x200;
- var DDPF_LUMINANCE = 0x20000;
- function fourCCToInt32(value) {
- return value.charCodeAt(0) +
- (value.charCodeAt(1) << 8) +
- (value.charCodeAt(2) << 16) +
- (value.charCodeAt(3) << 24);
- }
- function int32ToFourCC(value) {
- return String.fromCharCode(
- value & 0xff,
- (value >> 8) & 0xff,
- (value >> 16) & 0xff,
- (value >> 24) & 0xff
- );
- }
- var headerLengthInt = 31; // The header length in 32 bit ints
- var FOURCC_DXT1 = fourCCToInt32('DXT1');
- var FOURCC_DXT3 = fourCCToInt32('DXT3');
- var FOURCC_DXT5 = fourCCToInt32('DXT5');
- // Offsets into the header array
- var off_magic = 0;
- var off_size = 1;
- var off_flags = 2;
- var off_height = 3;
- var off_width = 4;
- var off_mipmapCount = 7;
- var off_pfFlags = 20;
- var off_pfFourCC = 21;
- var off_caps = 27;
- var off_caps2 = 28;
- var off_caps3 = 29;
- var off_caps4 = 30;
- var ret = {
- parse: function (arrayBuffer, out) {
- var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
- if (header[off_magic] !== DDS_MAGIC) {
- return null;
- }
- if (!header(off_pfFlags) & DDPF_FOURCC) {
- return null;
- }
- var fourCC = header(off_pfFourCC);
- var width = header[off_width];
- var height = header[off_height];
- var isCubeMap = header[off_caps2] & DDSCAPS2_CUBEMAP;
- var hasMipmap = header[off_flags] & DDSD_MIPMAPCOUNT;
- var blockBytes, internalFormat;
- switch (fourCC) {
- case FOURCC_DXT1:
- blockBytes = 8;
- internalFormat = __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].COMPRESSED_RGB_S3TC_DXT1_EXT;
- break;
- case FOURCC_DXT3:
- blockBytes = 16;
- internalFormat = __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].COMPRESSED_RGBA_S3TC_DXT3_EXT;
- break;
- case FOURCC_DXT5:
- blockBytes = 16;
- internalFormat = __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].COMPRESSED_RGBA_S3TC_DXT5_EXT;
- break;
- default:
- return null;
- }
- var dataOffset = header[off_size] + 4;
- // TODO: Suppose all face are existed
- var faceNumber = isCubeMap ? 6 : 1;
- var mipmapCount = 1;
- if (hasMipmap) {
- mipmapCount = Math.max(1, header[off_mipmapCount]);
- }
- var textures = [];
- for (var f = 0; f < faceNumber; f++) {
- var _width = width;
- var _height = height;
- textures[f] = new __WEBPACK_IMPORTED_MODULE_1__Texture2D__["a" /* default */]({
- width: _width,
- height: _height,
- format: internalFormat
- });
- var mipmaps = [];
- for (var i = 0; i < mipmapCount; i++) {
- var dataLength = Math.max(4, _width) / 4 * Math.max(4, _height) / 4 * blockBytes;
- var byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
- dataOffset += dataLength;
- _width *= 0.5;
- _height *= 0.5;
- mipmaps[i] = byteArray;
- }
- textures[f].pixels = mipmaps[0];
- if (hasMipmap) {
- textures[f].mipmaps = mipmaps;
- }
- }
- // TODO
- // return isCubeMap ? textures : textures[0];
- if (out) {
- out.width = textures[0].width;
- out.height = textures[0].height;
- out.format = textures[0].format;
- out.pixels = textures[0].pixels;
- out.mipmaps = textures[0].mipmaps;
- }
- else {
- return textures[0];
- }
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (ret);
- /***/
- }),
- /* 123 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Texture2D__ = __webpack_require__(5);
- var toChar = String.fromCharCode;
- var MINELEN = 8;
- var MAXELEN = 0x7fff;
- function rgbe2float(rgbe, buffer, offset, exposure) {
- if (rgbe[3] > 0) {
- var f = Math.pow(2.0, rgbe[3] - 128 - 8 + exposure);
- buffer[offset + 0] = rgbe[0] * f;
- buffer[offset + 1] = rgbe[1] * f;
- buffer[offset + 2] = rgbe[2] * f;
- }
- else {
- buffer[offset + 0] = 0;
- buffer[offset + 1] = 0;
- buffer[offset + 2] = 0;
- }
- buffer[offset + 3] = 1.0;
- return buffer;
- }
- function uint82string(array, offset, size) {
- var str = '';
- for (var i = offset; i < size; i++) {
- str += toChar(array[i]);
- }
- return str;
- }
- function copyrgbe(s, t) {
- t[0] = s[0];
- t[1] = s[1];
- t[2] = s[2];
- t[3] = s[3];
- }
- // TODO : check
- function oldReadColors(scan, buffer, offset, xmax) {
- var rshift = 0, x = 0, len = xmax;
- while (len > 0) {
- scan[x][0] = buffer[offset++];
- scan[x][1] = buffer[offset++];
- scan[x][2] = buffer[offset++];
- scan[x][3] = buffer[offset++];
- if (scan[x][0] === 1 && scan[x][1] === 1 && scan[x][2] === 1) {
- // exp is count of repeated pixels
- for (var i = (scan[x][3] << rshift) >>> 0; i > 0; i--) {
- copyrgbe(scan[x - 1], scan[x]);
- x++;
- len--;
- }
- rshift += 8;
- } else {
- x++;
- len--;
- rshift = 0;
- }
- }
- return offset;
- }
- function readColors(scan, buffer, offset, xmax) {
- if ((xmax < MINELEN) | (xmax > MAXELEN)) {
- return oldReadColors(scan, buffer, offset, xmax);
- }
- var i = buffer[offset++];
- if (i != 2) {
- return oldReadColors(scan, buffer, offset - 1, xmax);
- }
- scan[0][1] = buffer[offset++];
- scan[0][2] = buffer[offset++];
- i = buffer[offset++];
- if ((((scan[0][2] << 8) >>> 0) | i) >>> 0 !== xmax) {
- return null;
- }
- for (var i = 0; i < 4; i++) {
- for (var x = 0; x < xmax;) {
- var code = buffer[offset++];
- if (code > 128) {
- code = (code & 127) >>> 0;
- var val = buffer[offset++];
- while (code--) {
- scan[x++][i] = val;
- }
- } else {
- while (code--) {
- scan[x++][i] = buffer[offset++];
- }
- }
- }
- }
- return offset;
- }
- var ret = {
- // http://www.graphics.cornell.edu/~bjw/rgbe.html
- // Blender source
- // http://radsite.lbl.gov/radiance/refer/Notes/picture_format.html
- parseRGBE: function (arrayBuffer, texture, exposure) {
- if (exposure == null) {
- exposure = 0;
- }
- var data = new Uint8Array(arrayBuffer);
- var size = data.length;
- if (uint82string(data, 0, 2) !== '#?') {
- return;
- }
- // find empty line, next line is resolution info
- for (var i = 2; i < size; i++) {
- if (toChar(data[i]) === '\n' && toChar(data[i + 1]) === '\n') {
- break;
- }
- }
- if (i >= size) { // not found
- return;
- }
- // find resolution info line
- i += 2;
- var str = '';
- for (; i < size; i++) {
- var _char = toChar(data[i]);
- if (_char === '\n') {
- break;
- }
- str += _char;
- }
- // -Y M +X N
- var tmp = str.split(' ');
- var height = parseInt(tmp[1]);
- var width = parseInt(tmp[3]);
- if (!width || !height) {
- return;
- }
- // read and decode actual data
- var offset = i + 1;
- var scanline = [];
- // memzero
- for (var x = 0; x < width; x++) {
- scanline[x] = [];
- for (var j = 0; j < 4; j++) {
- scanline[x][j] = 0;
- }
- }
- var pixels = new Float32Array(width * height * 4);
- var offset2 = 0;
- for (var y = 0; y < height; y++) {
- var offset = readColors(scanline, data, offset, width);
- if (!offset) {
- return null;
- }
- for (var x = 0; x < width; x++) {
- rgbe2float(scanline[x], pixels, offset2, exposure);
- offset2 += 4;
- }
- }
- if (!texture) {
- texture = new __WEBPACK_IMPORTED_MODULE_1__Texture2D__["a" /* default */]();
- }
- texture.width = width;
- texture.height = height;
- texture.pixels = pixels;
- // HALF_FLOAT can't use Float32Array
- texture.type = __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].FLOAT;
- return texture;
- },
- parseRGBEFromPNG: function (png) {
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (ret);
- /***/
- }),
- /* 124 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector2__ = __webpack_require__(26);
- /**
- * Surface texture in the 3D scene.
- * Provide management and rendering of zrender shapes and groups
- *
- * @module echarts-gl/util/EChartsSurface
- * @author Yi Shen(http://github.com/pissang)
- */
- var events = ['mousedown', 'mouseup', 'mousemove', 'mouseover', 'mouseout', 'click', 'dblclick', 'contextmenu'];
- function makeHandlerName(eventName) {
- return '_on' + eventName;
- }
- /**
- * @constructor
- * @alias echarts-gl/util/EChartsSurface
- * @param {module:echarts~ECharts} chart
- */
- var EChartsSurface = function (chart) {
- var self = this;
- this._texture = new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Texture2D__["a" /* default */]({
- anisotropic: 32,
- flipY: false,
- surface: this,
- dispose: function (renderer) {
- self.dispose();
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Texture2D__["a" /* default */].prototype.dispose.call(this, renderer);
- }
- });
- events.forEach(function (eventName) {
- this[makeHandlerName(eventName)] = function (eveObj) {
- if (!eveObj.triangle) {
- return;
- }
- this._meshes.forEach(function (mesh) {
- this.dispatchEvent(eventName, mesh, eveObj.triangle, eveObj.point);
- }, this);
- };
- }, this);
- this._meshes = [];
- if (chart) {
- this.setECharts(chart);
- }
- // Texture updated callback;
- this.onupdate = null;
- };
- EChartsSurface.prototype = {
- constructor: EChartsSurface,
- getTexture: function () {
- return this._texture;
- },
- setECharts: function (chart) {
- this._chart = chart;
- var canvas = chart.getDom();
- if (!(canvas instanceof HTMLCanvasElement)) {
- console.error('ECharts must init on canvas if it is used as texture.');
- // Use an empty canvas
- canvas = document.createElement('canvas');
- }
- else {
- var self = this;
- // Wrap refreshImmediately
- var zr = chart.getZr();
- var oldRefreshImmediately = zr.__oldRefreshImmediately || zr.refreshImmediately;
- zr.refreshImmediately = function () {
- oldRefreshImmediately.call(this);
- self._texture.dirty();
- self.onupdate && self.onupdate();
- };
- zr.__oldRefreshImmediately = oldRefreshImmediately;
- }
- this._texture.image = canvas;
- this._texture.dirty();
- this.onupdate && this.onupdate();
- },
- /**
- * @method
- * @param {clay.Mesh} attachedMesh
- * @param {Array.<number>} triangle Triangle indices
- * @param {clay.math.Vector3} point
- */
- dispatchEvent: (function () {
- var p0 = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__["a" /* default */]();
- var p1 = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__["a" /* default */]();
- var p2 = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__["a" /* default */]();
- var uv0 = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector2__["a" /* default */]();
- var uv1 = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector2__["a" /* default */]();
- var uv2 = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector2__["a" /* default */]();
- var uv = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector2__["a" /* default */]();
- var vCross = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__["a" /* default */]();
- return function (eventName, attachedMesh, triangle, point) {
- var geo = attachedMesh.geometry;
- var position = geo.attributes.position;
- var texcoord = geo.attributes.texcoord0;
- var dot = __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__["a" /* default */].dot;
- var cross = __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__["a" /* default */].cross;
- position.get(triangle[0], p0.array);
- position.get(triangle[1], p1.array);
- position.get(triangle[2], p2.array);
- texcoord.get(triangle[0], uv0.array);
- texcoord.get(triangle[1], uv1.array);
- texcoord.get(triangle[2], uv2.array);
- cross(vCross, p1, p2);
- var det = dot(p0, vCross);
- var t = dot(point, vCross) / det;
- cross(vCross, p2, p0);
- var u = dot(point, vCross) / det;
- cross(vCross, p0, p1);
- var v = dot(point, vCross) / det;
- __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector2__["a" /* default */].scale(uv, uv0, t);
- __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector2__["a" /* default */].scaleAndAdd(uv, uv, uv1, u);
- __WEBPACK_IMPORTED_MODULE_2_claygl_src_math_Vector2__["a" /* default */].scaleAndAdd(uv, uv, uv2, v);
- var x = uv.x * this._chart.getWidth();
- var y = uv.y * this._chart.getHeight();
- this._chart.getZr().handler.dispatch(eventName, {
- zrX: x,
- zrY: y
- });
- };
- })(),
- attachToMesh: function (mesh) {
- if (this._meshes.indexOf(mesh) >= 0) {
- return;
- }
- events.forEach(function (eventName) {
- mesh.on(eventName, this[makeHandlerName(eventName)], this);
- }, this);
- this._meshes.push(mesh);
- },
- detachFromMesh: function (mesh) {
- var idx = this._meshes.indexOf(mesh);
- if (idx >= 0) {
- this._meshes.splice(idx, 1);
- }
- events.forEach(function (eventName) {
- mesh.off(eventName, this[makeHandlerName(eventName)]);
- }, this);
- },
- dispose: function () {
- this._meshes.forEach(function (mesh) {
- this.detachFromMesh(mesh);
- }, this);
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (EChartsSurface);
- /***/
- }),
- /* 125 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_cubemap__ = __webpack_require__(77);
- // https://docs.unrealengine.com/latest/INT/Engine/Rendering/LightingAndShadows/AmbientCubemap/
- /**
- * Ambient cubemap light provides specular parts of Image Based Lighting.
- * Which is a basic requirement for Physically Based Rendering
- * @constructor clay.light.AmbientCubemap
- * @extends clay.Light
- */
- var AmbientCubemapLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend({
- /**
- * @type {clay.TextureCube}
- * @memberOf clay.light.AmbientCubemap#
- */
- cubemap: null,
- // TODO
- // range: 100,
- castShadow: false,
- _normalDistribution: null,
- _brdfLookup: null
- }, /** @lends clay.light.AmbientCubemap# */ {
- type: 'AMBIENT_CUBEMAP_LIGHT',
- /**
- * Do prefitering the cubemap
- * @param {clay.Renderer} renderer
- * @param {number} [size=32]
- */
- prefilter: function (renderer, size) {
- if (!renderer.getGLExtension('EXT_shader_texture_lod')) {
- console.warn('Device not support textureCubeLodEXT');
- return;
- }
- if (!this._brdfLookup) {
- this._normalDistribution = __WEBPACK_IMPORTED_MODULE_1__util_cubemap__["a" /* default */].generateNormalDistribution();
- this._brdfLookup = __WEBPACK_IMPORTED_MODULE_1__util_cubemap__["a" /* default */].integrateBRDF(renderer, this._normalDistribution);
- }
- var cubemap = this.cubemap;
- if (cubemap.__prefiltered) {
- return;
- }
- var result = __WEBPACK_IMPORTED_MODULE_1__util_cubemap__["a" /* default */].prefilterEnvironmentMap(
- renderer, cubemap, {
- encodeRGBM: true,
- width: size,
- height: size
- }, this._normalDistribution, this._brdfLookup
- );
- this.cubemap = result.environmentMap;
- this.cubemap.__prefiltered = true;
- cubemap.dispose(renderer);
- },
- getBRDFLookup: function () {
- return this._brdfLookup;
- },
- uniformTemplates: {
- ambientCubemapLightColor: {
- type: '3f',
- value: function (instance) {
- var color = instance.color;
- var intensity = instance.intensity;
- return [color[0] * intensity, color[1] * intensity, color[2] * intensity];
- }
- },
- ambientCubemapLightCubemap: {
- type: 't',
- value: function (instance) {
- return instance.cubemap;
- }
- },
- ambientCubemapLightBRDFLookup: {
- type: 't',
- value: function (instance) {
- return instance._brdfLookup;
- }
- }
- }
- /**
- * @function
- * @name clone
- * @return {clay.light.AmbientCubemap}
- * @memberOf clay.light.AmbientCubemap.prototype
- */
- });
- /* harmony default export */ __webpack_exports__["a"] = (AmbientCubemapLight);
- /***/
- }),
- /* 126 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("\n@export clay.compositor.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nvarying vec2 v_Texcoord;\nvoid main()\n{\n v_Texcoord = texcoord;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end");
- /***/
- }),
- /* 127 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform sampler2D normalDistribution;\nuniform vec2 viewportSize : [512, 256];\nconst vec3 N = vec3(0.0, 0.0, 1.0);\nconst float fSampleNumber = float(SAMPLE_NUMBER);\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nfloat G_Smith(float roughness, float NoV, float NoL) {\n float k = roughness * roughness / 2.0;\n float G1V = NoV / (NoV * (1.0 - k) + k);\n float G1L = NoL / (NoL * (1.0 - k) + k);\n return G1L * G1V;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / viewportSize;\n float NoV = uv.x;\n float roughness = uv.y;\n vec3 V;\n V.x = sqrt(1.0 - NoV * NoV);\n V.y = 0.0;\n V.z = NoV;\n float A = 0.0;\n float B = 0.0;\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(L.z, 0.0, 1.0);\n float NoH = clamp(H.z, 0.0, 1.0);\n float VoH = clamp(dot(V, H), 0.0, 1.0);\n if (NoL > 0.0) {\n float G = G_Smith(roughness, NoV, NoL);\n float G_Vis = G * VoH / (NoH * NoV);\n float Fc = pow(1.0 - VoH, 5.0);\n A += (1.0 - Fc) * G_Vis;\n B += Fc * G_Vis;\n }\n }\n gl_FragColor = vec4(vec2(A, B) / fSampleNumber, 0.0, 1.0);\n}\n");
- /***/
- }),
- /* 128 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("#define SHADER_NAME prefilter\n#define SAMPLE_NUMBER 1024\n#define PI 3.14159265358979\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform sampler2D normalDistribution;\nuniform float roughness : 0.5;\nvarying vec2 v_Texcoord;\nvarying vec3 v_WorldPosition;\n@import clay.util.rgbm\nvec3 importanceSampleNormal(float i, float roughness, vec3 N) {\n vec3 H = texture2D(normalDistribution, vec2(roughness, i)).rgb;\n vec3 upVector = abs(N.y) > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvoid main() {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(v_WorldPosition - eyePos);\n vec3 N = V;\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n float fMaxSampleNumber = float(SAMPLE_NUMBER);\n for (int i = 0; i < SAMPLE_NUMBER; i++) {\n vec3 H = importanceSampleNormal(float(i) / fMaxSampleNumber, roughness, N);\n vec3 L = reflect(-V, H);\n float NoL = clamp(dot(N, L), 0.0, 1.0);\n if (NoL > 0.0) {\n prefilteredColor += decodeHDR(textureCube(environmentMap, L)).rgb * NoL;\n totalWeight += NoL;\n }\n }\n gl_FragColor = encodeHDR(vec4(prefilteredColor / totalWeight, 1.0));\n}\n");
- /***/
- }),
- /* 129 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_vendor__ = __webpack_require__(14);
- /**
- * Spherical Harmonic Ambient Light
- * @constructor clay.light.AmbientSH
- * @extends clay.Light
- */
- var AmbientSHLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend({
- castShadow: false,
- /**
- * Spherical Harmonic Coefficients
- * @type {Array.<number>}
- * @memberOf clay.light.AmbientSH#
- */
- coefficients: [],
- }, function () {
- this._coefficientsTmpArr = new __WEBPACK_IMPORTED_MODULE_1__core_vendor__["a" /* default */].Float32Array(9 * 3);
- }, {
- type: 'AMBIENT_SH_LIGHT',
- uniformTemplates: {
- ambientSHLightColor: {
- type: '3f',
- value: function (instance) {
- var color = instance.color;
- var intensity = instance.intensity;
- return [color[0] * intensity, color[1] * intensity, color[2] * intensity];
- }
- },
- ambientSHLightCoefficients: {
- type: '3f',
- value: function (instance) {
- var coefficientsTmpArr = instance._coefficientsTmpArr;
- for (var i = 0; i < instance.coefficients.length; i++) {
- coefficientsTmpArr[i] = instance.coefficients[i];
- }
- return coefficientsTmpArr;
- }
- }
- }
- /**
- * @function
- * @name clone
- * @return {clay.light.Ambient}
- * @memberOf clay.light.Ambient.prototype
- */
- });
- /* harmony default export */ __webpack_exports__["a"] = (AmbientSHLight);
- /***/
- }),
- /* 130 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__FrameBuffer__ = __webpack_require__(10);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__compositor_Pass__ = __webpack_require__(16);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_vendor__ = __webpack_require__(14);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__plugin_Skybox__ = __webpack_require__(42);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__plugin_Skydome__ = __webpack_require__(75);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__prePass_EnvironmentMap__ = __webpack_require__(62);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Scene__ = __webpack_require__(36);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__ = __webpack_require__(12);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__shader_projectEnvMap_glsl_js__ = __webpack_require__(131);
- // Spherical Harmonic Helpers
- var sh = {};
- var targets = ['px', 'nx', 'py', 'ny', 'pz', 'nz'];
- // Project on gpu, but needs browser to support readPixels as Float32Array.
- function projectEnvironmentMapGPU(renderer, envMap) {
- var shTexture = new __WEBPACK_IMPORTED_MODULE_2__Texture2D__["a" /* default */]({
- width: 9,
- height: 1,
- type: __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].FLOAT
- });
- var pass = new __WEBPACK_IMPORTED_MODULE_3__compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_10__shader_projectEnvMap_glsl_js__["a" /* default */]
- });
- pass.material.define('fragment', 'TEXTURE_SIZE', envMap.width);
- pass.setUniform('environmentMap', envMap);
- var framebuffer = new __WEBPACK_IMPORTED_MODULE_1__FrameBuffer__["a" /* default */]();
- framebuffer.attach(shTexture);
- pass.render(renderer, framebuffer);
- framebuffer.bind(renderer);
- // TODO Only chrome and firefox support Float32Array
- var pixels = new __WEBPACK_IMPORTED_MODULE_4__core_vendor__["a" /* default */].Float32Array(9 * 4);
- renderer.gl.readPixels(0, 0, 9, 1, __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].RGBA, __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].FLOAT, pixels);
- var coeff = new __WEBPACK_IMPORTED_MODULE_4__core_vendor__["a" /* default */].Float32Array(9 * 3);
- for (var i = 0; i < 9; i++) {
- coeff[i * 3] = pixels[i * 4];
- coeff[i * 3 + 1] = pixels[i * 4 + 1];
- coeff[i * 3 + 2] = pixels[i * 4 + 2];
- }
- framebuffer.unbind(renderer);
- framebuffer.dispose(renderer);
- pass.dispose(renderer);
- return coeff;
- }
- function harmonics(normal, index) {
- var x = normal[0];
- var y = normal[1];
- var z = normal[2];
- if (index === 0) {
- return 1.0;
- }
- else if (index === 1) {
- return x;
- }
- else if (index === 2) {
- return y;
- }
- else if (index === 3) {
- return z;
- }
- else if (index === 4) {
- return x * z;
- }
- else if (index === 5) {
- return y * z;
- }
- else if (index === 6) {
- return x * y;
- }
- else if (index === 7) {
- return 3.0 * z * z - 1.0;
- }
- else {
- return x * x - y * y;
- }
- }
- var normalTransform = {
- px: [2, 1, 0, -1, -1, 1],
- nx: [2, 1, 0, 1, -1, -1],
- py: [0, 2, 1, 1, -1, -1],
- ny: [0, 2, 1, 1, 1, 1],
- pz: [0, 1, 2, -1, -1, -1],
- nz: [0, 1, 2, 1, -1, 1]
- };
- // Project on cpu.
- function projectEnvironmentMapCPU(renderer, cubePixels, width, height) {
- var coeff = new __WEBPACK_IMPORTED_MODULE_4__core_vendor__["a" /* default */].Float32Array(9 * 3);
- var normal = __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].create();
- var texel = __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].create();
- var fetchNormal = __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].create();
- for (var m = 0; m < 9; m++) {
- var result = __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].create();
- for (var k = 0; k < targets.length; k++) {
- var pixels = cubePixels[targets[k]];
- var sideResult = __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].create();
- var divider = 0;
- var i = 0;
- var transform = normalTransform[targets[k]];
- for (var y = 0; y < height; y++) {
- for (var x = 0; x < width; x++) {
- normal[0] = x / (width - 1.0) * 2.0 - 1.0;
- // TODO Flip y?
- normal[1] = y / (height - 1.0) * 2.0 - 1.0;
- normal[2] = -1.0;
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].normalize(normal, normal);
- fetchNormal[0] = normal[transform[0]] * transform[3];
- fetchNormal[1] = normal[transform[1]] * transform[4];
- fetchNormal[2] = normal[transform[2]] * transform[5];
- texel[0] = pixels[i++] / 255;
- texel[1] = pixels[i++] / 255;
- texel[2] = pixels[i++] / 255;
- // RGBM Decode
- var scale = pixels[i++] / 255 * 8.12;
- texel[0] *= scale;
- texel[1] *= scale;
- texel[2] *= scale;
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].scaleAndAdd(sideResult, sideResult, texel, harmonics(fetchNormal, m) * -normal[2]);
- // -normal.z equals cos(theta) of Lambertian
- divider += -normal[2];
- }
- }
- __WEBPACK_IMPORTED_MODULE_9__glmatrix_vec3__["a" /* default */].scaleAndAdd(result, result, sideResult, 1 / divider);
- }
- coeff[m * 3] = result[0] / 6.0;
- coeff[m * 3 + 1] = result[1] / 6.0;
- coeff[m * 3 + 2] = result[2] / 6.0;
- }
- return coeff;
- }
- /**
- * @param {clay.Renderer} renderer
- * @param {clay.Texture} envMap
- * @param {Object} [textureOpts]
- * @param {Object} [textureOpts.lod]
- * @param {boolean} [textureOpts.decodeRGBM]
- */
- sh.projectEnvironmentMap = function (renderer, envMap, opts) {
- // TODO sRGB
- opts = opts || {};
- opts.lod = opts.lod || 0;
- var skybox;
- var dummyScene = new __WEBPACK_IMPORTED_MODULE_8__Scene__["a" /* default */]();
- var size = 64;
- if (envMap.textureType === 'texture2D') {
- skybox = new __WEBPACK_IMPORTED_MODULE_6__plugin_Skydome__["a" /* default */]({
- scene: dummyScene,
- environmentMap: envMap
- });
- }
- else {
- size = (envMap.image && envMap.image.px) ? envMap.image.px.width : envMap.width;
- skybox = new __WEBPACK_IMPORTED_MODULE_5__plugin_Skybox__["a" /* default */]({
- scene: dummyScene,
- environmentMap: envMap
- });
- }
- // Convert to rgbm
- var width = Math.ceil(size / Math.pow(2, opts.lod));
- var height = Math.ceil(size / Math.pow(2, opts.lod));
- var rgbmTexture = new __WEBPACK_IMPORTED_MODULE_2__Texture2D__["a" /* default */]({
- width: width,
- height: height
- });
- var framebuffer = new __WEBPACK_IMPORTED_MODULE_1__FrameBuffer__["a" /* default */]();
- skybox.material.define('fragment', 'RGBM_ENCODE');
- if (opts.decodeRGBM) {
- skybox.material.define('fragment', 'RGBM_DECODE');
- }
- skybox.material.set('lod', opts.lod);
- var envMapPass = new __WEBPACK_IMPORTED_MODULE_7__prePass_EnvironmentMap__["a" /* default */]({
- texture: rgbmTexture
- });
- var cubePixels = {};
- for (var i = 0; i < targets.length; i++) {
- cubePixels[targets[i]] = new Uint8Array(width * height * 4);
- var camera = envMapPass.getCamera(targets[i]);
- camera.fov = 90;
- framebuffer.attach(rgbmTexture);
- framebuffer.bind(renderer);
- renderer.render(dummyScene, camera);
- renderer.gl.readPixels(
- 0, 0, width, height,
- __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].RGBA, __WEBPACK_IMPORTED_MODULE_0__Texture__["a" /* default */].UNSIGNED_BYTE, cubePixels[targets[i]]
- );
- framebuffer.unbind(renderer);
- }
- skybox.dispose(renderer);
- framebuffer.dispose(renderer);
- rgbmTexture.dispose(renderer);
- return projectEnvironmentMapCPU(renderer, cubePixels, width, height);
- };
- /* harmony default export */ __webpack_exports__["a"] = (sh);
- /***/
- }),
- /* 131 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("uniform samplerCube environmentMap;\nvarying vec2 v_Texcoord;\n#define TEXTURE_SIZE 16\nmat3 front = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n);\nmat3 back = mat3(\n -1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, -1.0\n);\nmat3 left = mat3(\n 0.0, 0.0, -1.0,\n 0.0, 1.0, 0.0,\n 1.0, 0.0, 0.0\n);\nmat3 right = mat3(\n 0.0, 0.0, 1.0,\n 0.0, 1.0, 0.0,\n -1.0, 0.0, 0.0\n);\nmat3 up = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 0.0, 1.0,\n 0.0, -1.0, 0.0\n);\nmat3 down = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 0.0, -1.0,\n 0.0, 1.0, 0.0\n);\nfloat harmonics(vec3 normal){\n int index = int(gl_FragCoord.x);\n float x = normal.x;\n float y = normal.y;\n float z = normal.z;\n if(index==0){\n return 1.0;\n }\n else if(index==1){\n return x;\n }\n else if(index==2){\n return y;\n }\n else if(index==3){\n return z;\n }\n else if(index==4){\n return x*z;\n }\n else if(index==5){\n return y*z;\n }\n else if(index==6){\n return x*y;\n }\n else if(index==7){\n return 3.0*z*z - 1.0;\n }\n else{\n return x*x - y*y;\n }\n}\nvec3 sampleSide(mat3 rot)\n{\n vec3 result = vec3(0.0);\n float divider = 0.0;\n for (int i = 0; i < TEXTURE_SIZE * TEXTURE_SIZE; i++) {\n float x = mod(float(i), float(TEXTURE_SIZE));\n float y = float(i / TEXTURE_SIZE);\n vec2 sidecoord = ((vec2(x, y) + vec2(0.5, 0.5)) / vec2(TEXTURE_SIZE)) * 2.0 - 1.0;\n vec3 normal = normalize(vec3(sidecoord, -1.0));\n vec3 fetchNormal = rot * normal;\n vec3 texel = textureCube(environmentMap, fetchNormal).rgb;\n result += harmonics(fetchNormal) * texel * -normal.z;\n divider += -normal.z;\n }\n return result / divider;\n}\nvoid main()\n{\n vec3 result = (\n sampleSide(front) +\n sampleSide(back) +\n sampleSide(left) +\n sampleSide(right) +\n sampleSide(up) +\n sampleSide(down)\n ) / 6.0;\n gl_FragColor = vec4(result, 1.0);\n}");
- /***/
- }),
- /* 132 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Geometry__ = __webpack_require__(15);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_BoundingBox__ = __webpack_require__(18);
- /**
- * @constructor clay.geometry.Sphere
- * @extends clay.Geometry
- * @param {Object} [opt]
- * @param {number} [widthSegments]
- * @param {number} [heightSegments]
- * @param {number} [phiStart]
- * @param {number} [phiLength]
- * @param {number} [thetaStart]
- * @param {number} [thetaLength]
- * @param {number} [radius]
- */
- var Sphere = __WEBPACK_IMPORTED_MODULE_0__Geometry__["a" /* default */].extend(/** @lends clay.geometry.Sphere# */ {
- dynamic: false,
- /**
- * @type {number}
- */
- widthSegments: 40,
- /**
- * @type {number}
- */
- heightSegments: 20,
- /**
- * @type {number}
- */
- phiStart: 0,
- /**
- * @type {number}
- */
- phiLength: Math.PI * 2,
- /**
- * @type {number}
- */
- thetaStart: 0,
- /**
- * @type {number}
- */
- thetaLength: Math.PI,
- /**
- * @type {number}
- */
- radius: 1
- }, function () {
- this.build();
- },
- /** @lends clay.geometry.Sphere.prototype */
- {
- /**
- * Build sphere geometry
- */
- build: function () {
- var heightSegments = this.heightSegments;
- var widthSegments = this.widthSegments;
- var positionAttr = this.attributes.position;
- var texcoordAttr = this.attributes.texcoord0;
- var normalAttr = this.attributes.normal;
- var vertexCount = (widthSegments + 1) * (heightSegments + 1);
- positionAttr.init(vertexCount);
- texcoordAttr.init(vertexCount);
- normalAttr.init(vertexCount);
- var IndicesCtor = vertexCount > 0xffff ? Uint32Array : Uint16Array;
- var indices = this.indices = new IndicesCtor(widthSegments * heightSegments * 6);
- var x, y, z,
- u, v,
- i, j;
- var radius = this.radius;
- var phiStart = this.phiStart;
- var phiLength = this.phiLength;
- var thetaStart = this.thetaStart;
- var thetaLength = this.thetaLength;
- var radius = this.radius;
- var pos = [];
- var uv = [];
- var offset = 0;
- var divider = 1 / radius;
- for (j = 0; j <= heightSegments; j++) {
- for (i = 0; i <= widthSegments; i++) {
- u = i / widthSegments;
- v = j / heightSegments;
- // X axis is inverted so texture can be mapped from left to right
- x = -radius * Math.cos(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);
- y = radius * Math.cos(thetaStart + v * thetaLength);
- z = radius * Math.sin(phiStart + u * phiLength) * Math.sin(thetaStart + v * thetaLength);
- pos[0] = x; pos[1] = y; pos[2] = z;
- uv[0] = u; uv[1] = v;
- positionAttr.set(offset, pos);
- texcoordAttr.set(offset, uv);
- pos[0] *= divider;
- pos[1] *= divider;
- pos[2] *= divider;
- normalAttr.set(offset, pos);
- offset++;
- }
- }
- var i1, i2, i3, i4;
- var len = widthSegments + 1;
- var n = 0;
- for (j = 0; j < heightSegments; j++) {
- for (i = 0; i < widthSegments; i++) {
- i2 = j * len + i;
- i1 = (j * len + i + 1);
- i4 = (j + 1) * len + i + 1;
- i3 = (j + 1) * len + i;
- indices[n++] = i1;
- indices[n++] = i2;
- indices[n++] = i4;
- indices[n++] = i2;
- indices[n++] = i3;
- indices[n++] = i4;
- }
- }
- this.boundingBox = new __WEBPACK_IMPORTED_MODULE_1__math_BoundingBox__["a" /* default */]();
- this.boundingBox.max.set(radius, radius, radius);
- this.boundingBox.min.set(-radius, -radius, -radius);
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Sphere);
- /***/
- }),
- /* 133 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24);
- /**
- * @constructor clay.light.Ambient
- * @extends clay.Light
- */
- var AmbientLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend({
- castShadow: false
- }, {
- type: 'AMBIENT_LIGHT',
- uniformTemplates: {
- ambientLightColor: {
- type: '3f',
- value: function (instance) {
- var color = instance.color;
- var intensity = instance.intensity;
- return [color[0] * intensity, color[1] * intensity, color[2] * intensity];
- }
- }
- }
- /**
- * @function
- * @name clone
- * @return {clay.light.Ambient}
- * @memberOf clay.light.Ambient.prototype
- */
- });
- /* harmony default export */ __webpack_exports__["a"] = (AmbientLight);
- /***/
- }),
- /* 134 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(3);
- /**
- * @constructor clay.light.Directional
- * @extends clay.Light
- *
- * @example
- * var light = new clay.light.Directional({
- * intensity: 0.5,
- * color: [1.0, 0.0, 0.0]
- * });
- * light.position.set(10, 10, 10);
- * light.lookAt(clay.Vector3.ZERO);
- * scene.add(light);
- */
- var DirectionalLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend(/** @lends clay.light.Directional# */ {
- /**
- * @type {number}
- */
- shadowBias: 0.001,
- /**
- * @type {number}
- */
- shadowSlopeScale: 2.0,
- /**
- * Shadow cascade.
- * Use PSSM technique when it is larger than 1 and have a unique directional light in scene.
- * @type {number}
- */
- shadowCascade: 1,
- /**
- * Available when shadowCascade is larger than 1 and have a unique directional light in scene.
- * @type {number}
- */
- cascadeSplitLogFactor: 0.2
- }, {
- type: 'DIRECTIONAL_LIGHT',
- uniformTemplates: {
- directionalLightDirection: {
- type: '3f',
- value: function (instance) {
- instance.__dir = instance.__dir || new __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */]();
- // Direction is target to eye
- return instance.__dir.copy(instance.worldTransform.z).normalize().negate().array;
- }
- },
- directionalLightColor: {
- type: '3f',
- value: function (instance) {
- var color = instance.color;
- var intensity = instance.intensity;
- return [color[0] * intensity, color[1] * intensity, color[2] * intensity];
- }
- }
- },
- /**
- * @return {clay.light.Directional}
- * @memberOf clay.light.Directional.prototype
- */
- clone: function () {
- var light = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].prototype.clone.call(this);
- light.shadowBias = this.shadowBias;
- light.shadowSlopeScale = this.shadowSlopeScale;
- return light;
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (DirectionalLight);
- /***/
- }),
- /* 135 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24);
- /**
- * @constructor clay.light.Point
- * @extends clay.Light
- */
- var PointLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend(/** @lends clay.light.Point# */ {
- /**
- * @type {number}
- */
- range: 100,
- /**
- * @type {number}
- */
- castShadow: false
- }, {
- type: 'POINT_LIGHT',
- uniformTemplates: {
- pointLightPosition: {
- type: '3f',
- value: function (instance) {
- return instance.getWorldPosition().array;
- }
- },
- pointLightRange: {
- type: '1f',
- value: function (instance) {
- return instance.range;
- }
- },
- pointLightColor: {
- type: '3f',
- value: function (instance) {
- var color = instance.color;
- var intensity = instance.intensity;
- return [color[0] * intensity, color[1] * intensity, color[2] * intensity];
- }
- }
- },
- /**
- * @return {clay.light.Point}
- * @memberOf clay.light.Point.prototype
- */
- clone: function () {
- var light = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].prototype.clone.call(this);
- light.range = this.range;
- return light;
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (PointLight);
- /***/
- }),
- /* 136 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Light__ = __webpack_require__(24);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math_Vector3__ = __webpack_require__(3);
- /**
- * @constructor clay.light.Spot
- * @extends clay.Light
- */
- var SpotLight = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].extend(/**@lends clay.light.Spot */ {
- /**
- * @type {number}
- */
- range: 20,
- /**
- * @type {number}
- */
- umbraAngle: 30,
- /**
- * @type {number}
- */
- penumbraAngle: 45,
- /**
- * @type {number}
- */
- falloffFactor: 2.0,
- /**
- * @type {number}
- */
- shadowBias: 0.001,
- /**
- * @type {number}
- */
- shadowSlopeScale: 2.0
- }, {
- type: 'SPOT_LIGHT',
- uniformTemplates: {
- spotLightPosition: {
- type: '3f',
- value: function (instance) {
- return instance.getWorldPosition().array;
- }
- },
- spotLightRange: {
- type: '1f',
- value: function (instance) {
- return instance.range;
- }
- },
- spotLightUmbraAngleCosine: {
- type: '1f',
- value: function (instance) {
- return Math.cos(instance.umbraAngle * Math.PI / 180);
- }
- },
- spotLightPenumbraAngleCosine: {
- type: '1f',
- value: function (instance) {
- return Math.cos(instance.penumbraAngle * Math.PI / 180);
- }
- },
- spotLightFalloffFactor: {
- type: '1f',
- value: function (instance) {
- return instance.falloffFactor;
- }
- },
- spotLightDirection: {
- type: '3f',
- value: function (instance) {
- instance.__dir = instance.__dir || new __WEBPACK_IMPORTED_MODULE_1__math_Vector3__["a" /* default */]();
- // Direction is target to eye
- return instance.__dir.copy(instance.worldTransform.z).negate().array;
- }
- },
- spotLightColor: {
- type: '3f',
- value: function (instance) {
- var color = instance.color;
- var intensity = instance.intensity;
- return [color[0] * intensity, color[1] * intensity, color[2] * intensity];
- }
- }
- },
- /**
- * @return {clay.light.Spot}
- * @memberOf clay.light.Spot.prototype
- */
- clone: function () {
- var light = __WEBPACK_IMPORTED_MODULE_0__Light__["a" /* default */].prototype.clone.call(this);
- light.range = this.range;
- light.umbraAngle = this.umbraAngle;
- light.penumbraAngle = this.penumbraAngle;
- light.falloffFactor = this.falloffFactor;
- light.shadowBias = this.shadowBias;
- light.shadowSlopeScale = this.shadowSlopeScale;
- return light;
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (SpotLight);
- /***/
- }),
- /* 137 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__ = __webpack_require__(33);
- /**
- * @constructor
- * @alias clay.Vector4
- * @param {number} x
- * @param {number} y
- * @param {number} z
- * @param {number} w
- */
- var Vector4 = function (x, y, z, w) {
- x = x || 0;
- y = y || 0;
- z = z || 0;
- w = w || 0;
- /**
- * Storage of Vector4, read and write of x, y, z, w will change the values in array
- * All methods also operate on the array instead of x, y, z, w components
- * @name array
- * @type {Float32Array}
- * @memberOf clay.Vector4#
- */
- this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].fromValues(x, y, z, w);
- /**
- * Dirty flag is used by the Node to determine
- * if the matrix is updated to latest
- * @name _dirty
- * @type {boolean}
- * @memberOf clay.Vector4#
- */
- this._dirty = true;
- };
- Vector4.prototype = {
- constructor: Vector4,
- /**
- * Add b to self
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- add: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].add(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Set x, y and z components
- * @param {number} x
- * @param {number} y
- * @param {number} z
- * @param {number} w
- * @return {clay.Vector4}
- */
- set: function (x, y, z, w) {
- this.array[0] = x;
- this.array[1] = y;
- this.array[2] = z;
- this.array[3] = w;
- this._dirty = true;
- return this;
- },
- /**
- * Set x, y, z and w components from array
- * @param {Float32Array|number[]} arr
- * @return {clay.Vector4}
- */
- setArray: function (arr) {
- this.array[0] = arr[0];
- this.array[1] = arr[1];
- this.array[2] = arr[2];
- this.array[3] = arr[3];
- this._dirty = true;
- return this;
- },
- /**
- * Clone a new Vector4
- * @return {clay.Vector4}
- */
- clone: function () {
- return new Vector4(this.x, this.y, this.z, this.w);
- },
- /**
- * Copy from b
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- copy: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].copy(this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for distance
- * @param {clay.Vector4} b
- * @return {number}
- */
- dist: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].dist(this.array, b.array);
- },
- /**
- * Distance between self and b
- * @param {clay.Vector4} b
- * @return {number}
- */
- distance: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].distance(this.array, b.array);
- },
- /**
- * Alias for divide
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- div: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].div(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Divide self by b
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- divide: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].divide(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Dot product of self and b
- * @param {clay.Vector4} b
- * @return {number}
- */
- dot: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].dot(this.array, b.array);
- },
- /**
- * Alias of length
- * @return {number}
- */
- len: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].len(this.array);
- },
- /**
- * Calculate the length
- * @return {number}
- */
- length: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].length(this.array);
- },
- /**
- * Linear interpolation between a and b
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @param {number} t
- * @return {clay.Vector4}
- */
- lerp: function (a, b, t) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].lerp(this.array, a.array, b.array, t);
- this._dirty = true;
- return this;
- },
- /**
- * Minimum of self and b
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- min: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].min(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Maximum of self and b
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- max: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].max(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for multiply
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- mul: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].mul(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Mutiply self and b
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- multiply: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].multiply(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Negate self
- * @return {clay.Vector4}
- */
- negate: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].negate(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Normalize self
- * @return {clay.Vector4}
- */
- normalize: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].normalize(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Generate random x, y, z, w components with a given scale
- * @param {number} scale
- * @return {clay.Vector4}
- */
- random: function (scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].random(this.array, scale);
- this._dirty = true;
- return this;
- },
- /**
- * Scale self
- * @param {number} scale
- * @return {clay.Vector4}
- */
- scale: function (s) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].scale(this.array, this.array, s);
- this._dirty = true;
- return this;
- },
- /**
- * Scale b and add to self
- * @param {clay.Vector4} b
- * @param {number} scale
- * @return {clay.Vector4}
- */
- scaleAndAdd: function (b, s) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].scaleAndAdd(this.array, this.array, b.array, s);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for squaredDistance
- * @param {clay.Vector4} b
- * @return {number}
- */
- sqrDist: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].sqrDist(this.array, b.array);
- },
- /**
- * Squared distance between self and b
- * @param {clay.Vector4} b
- * @return {number}
- */
- squaredDistance: function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].squaredDistance(this.array, b.array);
- },
- /**
- * Alias for squaredLength
- * @return {number}
- */
- sqrLen: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].sqrLen(this.array);
- },
- /**
- * Squared length of self
- * @return {number}
- */
- squaredLength: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].squaredLength(this.array);
- },
- /**
- * Alias for subtract
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- sub: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].sub(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Subtract b from self
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- subtract: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].subtract(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transform self with a Matrix4 m
- * @param {clay.Matrix4} m
- * @return {clay.Vector4}
- */
- transformMat4: function (m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].transformMat4(this.array, this.array, m.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transform self with a Quaternion q
- * @param {clay.Quaternion} q
- * @return {clay.Vector4}
- */
- transformQuat: function (q) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].transformQuat(this.array, this.array, q.array);
- this._dirty = true;
- return this;
- },
- toString: function () {
- return '[' + Array.prototype.join.call(this.array, ',') + ']';
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array);
- }
- };
- var defineProperty = Object.defineProperty;
- // Getter and Setter
- if (defineProperty) {
- var proto = Vector4.prototype;
- /**
- * @name x
- * @type {number}
- * @memberOf clay.Vector4
- * @instance
- */
- defineProperty(proto, 'x', {
- get: function () {
- return this.array[0];
- },
- set: function (value) {
- this.array[0] = value;
- this._dirty = true;
- }
- });
- /**
- * @name y
- * @type {number}
- * @memberOf clay.Vector4
- * @instance
- */
- defineProperty(proto, 'y', {
- get: function () {
- return this.array[1];
- },
- set: function (value) {
- this.array[1] = value;
- this._dirty = true;
- }
- });
- /**
- * @name z
- * @type {number}
- * @memberOf clay.Vector4
- * @instance
- */
- defineProperty(proto, 'z', {
- get: function () {
- return this.array[2];
- },
- set: function (value) {
- this.array[2] = value;
- this._dirty = true;
- }
- });
- /**
- * @name w
- * @type {number}
- * @memberOf clay.Vector4
- * @instance
- */
- defineProperty(proto, 'w', {
- get: function () {
- return this.array[3];
- },
- set: function (value) {
- this.array[3] = value;
- this._dirty = true;
- }
- });
- }
- // Supply methods that are not in place
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- Vector4.add = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].add(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector4} out
- * @param {number} x
- * @param {number} y
- * @param {number} z
- * @return {clay.Vector4}
- */
- Vector4.set = function (out, x, y, z, w) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].set(out.array, x, y, z, w);
- out._dirty = true;
- };
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- Vector4.copy = function (out, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].copy(out.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {number}
- */
- Vector4.dist = function (a, b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].distance(a.array, b.array);
- };
- /**
- * @function
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {number}
- */
- Vector4.distance = Vector4.dist;
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- Vector4.div = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].divide(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- Vector4.divide = Vector4.div;
- /**
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {number}
- */
- Vector4.dot = function (a, b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].dot(a.array, b.array);
- };
- /**
- * @param {clay.Vector4} a
- * @return {number}
- */
- Vector4.len = function (b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].length(b.array);
- };
- // Vector4.length = Vector4.len;
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @param {number} t
- * @return {clay.Vector4}
- */
- Vector4.lerp = function (out, a, b, t) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].lerp(out.array, a.array, b.array, t);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- Vector4.min = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].min(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- Vector4.max = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].max(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- Vector4.mul = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].multiply(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- Vector4.multiply = Vector4.mul;
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @return {clay.Vector4}
- */
- Vector4.negate = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].negate(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @return {clay.Vector4}
- */
- Vector4.normalize = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].normalize(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector4} out
- * @param {number} scale
- * @return {clay.Vector4}
- */
- Vector4.random = function (out, scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].random(out.array, scale);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {number} scale
- * @return {clay.Vector4}
- */
- Vector4.scale = function (out, a, scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].scale(out.array, a.array, scale);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @param {number} scale
- * @return {clay.Vector4}
- */
- Vector4.scaleAndAdd = function (out, a, b, scale) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].scaleAndAdd(out.array, a.array, b.array, scale);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {number}
- */
- Vector4.sqrDist = function (a, b) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].sqrDist(a.array, b.array);
- };
- /**
- * @function
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {number}
- */
- Vector4.squaredDistance = Vector4.sqrDist;
- /**
- * @param {clay.Vector4} a
- * @return {number}
- */
- Vector4.sqrLen = function (a) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].sqrLen(a.array);
- };
- /**
- * @function
- * @param {clay.Vector4} a
- * @return {number}
- */
- Vector4.squaredLength = Vector4.sqrLen;
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- Vector4.sub = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].subtract(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Vector4} b
- * @return {clay.Vector4}
- */
- Vector4.subtract = Vector4.sub;
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Matrix4} m
- * @return {clay.Vector4}
- */
- Vector4.transformMat4 = function (out, a, m) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].transformMat4(out.array, a.array, m.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Vector4} out
- * @param {clay.Vector4} a
- * @param {clay.Quaternion} q
- * @return {clay.Vector4}
- */
- Vector4.transformQuat = function (out, a, q) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_vec4__["a" /* default */].transformQuat(out.array, a.array, q.array);
- out._dirty = true;
- return out;
- };
- /* harmony default export */ __webpack_exports__["a"] = (Vector4);
- /***/
- }),
- /* 138 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__ = __webpack_require__(78);
- /**
- * @constructor
- * @alias clay.Matrix2
- */
- var Matrix2 = function () {
- /**
- * Storage of Matrix2
- * @name array
- * @type {Float32Array}
- * @memberOf clay.Matrix2#
- */
- this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].create();
- /**
- * @name _dirty
- * @type {boolean}
- * @memberOf clay.Matrix2#
- */
- this._dirty = true;
- };
- Matrix2.prototype = {
- constructor: Matrix2,
- /**
- * Set components from array
- * @param {Float32Array|number[]} arr
- */
- setArray: function (arr) {
- for (var i = 0; i < this.array.length; i++) {
- this.array[i] = arr[i];
- }
- this._dirty = true;
- return this;
- },
- /**
- * Clone a new Matrix2
- * @return {clay.Matrix2}
- */
- clone: function () {
- return (new Matrix2()).copy(this);
- },
- /**
- * Copy from b
- * @param {clay.Matrix2} b
- * @return {clay.Matrix2}
- */
- copy: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].copy(this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Calculate the adjugate of self, in-place
- * @return {clay.Matrix2}
- */
- adjoint: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].adjoint(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Calculate matrix determinant
- * @return {number}
- */
- determinant: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].determinant(this.array);
- },
- /**
- * Set to a identity matrix
- * @return {clay.Matrix2}
- */
- identity: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].identity(this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Invert self
- * @return {clay.Matrix2}
- */
- invert: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].invert(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for mutiply
- * @param {clay.Matrix2} b
- * @return {clay.Matrix2}
- */
- mul: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].mul(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for multiplyLeft
- * @param {clay.Matrix2} a
- * @return {clay.Matrix2}
- */
- mulLeft: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].mul(this.array, a.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Multiply self and b
- * @param {clay.Matrix2} b
- * @return {clay.Matrix2}
- */
- multiply: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].multiply(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Multiply a and self, a is on the left
- * @param {clay.Matrix2} a
- * @return {clay.Matrix2}
- */
- multiplyLeft: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].multiply(this.array, a.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Rotate self by a given radian
- * @param {number} rad
- * @return {clay.Matrix2}
- */
- rotate: function (rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].rotate(this.array, this.array, rad);
- this._dirty = true;
- return this;
- },
- /**
- * Scale self by s
- * @param {clay.Vector2} s
- * @return {clay.Matrix2}
- */
- scale: function (v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].scale(this.array, this.array, v.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transpose self, in-place.
- * @return {clay.Matrix2}
- */
- transpose: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].transpose(this.array, this.array);
- this._dirty = true;
- return this;
- },
- toString: function () {
- return '[' + Array.prototype.join.call(this.array, ',') + ']';
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array);
- }
- };
- /**
- * @param {Matrix2} out
- * @param {Matrix2} a
- * @return {Matrix2}
- */
- Matrix2.adjoint = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].adjoint(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix2} out
- * @param {clay.Matrix2} a
- * @return {clay.Matrix2}
- */
- Matrix2.copy = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].copy(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix2} a
- * @return {number}
- */
- Matrix2.determinant = function (a) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].determinant(a.array);
- };
- /**
- * @param {clay.Matrix2} out
- * @return {clay.Matrix2}
- */
- Matrix2.identity = function (out) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].identity(out.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix2} out
- * @param {clay.Matrix2} a
- * @return {clay.Matrix2}
- */
- Matrix2.invert = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].invert(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix2} out
- * @param {clay.Matrix2} a
- * @param {clay.Matrix2} b
- * @return {clay.Matrix2}
- */
- Matrix2.mul = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].mul(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Matrix2} out
- * @param {clay.Matrix2} a
- * @param {clay.Matrix2} b
- * @return {clay.Matrix2}
- */
- Matrix2.multiply = Matrix2.mul;
- /**
- * @param {clay.Matrix2} out
- * @param {clay.Matrix2} a
- * @param {number} rad
- * @return {clay.Matrix2}
- */
- Matrix2.rotate = function (out, a, rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].rotate(out.array, a.array, rad);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix2} out
- * @param {clay.Matrix2} a
- * @param {clay.Vector2} v
- * @return {clay.Matrix2}
- */
- Matrix2.scale = function (out, a, v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].scale(out.array, a.array, v.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {Matrix2} out
- * @param {Matrix2} a
- * @return {Matrix2}
- */
- Matrix2.transpose = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2__["a" /* default */].transpose(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /* harmony default export */ __webpack_exports__["a"] = (Matrix2);
- /***/
- }),
- /* 139 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__ = __webpack_require__(79);
- /**
- * @constructor
- * @alias clay.Matrix2d
- */
- var Matrix2d = function () {
- /**
- * Storage of Matrix2d
- * @name array
- * @type {Float32Array}
- * @memberOf clay.Matrix2d#
- */
- this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].create();
- /**
- * @name _dirty
- * @type {boolean}
- * @memberOf clay.Matrix2d#
- */
- this._dirty = true;
- };
- Matrix2d.prototype = {
- constructor: Matrix2d,
- /**
- * Set components from array
- * @param {Float32Array|number[]} arr
- */
- setArray: function (arr) {
- for (var i = 0; i < this.array.length; i++) {
- this.array[i] = arr[i];
- }
- this._dirty = true;
- return this;
- },
- /**
- * Clone a new Matrix2d
- * @return {clay.Matrix2d}
- */
- clone: function () {
- return (new Matrix2d()).copy(this);
- },
- /**
- * Copy from b
- * @param {clay.Matrix2d} b
- * @return {clay.Matrix2d}
- */
- copy: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].copy(this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Calculate matrix determinant
- * @return {number}
- */
- determinant: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].determinant(this.array);
- },
- /**
- * Set to a identity matrix
- * @return {clay.Matrix2d}
- */
- identity: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].identity(this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Invert self
- * @return {clay.Matrix2d}
- */
- invert: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].invert(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for mutiply
- * @param {clay.Matrix2d} b
- * @return {clay.Matrix2d}
- */
- mul: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].mul(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for multiplyLeft
- * @param {clay.Matrix2d} a
- * @return {clay.Matrix2d}
- */
- mulLeft: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].mul(this.array, b.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Multiply self and b
- * @param {clay.Matrix2d} b
- * @return {clay.Matrix2d}
- */
- multiply: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].multiply(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Multiply a and self, a is on the left
- * @param {clay.Matrix2d} a
- * @return {clay.Matrix2d}
- */
- multiplyLeft: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].multiply(this.array, b.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Rotate self by a given radian
- * @param {number} rad
- * @return {clay.Matrix2d}
- */
- rotate: function (rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].rotate(this.array, this.array, rad);
- this._dirty = true;
- return this;
- },
- /**
- * Scale self by s
- * @param {clay.Vector2} s
- * @return {clay.Matrix2d}
- */
- scale: function (s) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].scale(this.array, this.array, s.array);
- this._dirty = true;
- return this;
- },
- /**
- * Translate self by v
- * @param {clay.Vector2} v
- * @return {clay.Matrix2d}
- */
- translate: function (v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].translate(this.array, this.array, v.array);
- this._dirty = true;
- return this;
- },
- toString: function () {
- return '[' + Array.prototype.join.call(this.array, ',') + ']';
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array);
- }
- };
- /**
- * @param {clay.Matrix2d} out
- * @param {clay.Matrix2d} a
- * @return {clay.Matrix2d}
- */
- Matrix2d.copy = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].copy(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix2d} a
- * @return {number}
- */
- Matrix2d.determinant = function (a) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].determinant(a.array);
- };
- /**
- * @param {clay.Matrix2d} out
- * @return {clay.Matrix2d}
- */
- Matrix2d.identity = function (out) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].identity(out.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix2d} out
- * @param {clay.Matrix2d} a
- * @return {clay.Matrix2d}
- */
- Matrix2d.invert = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].invert(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix2d} out
- * @param {clay.Matrix2d} a
- * @param {clay.Matrix2d} b
- * @return {clay.Matrix2d}
- */
- Matrix2d.mul = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].mul(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Matrix2d} out
- * @param {clay.Matrix2d} a
- * @param {clay.Matrix2d} b
- * @return {clay.Matrix2d}
- */
- Matrix2d.multiply = Matrix2d.mul;
- /**
- * @param {clay.Matrix2d} out
- * @param {clay.Matrix2d} a
- * @param {number} rad
- * @return {clay.Matrix2d}
- */
- Matrix2d.rotate = function (out, a, rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].rotate(out.array, a.array, rad);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix2d} out
- * @param {clay.Matrix2d} a
- * @param {clay.Vector2} v
- * @return {clay.Matrix2d}
- */
- Matrix2d.scale = function (out, a, v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].scale(out.array, a.array, v.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix2d} out
- * @param {clay.Matrix2d} a
- * @param {clay.Vector2} v
- * @return {clay.Matrix2d}
- */
- Matrix2d.translate = function (out, a, v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat2d__["a" /* default */].translate(out.array, a.array, v.array);
- out._dirty = true;
- return out;
- };
- /* harmony default export */ __webpack_exports__["a"] = (Matrix2d);
- /***/
- }),
- /* 140 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__ = __webpack_require__(34);
- /**
- * @constructor
- * @alias clay.Matrix3
- */
- var Matrix3 = function () {
- /**
- * Storage of Matrix3
- * @name array
- * @type {Float32Array}
- * @memberOf clay.Matrix3#
- */
- this.array = __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].create();
- /**
- * @name _dirty
- * @type {boolean}
- * @memberOf clay.Matrix3#
- */
- this._dirty = true;
- };
- Matrix3.prototype = {
- constructor: Matrix3,
- /**
- * Set components from array
- * @param {Float32Array|number[]} arr
- */
- setArray: function (arr) {
- for (var i = 0; i < this.array.length; i++) {
- this.array[i] = arr[i];
- }
- this._dirty = true;
- return this;
- },
- /**
- * Calculate the adjugate of self, in-place
- * @return {clay.Matrix3}
- */
- adjoint: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].adjoint(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Clone a new Matrix3
- * @return {clay.Matrix3}
- */
- clone: function () {
- return (new Matrix3()).copy(this);
- },
- /**
- * Copy from b
- * @param {clay.Matrix3} b
- * @return {clay.Matrix3}
- */
- copy: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].copy(this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Calculate matrix determinant
- * @return {number}
- */
- determinant: function () {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].determinant(this.array);
- },
- /**
- * Copy the values from Matrix2d a
- * @param {clay.Matrix2d} a
- * @return {clay.Matrix3}
- */
- fromMat2d: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromMat2d(this.array, a.array);
- this._dirty = true;
- return this;
- },
- /**
- * Copies the upper-left 3x3 values of Matrix4
- * @param {clay.Matrix4} a
- * @return {clay.Matrix3}
- */
- fromMat4: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromMat4(this.array, a.array);
- this._dirty = true;
- return this;
- },
- /**
- * Calculates a rotation matrix from the given quaternion
- * @param {clay.Quaternion} q
- * @return {clay.Matrix3}
- */
- fromQuat: function (q) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromQuat(this.array, q.array);
- this._dirty = true;
- return this;
- },
- /**
- * Set to a identity matrix
- * @return {clay.Matrix3}
- */
- identity: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].identity(this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Invert self
- * @return {clay.Matrix3}
- */
- invert: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].invert(this.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for mutiply
- * @param {clay.Matrix3} b
- * @return {clay.Matrix3}
- */
- mul: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].mul(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Alias for multiplyLeft
- * @param {clay.Matrix3} a
- * @return {clay.Matrix3}
- */
- mulLeft: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].mul(this.array, a.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Multiply self and b
- * @param {clay.Matrix3} b
- * @return {clay.Matrix3}
- */
- multiply: function (b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].multiply(this.array, this.array, b.array);
- this._dirty = true;
- return this;
- },
- /**
- * Multiply a and self, a is on the left
- * @param {clay.Matrix3} a
- * @return {clay.Matrix3}
- */
- multiplyLeft: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].multiply(this.array, a.array, this.array);
- this._dirty = true;
- return this;
- },
- /**
- * Rotate self by a given radian
- * @param {number} rad
- * @return {clay.Matrix3}
- */
- rotate: function (rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].rotate(this.array, this.array, rad);
- this._dirty = true;
- return this;
- },
- /**
- * Scale self by s
- * @param {clay.Vector2} s
- * @return {clay.Matrix3}
- */
- scale: function (v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].scale(this.array, this.array, v.array);
- this._dirty = true;
- return this;
- },
- /**
- * Translate self by v
- * @param {clay.Vector2} v
- * @return {clay.Matrix3}
- */
- translate: function (v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].translate(this.array, this.array, v.array);
- this._dirty = true;
- return this;
- },
- /**
- * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
- * @param {clay.Matrix4} a
- */
- normalFromMat4: function (a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].normalFromMat4(this.array, a.array);
- this._dirty = true;
- return this;
- },
- /**
- * Transpose self, in-place.
- * @return {clay.Matrix2}
- */
- transpose: function () {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].transpose(this.array, this.array);
- this._dirty = true;
- return this;
- },
- toString: function () {
- return '[' + Array.prototype.join.call(this.array, ',') + ']';
- },
- toArray: function () {
- return Array.prototype.slice.call(this.array);
- }
- };
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Matrix3} a
- * @return {clay.Matrix3}
- */
- Matrix3.adjoint = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].adjoint(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Matrix3} a
- * @return {clay.Matrix3}
- */
- Matrix3.copy = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].copy(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix3} a
- * @return {number}
- */
- Matrix3.determinant = function (a) {
- return __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].determinant(a.array);
- };
- /**
- * @param {clay.Matrix3} out
- * @return {clay.Matrix3}
- */
- Matrix3.identity = function (out) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].identity(out.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Matrix3} a
- * @return {clay.Matrix3}
- */
- Matrix3.invert = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].invert(out.array, a.array);
- return out;
- };
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Matrix3} a
- * @param {clay.Matrix3} b
- * @return {clay.Matrix3}
- */
- Matrix3.mul = function (out, a, b) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].mul(out.array, a.array, b.array);
- out._dirty = true;
- return out;
- };
- /**
- * @function
- * @param {clay.Matrix3} out
- * @param {clay.Matrix3} a
- * @param {clay.Matrix3} b
- * @return {clay.Matrix3}
- */
- Matrix3.multiply = Matrix3.mul;
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Matrix2d} a
- * @return {clay.Matrix3}
- */
- Matrix3.fromMat2d = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromMat2d(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Matrix4} a
- * @return {clay.Matrix3}
- */
- Matrix3.fromMat4 = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromMat4(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Quaternion} a
- * @return {clay.Matrix3}
- */
- Matrix3.fromQuat = function (out, q) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].fromQuat(out.array, q.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Matrix4} a
- * @return {clay.Matrix3}
- */
- Matrix3.normalFromMat4 = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].normalFromMat4(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Matrix3} a
- * @param {number} rad
- * @return {clay.Matrix3}
- */
- Matrix3.rotate = function (out, a, rad) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].rotate(out.array, a.array, rad);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Matrix3} a
- * @param {clay.Vector2} v
- * @return {clay.Matrix3}
- */
- Matrix3.scale = function (out, a, v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].scale(out.array, a.array, v.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Matrix3} a
- * @return {clay.Matrix3}
- */
- Matrix3.transpose = function (out, a) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].transpose(out.array, a.array);
- out._dirty = true;
- return out;
- };
- /**
- * @param {clay.Matrix3} out
- * @param {clay.Matrix3} a
- * @param {clay.Vector2} v
- * @return {clay.Matrix3}
- */
- Matrix3.translate = function (out, a, v) {
- __WEBPACK_IMPORTED_MODULE_0__glmatrix_mat3__["a" /* default */].translate(out.array, a.array, v.array);
- out._dirty = true;
- return out;
- };
- /* harmony default export */ __webpack_exports__["a"] = (Matrix3);
- /***/
- }),
- /* 141 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zrender_lib_animation_Animator__ = __webpack_require__(142);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_zrender_lib_animation_Animator___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_zrender_lib_animation_Animator__);
- var animatableMixin = {
- _animators: null,
- getAnimators: function () {
- this._animators = this._animators || [];
- return this._animators;
- },
- animate: function (path, opts) {
- this._animators = this._animators || [];
- var el = this;
- var target;
- if (path) {
- var pathSplitted = path.split('.');
- var prop = el;
- for (var i = 0, l = pathSplitted.length; i < l; i++) {
- if (!prop) {
- continue;
- }
- prop = prop[pathSplitted[i]];
- }
- if (prop) {
- target = prop;
- }
- }
- else {
- target = el;
- }
- if (target == null) {
- throw new Error('Target ' + path + ' not exists');
- }
- var animators = this._animators;
- var animator = new __WEBPACK_IMPORTED_MODULE_0_zrender_lib_animation_Animator___default.a(target, opts);
- var self = this;
- animator.during(function () {
- if (self.__zr) {
- self.__zr.refresh();
- }
- }).done(function () {
- var idx = animators.indexOf(animator);
- if (idx >= 0) {
- animators.splice(idx, 1);
- }
- });
- animators.push(animator);
- if (this.__zr) {
- this.__zr.animation.addAnimator(animator);
- }
- return animator;
- },
- stopAnimation: function (forwardToLast) {
- this._animators = this._animators || [];
- var animators = this._animators;
- var len = animators.length;
- for (var i = 0; i < len; i++) {
- animators[i].stop(forwardToLast);
- }
- animators.length = 0;
- return this;
- },
- addAnimatorsToZr: function (zr) {
- if (this._animators) {
- for (var i = 0; i < this._animators.length; i++) {
- zr.animation.addAnimator(this._animators[i]);
- }
- }
- },
- removeAnimatorsFromZr: function (zr) {
- if (this._animators) {
- for (var i = 0; i < this._animators.length; i++) {
- zr.animation.removeAnimator(this._animators[i]);
- }
- }
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (animatableMixin);
- /***/
- }),
- /* 142 */
- /***/ (function (module, exports, __webpack_require__) {
- var Clip = __webpack_require__(143);
- var color = __webpack_require__(145);
- var _util = __webpack_require__(13);
- var isArrayLike = _util.isArrayLike;
- /**
- * @module echarts/animation/Animator
- */
- var arraySlice = Array.prototype.slice;
- function defaultGetter(target, key) {
- return target[key];
- }
- function defaultSetter(target, key, value) {
- target[key] = value;
- }
- /**
- * @param {number} p0
- * @param {number} p1
- * @param {number} percent
- * @return {number}
- */
- function interpolateNumber(p0, p1, percent) {
- return (p1 - p0) * percent + p0;
- }
- /**
- * @param {string} p0
- * @param {string} p1
- * @param {number} percent
- * @return {string}
- */
- function interpolateString(p0, p1, percent) {
- return percent > 0.5 ? p1 : p0;
- }
- /**
- * @param {Array} p0
- * @param {Array} p1
- * @param {number} percent
- * @param {Array} out
- * @param {number} arrDim
- */
- function interpolateArray(p0, p1, percent, out, arrDim) {
- var len = p0.length;
- if (arrDim == 1) {
- for (var i = 0; i < len; i++) {
- out[i] = interpolateNumber(p0[i], p1[i], percent);
- }
- } else {
- var len2 = len && p0[0].length;
- for (var i = 0; i < len; i++) {
- for (var j = 0; j < len2; j++) {
- out[i][j] = interpolateNumber(p0[i][j], p1[i][j], percent);
- }
- }
- }
- } // arr0 is source array, arr1 is target array.
- // Do some preprocess to avoid error happened when interpolating from arr0 to arr1
- function fillArr(arr0, arr1, arrDim) {
- var arr0Len = arr0.length;
- var arr1Len = arr1.length;
- if (arr0Len !== arr1Len) {
- // FIXME Not work for TypedArray
- var isPreviousLarger = arr0Len > arr1Len;
- if (isPreviousLarger) {
- // Cut the previous
- arr0.length = arr1Len;
- } else {
- // Fill the previous
- for (var i = arr0Len; i < arr1Len; i++) {
- arr0.push(arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i]));
- }
- }
- } // Handling NaN value
- var len2 = arr0[0] && arr0[0].length;
- for (var i = 0; i < arr0.length; i++) {
- if (arrDim === 1) {
- if (isNaN(arr0[i])) {
- arr0[i] = arr1[i];
- }
- } else {
- for (var j = 0; j < len2; j++) {
- if (isNaN(arr0[i][j])) {
- arr0[i][j] = arr1[i][j];
- }
- }
- }
- }
- }
- /**
- * @param {Array} arr0
- * @param {Array} arr1
- * @param {number} arrDim
- * @return {boolean}
- */
- function isArraySame(arr0, arr1, arrDim) {
- if (arr0 === arr1) {
- return true;
- }
- var len = arr0.length;
- if (len !== arr1.length) {
- return false;
- }
- if (arrDim === 1) {
- for (var i = 0; i < len; i++) {
- if (arr0[i] !== arr1[i]) {
- return false;
- }
- }
- } else {
- var len2 = arr0[0].length;
- for (var i = 0; i < len; i++) {
- for (var j = 0; j < len2; j++) {
- if (arr0[i][j] !== arr1[i][j]) {
- return false;
- }
- }
- }
- }
- return true;
- }
- /**
- * Catmull Rom interpolate array
- * @param {Array} p0
- * @param {Array} p1
- * @param {Array} p2
- * @param {Array} p3
- * @param {number} t
- * @param {number} t2
- * @param {number} t3
- * @param {Array} out
- * @param {number} arrDim
- */
- function catmullRomInterpolateArray(p0, p1, p2, p3, t, t2, t3, out, arrDim) {
- var len = p0.length;
- if (arrDim == 1) {
- for (var i = 0; i < len; i++) {
- out[i] = catmullRomInterpolate(p0[i], p1[i], p2[i], p3[i], t, t2, t3);
- }
- } else {
- var len2 = p0[0].length;
- for (var i = 0; i < len; i++) {
- for (var j = 0; j < len2; j++) {
- out[i][j] = catmullRomInterpolate(p0[i][j], p1[i][j], p2[i][j], p3[i][j], t, t2, t3);
- }
- }
- }
- }
- /**
- * Catmull Rom interpolate number
- * @param {number} p0
- * @param {number} p1
- * @param {number} p2
- * @param {number} p3
- * @param {number} t
- * @param {number} t2
- * @param {number} t3
- * @return {number}
- */
- function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) {
- var v0 = (p2 - p0) * 0.5;
- var v1 = (p3 - p1) * 0.5;
- return (2 * (p1 - p2) + v0 + v1) * t3 + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + v0 * t + p1;
- }
- function cloneValue(value) {
- if (isArrayLike(value)) {
- var len = value.length;
- if (isArrayLike(value[0])) {
- var ret = [];
- for (var i = 0; i < len; i++) {
- ret.push(arraySlice.call(value[i]));
- }
- return ret;
- }
- return arraySlice.call(value);
- }
- return value;
- }
- function rgba2String(rgba) {
- rgba[0] = Math.floor(rgba[0]);
- rgba[1] = Math.floor(rgba[1]);
- rgba[2] = Math.floor(rgba[2]);
- return 'rgba(' + rgba.join(',') + ')';
- }
- function getArrayDim(keyframes) {
- var lastValue = keyframes[keyframes.length - 1].value;
- return isArrayLike(lastValue && lastValue[0]) ? 2 : 1;
- }
- function createTrackClip(animator, easing, oneTrackDone, keyframes, propName, forceAnimate) {
- var getter = animator._getter;
- var setter = animator._setter;
- var useSpline = easing === 'spline';
- var trackLen = keyframes.length;
- if (!trackLen) {
- return;
- } // Guess data type
- var firstVal = keyframes[0].value;
- var isValueArray = isArrayLike(firstVal);
- var isValueColor = false;
- var isValueString = false; // For vertices morphing
- var arrDim = isValueArray ? getArrayDim(keyframes) : 0;
- var trackMaxTime; // Sort keyframe as ascending
- keyframes.sort(function (a, b) {
- return a.time - b.time;
- });
- trackMaxTime = keyframes[trackLen - 1].time; // Percents of each keyframe
- var kfPercents = []; // Value of each keyframe
- var kfValues = [];
- var prevValue = keyframes[0].value;
- var isAllValueEqual = true;
- for (var i = 0; i < trackLen; i++) {
- kfPercents.push(keyframes[i].time / trackMaxTime); // Assume value is a color when it is a string
- var value = keyframes[i].value; // Check if value is equal, deep check if value is array
- if (!(isValueArray && isArraySame(value, prevValue, arrDim) || !isValueArray && value === prevValue)) {
- isAllValueEqual = false;
- }
- prevValue = value; // Try converting a string to a color array
- if (typeof value == 'string') {
- var colorArray = color.parse(value);
- if (colorArray) {
- value = colorArray;
- isValueColor = true;
- } else {
- isValueString = true;
- }
- }
- kfValues.push(value);
- }
- if (!forceAnimate && isAllValueEqual) {
- return;
- }
- var lastValue = kfValues[trackLen - 1]; // Polyfill array and NaN value
- for (var i = 0; i < trackLen - 1; i++) {
- if (isValueArray) {
- fillArr(kfValues[i], lastValue, arrDim);
- } else {
- if (isNaN(kfValues[i]) && !isNaN(lastValue) && !isValueString && !isValueColor) {
- kfValues[i] = lastValue;
- }
- }
- }
- isValueArray && fillArr(getter(animator._target, propName), lastValue, arrDim); // Cache the key of last frame to speed up when
- // animation playback is sequency
- var lastFrame = 0;
- var lastFramePercent = 0;
- var start;
- var w;
- var p0;
- var p1;
- var p2;
- var p3;
- if (isValueColor) {
- var rgba = [0, 0, 0, 0];
- }
- var onframe = function (target, percent) {
- // Find the range keyframes
- // kf1-----kf2---------current--------kf3
- // find kf2 and kf3 and do interpolation
- var frame; // In the easing function like elasticOut, percent may less than 0
- if (percent < 0) {
- frame = 0;
- } else if (percent < lastFramePercent) {
- // Start from next key
- // PENDING start from lastFrame ?
- start = Math.min(lastFrame + 1, trackLen - 1);
- for (frame = start; frame >= 0; frame--) {
- if (kfPercents[frame] <= percent) {
- break;
- }
- } // PENDING really need to do this ?
- frame = Math.min(frame, trackLen - 2);
- } else {
- for (frame = lastFrame; frame < trackLen; frame++) {
- if (kfPercents[frame] > percent) {
- break;
- }
- }
- frame = Math.min(frame - 1, trackLen - 2);
- }
- lastFrame = frame;
- lastFramePercent = percent;
- var range = kfPercents[frame + 1] - kfPercents[frame];
- if (range === 0) {
- return;
- } else {
- w = (percent - kfPercents[frame]) / range;
- }
- if (useSpline) {
- p1 = kfValues[frame];
- p0 = kfValues[frame === 0 ? frame : frame - 1];
- p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1];
- p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2];
- if (isValueArray) {
- catmullRomInterpolateArray(p0, p1, p2, p3, w, w * w, w * w * w, getter(target, propName), arrDim);
- } else {
- var value;
- if (isValueColor) {
- value = catmullRomInterpolateArray(p0, p1, p2, p3, w, w * w, w * w * w, rgba, 1);
- value = rgba2String(rgba);
- } else if (isValueString) {
- // String is step(0.5)
- return interpolateString(p1, p2, w);
- } else {
- value = catmullRomInterpolate(p0, p1, p2, p3, w, w * w, w * w * w);
- }
- setter(target, propName, value);
- }
- } else {
- if (isValueArray) {
- interpolateArray(kfValues[frame], kfValues[frame + 1], w, getter(target, propName), arrDim);
- } else {
- var value;
- if (isValueColor) {
- interpolateArray(kfValues[frame], kfValues[frame + 1], w, rgba, 1);
- value = rgba2String(rgba);
- } else if (isValueString) {
- // String is step(0.5)
- return interpolateString(kfValues[frame], kfValues[frame + 1], w);
- } else {
- value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w);
- }
- setter(target, propName, value);
- }
- }
- };
- var clip = new Clip({
- target: animator._target,
- life: trackMaxTime,
- loop: animator._loop,
- delay: animator._delay,
- onframe: onframe,
- ondestroy: oneTrackDone
- });
- if (easing && easing !== 'spline') {
- clip.easing = easing;
- }
- return clip;
- }
- /**
- * @alias module:zrender/animation/Animator
- * @constructor
- * @param {Object} target
- * @param {boolean} loop
- * @param {Function} getter
- * @param {Function} setter
- */
- var Animator = function (target, loop, getter, setter) {
- this._tracks = {};
- this._target = target;
- this._loop = loop || false;
- this._getter = getter || defaultGetter;
- this._setter = setter || defaultSetter;
- this._clipCount = 0;
- this._delay = 0;
- this._doneList = [];
- this._onframeList = [];
- this._clipList = [];
- };
- Animator.prototype = {
- /**
- * 设置动画关键帧
- * @param {number} time 关键帧时间,å•使˜¯ms
- * @param {Object} props 关键帧的属性值,key-value表示
- * @return {module:zrender/animation/Animator}
- */
- when: function (time
- /* ms */
- , props) {
- var tracks = this._tracks;
- for (var propName in props) {
- if (!props.hasOwnProperty(propName)) {
- continue;
- }
- if (!tracks[propName]) {
- tracks[propName] = []; // Invalid value
- var value = this._getter(this._target, propName);
- if (value == null) {
- // zrLog('Invalid property ' + propName);
- continue;
- } // If time is 0
- // Then props is given initialize value
- // Else
- // Initialize value from current prop value
- if (time !== 0) {
- tracks[propName].push({
- time: 0,
- value: cloneValue(value)
- });
- }
- }
- tracks[propName].push({
- time: time,
- value: props[propName]
- });
- }
- return this;
- },
- /**
- * æ·»åŠ åŠ¨ç”»æ¯ä¸€å¸§çš„回调函数
- * @param {Function} callback
- * @return {module:zrender/animation/Animator}
- */
- during: function (callback) {
- this._onframeList.push(callback);
- return this;
- },
- pause: function () {
- for (var i = 0; i < this._clipList.length; i++) {
- this._clipList[i].pause();
- }
- this._paused = true;
- },
- resume: function () {
- for (var i = 0; i < this._clipList.length; i++) {
- this._clipList[i].resume();
- }
- this._paused = false;
- },
- isPaused: function () {
- return !!this._paused;
- },
- _doneCallback: function () {
- // Clear all tracks
- this._tracks = {}; // Clear all clips
- this._clipList.length = 0;
- var doneList = this._doneList;
- var len = doneList.length;
- for (var i = 0; i < len; i++) {
- doneList[i].call(this);
- }
- },
- /**
- * 开始执行动画
- * @param {string|Function} [easing]
- * 动画缓动函数,详è§{@link module:zrender/animation/easing}
- * @param {boolean} forceAnimate
- * @return {module:zrender/animation/Animator}
- */
- start: function (easing, forceAnimate) {
- var self = this;
- var clipCount = 0;
- var oneTrackDone = function () {
- clipCount--;
- if (!clipCount) {
- self._doneCallback();
- }
- };
- var lastClip;
- for (var propName in this._tracks) {
- if (!this._tracks.hasOwnProperty(propName)) {
- continue;
- }
- var clip = createTrackClip(this, easing, oneTrackDone, this._tracks[propName], propName, forceAnimate);
- if (clip) {
- this._clipList.push(clip);
- clipCount++; // If start after added to animation
- if (this.animation) {
- this.animation.addClip(clip);
- }
- lastClip = clip;
- }
- } // Add during callback on the last clip
- if (lastClip) {
- var oldOnFrame = lastClip.onframe;
- lastClip.onframe = function (target, percent) {
- oldOnFrame(target, percent);
- for (var i = 0; i < self._onframeList.length; i++) {
- self._onframeList[i](target, percent);
- }
- };
- } // This optimization will help the case that in the upper application
- // the view may be refreshed frequently, where animation will be
- // called repeatly but nothing changed.
- if (!clipCount) {
- this._doneCallback();
- }
- return this;
- },
- /**
- * åœæ¢åŠ¨ç”»
- * @param {boolean} forwardToLast If move to last frame before stop
- */
- stop: function (forwardToLast) {
- var clipList = this._clipList;
- var animation = this.animation;
- for (var i = 0; i < clipList.length; i++) {
- var clip = clipList[i];
- if (forwardToLast) {
- // Move to last frame before stop
- clip.onframe(this._target, 1);
- }
- animation && animation.removeClip(clip);
- }
- clipList.length = 0;
- },
- /**
- * 设置动画延迟开始的时间
- * @param {number} time å•ä½ms
- * @return {module:zrender/animation/Animator}
- */
- delay: function (time) {
- this._delay = time;
- return this;
- },
- /**
- * æ·»åŠ åŠ¨ç”»ç»“æŸçš„回调
- * @param {Function} cb
- * @return {module:zrender/animation/Animator}
- */
- done: function (cb) {
- if (cb) {
- this._doneList.push(cb);
- }
- return this;
- },
- /**
- * @return {Array.<module:zrender/animation/Clip>}
- */
- getClips: function () {
- return this._clipList;
- }
- };
- var _default = Animator;
- module.exports = _default;
- /***/
- }),
- /* 143 */
- /***/ (function (module, exports, __webpack_require__) {
- var easingFuncs = __webpack_require__(144);
- /**
- * 动画主控制器
- * @config target 动画对象,å¯ä»¥æ˜¯æ•°ç»„,如果是数组的è¯ä¼šæ‰¹é‡åˆ†å‘onframeç‰äº‹ä»¶
- * @config life(1000) 动画时长
- * @config delay(0) 动画延迟时间
- * @config loop(true)
- * @config gap(0) 循环的间隔时间
- * @config onframe
- * @config easing(optional)
- * @config ondestroy(optional)
- * @config onrestart(optional)
- *
- * TODO pause
- */
- function Clip(options) {
- this._target = options.target; // 生命周期
- this._life = options.life || 1000; // å»¶æ—¶
- this._delay = options.delay || 0; // 开始时间
- // this._startTime = new Date().getTime() + this._delay;// å•使¯«ç§’
- this._initialized = false; // 是å¦å¾ªçޝ
- this.loop = options.loop == null ? false : options.loop;
- this.gap = options.gap || 0;
- this.easing = options.easing || 'Linear';
- this.onframe = options.onframe;
- this.ondestroy = options.ondestroy;
- this.onrestart = options.onrestart;
- this._pausedTime = 0;
- this._paused = false;
- }
- Clip.prototype = {
- constructor: Clip,
- step: function (globalTime, deltaTime) {
- // Set startTime on first step, or _startTime may has milleseconds different between clips
- // PENDING
- if (!this._initialized) {
- this._startTime = globalTime + this._delay;
- this._initialized = true;
- }
- if (this._paused) {
- this._pausedTime += deltaTime;
- return;
- }
- var percent = (globalTime - this._startTime - this._pausedTime) / this._life; // 还没开始
- if (percent < 0) {
- return;
- }
- percent = Math.min(percent, 1);
- var easing = this.easing;
- var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing;
- var schedule = typeof easingFunc === 'function' ? easingFunc(percent) : percent;
- this.fire('frame', schedule); // 结æŸ
- if (percent == 1) {
- if (this.loop) {
- this.restart(globalTime); // 釿–°å¼€å§‹å‘¨æœŸ
- // æŠ›å‡ºè€Œä¸æ˜¯ç›´æŽ¥è°ƒç”¨äº‹ä»¶ç›´åˆ° stage.update åŽå†ç»Ÿä¸€è°ƒç”¨è¿™äº›äº‹ä»¶
- return 'restart';
- } // 动画完æˆå°†è¿™ä¸ªæŽ§åˆ¶å™¨æ ‡è¯†ä¸ºå¾…åˆ é™¤
- // 在Animation.updateä¸è¿›è¡Œæ‰¹é‡åˆ 除
- this._needsRemove = true;
- return 'destroy';
- }
- return null;
- },
- restart: function (globalTime) {
- var remainder = (globalTime - this._startTime - this._pausedTime) % this._life;
- this._startTime = globalTime - remainder + this.gap;
- this._pausedTime = 0;
- this._needsRemove = false;
- },
- fire: function (eventType, arg) {
- eventType = 'on' + eventType;
- if (this[eventType]) {
- this[eventType](this._target, arg);
- }
- },
- pause: function () {
- this._paused = true;
- },
- resume: function () {
- this._paused = false;
- }
- };
- var _default = Clip;
- module.exports = _default;
- /***/
- }),
- /* 144 */
- /***/ (function (module, exports) {
- /**
- * ç¼“åŠ¨ä»£ç æ¥è‡ª https://github.com/sole/tween.js/blob/master/src/Tween.js
- * @see http://sole.github.io/tween.js/examples/03_graphs.html
- * @exports zrender/animation/easing
- */
- var easing = {
- /**
- * @param {number} k
- * @return {number}
- */
- linear: function (k) {
- return k;
- },
- /**
- * @param {number} k
- * @return {number}
- */
- quadraticIn: function (k) {
- return k * k;
- },
- /**
- * @param {number} k
- * @return {number}
- */
- quadraticOut: function (k) {
- return k * (2 - k);
- },
- /**
- * @param {number} k
- * @return {number}
- */
- quadraticInOut: function (k) {
- if ((k *= 2) < 1) {
- return 0.5 * k * k;
- }
- return -0.5 * (--k * (k - 2) - 1);
- },
- // 三次方的缓动(t^3)
- /**
- * @param {number} k
- * @return {number}
- */
- cubicIn: function (k) {
- return k * k * k;
- },
- /**
- * @param {number} k
- * @return {number}
- */
- cubicOut: function (k) {
- return --k * k * k + 1;
- },
- /**
- * @param {number} k
- * @return {number}
- */
- cubicInOut: function (k) {
- if ((k *= 2) < 1) {
- return 0.5 * k * k * k;
- }
- return 0.5 * ((k -= 2) * k * k + 2);
- },
- // 四次方的缓动(t^4)
- /**
- * @param {number} k
- * @return {number}
- */
- quarticIn: function (k) {
- return k * k * k * k;
- },
- /**
- * @param {number} k
- * @return {number}
- */
- quarticOut: function (k) {
- return 1 - --k * k * k * k;
- },
- /**
- * @param {number} k
- * @return {number}
- */
- quarticInOut: function (k) {
- if ((k *= 2) < 1) {
- return 0.5 * k * k * k * k;
- }
- return -0.5 * ((k -= 2) * k * k * k - 2);
- },
- // 五次方的缓动(t^5)
- /**
- * @param {number} k
- * @return {number}
- */
- quinticIn: function (k) {
- return k * k * k * k * k;
- },
- /**
- * @param {number} k
- * @return {number}
- */
- quinticOut: function (k) {
- return --k * k * k * k * k + 1;
- },
- /**
- * @param {number} k
- * @return {number}
- */
- quinticInOut: function (k) {
- if ((k *= 2) < 1) {
- return 0.5 * k * k * k * k * k;
- }
- return 0.5 * ((k -= 2) * k * k * k * k + 2);
- },
- // æ£å¼¦æ›²çº¿çš„缓动(sin(t))
- /**
- * @param {number} k
- * @return {number}
- */
- sinusoidalIn: function (k) {
- return 1 - Math.cos(k * Math.PI / 2);
- },
- /**
- * @param {number} k
- * @return {number}
- */
- sinusoidalOut: function (k) {
- return Math.sin(k * Math.PI / 2);
- },
- /**
- * @param {number} k
- * @return {number}
- */
- sinusoidalInOut: function (k) {
- return 0.5 * (1 - Math.cos(Math.PI * k));
- },
- // 指数曲线的缓动(2^t)
- /**
- * @param {number} k
- * @return {number}
- */
- exponentialIn: function (k) {
- return k === 0 ? 0 : Math.pow(1024, k - 1);
- },
- /**
- * @param {number} k
- * @return {number}
- */
- exponentialOut: function (k) {
- return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
- },
- /**
- * @param {number} k
- * @return {number}
- */
- exponentialInOut: function (k) {
- if (k === 0) {
- return 0;
- }
- if (k === 1) {
- return 1;
- }
- if ((k *= 2) < 1) {
- return 0.5 * Math.pow(1024, k - 1);
- }
- return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
- },
- // 圆形曲线的缓动(sqrt(1-t^2))
- /**
- * @param {number} k
- * @return {number}
- */
- circularIn: function (k) {
- return 1 - Math.sqrt(1 - k * k);
- },
- /**
- * @param {number} k
- * @return {number}
- */
- circularOut: function (k) {
- return Math.sqrt(1 - --k * k);
- },
- /**
- * @param {number} k
- * @return {number}
- */
- circularInOut: function (k) {
- if ((k *= 2) < 1) {
- return -0.5 * (Math.sqrt(1 - k * k) - 1);
- }
- return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
- },
- // åˆ›å»ºç±»ä¼¼äºŽå¼¹ç°§åœ¨åœæ¢å‰æ¥å›žæŒ¯è¡çš„动画
- /**
- * @param {number} k
- * @return {number}
- */
- elasticIn: function (k) {
- var s;
- var a = 0.1;
- var p = 0.4;
- if (k === 0) {
- return 0;
- }
- if (k === 1) {
- return 1;
- }
- if (!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p * Math.asin(1 / a) / (2 * Math.PI);
- }
- return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
- },
- /**
- * @param {number} k
- * @return {number}
- */
- elasticOut: function (k) {
- var s;
- var a = 0.1;
- var p = 0.4;
- if (k === 0) {
- return 0;
- }
- if (k === 1) {
- return 1;
- }
- if (!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p * Math.asin(1 / a) / (2 * Math.PI);
- }
- return a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1;
- },
- /**
- * @param {number} k
- * @return {number}
- */
- elasticInOut: function (k) {
- var s;
- var a = 0.1;
- var p = 0.4;
- if (k === 0) {
- return 0;
- }
- if (k === 1) {
- return 1;
- }
- if (!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p * Math.asin(1 / a) / (2 * Math.PI);
- }
- if ((k *= 2) < 1) {
- return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
- }
- return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
- },
- // 在æŸä¸€åŠ¨ç”»å¼€å§‹æ²¿æŒ‡ç¤ºçš„è·¯å¾„è¿›è¡ŒåŠ¨ç”»å¤„ç†å‰ç¨ç¨æ”¶å›žè¯¥åŠ¨ç”»çš„ç§»åŠ¨
- /**
- * @param {number} k
- * @return {number}
- */
- backIn: function (k) {
- var s = 1.70158;
- return k * k * ((s + 1) * k - s);
- },
- /**
- * @param {number} k
- * @return {number}
- */
- backOut: function (k) {
- var s = 1.70158;
- return --k * k * ((s + 1) * k + s) + 1;
- },
- /**
- * @param {number} k
- * @return {number}
- */
- backInOut: function (k) {
- var s = 1.70158 * 1.525;
- if ((k *= 2) < 1) {
- return 0.5 * (k * k * ((s + 1) * k - s));
- }
- return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
- },
- // 创建弹跳效果
- /**
- * @param {number} k
- * @return {number}
- */
- bounceIn: function (k) {
- return 1 - easing.bounceOut(1 - k);
- },
- /**
- * @param {number} k
- * @return {number}
- */
- bounceOut: function (k) {
- if (k < 1 / 2.75) {
- return 7.5625 * k * k;
- } else if (k < 2 / 2.75) {
- return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
- } else if (k < 2.5 / 2.75) {
- return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
- } else {
- return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
- }
- },
- /**
- * @param {number} k
- * @return {number}
- */
- bounceInOut: function (k) {
- if (k < 0.5) {
- return easing.bounceIn(k * 2) * 0.5;
- }
- return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
- }
- };
- var _default = easing;
- module.exports = _default;
- /***/
- }),
- /* 145 */
- /***/ (function (module, exports, __webpack_require__) {
- var LRU = __webpack_require__(60);
- var kCSSColorTable = {
- 'transparent': [0, 0, 0, 0],
- 'aliceblue': [240, 248, 255, 1],
- 'antiquewhite': [250, 235, 215, 1],
- 'aqua': [0, 255, 255, 1],
- 'aquamarine': [127, 255, 212, 1],
- 'azure': [240, 255, 255, 1],
- 'beige': [245, 245, 220, 1],
- 'bisque': [255, 228, 196, 1],
- 'black': [0, 0, 0, 1],
- 'blanchedalmond': [255, 235, 205, 1],
- 'blue': [0, 0, 255, 1],
- 'blueviolet': [138, 43, 226, 1],
- 'brown': [165, 42, 42, 1],
- 'burlywood': [222, 184, 135, 1],
- 'cadetblue': [95, 158, 160, 1],
- 'chartreuse': [127, 255, 0, 1],
- 'chocolate': [210, 105, 30, 1],
- 'coral': [255, 127, 80, 1],
- 'cornflowerblue': [100, 149, 237, 1],
- 'cornsilk': [255, 248, 220, 1],
- 'crimson': [220, 20, 60, 1],
- 'cyan': [0, 255, 255, 1],
- 'darkblue': [0, 0, 139, 1],
- 'darkcyan': [0, 139, 139, 1],
- 'darkgoldenrod': [184, 134, 11, 1],
- 'darkgray': [169, 169, 169, 1],
- 'darkgreen': [0, 100, 0, 1],
- 'darkgrey': [169, 169, 169, 1],
- 'darkkhaki': [189, 183, 107, 1],
- 'darkmagenta': [139, 0, 139, 1],
- 'darkolivegreen': [85, 107, 47, 1],
- 'darkorange': [255, 140, 0, 1],
- 'darkorchid': [153, 50, 204, 1],
- 'darkred': [139, 0, 0, 1],
- 'darksalmon': [233, 150, 122, 1],
- 'darkseagreen': [143, 188, 143, 1],
- 'darkslateblue': [72, 61, 139, 1],
- 'darkslategray': [47, 79, 79, 1],
- 'darkslategrey': [47, 79, 79, 1],
- 'darkturquoise': [0, 206, 209, 1],
- 'darkviolet': [148, 0, 211, 1],
- 'deeppink': [255, 20, 147, 1],
- 'deepskyblue': [0, 191, 255, 1],
- 'dimgray': [105, 105, 105, 1],
- 'dimgrey': [105, 105, 105, 1],
- 'dodgerblue': [30, 144, 255, 1],
- 'firebrick': [178, 34, 34, 1],
- 'floralwhite': [255, 250, 240, 1],
- 'forestgreen': [34, 139, 34, 1],
- 'fuchsia': [255, 0, 255, 1],
- 'gainsboro': [220, 220, 220, 1],
- 'ghostwhite': [248, 248, 255, 1],
- 'gold': [255, 215, 0, 1],
- 'goldenrod': [218, 165, 32, 1],
- 'gray': [128, 128, 128, 1],
- 'green': [0, 128, 0, 1],
- 'greenyellow': [173, 255, 47, 1],
- 'grey': [128, 128, 128, 1],
- 'honeydew': [240, 255, 240, 1],
- 'hotpink': [255, 105, 180, 1],
- 'indianred': [205, 92, 92, 1],
- 'indigo': [75, 0, 130, 1],
- 'ivory': [255, 255, 240, 1],
- 'khaki': [240, 230, 140, 1],
- 'lavender': [230, 230, 250, 1],
- 'lavenderblush': [255, 240, 245, 1],
- 'lawngreen': [124, 252, 0, 1],
- 'lemonchiffon': [255, 250, 205, 1],
- 'lightblue': [173, 216, 230, 1],
- 'lightcoral': [240, 128, 128, 1],
- 'lightcyan': [224, 255, 255, 1],
- 'lightgoldenrodyellow': [250, 250, 210, 1],
- 'lightgray': [211, 211, 211, 1],
- 'lightgreen': [144, 238, 144, 1],
- 'lightgrey': [211, 211, 211, 1],
- 'lightpink': [255, 182, 193, 1],
- 'lightsalmon': [255, 160, 122, 1],
- 'lightseagreen': [32, 178, 170, 1],
- 'lightskyblue': [135, 206, 250, 1],
- 'lightslategray': [119, 136, 153, 1],
- 'lightslategrey': [119, 136, 153, 1],
- 'lightsteelblue': [176, 196, 222, 1],
- 'lightyellow': [255, 255, 224, 1],
- 'lime': [0, 255, 0, 1],
- 'limegreen': [50, 205, 50, 1],
- 'linen': [250, 240, 230, 1],
- 'magenta': [255, 0, 255, 1],
- 'maroon': [128, 0, 0, 1],
- 'mediumaquamarine': [102, 205, 170, 1],
- 'mediumblue': [0, 0, 205, 1],
- 'mediumorchid': [186, 85, 211, 1],
- 'mediumpurple': [147, 112, 219, 1],
- 'mediumseagreen': [60, 179, 113, 1],
- 'mediumslateblue': [123, 104, 238, 1],
- 'mediumspringgreen': [0, 250, 154, 1],
- 'mediumturquoise': [72, 209, 204, 1],
- 'mediumvioletred': [199, 21, 133, 1],
- 'midnightblue': [25, 25, 112, 1],
- 'mintcream': [245, 255, 250, 1],
- 'mistyrose': [255, 228, 225, 1],
- 'moccasin': [255, 228, 181, 1],
- 'navajowhite': [255, 222, 173, 1],
- 'navy': [0, 0, 128, 1],
- 'oldlace': [253, 245, 230, 1],
- 'olive': [128, 128, 0, 1],
- 'olivedrab': [107, 142, 35, 1],
- 'orange': [255, 165, 0, 1],
- 'orangered': [255, 69, 0, 1],
- 'orchid': [218, 112, 214, 1],
- 'palegoldenrod': [238, 232, 170, 1],
- 'palegreen': [152, 251, 152, 1],
- 'paleturquoise': [175, 238, 238, 1],
- 'palevioletred': [219, 112, 147, 1],
- 'papayawhip': [255, 239, 213, 1],
- 'peachpuff': [255, 218, 185, 1],
- 'peru': [205, 133, 63, 1],
- 'pink': [255, 192, 203, 1],
- 'plum': [221, 160, 221, 1],
- 'powderblue': [176, 224, 230, 1],
- 'purple': [128, 0, 128, 1],
- 'red': [255, 0, 0, 1],
- 'rosybrown': [188, 143, 143, 1],
- 'royalblue': [65, 105, 225, 1],
- 'saddlebrown': [139, 69, 19, 1],
- 'salmon': [250, 128, 114, 1],
- 'sandybrown': [244, 164, 96, 1],
- 'seagreen': [46, 139, 87, 1],
- 'seashell': [255, 245, 238, 1],
- 'sienna': [160, 82, 45, 1],
- 'silver': [192, 192, 192, 1],
- 'skyblue': [135, 206, 235, 1],
- 'slateblue': [106, 90, 205, 1],
- 'slategray': [112, 128, 144, 1],
- 'slategrey': [112, 128, 144, 1],
- 'snow': [255, 250, 250, 1],
- 'springgreen': [0, 255, 127, 1],
- 'steelblue': [70, 130, 180, 1],
- 'tan': [210, 180, 140, 1],
- 'teal': [0, 128, 128, 1],
- 'thistle': [216, 191, 216, 1],
- 'tomato': [255, 99, 71, 1],
- 'turquoise': [64, 224, 208, 1],
- 'violet': [238, 130, 238, 1],
- 'wheat': [245, 222, 179, 1],
- 'white': [255, 255, 255, 1],
- 'whitesmoke': [245, 245, 245, 1],
- 'yellow': [255, 255, 0, 1],
- 'yellowgreen': [154, 205, 50, 1]
- };
- function clampCssByte(i) {
- // Clamp to integer 0 .. 255.
- i = Math.round(i); // Seems to be what Chrome does (vs truncation).
- return i < 0 ? 0 : i > 255 ? 255 : i;
- }
- function clampCssAngle(i) {
- // Clamp to integer 0 .. 360.
- i = Math.round(i); // Seems to be what Chrome does (vs truncation).
- return i < 0 ? 0 : i > 360 ? 360 : i;
- }
- function clampCssFloat(f) {
- // Clamp to float 0.0 .. 1.0.
- return f < 0 ? 0 : f > 1 ? 1 : f;
- }
- function parseCssInt(str) {
- // int or percentage.
- if (str.length && str.charAt(str.length - 1) === '%') {
- return clampCssByte(parseFloat(str) / 100 * 255);
- }
- return clampCssByte(parseInt(str, 10));
- }
- function parseCssFloat(str) {
- // float or percentage.
- if (str.length && str.charAt(str.length - 1) === '%') {
- return clampCssFloat(parseFloat(str) / 100);
- }
- return clampCssFloat(parseFloat(str));
- }
- function cssHueToRgb(m1, m2, h) {
- if (h < 0) {
- h += 1;
- } else if (h > 1) {
- h -= 1;
- }
- if (h * 6 < 1) {
- return m1 + (m2 - m1) * h * 6;
- }
- if (h * 2 < 1) {
- return m2;
- }
- if (h * 3 < 2) {
- return m1 + (m2 - m1) * (2 / 3 - h) * 6;
- }
- return m1;
- }
- function lerpNumber(a, b, p) {
- return a + (b - a) * p;
- }
- function setRgba(out, r, g, b, a) {
- out[0] = r;
- out[1] = g;
- out[2] = b;
- out[3] = a;
- return out;
- }
- function copyRgba(out, a) {
- out[0] = a[0];
- out[1] = a[1];
- out[2] = a[2];
- out[3] = a[3];
- return out;
- }
- var colorCache = new LRU(20);
- var lastRemovedArr = null;
- function putToCache(colorStr, rgbaArr) {
- // Reuse removed array
- if (lastRemovedArr) {
- copyRgba(lastRemovedArr, rgbaArr);
- }
- lastRemovedArr = colorCache.put(colorStr, lastRemovedArr || rgbaArr.slice());
- }
- /**
- * @param {string} colorStr
- * @param {Array.<number>} out
- * @return {Array.<number>}
- * @memberOf module:zrender/util/color
- */
- function parse(colorStr, rgbaArr) {
- if (!colorStr) {
- return;
- }
- rgbaArr = rgbaArr || [];
- var cached = colorCache.get(colorStr);
- if (cached) {
- return copyRgba(rgbaArr, cached);
- } // colorStr may be not string
- colorStr = colorStr + ''; // Remove all whitespace, not compliant, but should just be more accepting.
- var str = colorStr.replace(/ /g, '').toLowerCase(); // Color keywords (and transparent) lookup.
- if (str in kCSSColorTable) {
- copyRgba(rgbaArr, kCSSColorTable[str]);
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- } // #abc and #abc123 syntax.
- if (str.charAt(0) === '#') {
- if (str.length === 4) {
- var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
- if (!(iv >= 0 && iv <= 0xfff)) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return; // Covers NaN.
- }
- setRgba(rgbaArr, (iv & 0xf00) >> 4 | (iv & 0xf00) >> 8, iv & 0xf0 | (iv & 0xf0) >> 4, iv & 0xf | (iv & 0xf) << 4, 1);
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- } else if (str.length === 7) {
- var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
- if (!(iv >= 0 && iv <= 0xffffff)) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return; // Covers NaN.
- }
- setRgba(rgbaArr, (iv & 0xff0000) >> 16, (iv & 0xff00) >> 8, iv & 0xff, 1);
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- }
- return;
- }
- var op = str.indexOf('('),
- ep = str.indexOf(')');
- if (op !== -1 && ep + 1 === str.length) {
- var fname = str.substr(0, op);
- var params = str.substr(op + 1, ep - (op + 1)).split(',');
- var alpha = 1; // To allow case fallthrough.
- switch (fname) {
- case 'rgba':
- if (params.length !== 4) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return;
- }
- alpha = parseCssFloat(params.pop());
- // jshint ignore:line
- // Fall through.
- case 'rgb':
- if (params.length !== 3) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return;
- }
- setRgba(rgbaArr, parseCssInt(params[0]), parseCssInt(params[1]), parseCssInt(params[2]), alpha);
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- case 'hsla':
- if (params.length !== 4) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return;
- }
- params[3] = parseCssFloat(params[3]);
- hsla2rgba(params, rgbaArr);
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- case 'hsl':
- if (params.length !== 3) {
- setRgba(rgbaArr, 0, 0, 0, 1);
- return;
- }
- hsla2rgba(params, rgbaArr);
- putToCache(colorStr, rgbaArr);
- return rgbaArr;
- default:
- return;
- }
- }
- setRgba(rgbaArr, 0, 0, 0, 1);
- return;
- }
- /**
- * @param {Array.<number>} hsla
- * @param {Array.<number>} rgba
- * @return {Array.<number>} rgba
- */
- function hsla2rgba(hsla, rgba) {
- var h = (parseFloat(hsla[0]) % 360 + 360) % 360 / 360; // 0 .. 1
- // NOTE(deanm): According to the CSS spec s/l should only be
- // percentages, but we don't bother and let float or percentage.
- var s = parseCssFloat(hsla[1]);
- var l = parseCssFloat(hsla[2]);
- var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
- var m1 = l * 2 - m2;
- rgba = rgba || [];
- setRgba(rgba, clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), clampCssByte(cssHueToRgb(m1, m2, h) * 255), clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255), 1);
- if (hsla.length === 4) {
- rgba[3] = hsla[3];
- }
- return rgba;
- }
- /**
- * @param {Array.<number>} rgba
- * @return {Array.<number>} hsla
- */
- function rgba2hsla(rgba) {
- if (!rgba) {
- return;
- } // RGB from 0 to 255
- var R = rgba[0] / 255;
- var G = rgba[1] / 255;
- var B = rgba[2] / 255;
- var vMin = Math.min(R, G, B); // Min. value of RGB
- var vMax = Math.max(R, G, B); // Max. value of RGB
- var delta = vMax - vMin; // Delta RGB value
- var L = (vMax + vMin) / 2;
- var H;
- var S; // HSL results from 0 to 1
- if (delta === 0) {
- H = 0;
- S = 0;
- } else {
- if (L < 0.5) {
- S = delta / (vMax + vMin);
- } else {
- S = delta / (2 - vMax - vMin);
- }
- var deltaR = ((vMax - R) / 6 + delta / 2) / delta;
- var deltaG = ((vMax - G) / 6 + delta / 2) / delta;
- var deltaB = ((vMax - B) / 6 + delta / 2) / delta;
- if (R === vMax) {
- H = deltaB - deltaG;
- } else if (G === vMax) {
- H = 1 / 3 + deltaR - deltaB;
- } else if (B === vMax) {
- H = 2 / 3 + deltaG - deltaR;
- }
- if (H < 0) {
- H += 1;
- }
- if (H > 1) {
- H -= 1;
- }
- }
- var hsla = [H * 360, S, L];
- if (rgba[3] != null) {
- hsla.push(rgba[3]);
- }
- return hsla;
- }
- /**
- * @param {string} color
- * @param {number} level
- * @return {string}
- * @memberOf module:zrender/util/color
- */
- function lift(color, level) {
- var colorArr = parse(color);
- if (colorArr) {
- for (var i = 0; i < 3; i++) {
- if (level < 0) {
- colorArr[i] = colorArr[i] * (1 - level) | 0;
- } else {
- colorArr[i] = (255 - colorArr[i]) * level + colorArr[i] | 0;
- }
- if (colorArr[i] > 255) {
- colorArr[i] = 255;
- } else if (color[i] < 0) {
- colorArr[i] = 0;
- }
- }
- return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb');
- }
- }
- /**
- * @param {string} color
- * @return {string}
- * @memberOf module:zrender/util/color
- */
- function toHex(color) {
- var colorArr = parse(color);
- if (colorArr) {
- return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + +colorArr[2]).toString(16).slice(1);
- }
- }
- /**
- * Map value to color. Faster than lerp methods because color is represented by rgba array.
- * @param {number} normalizedValue A float between 0 and 1.
- * @param {Array.<Array.<number>>} colors List of rgba color array
- * @param {Array.<number>} [out] Mapped gba color array
- * @return {Array.<number>} will be null/undefined if input illegal.
- */
- function fastLerp(normalizedValue, colors, out) {
- if (!(colors && colors.length) || !(normalizedValue >= 0 && normalizedValue <= 1)) {
- return;
- }
- out = out || [];
- var value = normalizedValue * (colors.length - 1);
- var leftIndex = Math.floor(value);
- var rightIndex = Math.ceil(value);
- var leftColor = colors[leftIndex];
- var rightColor = colors[rightIndex];
- var dv = value - leftIndex;
- out[0] = clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv));
- out[1] = clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv));
- out[2] = clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv));
- out[3] = clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv));
- return out;
- }
- /**
- * @deprecated
- */
- var fastMapToColor = fastLerp;
- /**
- * @param {number} normalizedValue A float between 0 and 1.
- * @param {Array.<string>} colors Color list.
- * @param {boolean=} fullOutput Default false.
- * @return {(string|Object)} Result color. If fullOutput,
- * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...},
- * @memberOf module:zrender/util/color
- */
- function lerp(normalizedValue, colors, fullOutput) {
- if (!(colors && colors.length) || !(normalizedValue >= 0 && normalizedValue <= 1)) {
- return;
- }
- var value = normalizedValue * (colors.length - 1);
- var leftIndex = Math.floor(value);
- var rightIndex = Math.ceil(value);
- var leftColor = parse(colors[leftIndex]);
- var rightColor = parse(colors[rightIndex]);
- var dv = value - leftIndex;
- var color = stringify([clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)), clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)), clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)), clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv))], 'rgba');
- return fullOutput ? {
- color: color,
- leftIndex: leftIndex,
- rightIndex: rightIndex,
- value: value
- } : color;
- }
- /**
- * @deprecated
- */
- var mapToColor = lerp;
- /**
- * @param {string} color
- * @param {number=} h 0 ~ 360, ignore when null.
- * @param {number=} s 0 ~ 1, ignore when null.
- * @param {number=} l 0 ~ 1, ignore when null.
- * @return {string} Color string in rgba format.
- * @memberOf module:zrender/util/color
- */
- function modifyHSL(color, h, s, l) {
- color = parse(color);
- if (color) {
- color = rgba2hsla(color);
- h != null && (color[0] = clampCssAngle(h));
- s != null && (color[1] = parseCssFloat(s));
- l != null && (color[2] = parseCssFloat(l));
- return stringify(hsla2rgba(color), 'rgba');
- }
- }
- /**
- * @param {string} color
- * @param {number=} alpha 0 ~ 1
- * @return {string} Color string in rgba format.
- * @memberOf module:zrender/util/color
- */
- function modifyAlpha(color, alpha) {
- color = parse(color);
- if (color && alpha != null) {
- color[3] = clampCssFloat(alpha);
- return stringify(color, 'rgba');
- }
- }
- /**
- * @param {Array.<number>} arrColor like [12,33,44,0.4]
- * @param {string} type 'rgba', 'hsva', ...
- * @return {string} Result color. (If input illegal, return undefined).
- */
- function stringify(arrColor, type) {
- if (!arrColor || !arrColor.length) {
- return;
- }
- var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2];
- if (type === 'rgba' || type === 'hsva' || type === 'hsla') {
- colorStr += ',' + arrColor[3];
- }
- return type + '(' + colorStr + ')';
- }
- exports.parse = parse;
- exports.lift = lift;
- exports.toHex = toHex;
- exports.fastLerp = fastLerp;
- exports.fastMapToColor = fastMapToColor;
- exports.lerp = lerp;
- exports.mapToColor = mapToColor;
- exports.modifyHSL = modifyHSL;
- exports.modifyAlpha = modifyAlpha;
- exports.stringify = stringify;
- /***/
- }),
- /* 146 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("\n@export clay.util.rand\nhighp float rand(vec2 uv) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, 3.141592653589793);\n return fract(sin(sn) * c);\n}\n@end\n@export clay.util.calculate_attenuation\nuniform float attenuationFactor : 5.0;\nfloat lightAttenuation(float dist, float range)\n{\n float attenuation = 1.0;\n attenuation = dist*dist/(range*range+1.0);\n float att_s = attenuationFactor;\n attenuation = 1.0/(attenuation*att_s+1.0);\n att_s = 1.0/(att_s+1.0);\n attenuation = attenuation - att_s;\n attenuation /= 1.0 - att_s;\n return clamp(attenuation, 0.0, 1.0);\n}\n@end\n@export clay.util.edge_factor\n#ifdef SUPPORT_STANDARD_DERIVATIVES\nfloat edgeFactor(float width)\n{\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * width, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#else\nfloat edgeFactor(float width)\n{\n return 1.0;\n}\n#endif\n@end\n@export clay.util.encode_float\nvec4 encodeFloat(const in float depth)\n{\n const vec4 bitShifts = vec4(256.0*256.0*256.0, 256.0*256.0, 256.0, 1.0);\n const vec4 bit_mask = vec4(0.0, 1.0/256.0, 1.0/256.0, 1.0/256.0);\n vec4 res = fract(depth * bitShifts);\n res -= res.xxyz * bit_mask;\n return res;\n}\n@end\n@export clay.util.decode_float\nfloat decodeFloat(const in vec4 color)\n{\n const vec4 bitShifts = vec4(1.0/(256.0*256.0*256.0), 1.0/(256.0*256.0), 1.0/256.0, 1.0);\n return dot(color, bitShifts);\n}\n@end\n@export clay.util.float\n@import clay.util.encode_float\n@import clay.util.decode_float\n@end\n@export clay.util.rgbm_decode\nvec3 RGBMDecode(vec4 rgbm, float range) {\n return range * rgbm.rgb * rgbm.a;\n}\n@end\n@export clay.util.rgbm_encode\nvec4 RGBMEncode(vec3 color, float range) {\n if (dot(color, color) == 0.0) {\n return vec4(0.0);\n }\n vec4 rgbm;\n color /= range;\n rgbm.a = clamp(max(max(color.r, color.g), max(color.b, 1e-6)), 0.0, 1.0);\n rgbm.a = ceil(rgbm.a * 255.0) / 255.0;\n rgbm.rgb = color / rgbm.a;\n return rgbm;\n}\n@end\n@export clay.util.rgbm\n@import clay.util.rgbm_decode\n@import clay.util.rgbm_encode\nvec4 decodeHDR(vec4 color)\n{\n#if defined(RGBM_DECODE) || defined(RGBM)\n return vec4(RGBMDecode(color, 8.12), 1.0);\n#else\n return color;\n#endif\n}\nvec4 encodeHDR(vec4 color)\n{\n#if defined(RGBM_ENCODE) || defined(RGBM)\n return RGBMEncode(color.xyz, 8.12);\n#else\n return color;\n#endif\n}\n@end\n@export clay.util.srgb\nvec4 sRGBToLinear(in vec4 value) {\n return vec4(mix(pow(value.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), value.rgb * 0.0773993808, vec3(lessThanEqual(value.rgb, vec3(0.04045)))), value.w);\n}\nvec4 linearTosRGB(in vec4 value) {\n return vec4(mix(pow(value.rgb, vec3(0.41666)) * 1.055 - vec3(0.055), value.rgb * 12.92, vec3(lessThanEqual(value.rgb, vec3(0.0031308)))), value.w);\n}\n@end\n@export clay.chunk.skinning_header\n#ifdef SKINNING\nattribute vec3 weight : WEIGHT;\nattribute vec4 joint : JOINT;\n#ifdef USE_SKIN_MATRICES_TEXTURE\nuniform sampler2D skinMatricesTexture : ignore;\nuniform float skinMatricesTextureSize: ignore;\nmat4 getSkinMatrix(sampler2D tex, float idx) {\n float j = idx * 4.0;\n float x = mod(j, skinMatricesTextureSize);\n float y = floor(j / skinMatricesTextureSize) + 0.5;\n vec2 scale = vec2(skinMatricesTextureSize);\n return mat4(\n texture2D(tex, vec2(x + 0.5, y) / scale),\n texture2D(tex, vec2(x + 1.5, y) / scale),\n texture2D(tex, vec2(x + 2.5, y) / scale),\n texture2D(tex, vec2(x + 3.5, y) / scale)\n );\n}\nmat4 getSkinMatrix(float idx) {\n return getSkinMatrix(skinMatricesTexture, idx);\n}\n#else\nuniform mat4 skinMatrix[JOINT_COUNT] : SKIN_MATRIX;\nmat4 getSkinMatrix(float idx) {\n return skinMatrix[int(idx)];\n}\n#endif\n#endif\n@end\n@export clay.chunk.skin_matrix\nmat4 skinMatrixWS = getSkinMatrix(joint.x) * weight.x;\nif (weight.y > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.y) * weight.y;\n}\nif (weight.z > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.z) * weight.z;\n}\nfloat weightW = 1.0-weight.x-weight.y-weight.z;\nif (weightW > 1e-4)\n{\n skinMatrixWS += getSkinMatrix(joint.w) * weightW;\n}\n@end\n@export clay.util.parallax_correct\nvec3 parallaxCorrect(in vec3 dir, in vec3 pos, in vec3 boxMin, in vec3 boxMax) {\n vec3 first = (boxMax - pos) / dir;\n vec3 second = (boxMin - pos) / dir;\n vec3 further = max(first, second);\n float dist = min(further.x, min(further.y, further.z));\n vec3 fixedPos = pos + dir * dist;\n vec3 boxCenter = (boxMax + boxMin) * 0.5;\n return normalize(fixedPos - boxCenter);\n}\n@end\n@export clay.util.clamp_sample\nvec4 clampSample(const in sampler2D texture, const in vec2 coord)\n{\n#ifdef STEREO\n float eye = step(0.5, coord.x) * 0.5;\n vec2 coordClamped = clamp(coord, vec2(eye, 0.0), vec2(0.5 + eye, 1.0));\n#else\n vec2 coordClamped = clamp(coord, vec2(0.0), vec2(1.0));\n#endif\n return texture2D(texture, coordClamped);\n}\n@end\n@export clay.util.ACES\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\n@end");
- /***/
- }),
- /* 147 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("\n@export ecgl.common.transformUniforms\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 worldInverseTranspose : WORLDINVERSETRANSPOSE;\nuniform mat4 world : WORLD;\n@end\n\n@export ecgl.common.attributes\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 normal : NORMAL;\n@end\n\n@export ecgl.common.uv.header\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nuniform vec2 detailUvRepeat : [1.0, 1.0];\nuniform vec2 detailUvOffset : [0.0, 0.0];\n\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n@export ecgl.common.uv.main\nv_Texcoord = texcoord * uvRepeat + uvOffset;\nv_DetailTexcoord = texcoord * detailUvRepeat + detailUvOffset;\n@end\n\n@export ecgl.common.uv.fragmentHeader\nvarying vec2 v_Texcoord;\nvarying vec2 v_DetailTexcoord;\n@end\n\n\n@export ecgl.common.albedo.main\n\n vec4 albedoTexel = vec4(1.0);\n#ifdef DIFFUSEMAP_ENABLED\n albedoTexel = texture2D(diffuseMap, v_Texcoord);\n #ifdef SRGB_DECODE\n albedoTexel = sRGBToLinear(albedoTexel);\n #endif\n#endif\n\n#ifdef DETAILMAP_ENABLED\n vec4 detailTexel = texture2D(detailMap, v_DetailTexcoord);\n #ifdef SRGB_DECODE\n detailTexel = sRGBToLinear(detailTexel);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, detailTexel.rgb, detailTexel.a);\n albedoTexel.a = detailTexel.a + (1.0 - detailTexel.a) * albedoTexel.a;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexHeader\n\n#ifdef WIREFRAME_QUAD\nattribute vec4 barycentric;\nvarying vec4 v_Barycentric;\n#elif defined(WIREFRAME_TRIANGLE)\nattribute vec3 barycentric;\nvarying vec3 v_Barycentric;\n#endif\n\n@end\n\n@export ecgl.common.wireframe.vertexMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n v_Barycentric = barycentric;\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentHeader\n\nuniform float wireframeLineWidth : 1;\nuniform vec4 wireframeLineColor: [0, 0, 0, 0.5];\n\n#ifdef WIREFRAME_QUAD\nvarying vec4 v_Barycentric;\nfloat edgeFactor () {\n vec4 d = fwidth(v_Barycentric);\n vec4 a4 = smoothstep(vec4(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(min(a4.x, a4.y), a4.z), a4.w);\n}\n#elif defined(WIREFRAME_TRIANGLE)\nvarying vec3 v_Barycentric;\nfloat edgeFactor () {\n vec3 d = fwidth(v_Barycentric);\n vec3 a3 = smoothstep(vec3(0.0), d * wireframeLineWidth, v_Barycentric);\n return min(min(a3.x, a3.y), a3.z);\n}\n#endif\n\n@end\n\n\n@export ecgl.common.wireframe.fragmentMain\n\n#if defined(WIREFRAME_QUAD) || defined(WIREFRAME_TRIANGLE)\n if (wireframeLineWidth > 0.) {\n vec4 lineColor = wireframeLineColor;\n#ifdef SRGB_DECODE\n lineColor = sRGBToLinear(lineColor);\n#endif\n\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor()) * lineColor.a);\n }\n#endif\n@end\n\n\n\n\n@export ecgl.common.bumpMap.header\n\n#ifdef BUMPMAP_ENABLED\nuniform sampler2D bumpMap;\nuniform float bumpScale : 1.0;\n\n\nvec3 bumpNormal(vec3 surfPos, vec3 surfNormal, vec3 baseNormal)\n{\n vec2 dSTdx = dFdx(v_Texcoord);\n vec2 dSTdy = dFdy(v_Texcoord);\n\n float Hll = bumpScale * texture2D(bumpMap, v_Texcoord).x;\n float dHx = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdx).x - Hll;\n float dHy = bumpScale * texture2D(bumpMap, v_Texcoord + dSTdy).x - Hll;\n\n vec3 vSigmaX = dFdx(surfPos);\n vec3 vSigmaY = dFdy(surfPos);\n vec3 vN = surfNormal;\n\n vec3 R1 = cross(vSigmaY, vN);\n vec3 R2 = cross(vN, vSigmaX);\n\n float fDet = dot(vSigmaX, R1);\n\n vec3 vGrad = sign(fDet) * (dHx * R1 + dHy * R2);\n return normalize(abs(fDet) * baseNormal - vGrad);\n\n}\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexHeader\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.vertexMain\n\n#ifdef NORMALMAP_ENABLED\n if (dot(tangent, tangent) > 0.0) {\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n }\n#endif\n\n@end\n\n\n@export ecgl.common.normalMap.fragmentHeader\n\n#ifdef NORMALMAP_ENABLED\nuniform sampler2D normalMap;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@end\n\n@export ecgl.common.normalMap.fragmentMain\n#ifdef NORMALMAP_ENABLED\n if (dot(v_Tangent, v_Tangent) > 0.0) {\n vec3 normalTexel = texture2D(normalMap, v_DetailTexcoord).xyz;\n if (dot(normalTexel, normalTexel) > 0.0) { N = normalTexel * 2.0 - 1.0;\n mat3 tbn = mat3(v_Tangent, v_Bitangent, v_Normal);\n N = normalize(tbn * N);\n }\n }\n#endif\n@end\n\n\n\n@export ecgl.common.vertexAnimation.header\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute vec3 prevNormal;\nuniform float percent;\n#endif\n\n@end\n\n@export ecgl.common.vertexAnimation.main\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n vec3 norm = mix(prevNormal, normal, percent);\n#else\n vec3 pos = position;\n vec3 norm = normal;\n#endif\n\n@end\n\n\n@export ecgl.common.ssaoMap.header\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n@end\n\n@export ecgl.common.ssaoMap.main\n float ao = 1.0;\n#ifdef SSAOMAP_ENABLED\n ao = texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n@end\n\n\n\n\n@export ecgl.common.diffuseLayer.header\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\nuniform float layerDiffuseIntensity[LAYER_DIFFUSEMAP_COUNT];\nuniform sampler2D layerDiffuseMap[LAYER_DIFFUSEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.header\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\nuniform float layerEmissionIntensity[LAYER_EMISSIVEMAP_COUNT];\nuniform sampler2D layerEmissiveMap[LAYER_EMISSIVEMAP_COUNT];\n#endif\n\n@end\n\n@export ecgl.common.layers.header\n@import ecgl.common.diffuseLayer.header\n@import ecgl.common.emissiveLayer.header\n@end\n\n@export ecgl.common.diffuseLayer.main\n\n#if (LAYER_DIFFUSEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_DIFFUSEMAP_COUNT; _idx_++) {{\n float intensity = layerDiffuseIntensity[_idx_];\n vec4 texel2 = texture2D(layerDiffuseMap[_idx_], v_Texcoord);\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n albedoTexel.rgb = mix(albedoTexel.rgb, texel2.rgb * intensity, texel2.a);\n albedoTexel.a = texel2.a + (1.0 - texel2.a) * albedoTexel.a;\n }}\n#endif\n\n@end\n\n@export ecgl.common.emissiveLayer.main\n\n#if (LAYER_EMISSIVEMAP_COUNT > 0)\n for (int _idx_ = 0; _idx_ < LAYER_EMISSIVEMAP_COUNT; _idx_++)\n {{\n vec4 texel2 = texture2D(layerEmissiveMap[_idx_], v_Texcoord) * layerEmissionIntensity[_idx_];\n #ifdef SRGB_DECODE\n texel2 = sRGBToLinear(texel2);\n #endif\n float intensity = layerEmissionIntensity[_idx_];\n gl_FragColor.rgb += texel2.rgb * texel2.a * intensity;\n }}\n#endif\n\n@end\n");
- /***/
- }),
- /* 148 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.color.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\n@import ecgl.common.uv.header\n\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position: POSITION;\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvoid main()\n{\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n @import ecgl.common.uv.main\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n@export ecgl.color.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.layers.header\n\n@import ecgl.common.uv.fragmentHeader\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n\n}\n@end");
- /***/
- }),
- /* 149 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("/**\n * http: */\n\n@export ecgl.lambert.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n\n@import ecgl.common.attributes\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.vertexAnimation.header\n\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n}\n\n@end\n\n\n@export ecgl.lambert.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\nuniform sampler2D detailMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color);\n#else\n gl_FragColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n gl_FragColor *= sRGBToLinear(v_Color);\n #else\n gl_FragColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n gl_FragColor *= albedoTexel;\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n diffuseColor += ambientLightColor[i] * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end");
- /***/
- }),
- /* 150 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.realistic.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\n\n@import ecgl.common.wireframe.vertexHeader\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\nattribute vec4 tangent : TANGENT;\nvarying vec3 v_Tangent;\nvarying vec3 v_Bitangent;\n#endif\n\n@import ecgl.common.vertexAnimation.header\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nvoid main()\n{\n\n @import ecgl.common.uv.main\n\n @import ecgl.common.vertexAnimation.main\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n v_Normal = normalize((worldInverseTranspose * vec4(norm, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n\n#ifdef NORMALMAP_ENABLED\n v_Tangent = normalize((worldInverseTranspose * vec4(tangent.xyz, 0.0)).xyz);\n v_Bitangent = normalize(cross(v_Normal, v_Tangent) * tangent.w);\n#endif\n\n @import ecgl.common.wireframe.vertexMain\n\n}\n\n@end\n\n\n\n@export ecgl.realistic.fragment\n\n#define LAYER_DIFFUSEMAP_COUNT 0\n#define LAYER_EMISSIVEMAP_COUNT 0\n#define PI 3.14159265358979\n#define ROUGHNESS_CHANEL 0\n#define METALNESS_CHANEL 1\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform sampler2D diffuseMap;\n\nuniform sampler2D detailMap;\nuniform sampler2D metalnessMap;\nuniform sampler2D roughnessMap;\n\n@import ecgl.common.layers.header\n\nuniform float emissionIntensity: 1.0;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nuniform float metalness : 0.0;\nuniform float roughness : 0.5;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n@import clay.header.ambient_cubemap_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n@import ecgl.common.normalMap.fragmentHeader\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import clay.util.rgbm\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n\nfloat D_Phong(float g, float ndh) {\n float a = pow(8192.0, g);\n return (a + 2.0) / 8.0 * pow(ndh, a);\n}\n\nvoid main()\n{\n vec4 albedoColor = color;\n\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n albedoColor *= sRGBToLinear(v_Color);\n #else\n albedoColor *= v_Color;\n #endif\n#endif\n\n @import ecgl.common.albedo.main\n\n @import ecgl.common.diffuseLayer.main\n\n albedoColor *= albedoTexel;\n\n float m = metalness;\n\n#ifdef METALNESSMAP_ENABLED\n float m2 = texture2D(metalnessMap, v_DetailTexcoord)[METALNESS_CHANEL];\n m = clamp(m2 + (m - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 baseColor = albedoColor.rgb;\n albedoColor.rgb = baseColor * (1.0 - m);\n vec3 specFactor = mix(vec3(0.04), baseColor, m);\n\n float g = 1.0 - roughness;\n\n#ifdef ROUGHNESSMAP_ENABLED\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n#endif\n\n vec3 N = v_Normal;\n\n#ifdef DOUBLE_SIDED\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n@import ecgl.common.normalMap.fragmentMain\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n vec3 diffuseTerm = vec3(0.0);\n vec3 specularTerm = vec3(0.0);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n vec3 fresnelTerm = F_Schlick(ndv, specFactor);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += ambientLightColor[_idx_] * ambientFactor * ao;\n }}\n#endif\n\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseTerm += calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_] * ao;\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++)\n {{\n vec3 L = -directionalLightDirection[_idx_];\n vec3 lc = directionalLightColor[_idx_];\n\n vec3 H = normalize(L + V);\n float ndl = clamp(dot(N, normalize(L)), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[_idx_];\n }\n#endif\n\n vec3 li = lc * ndl * shadowContrib;\n\n diffuseTerm += li;\n specularTerm += li * fresnelTerm * D_Phong(g, ndh);\n }}\n#endif\n\n\n#ifdef AMBIENT_CUBEMAP_LIGHT_COUNT\n vec3 L = reflect(-V, N);\n L = vec3(L.x, L[NORMAL_UP_AXIS], L[NORMAL_FRONT_AXIS]);\n float rough2 = clamp(1.0 - g, 0.0, 1.0);\n float bias2 = rough2 * 5.0;\n vec2 brdfParam2 = texture2D(ambientCubemapLightBRDFLookup[0], vec2(rough2, ndv)).xy;\n vec3 envWeight2 = specFactor * brdfParam2.x + brdfParam2.y;\n vec3 envTexel2;\n for(int _idx_ = 0; _idx_ < AMBIENT_CUBEMAP_LIGHT_COUNT; _idx_++)\n {{\n envTexel2 = RGBMDecode(textureCubeLodEXT(ambientCubemapLightCubemap[_idx_], L, bias2), 8.12);\n specularTerm += ambientCubemapLightColor[_idx_] * envTexel2 * envWeight2 * ao;\n }}\n#endif\n\n gl_FragColor.rgb = albedoColor.rgb * diffuseTerm + specularTerm;\n gl_FragColor.a = albedoColor.a;\n\n#ifdef SRGB_ENCODE\n gl_FragColor = linearTosRGB(gl_FragColor);\n#endif\n\n @import ecgl.common.emissiveLayer.main\n\n @import ecgl.common.wireframe.fragmentMain\n}\n\n@end");
- /***/
- }),
- /* 151 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.hatching.vertex\n\n@import ecgl.realistic.vertex\n\n@end\n\n\n@export ecgl.hatching.fragment\n\n#define NORMAL_UP_AXIS 1\n#define NORMAL_FRONT_AXIS 2\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [0.0, 0.0, 0.0, 1.0];\nuniform vec4 paperColor : [1.0, 1.0, 1.0, 1.0];\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import clay.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import clay.header.ambient_sh_light\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import clay.header.directional_light\n#endif\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\n\n@import ecgl.common.ssaoMap.header\n\n@import ecgl.common.bumpMap.header\n\n@import clay.util.srgb\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.plugin.compute_shadow_map\n\nuniform sampler2D hatch1;\nuniform sampler2D hatch2;\nuniform sampler2D hatch3;\nuniform sampler2D hatch4;\nuniform sampler2D hatch5;\nuniform sampler2D hatch6;\n\nfloat shade(in float tone) {\n vec4 c = vec4(1. ,1., 1., 1.);\n float step = 1. / 6.;\n vec2 uv = v_DetailTexcoord;\n if (tone <= step / 2.0) {\n c = mix(vec4(0.), texture2D(hatch6, uv), 12. * tone);\n }\n else if (tone <= step) {\n c = mix(texture2D(hatch6, uv), texture2D(hatch5, uv), 6. * tone);\n }\n if(tone > step && tone <= 2. * step){\n c = mix(texture2D(hatch5, uv), texture2D(hatch4, uv) , 6. * (tone - step));\n }\n if(tone > 2. * step && tone <= 3. * step){\n c = mix(texture2D(hatch4, uv), texture2D(hatch3, uv), 6. * (tone - 2. * step));\n }\n if(tone > 3. * step && tone <= 4. * step){\n c = mix(texture2D(hatch3, uv), texture2D(hatch2, uv), 6. * (tone - 3. * step));\n }\n if(tone > 4. * step && tone <= 5. * step){\n c = mix(texture2D(hatch2, uv), texture2D(hatch1, uv), 6. * (tone - 4. * step));\n }\n if(tone > 5. * step){\n c = mix(texture2D(hatch1, uv), vec4(1.), 6. * (tone - 5. * step));\n }\n\n return c.r;\n}\n\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n\nvoid main()\n{\n#ifdef SRGB_DECODE\n vec4 inkColor = sRGBToLinear(color);\n#else\n vec4 inkColor = color;\n#endif\n\n#ifdef VERTEX_COLOR\n #ifdef SRGB_DECODE\n inkColor *= sRGBToLinear(v_Color);\n #else\n inkColor *= v_Color;\n #endif\n#endif\n\n vec3 N = v_Normal;\n#ifdef DOUBLE_SIDED\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n N = -N;\n }\n#endif\n\n float tone = 0.0;\n\n float ambientFactor = 1.0;\n\n#ifdef BUMPMAP_ENABLED\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n ambientFactor = dot(v_Normal, N);\n#endif\n\n vec3 N2 = vec3(N.x, N[NORMAL_UP_AXIS], N[NORMAL_FRONT_AXIS]);\n\n @import ecgl.common.ssaoMap.main\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int i = 0; i < AMBIENT_LIGHT_COUNT; i++)\n {\n tone += dot(ambientLightColor[i], w) * ambientFactor * ao;\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n tone += dot(calcAmbientSHLight(_idx_, N2) * ambientSHLightColor[_idx_], w) * ao;\n }}\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n float lightTone = dot(directionalLightColor[i], w);\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if (shadowEnabled)\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n float ndl = dot(N, normalize(lightDirection)) * shadowContrib;\n\n tone += lightTone * clamp(ndl, 0.0, 1.0);\n }\n#endif\n\n gl_FragColor = mix(inkColor, paperColor, shade(clamp(tone, 0.0, 1.0)));\n }\n@end\n");
- /***/
- }),
- /* 152 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.sm.depth.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nuniform float percent : 1.0;\n#endif\n\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\n\nvoid main(){\n\n#ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n#else\n vec3 pos = position;\n#endif\n\n v_ViewPosition = worldViewProjection * vec4(pos, 1.0);\n gl_Position = v_ViewPosition;\n\n v_Texcoord = texcoord;\n\n}\n@end\n\n\n\n@export ecgl.sm.depth.fragment\n\n@import clay.sm.depth.fragment\n\n@end");
- /***/
- }),
- /* 153 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- var GL_SERIES = ['bar3D', 'line3D', 'map3D', 'scatter3D', 'surface', 'lines3D', 'scatterGL', 'scatter3D'];
- function convertNormalEmphasis(option, optType) {
- if (option && option[optType] && (option[optType].normal || option[optType].emphasis)) {
- var normalOpt = option[optType].normal;
- var emphasisOpt = option[optType].emphasis;
- if (normalOpt) {
- option[optType] = normalOpt;
- }
- if (emphasisOpt) {
- option.emphasis = option.emphasis || {};
- option.emphasis[optType] = emphasisOpt;
- }
- }
- }
- function convertNormalEmphasisForEach(option) {
- convertNormalEmphasis(option, 'itemStyle');
- convertNormalEmphasis(option, 'lineStyle');
- convertNormalEmphasis(option, 'areaStyle');
- convertNormalEmphasis(option, 'label');
- }
- function removeTextStyleInAxis(axesOpt) {
- if (!axesOpt) {
- return;
- }
- if (!(axesOpt instanceof Array)) {
- axesOpt = [axesOpt];
- }
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.each(axesOpt, function (axisOpt) {
- if (axisOpt.axisLabel) {
- var labelOpt = axisOpt.axisLabel;
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend(labelOpt, labelOpt.textStyle);
- labelOpt.textStyle = null;
- }
- });
- }
- /* harmony default export */ __webpack_exports__["a"] = (function (option) {
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.each(option.series, function (series) {
- if (__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.indexOf(GL_SERIES, series.type) >= 0) {
- convertNormalEmphasisForEach(series);
- // Compatitable with original mapbox
- if (series.coordinateSystem === 'mapbox') {
- series.coordinateSystem = 'mapbox3D';
- option.mapbox3D = option.mapbox;
- }
- }
- });
- removeTextStyleInAxis(option.xAxis3D);
- removeTextStyleInAxis(option.yAxis3D);
- removeTextStyleInAxis(option.zAxis3D);
- removeTextStyleInAxis(option.grid3D);
- convertNormalEmphasis(option.geo3D);
- });;
- /***/
- }),
- /* 154 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__grid3D_Axis3DModel__ = __webpack_require__(155);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__grid3D_Grid3DModel__ = __webpack_require__(159);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__grid3D_Grid3DView__ = __webpack_require__(160);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__coord_grid3DCreator__ = __webpack_require__(167);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_echarts_lib_echarts__);
- __WEBPACK_IMPORTED_MODULE_4_echarts_lib_echarts___default.a.registerAction({
- type: 'grid3DChangeCamera',
- event: 'grid3dcamerachanged',
- update: 'series:updateCamera'
- }, function (payload, ecModel) {
- ecModel.eachComponent({
- mainType: 'grid3D', query: payload
- }, function (componentModel) {
- componentModel.setView(payload);
- });
- });
- __WEBPACK_IMPORTED_MODULE_4_echarts_lib_echarts___default.a.registerAction({
- type: 'grid3DShowAxisPointer',
- event: 'grid3dshowaxispointer',
- update: 'grid3D:showAxisPointer'
- }, function (payload, ecModel) {
- });
- __WEBPACK_IMPORTED_MODULE_4_echarts_lib_echarts___default.a.registerAction({
- type: 'grid3DHideAxisPointer',
- event: 'grid3dhideaxispointer',
- update: 'grid3D:hideAxisPointer'
- }, function (payload, ecModel) {
- });
- /***/
- }),
- /* 155 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__createAxis3DModel__ = __webpack_require__(156);
- var Axis3DModel = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendComponentModel({
- type: 'cartesian3DAxis',
- axis: null,
- /**
- * @override
- */
- getCoordSysModel: function () {
- return this.ecModel.queryComponents({
- mainType: 'grid3D',
- index: this.option.gridIndex,
- id: this.option.gridId
- })[0];
- }
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.mixinAxisModelCommonMethods(Axis3DModel);
- function getAxisType(axisDim, option) {
- // Default axis with data is category axis
- return option.type || (option.data ? 'category' : 'value');
- }
- Object(__WEBPACK_IMPORTED_MODULE_1__createAxis3DModel__["a" /* default */])('x', Axis3DModel, getAxisType, {
- name: 'X'
- });
- Object(__WEBPACK_IMPORTED_MODULE_1__createAxis3DModel__["a" /* default */])('y', Axis3DModel, getAxisType, {
- name: 'Y'
- });
- Object(__WEBPACK_IMPORTED_MODULE_1__createAxis3DModel__["a" /* default */])('z', Axis3DModel, getAxisType, {
- name: 'Z'
- });
- /***/
- }),
- /* 156 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__axis3DDefault__ = __webpack_require__(157);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_OrdinalMeta__ = __webpack_require__(158);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_OrdinalMeta___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_OrdinalMeta__);
- var AXIS_TYPES = ['value', 'category', 'time', 'log'];
- /**
- * Generate sub axis model class
- * @param {string} dim 'x' 'y' 'radius' 'angle' 'parallel'
- * @param {module:echarts/model/Component} BaseAxisModelClass
- * @param {Function} axisTypeDefaulter
- * @param {Object} [extraDefaultOption]
- */
- /* harmony default export */ __webpack_exports__["a"] = (function (dim, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) {
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.each(AXIS_TYPES, function (axisType) {
- BaseAxisModelClass.extend({
- type: dim + 'Axis3D.' + axisType,
- /**
- * @type readOnly
- */
- __ordinalMeta: null,
- mergeDefaultAndTheme: function (option, ecModel) {
- var themeModel = ecModel.getTheme();
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(option, themeModel.get(axisType + 'Axis3D'));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(option, this.getDefaultOption());
- option.type = axisTypeDefaulter(dim, option);
- },
- /**
- * @override
- */
- optionUpdated: function () {
- var thisOption = this.option;
- if (thisOption.type === 'category') {
- this.__ordinalMeta = __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_OrdinalMeta___default.a.createByAxisModel(this);
- }
- },
- getCategories: function () {
- if (this.option.type === 'category') {
- return this.__ordinalMeta.categories;
- }
- },
- getOrdinalMeta: function () {
- return this.__ordinalMeta;
- },
- defaultOption: __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.clone(__WEBPACK_IMPORTED_MODULE_1__axis3DDefault__["a" /* default */][axisType + 'Axis3D']),
- extraDefaultOption || {},
- true
- )
- });
- });
- // TODO
- BaseAxisModelClass.superClass.registerSubTypeDefaulter(
- dim + 'Axis3D',
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.curry(axisTypeDefaulter, dim)
- );
- });;
- /***/
- }),
- /* 157 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- var defaultOption = {
- show: true,
- grid3DIndex: 0,
- // åå‘åæ ‡è½´
- inverse: false,
- // åæ ‡è½´åå—
- name: '',
- // åæ ‡è½´åå—ä½ç½®
- nameLocation: 'middle',
- nameTextStyle: {
- fontSize: 16
- },
- // æ–‡å—与轴线è·ç¦»
- nameGap: 20,
- axisPointer: {},
- axisLine: {},
- // åæ ‡è½´å°æ ‡è®°
- axisTick: {},
- axisLabel: {},
- // 分隔区域
- splitArea: {}
- };
- var categoryAxis = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge({
- // 类目起始和结æŸä¸¤ç«¯ç©ºç™½ç–ç•¥
- boundaryGap: true,
- // splitArea: {
- // show: false
- // },
- // åæ ‡è½´å°æ ‡è®°
- axisTick: {
- // If tick is align with label when boundaryGap is true
- // Default with axisTick
- alignWithLabel: false,
- interval: 'auto'
- },
- // åæ ‡è½´æ–‡æœ¬æ ‡ç¾ï¼Œè¯¦è§axis.axisLabel
- axisLabel: {
- interval: 'auto'
- },
- axisPointer: {
- label: {
- show: false
- }
- }
- }, defaultOption);
- var valueAxis = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge({
- // 数值起始和结æŸä¸¤ç«¯ç©ºç™½ç–ç•¥
- boundaryGap: [0, 0],
- // 最å°å€¼, è®¾ç½®æˆ 'dataMin' 则从数æ®ä¸è®¡ç®—最å°å€¼
- // min: null,
- // æœ€å¤§å€¼ï¼Œè®¾ç½®æˆ 'dataMax' 则从数æ®ä¸è®¡ç®—最大值
- // max: null,
- // 脱离0值比例,放大èšç„¦åˆ°æœ€ç»ˆ_min,_max区间
- // scale: false,
- // 分割段数,默认为5
- splitNumber: 5,
- // Minimum interval
- // minInterval: null
- axisPointer: {
- label: {
- }
- }
- }, defaultOption);
- // FIXME
- var timeAxis = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.defaults({
- scale: true,
- min: 'dataMin',
- max: 'dataMax'
- }, valueAxis);
- var logAxis = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.defaults({
- logBase: 10
- }, valueAxis);
- logAxis.scale = true;
- /* harmony default export */ __webpack_exports__["a"] = ({
- categoryAxis3D: categoryAxis,
- valueAxis3D: valueAxis,
- timeAxis3D: timeAxis,
- logAxis3D: logAxis
- });
- /***/
- }),
- /* 158 */
- /***/ (function (module, exports, __webpack_require__) {
- var _util = __webpack_require__(13);
- var createHashMap = _util.createHashMap;
- var isObject = _util.isObject;
- var map = _util.map;
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- /**
- * @constructor
- * @param {Object} [opt]
- * @param {Object} [opt.categories=[]]
- * @param {Object} [opt.needCollect=false]
- * @param {Object} [opt.deduplication=false]
- */
- function OrdinalMeta(opt) {
- /**
- * @readOnly
- * @type {Array.<string>}
- */
- this.categories = opt.categories || [];
- /**
- * @private
- * @type {boolean}
- */
- this._needCollect = opt.needCollect;
- /**
- * @private
- * @type {boolean}
- */
- this._deduplication = opt.deduplication;
- /**
- * @private
- * @type {boolean}
- */
- this._map;
- }
- /**
- * @param {module:echarts/model/Model} axisModel
- * @return {module:echarts/data/OrdinalMeta}
- */
- OrdinalMeta.createByAxisModel = function (axisModel) {
- var option = axisModel.option;
- var data = option.data;
- var categories = data && map(data, getName);
- return new OrdinalMeta({
- categories: categories,
- needCollect: !categories,
- // deduplication is default in axis.
- deduplication: option.dedplication !== false
- });
- };
- var proto = OrdinalMeta.prototype;
- /**
- * @param {string} category
- * @return {number} ordinal
- */
- proto.getOrdinal = function (category) {
- return getOrCreateMap(this).get(category);
- };
- /**
- * @param {*} category
- * @return {number} The ordinal. If not found, return NaN.
- */
- proto.parseAndCollect = function (category) {
- var index;
- var needCollect = this._needCollect; // The value of category dim can be the index of the given category set.
- // This feature is only supported when !needCollect, because we should
- // consider a common case: a value is 2017, which is a number but is
- // expected to be tread as a category. This case usually happen in dataset,
- // where it happent to be no need of the index feature.
- if (typeof category !== 'string' && !needCollect) {
- return category;
- } // Optimize for the scenario:
- // category is ['2012-01-01', '2012-01-02', ...], where the input
- // data has been ensured not duplicate and is large data.
- // Notice, if a dataset dimension provide categroies, usually echarts
- // should remove duplication except user tell echarts dont do that
- // (set axis.deduplication = false), because echarts do not know whether
- // the values in the category dimension has duplication (consider the
- // parallel-aqi example)
- if (needCollect && !this._deduplication) {
- index = this.categories.length;
- this.categories[index] = category;
- return index;
- }
- var map = getOrCreateMap(this);
- index = map.get(category);
- if (index == null) {
- if (needCollect) {
- index = this.categories.length;
- this.categories[index] = category;
- map.set(category, index);
- } else {
- index = NaN;
- }
- }
- return index;
- }; // Consider big data, do not create map until needed.
- function getOrCreateMap(ordinalMeta) {
- return ordinalMeta._map || (ordinalMeta._map = createHashMap(ordinalMeta.categories));
- }
- function getName(obj) {
- if (isObject(obj) && obj.value != null) {
- return obj.value;
- } else {
- return obj + '';
- }
- }
- var _default = OrdinalMeta;
- module.exports = _default;
- /***/
- }),
- /* 159 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__ = __webpack_require__(44);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__ = __webpack_require__(28);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__ = __webpack_require__(29);
- var Grid3DModel = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendComponentModel({
- type: 'grid3D',
- dependencies: ['xAxis3D', 'yAxis3D', 'zAxis3D'],
- defaultOption: {
- show: true,
- zlevel: -10,
- // Layout used for viewport
- left: 0,
- top: 0,
- width: '100%',
- height: '100%',
- environment: 'auto',
- // Dimension of grid3D
- boxWidth: 100,
- boxHeight: 100,
- boxDepth: 100,
- // Common axis options.
- axisPointer: {
- show: true,
- lineStyle: {
- color: 'rgba(0, 0, 0, 0.8)',
- width: 1
- },
- label: {
- show: true,
- // (dimValue: number, value: Array) => string
- formatter: null,
- // TODO, Consider boxWidth
- margin: 8,
- // backgroundColor: '#ffbd67',
- // borderColor: '#000',
- // borderWidth: 0,
- textStyle: {
- fontSize: 14,
- color: '#fff',
- backgroundColor: 'rgba(0,0,0,0.5)',
- padding: 3,
- borderRadius: 3
- }
- }
- },
- axisLine: {
- show: true,
- lineStyle: {
- color: '#333',
- width: 2,
- type: 'solid'
- }
- },
- axisTick: {
- show: true,
- inside: false,
- length: 3,
- lineStyle: {
- width: 1
- }
- },
- axisLabel: {
- show: true,
- inside: false,
- rotate: 0,
- margin: 8,
- textStyle: {
- fontSize: 12
- }
- },
- splitLine: {
- show: true,
- lineStyle: {
- color: ['#ccc'],
- width: 1,
- type: 'solid'
- }
- },
- splitArea: {
- show: false,
- areaStyle: {
- color: ['rgba(250,250,250,0.3)', 'rgba(200,200,200,0.3)']
- }
- },
- // Light options
- light: {
- main: {
- // Alpha angle for top-down rotation
- // Positive to rotate to top.
- alpha: 30,
- // beta angle for left-right rotation
- // Positive to rotate to right.
- beta: 40
- },
- ambient: {
- intensity: 0.4
- }
- },
- viewControl: {
- // Small damping for precise control.
- // damping: 0.1,
- // Alpha angle for top-down rotation
- // Positive to rotate to top.
- alpha: 20,
- // beta angle for left-right rotation
- // Positive to rotate to right.
- beta: 40,
- autoRotate: false,
- // Distance to the surface of grid3D.
- distance: 200,
- // Min distance to the surface of grid3D
- minDistance: 40,
- // Max distance to the surface of grid3D
- maxDistance: 400
- }
- }
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Grid3DModel.prototype, __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Grid3DModel.prototype, __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Grid3DModel.prototype, __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__["a" /* default */]);
- /* unused harmony default export */ var _unused_webpack_default_export = (Grid3DModel);
- /***/
- }),
- /* 160 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__ = __webpack_require__(45);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(25);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_ZRTextureAtlasSurface__ = __webpack_require__(81);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__common_SceneHelper__ = __webpack_require__(30);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Grid3DFace__ = __webpack_require__(162);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Grid3DAxis__ = __webpack_require__(164);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__util_mesh_LabelsMesh__ = __webpack_require__(63);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__util_shader_lines3D_glsl_js__ = __webpack_require__(46);
- // TODO orthographic camera
- var firstNotNull = __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull;
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_10__util_shader_lines3D_glsl_js__["a" /* default */]);
- ['x', 'y', 'z'].forEach(function (dim) {
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendComponentView({
- type: dim + 'Axis3D'
- });
- });
- var dimIndicesMap = {
- // Left to right
- x: 0,
- // Far to near
- y: 2,
- // Bottom to up
- z: 1
- };
- /* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendComponentView({
- type: 'grid3D',
- __ecgl__: true,
- init: function (ecModel, api) {
- var FACES = [
- // planeDim0, planeDim1, offsetDim, dir on dim3 axis(gl), plane.
- ['y', 'z', 'x', -1, 'left'],
- ['y', 'z', 'x', 1, 'right'],
- ['x', 'y', 'z', -1, 'bottom'],
- ['x', 'y', 'z', 1, 'top'],
- ['x', 'z', 'y', -1, 'far'],
- ['x', 'z', 'y', 1, 'near']
- ];
- var DIMS = ['x', 'y', 'z'];
- var quadsMaterial = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- // transparent: true,
- shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.color'),
- depthMask: false,
- transparent: true
- });
- var linesMaterial = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- // transparent: true,
- shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.meshLines3D'),
- depthMask: false,
- transparent: true
- });
- quadsMaterial.define('fragment', 'DOUBLE_SIDED');
- quadsMaterial.define('both', 'VERTEX_COLOR');
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- this._control = new __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__["a" /* default */]({
- zr: api.getZr()
- });
- this._control.init();
- // Save mesh and other infos for each face.
- this._faces = FACES.map(function (faceInfo) {
- var face = new __WEBPACK_IMPORTED_MODULE_7__Grid3DFace__["a" /* default */](faceInfo, linesMaterial, quadsMaterial);
- this.groupGL.add(face.rootNode);
- return face;
- }, this);
- // Save mesh and other infos for each axis.
- this._axes = DIMS.map(function (dim) {
- var axis = new __WEBPACK_IMPORTED_MODULE_8__Grid3DAxis__["a" /* default */](dim, linesMaterial);
- this.groupGL.add(axis.rootNode);
- return axis;
- }, this);
- var dpr = api.getDevicePixelRatio();
- // Texture surface for label.
- this._axisLabelSurface = new __WEBPACK_IMPORTED_MODULE_5__util_ZRTextureAtlasSurface__["a" /* default */]({
- width: 256, height: 256,
- devicePixelRatio: dpr
- });
- this._axisLabelSurface.onupdate = function () {
- api.getZr().refresh();
- };
- this._axisPointerLineMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__["a" /* default */]({ useNativeLine: false }),
- material: linesMaterial,
- castShadow: false,
- // PENDING
- ignorePicking: true,
- renderOrder: 3
- });
- this.groupGL.add(this._axisPointerLineMesh);
- this._axisPointerLabelsSurface = new __WEBPACK_IMPORTED_MODULE_5__util_ZRTextureAtlasSurface__["a" /* default */]({
- width: 128, height: 128,
- devicePixelRatio: dpr
- });
- this._axisPointerLabelsMesh = new __WEBPACK_IMPORTED_MODULE_9__util_mesh_LabelsMesh__["a" /* default */]({
- ignorePicking: true, renderOrder: 4,
- castShadow: false
- });
- this._axisPointerLabelsMesh.material.set('textureAtlas', this._axisPointerLabelsSurface.getTexture());
- this.groupGL.add(this._axisPointerLabelsMesh);
- this._lightRoot = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- this._sceneHelper = new __WEBPACK_IMPORTED_MODULE_6__common_SceneHelper__["a" /* default */]();
- this._sceneHelper.initLight(this._lightRoot);
- },
- render: function (grid3DModel, ecModel, api) {
- this._model = grid3DModel;
- this._api = api;
- var cartesian = grid3DModel.coordinateSystem;
- // Always have light.
- cartesian.viewGL.add(this._lightRoot);
- if (grid3DModel.get('show')) {
- cartesian.viewGL.add(this.groupGL);
- }
- else {
- cartesian.viewGL.remove(this.groupGL);
- }
- // cartesian.viewGL.setCameraType(grid3DModel.get('viewControl.projection'));
- var control = this._control;
- control.setViewGL(cartesian.viewGL);
- var viewControlModel = grid3DModel.getModel('viewControl');
- control.setFromViewControlModel(viewControlModel, 0);
- this._axisLabelSurface.clear();
- control.off('update');
- if (grid3DModel.get('show')) {
- this._faces.forEach(function (face) {
- face.update(grid3DModel, ecModel, api);
- }, this);
- this._axes.forEach(function (axis) {
- axis.update(grid3DModel, this._axisLabelSurface, api);
- }, this);
- }
- control.on('update', this._onCameraChange.bind(this, grid3DModel, api), this);
- this._sceneHelper.setScene(cartesian.viewGL.scene);
- this._sceneHelper.updateLight(grid3DModel);
- // Set post effect
- cartesian.viewGL.setPostEffect(grid3DModel.getModel('postEffect'), api);
- cartesian.viewGL.setTemporalSuperSampling(grid3DModel.getModel('temporalSuperSampling'));
- this._initMouseHandler(grid3DModel);
- },
- afterRender: function (grid3DModel, ecModel, api, layerGL) {
- // Create ambient cubemap after render because we need to know the renderer.
- // TODO
- var renderer = layerGL.renderer;
- this._sceneHelper.updateAmbientCubemap(renderer, grid3DModel, api);
- this._sceneHelper.updateSkybox(renderer, grid3DModel, api);
- },
- /**
- * showAxisPointer will be triggered by action.
- */
- showAxisPointer: function (grid3dModel, ecModel, api, payload) {
- this._doShowAxisPointer();
- this._updateAxisPointer(payload.value);
- },
- /**
- * hideAxisPointer will be triggered by action.
- */
- hideAxisPointer: function (grid3dModel, ecModel, api, payload) {
- this._doHideAxisPointer();
- },
- _initMouseHandler: function (grid3DModel) {
- var cartesian = grid3DModel.coordinateSystem;
- var viewGL = cartesian.viewGL;
- // TODO xAxis3D.axisPointer.show ?
- if (grid3DModel.get('show') && grid3DModel.get('axisPointer.show')) {
- viewGL.on('mousemove', this._updateAxisPointerOnMousePosition, this);
- }
- else {
- viewGL.off('mousemove', this._updateAxisPointerOnMousePosition);
- }
- },
- /**
- * Try find and show axisPointer on the intersect point
- * of mouse ray with grid plane.
- */
- _updateAxisPointerOnMousePosition: function (e) {
- // Ignore if mouse is on the element.
- if (e.target) {
- return;
- }
- var grid3DModel = this._model;
- var cartesian = grid3DModel.coordinateSystem;
- var viewGL = cartesian.viewGL;
- var ray = viewGL.castRay(e.offsetX, e.offsetY, new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Ray());
- var nearestIntersectPoint;
- for (var i = 0; i < this._faces.length; i++) {
- var face = this._faces[i];
- if (face.rootNode.invisible) {
- continue;
- }
- // Plane is not face the camera. flip it
- if (face.plane.normal.dot(viewGL.camera.worldTransform.z) < 0) {
- face.plane.normal.negate();
- }
- var point = ray.intersectPlane(face.plane);
- if (!point) {
- continue;
- }
- var axis0 = cartesian.getAxis(face.faceInfo[0]);
- var axis1 = cartesian.getAxis(face.faceInfo[1]);
- var idx0 = dimIndicesMap[face.faceInfo[0]];
- var idx1 = dimIndicesMap[face.faceInfo[1]];
- if (axis0.contain(point.array[idx0]) && axis1.contain(point.array[idx1])) {
- nearestIntersectPoint = point;
- }
- }
- if (nearestIntersectPoint) {
- var data = cartesian.pointToData(nearestIntersectPoint.array, [], true);
- this._updateAxisPointer(data);
- this._doShowAxisPointer();
- }
- else {
- this._doHideAxisPointer();
- }
- },
- _onCameraChange: function (grid3DModel, api) {
- if (grid3DModel.get('show')) {
- this._updateFaceVisibility();
- this._updateAxisLinePosition();
- }
- var control = this._control;
- api.dispatchAction({
- type: 'grid3DChangeCamera',
- alpha: control.getAlpha(),
- beta: control.getBeta(),
- distance: control.getDistance(),
- center: control.getCenter(),
- from: this.uid,
- grid3DId: grid3DModel.id
- });
- },
- /**
- * Update visibility of each face when camera view changed, front face will be invisible.
- * @private
- */
- _updateFaceVisibility: function () {
- var camera = this._control.getCamera();
- var viewSpacePos = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Vector3();
- camera.update();
- for (var idx = 0; idx < this._faces.length / 2; idx++) {
- var depths = [];
- for (var k = 0; k < 2; k++) {
- var face = this._faces[idx * 2 + k];
- face.rootNode.getWorldPosition(viewSpacePos);
- viewSpacePos.transformMat4(camera.viewMatrix);
- depths[k] = viewSpacePos.z;
- }
- // Set the front face invisible
- var frontIndex = depths[0] > depths[1] ? 0 : 1;
- var frontFace = this._faces[idx * 2 + frontIndex];
- var backFace = this._faces[idx * 2 + 1 - frontIndex];
- // Update rotation.
- frontFace.rootNode.invisible = true;
- backFace.rootNode.invisible = false;
- }
- },
- /**
- * Update axis line position when camera view changed.
- * @private
- */
- _updateAxisLinePosition: function () {
- // Put xAxis, yAxis on x, y visible plane.
- // Put zAxis on the left.
- // TODO
- var cartesian = this._model.coordinateSystem;
- var xAxis = cartesian.getAxis('x');
- var yAxis = cartesian.getAxis('y');
- var zAxis = cartesian.getAxis('z');
- var top = zAxis.getExtentMax();
- var bottom = zAxis.getExtentMin();
- var left = xAxis.getExtentMin();
- var right = xAxis.getExtentMax();
- var near = yAxis.getExtentMax();
- var far = yAxis.getExtentMin();
- var xAxisNode = this._axes[0].rootNode;
- var yAxisNode = this._axes[1].rootNode;
- var zAxisNode = this._axes[2].rootNode;
- var faces = this._faces;
- // Notice: in cartesian up axis is z, but in webgl up axis is y.
- var xAxisZOffset = (faces[4].rootNode.invisible ? far : near);
- var xAxisYOffset = (faces[2].rootNode.invisible ? top : bottom);
- var yAxisXOffset = (faces[0].rootNode.invisible ? left : right);
- var yAxisYOffset = (faces[2].rootNode.invisible ? top : bottom);
- var zAxisXOffset = (faces[0].rootNode.invisible ? right : left);
- var zAxisZOffset = (faces[4].rootNode.invisible ? far : near);
- xAxisNode.rotation.identity();
- yAxisNode.rotation.identity();
- zAxisNode.rotation.identity();
- if (faces[4].rootNode.invisible) {
- this._axes[0].flipped = true;
- xAxisNode.rotation.rotateX(Math.PI);
- }
- if (faces[0].rootNode.invisible) {
- this._axes[1].flipped = true;
- yAxisNode.rotation.rotateZ(Math.PI);
- }
- if (faces[4].rootNode.invisible) {
- this._axes[2].flipped = true;
- zAxisNode.rotation.rotateY(Math.PI);
- }
- xAxisNode.position.set(0, xAxisYOffset, xAxisZOffset);
- yAxisNode.position.set(yAxisXOffset, yAxisYOffset, 0); // Actually z
- zAxisNode.position.set(zAxisXOffset, 0, zAxisZOffset); // Actually y
- xAxisNode.update();
- yAxisNode.update();
- zAxisNode.update();
- this._updateAxisLabelAlign();
- },
- /**
- * Update label align on axis when axisLine position changed.
- * @private
- */
- _updateAxisLabelAlign: function () {
- // var cartesian = this._model.coordinateSystem;
- var camera = this._control.getCamera();
- var coords = [new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Vector4(), new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Vector4()];
- var center = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Vector4();
- this.groupGL.getWorldPosition(center);
- center.w = 1.0;
- center.transformMat4(camera.viewMatrix)
- .transformMat4(camera.projectionMatrix);
- center.x /= center.w;
- center.y /= center.w;
- this._axes.forEach(function (axisInfo) {
- var lineCoords = axisInfo.axisLineCoords;
- var labelGeo = axisInfo.labelsMesh.geometry;
- for (var i = 0; i < coords.length; i++) {
- coords[i].setArray(lineCoords[i]);
- coords[i].w = 1.0;
- coords[i].transformMat4(axisInfo.rootNode.worldTransform)
- .transformMat4(camera.viewMatrix)
- .transformMat4(camera.projectionMatrix);
- coords[i].x /= coords[i].w;
- coords[i].y /= coords[i].w;
- }
- var dx = coords[1].x - coords[0].x;
- var dy = coords[1].y - coords[0].y;
- var cx = (coords[1].x + coords[0].x) / 2;
- var cy = (coords[1].y + coords[0].y) / 2;
- var textAlign;
- var verticalAlign;
- if (Math.abs(dy / dx) < 0.5) {
- textAlign = 'center';
- verticalAlign = cy > center.y ? 'bottom' : 'top';
- }
- else {
- verticalAlign = 'middle';
- textAlign = cx > center.x ? 'left' : 'right';
- }
- // axis labels
- axisInfo.setSpriteAlign(textAlign, verticalAlign, this._api);
- }, this);
- },
- _doShowAxisPointer: function () {
- if (!this._axisPointerLineMesh.invisible) {
- return;
- }
- this._axisPointerLineMesh.invisible = false;
- this._axisPointerLabelsMesh.invisible = false;
- this._api.getZr().refresh();
- },
- _doHideAxisPointer: function () {
- if (this._axisPointerLineMesh.invisible) {
- return;
- }
- this._axisPointerLineMesh.invisible = true;
- this._axisPointerLabelsMesh.invisible = true;
- this._api.getZr().refresh();
- },
- /**
- * @private updateAxisPointer.
- */
- _updateAxisPointer: function (data) {
- var cartesian = this._model.coordinateSystem;
- var point = cartesian.dataToPoint(data);
- var axisPointerLineMesh = this._axisPointerLineMesh;
- var linesGeo = axisPointerLineMesh.geometry;
- var axisPointerParentModel = this._model.getModel('axisPointer');
- var dpr = this._api.getDevicePixelRatio();
- linesGeo.convertToDynamicArray(true);
- function ifShowAxisPointer(axis) {
- return __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(
- axis.model.get('axisPointer.show'),
- axisPointerParentModel.get('show')
- );
- }
- function getAxisColorAndLineWidth(axis) {
- var axisPointerModel = axis.model.getModel('axisPointer', axisPointerParentModel);
- var lineStyleModel = axisPointerModel.getModel('lineStyle');
- var color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(lineStyleModel.get('color'));
- var lineWidth = firstNotNull(lineStyleModel.get('width'), 1);
- var opacity = firstNotNull(lineStyleModel.get('opacity'), 1);
- color[3] *= opacity;
- return {
- color: color,
- lineWidth: lineWidth
- };
- }
- for (var k = 0; k < this._faces.length; k++) {
- var face = this._faces[k];
- if (face.rootNode.invisible) {
- continue;
- }
- var faceInfo = face.faceInfo;
- var otherCoord = faceInfo[3] < 0
- ? cartesian.getAxis(faceInfo[2]).getExtentMin()
- : cartesian.getAxis(faceInfo[2]).getExtentMax();
- var otherDimIdx = dimIndicesMap[faceInfo[2]];
- // Line on face.
- for (var i = 0; i < 2; i++) {
- var dim = faceInfo[i];
- var faceOtherDim = faceInfo[1 - i];
- var axis = cartesian.getAxis(dim);
- var faceOtherAxis = cartesian.getAxis(faceOtherDim);
- if (!ifShowAxisPointer(axis)) {
- continue;
- }
- var p0 = [0, 0, 0]; var p1 = [0, 0, 0];
- var dimIdx = dimIndicesMap[dim];
- var faceOtherDimIdx = dimIndicesMap[faceOtherDim];
- p0[dimIdx] = p1[dimIdx] = point[dimIdx];
- p0[otherDimIdx] = p1[otherDimIdx] = otherCoord;
- p0[faceOtherDimIdx] = faceOtherAxis.getExtentMin();
- p1[faceOtherDimIdx] = faceOtherAxis.getExtentMax();
- var colorAndLineWidth = getAxisColorAndLineWidth(axis);
- linesGeo.addLine(p0, p1, colorAndLineWidth.color, colorAndLineWidth.lineWidth * dpr);
- }
- // Project line.
- if (ifShowAxisPointer(cartesian.getAxis(faceInfo[2]))) {
- var p0 = point.slice();
- var p1 = point.slice();
- p1[otherDimIdx] = otherCoord;
- var colorAndLineWidth = getAxisColorAndLineWidth(cartesian.getAxis(faceInfo[2]));
- linesGeo.addLine(p0, p1, colorAndLineWidth.color, colorAndLineWidth.lineWidth * dpr);
- }
- }
- linesGeo.convertToTypedArray();
- this._updateAxisPointerLabelsMesh(data);
- this._api.getZr().refresh();
- },
- _updateAxisPointerLabelsMesh: function (data) {
- var grid3dModel = this._model;
- var axisPointerLabelsMesh = this._axisPointerLabelsMesh;
- var axisPointerLabelsSurface = this._axisPointerLabelsSurface;
- var cartesian = grid3dModel.coordinateSystem;
- var axisPointerParentModel = grid3dModel.getModel('axisPointer');
- axisPointerLabelsMesh.geometry.convertToDynamicArray(true);
- axisPointerLabelsSurface.clear();
- var otherDim = {
- x: 'y', y: 'x', z: 'y'
- };
- this._axes.forEach(function (axisInfo, idx) {
- var axis = cartesian.getAxis(axisInfo.dim);
- var axisModel = axis.model;
- var axisPointerModel = axisModel.getModel('axisPointer', axisPointerParentModel);
- var labelModel = axisPointerModel.getModel('label');
- var lineColor = axisPointerModel.get('lineStyle.color');
- if (!labelModel.get('show') || !axisPointerModel.get('show')) {
- return;
- }
- var val = data[idx];
- var formatter = labelModel.get('formatter');
- var text = axis.scale.getLabel(val);
- if (formatter != null) {
- text = formatter(text, data);
- }
- else {
- if (axis.scale.type === 'interval' || axis.scale.type === 'log') {
- var precision = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.number.getPrecisionSafe(axis.scale.getTicks()[0]);
- text = val.toFixed(precision + 2);
- }
- }
- var textStyleModel = labelModel.getModel('textStyle');
- var labelColor = textStyleModel.get('color');
- var textEl = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Text();
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.setTextStyle(textEl.style, textStyleModel, {
- text: text,
- textFill: labelColor || lineColor,
- textAlign: 'left',
- textVerticalAlign: 'top'
- });
- var coords = axisPointerLabelsSurface.add(textEl);
- var rect = textEl.getBoundingRect();
- var dpr = this._api.getDevicePixelRatio();
- var pos = axisInfo.rootNode.position.toArray();
- var otherIdx = dimIndicesMap[otherDim[axisInfo.dim]];
- pos[otherIdx] += (axisInfo.flipped ? -1 : 1) * labelModel.get('margin');
- pos[dimIndicesMap[axisInfo.dim]] = axis.dataToCoord(data[idx]);
- axisPointerLabelsMesh.geometry.addSprite(
- pos, [rect.width * dpr, rect.height * dpr], coords,
- axisInfo.textAlign, axisInfo.textVerticalAlign
- );
- }, this);
- axisPointerLabelsSurface.getZr().refreshImmediately();
- axisPointerLabelsMesh.material.set('uvScale', axisPointerLabelsSurface.getCoordsScale());
- axisPointerLabelsMesh.geometry.convertToTypedArray();
- },
- dispose: function () {
- this.groupGL.removeAll();
- this._control.dispose();
- }
- }));
- /***/
- }),
- /* 161 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__vec2__ = __webpack_require__(70);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__vec3__ = __webpack_require__(12);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__vec4__ = __webpack_require__(33);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__mat2__ = __webpack_require__(78);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__mat2d__ = __webpack_require__(79);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__mat3__ = __webpack_require__(34);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__mat4__ = __webpack_require__(21);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__quat__ = __webpack_require__(55);
- /**
- * @fileoverview gl-matrix - High performance matrix and vector operations
- * @author Brandon Jones
- * @author Colin MacKenzie IV
- * @version 2.2.2
- */
- /* Copyright (c) 2013, Brandon Jones, Colin MacKenzie IV. All rights reserved.
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
- /* harmony default export */ __webpack_exports__["a"] = ({
- vec2: __WEBPACK_IMPORTED_MODULE_0__vec2__["a" /* default */],
- vec3: __WEBPACK_IMPORTED_MODULE_1__vec3__["a" /* default */],
- vec4: __WEBPACK_IMPORTED_MODULE_2__vec4__["a" /* default */],
- mat2: __WEBPACK_IMPORTED_MODULE_3__mat2__["a" /* default */],
- mat2d: __WEBPACK_IMPORTED_MODULE_4__mat2d__["a" /* default */],
- mat3: __WEBPACK_IMPORTED_MODULE_5__mat3__["a" /* default */],
- mat4: __WEBPACK_IMPORTED_MODULE_6__mat4__["a" /* default */],
- quat: __WEBPACK_IMPORTED_MODULE_7__quat__["a" /* default */]
- });
- /***/
- }),
- /* 162 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(25);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_Quads__ = __webpack_require__(163);
- var firstNotNull = __WEBPACK_IMPORTED_MODULE_2__util_retrieve__["a" /* default */].firstNotNull;
- var dimIndicesMap = {
- // Left to right
- x: 0,
- // Far to near
- y: 2,
- // Bottom to up
- z: 1
- };
- function updateFacePlane(node, plane, otherAxis, dir) {
- var coord = [0, 0, 0];
- var distance = dir < 0 ? otherAxis.getExtentMin() : otherAxis.getExtentMax();
- coord[dimIndicesMap[otherAxis.dim]] = distance;
- node.position.setArray(coord);
- node.rotation.identity();
- // Negative distance because on the opposite of normal direction.
- plane.distance = -Math.abs(distance);
- plane.normal.set(0, 0, 0);
- if (otherAxis.dim === 'x') {
- node.rotation.rotateY(dir * Math.PI / 2);
- plane.normal.x = -dir;
- }
- else if (otherAxis.dim === 'z') {
- node.rotation.rotateX(-dir * Math.PI / 2);
- plane.normal.y = -dir;
- }
- else {
- if (dir > 0) {
- node.rotation.rotateY(Math.PI);
- }
- plane.normal.z = -dir;
- }
- }
- function Grid3DFace(faceInfo, linesMaterial, quadsMaterial) {
- this.rootNode = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- var linesMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__["a" /* default */]({ useNativeLine: false }),
- material: linesMaterial,
- castShadow: false,
- ignorePicking: true,
- $ignorePicking: true,
- renderOrder: 1
- });
- var quadsMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_4__util_geometry_Quads__["a" /* default */](),
- material: quadsMaterial,
- castShadow: false,
- culling: false,
- ignorePicking: true,
- $ignorePicking: true,
- renderOrder: 0
- });
- // Quads are behind lines.
- this.rootNode.add(quadsMesh);
- this.rootNode.add(linesMesh);
- this.faceInfo = faceInfo;
- this.plane = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Plane();
- this.linesMesh = linesMesh;
- this.quadsMesh = quadsMesh;
- }
- Grid3DFace.prototype.update = function (grid3DModel, ecModel, api) {
- var cartesian = grid3DModel.coordinateSystem;
- var axes = [
- cartesian.getAxis(this.faceInfo[0]),
- cartesian.getAxis(this.faceInfo[1])
- ];
- var lineGeometry = this.linesMesh.geometry;
- var quadsGeometry = this.quadsMesh.geometry;
- lineGeometry.convertToDynamicArray(true);
- quadsGeometry.convertToDynamicArray(true);
- this._updateSplitLines(lineGeometry, axes, grid3DModel, api);
- this._udpateSplitAreas(quadsGeometry, axes, grid3DModel, api);
- lineGeometry.convertToTypedArray();
- quadsGeometry.convertToTypedArray();
- var otherAxis = cartesian.getAxis(this.faceInfo[2]);
- updateFacePlane(this.rootNode, this.plane, otherAxis, this.faceInfo[3]);
- };
- Grid3DFace.prototype._updateSplitLines = function (geometry, axes, grid3DModel, api) {
- var dpr = api.getDevicePixelRatio();
- axes.forEach(function (axis, idx) {
- var axisModel = axis.model;
- var otherExtent = axes[1 - idx].getExtent();
- if (axis.scale.isBlank()) {
- return;
- }
- var splitLineModel = axisModel.getModel('splitLine', grid3DModel.getModel('splitLine'));
- // Render splitLines
- if (splitLineModel.get('show')) {
- var lineStyleModel = splitLineModel.getModel('lineStyle');
- var lineColors = lineStyleModel.get('color');
- var opacity = firstNotNull(lineStyleModel.get('opacity'), 1.0);
- var lineWidth = firstNotNull(lineStyleModel.get('width'), 1.0);
- lineColors = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(lineColors) ? lineColors : [lineColors];
- var ticksCoords = axis.getTicksCoords({
- tickModel: splitLineModel
- });
- var count = 0;
- for (var i = 0; i < ticksCoords.length; i++) {
- var tickCoord = ticksCoords[i].coord;
- var lineColor = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(lineColors[count % lineColors.length]);
- lineColor[3] *= opacity;
- var p0 = [0, 0, 0]; var p1 = [0, 0, 0];
- // 0 - x, 1 - y
- p0[idx] = p1[idx] = tickCoord;
- p0[1 - idx] = otherExtent[0];
- p1[1 - idx] = otherExtent[1];
- geometry.addLine(p0, p1, lineColor, lineWidth * dpr);
- count++;
- }
- }
- });
- };
- Grid3DFace.prototype._udpateSplitAreas = function (geometry, axes, grid3DModel, api) {
- axes.forEach(function (axis, idx) {
- var axisModel = axis.model;
- var otherExtent = axes[1 - idx].getExtent();
- if (axis.scale.isBlank()) {
- return;
- }
- var splitAreaModel = axisModel.getModel('splitArea', grid3DModel.getModel('splitArea'));
- // Render splitAreas
- if (splitAreaModel.get('show')) {
- var areaStyleModel = splitAreaModel.getModel('areaStyle');
- var colors = areaStyleModel.get('color');
- var opacity = firstNotNull(areaStyleModel.get('opacity'), 1.0);
- colors = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(colors) ? colors : [colors];
- var ticksCoords = axis.getTicksCoords({
- tickModel: splitAreaModel,
- clamp: true
- });
- var count = 0;
- var prevP0 = [0, 0, 0];
- var prevP1 = [0, 0, 0];
- // 0 - x, 1 - y
- for (var i = 0; i < ticksCoords.length; i++) {
- var tickCoord = ticksCoords[i].coord;
- var p0 = [0, 0, 0]; var p1 = [0, 0, 0];
- // 0 - x, 1 - y
- p0[idx] = p1[idx] = tickCoord;
- p0[1 - idx] = otherExtent[0];
- p1[1 - idx] = otherExtent[1];
- if (i === 0) {
- prevP0 = p0;
- prevP1 = p1;
- continue;
- }
- var color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(colors[count % colors.length]);
- color[3] *= opacity;
- geometry.addQuad([prevP0, p0, p1, prevP1], color);
- prevP0 = p0;
- prevP1 = p1;
- count++;
- }
- }
- });
- };
- /* harmony default export */ __webpack_exports__["a"] = (Grid3DFace);
- /***/
- }),
- /* 163 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(15);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(38);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /**
- * @module echarts-gl/util/geometry/QuadsGeometry
- * @author Yi Shen(http://github.com/pissang)
- */
- var vec3 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- /**
- * @constructor
- * @alias module:echarts-gl/util/geometry/QuadsGeometry
- * @extends clay.Geometry
- */
- var QuadsGeometry = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].extend(function () {
- return {
- segmentScale: 1,
- /**
- * Need to use mesh to expand lines if lineWidth > MAX_LINE_WIDTH
- */
- useNativeLine: true,
- attributes: {
- position: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('position', 'float', 3, 'POSITION'),
- normal: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('normal', 'float', 3, 'NORMAL'),
- color: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('color', 'float', 4, 'COLOR')
- }
- };
- },
- /** @lends module: echarts-gl/util/geometry/QuadsGeometry.prototype */
- {
- /**
- * Reset offset
- */
- resetOffset: function () {
- this._vertexOffset = 0;
- this._faceOffset = 0;
- },
- /**
- * @param {number} nQuad
- */
- setQuadCount: function (nQuad) {
- var attributes = this.attributes;
- var vertexCount = this.getQuadVertexCount() * nQuad;
- var triangleCount = this.getQuadTriangleCount() * nQuad;
- if (this.vertexCount !== vertexCount) {
- attributes.position.init(vertexCount);
- attributes.normal.init(vertexCount);
- attributes.color.init(vertexCount);
- }
- if (this.triangleCount !== triangleCount) {
- this.indices = vertexCount > 0xffff ? new Uint32Array(triangleCount * 3) : new Uint16Array(triangleCount * 3);
- }
- },
- getQuadVertexCount: function () {
- return 4;
- },
- getQuadTriangleCount: function () {
- return 2;
- },
- /**
- * Add a quad, which in following order:
- * 0-----1
- * 3-----2
- */
- addQuad: (function () {
- var a = vec3.create();
- var b = vec3.create();
- var normal = vec3.create();
- var indices = [0, 3, 1, 3, 2, 1];
- return function (coords, color) {
- var positionAttr = this.attributes.position;
- var normalAttr = this.attributes.normal;
- var colorAttr = this.attributes.color;
- vec3.sub(a, coords[1], coords[0]);
- vec3.sub(b, coords[2], coords[1]);
- vec3.cross(normal, a, b);
- vec3.normalize(normal, normal);
- for (var i = 0; i < 4; i++) {
- positionAttr.set(this._vertexOffset + i, coords[i]);
- colorAttr.set(this._vertexOffset + i, color);
- normalAttr.set(this._vertexOffset + i, normal);
- }
- var idx = this._faceOffset * 3;
- for (var i = 0; i < 6; i++) {
- this.indices[idx + i] = indices[i] + this._vertexOffset;
- }
- this._vertexOffset += 4;
- this._faceOffset += 2;
- };
- })()
- });
- __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.util.defaults(QuadsGeometry.prototype, __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__["a" /* default */]);
- /* harmony default export */ __webpack_exports__["a"] = (QuadsGeometry);
- /***/
- }),
- /* 164 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_geometry_Lines3D__ = __webpack_require__(25);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_mesh_LabelsMesh__ = __webpack_require__(63);
- var firstNotNull = __WEBPACK_IMPORTED_MODULE_3__util_retrieve__["a" /* default */].firstNotNull;
- var dimIndicesMap = {
- // Left to right
- x: 0,
- // Far to near
- y: 2,
- // Bottom to up
- z: 1
- };
- function Grid3DAxis(dim, linesMaterial) {
- var linesMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_2__util_geometry_Lines3D__["a" /* default */]({ useNativeLine: false }),
- material: linesMaterial,
- castShadow: false,
- ignorePicking: true, renderOrder: 2
- });
- var axisLabelsMesh = new __WEBPACK_IMPORTED_MODULE_4__util_mesh_LabelsMesh__["a" /* default */]();
- axisLabelsMesh.material.depthMask = false;
- var rootNode = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- rootNode.add(linesMesh);
- rootNode.add(axisLabelsMesh);
- this.rootNode = rootNode;
- this.dim = dim;
- this.linesMesh = linesMesh;
- this.labelsMesh = axisLabelsMesh;
- this.axisLineCoords = null;
- this.labelElements = [];
- }
- var otherDim = {
- x: 'y', y: 'x', z: 'y'
- };
- Grid3DAxis.prototype.update = function (
- grid3DModel, axisLabelSurface, api
- ) {
- var cartesian = grid3DModel.coordinateSystem;
- var axis = cartesian.getAxis(this.dim);
- var linesGeo = this.linesMesh.geometry;
- var labelsGeo = this.labelsMesh.geometry;
- linesGeo.convertToDynamicArray(true);
- labelsGeo.convertToDynamicArray(true);
- var axisModel = axis.model;
- var extent = axis.getExtent();
- var dpr = api.getDevicePixelRatio();
- var axisLineModel = axisModel.getModel('axisLine', grid3DModel.getModel('axisLine'));
- var axisTickModel = axisModel.getModel('axisTick', grid3DModel.getModel('axisTick'));
- var axisLabelModel = axisModel.getModel('axisLabel', grid3DModel.getModel('axisLabel'));
- var axisLineColor = axisLineModel.get('lineStyle.color');
- // Render axisLine
- if (axisLineModel.get('show')) {
- var axisLineStyleModel = axisLineModel.getModel('lineStyle');
- var p0 = [0, 0, 0]; var p1 = [0, 0, 0];
- var idx = dimIndicesMap[axis.dim];
- p0[idx] = extent[0];
- p1[idx] = extent[1];
- // Save some useful info.
- this.axisLineCoords = [p0, p1];
- var color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(axisLineColor);
- var lineWidth = firstNotNull(axisLineStyleModel.get('width'), 1.0);
- var opacity = firstNotNull(axisLineStyleModel.get('opacity'), 1.0);
- color[3] *= opacity;
- linesGeo.addLine(p0, p1, color, lineWidth * dpr);
- }
- // Render axis ticksCoords
- if (axisTickModel.get('show')) {
- var lineStyleModel = axisTickModel.getModel('lineStyle');
- var lineColor = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(
- firstNotNull(lineStyleModel.get('color'), axisLineColor)
- );
- var lineWidth = firstNotNull(lineStyleModel.get('width'), 1.0);
- lineColor[3] *= firstNotNull(lineStyleModel.get('opacity'), 1.0);
- var ticksCoords = axis.getTicksCoords();
- var tickLength = axisTickModel.get('length');
- for (var i = 0; i < ticksCoords.length; i++) {
- var tickCoord = ticksCoords[i].coord;
- var p0 = [0, 0, 0]; var p1 = [0, 0, 0];
- var idx = dimIndicesMap[axis.dim];
- var otherIdx = dimIndicesMap[otherDim[axis.dim]];
- // 0 : x, 1 : y
- p0[idx] = p1[idx] = tickCoord;
- p1[otherIdx] = tickLength;
- linesGeo.addLine(p0, p1, lineColor, lineWidth * dpr);
- }
- }
- this.labelElements = [];
- var dpr = api.getDevicePixelRatio();
- if (axisLabelModel.get('show')) {
- var ticksCoords = axis.getTicksCoords();
- var categoryData = axisModel.get('data');
- var labelMargin = axisLabelModel.get('margin');
- var labels = axis.getViewLabels();
- for (var i = 0; i < labels.length; i++) {
- var tickValue = labels[i].tickValue;
- var formattedLabel = labels[i].formattedLabel;
- var rawLabel = labels[i].rawLabel;
- var tickCoord = axis.dataToCoord(tickValue);
- var p = [0, 0, 0];
- var idx = dimIndicesMap[axis.dim];
- var otherIdx = dimIndicesMap[otherDim[axis.dim]];
- // 0 : x, 1 : y
- p[idx] = p[idx] = tickCoord;
- p[otherIdx] = labelMargin;
- var itemTextStyleModel = axisLabelModel;
- if (categoryData && categoryData[tickValue] && categoryData[tickValue].textStyle) {
- itemTextStyleModel = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.Model(
- categoryData[tickValue].textStyle, axisLabelModel, axisModel.ecModel
- );
- }
- var textColor = firstNotNull(itemTextStyleModel.get('color'), axisLineColor);
- var textEl = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Text();
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.setTextStyle(textEl.style, itemTextStyleModel, {
- text: formattedLabel,
- textFill: typeof textColor === 'function'
- ? textColor(
- // (1) In category axis with data zoom, tick is not the original
- // index of axis.data. So tick should not be exposed to user
- // in category axis.
- // (2) Compatible with previous version, which always returns labelStr.
- // But in interval scale labelStr is like '223,445', which maked
- // user repalce ','. So we modify it to return original val but remain
- // it as 'string' to avoid error in replacing.
- axis.type === 'category' ? rawLabel : axis.type === 'value' ? tickValue + '' : tickValue,
- i
- )
- : textColor,
- textVerticalAlign: 'top',
- textAlign: 'left'
- });
- var coords = axisLabelSurface.add(textEl);
- var rect = textEl.getBoundingRect();
- labelsGeo.addSprite(p, [rect.width * dpr, rect.height * dpr], coords);
- this.labelElements.push(textEl);
- }
- }
- if (axisModel.get('name')) {
- var nameTextStyleModel = axisModel.getModel('nameTextStyle');
- var p = [0, 0, 0];
- var idx = dimIndicesMap[axis.dim];
- var otherIdx = dimIndicesMap[otherDim[axis.dim]];
- var labelColor = firstNotNull(nameTextStyleModel.get('color'), axisLineColor);
- var strokeColor = nameTextStyleModel.get('borderColor');
- var lineWidth = nameTextStyleModel.get('borderWidth');
- // TODO start and end
- p[idx] = p[idx] = (extent[0] + extent[1]) / 2;
- p[otherIdx] = axisModel.get('nameGap');
- var textEl = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.Text();
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.graphic.setTextStyle(textEl.style, nameTextStyleModel, {
- text: axisModel.get('name'),
- textFill: labelColor,
- textStroke: strokeColor,
- lineWidth: lineWidth
- });
- var coords = axisLabelSurface.add(textEl);
- var rect = textEl.getBoundingRect();
- labelsGeo.addSprite(p, [rect.width * dpr, rect.height * dpr], coords);
- textEl.__idx = this.labelElements.length;
- this.nameLabelElement = textEl;
- }
- this.labelsMesh.material.set('textureAtlas', axisLabelSurface.getTexture());
- this.labelsMesh.material.set('uvScale', axisLabelSurface.getCoordsScale());
- linesGeo.convertToTypedArray();
- labelsGeo.convertToTypedArray();
- };
- Grid3DAxis.prototype.setSpriteAlign = function (textAlign, textVerticalAlign, api) {
- var dpr = api.getDevicePixelRatio();
- var labelGeo = this.labelsMesh.geometry;
- for (var i = 0; i < this.labelElements.length; i++) {
- var labelEl = this.labelElements[i];
- var rect = labelEl.getBoundingRect();
- labelGeo.setSpriteAlign(i, [rect.width * dpr, rect.height * dpr], textAlign, textVerticalAlign);
- }
- // name label
- var nameLabelEl = this.nameLabelElement;
- if (nameLabelEl) {
- var rect = nameLabelEl.getBoundingRect();
- labelGeo.setSpriteAlign(nameLabelEl.__idx, [rect.width * dpr, rect.height * dpr], textAlign, textVerticalAlign);
- labelGeo.dirty();
- }
- this.textAlign = textAlign;
- this.textVerticalAlign = textVerticalAlign;
- };
- /* harmony default export */ __webpack_exports__["a"] = (Grid3DAxis);
- /***/
- }),
- /* 165 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__ = __webpack_require__(15);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__ = __webpack_require__(38);
- /**
- * Geometry collecting sprites
- *
- * @module echarts-gl/util/geometry/Sprites
- * @author Yi Shen(https://github.com/pissang)
- */
- var squareTriangles = [
- 0, 1, 2, 0, 2, 3
- ];
- var SpritesGeometry = __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__["a" /* default */].extend(function () {
- return {
- attributes: {
- position: new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__["a" /* default */].Attribute('position', 'float', 3, 'POSITION'),
- texcoord: new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__["a" /* default */].Attribute('texcoord', 'float', 2, 'TEXCOORD_0'),
- offset: new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__["a" /* default */].Attribute('offset', 'float', 2),
- color: new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__["a" /* default */].Attribute('color', 'float', 4, 'COLOR')
- }
- };
- }, {
- resetOffset: function () {
- this._vertexOffset = 0;
- this._faceOffset = 0;
- },
- setSpriteCount: function (spriteCount) {
- this._spriteCount = spriteCount;
- var vertexCount = spriteCount * 4;
- var triangleCount = spriteCount * 2;
- if (this.vertexCount !== vertexCount) {
- this.attributes.position.init(vertexCount);
- this.attributes.offset.init(vertexCount);
- this.attributes.color.init(vertexCount);
- }
- if (this.triangleCount !== triangleCount) {
- this.indices = vertexCount > 0xffff ? new Uint32Array(triangleCount * 3) : new Uint16Array(triangleCount * 3);
- }
- },
- setSpriteAlign: function (spriteOffset, size, align, verticalAlign, margin) {
- if (align == null) {
- align = 'left';
- }
- if (verticalAlign == null) {
- verticalAlign = 'top';
- }
- var leftOffset, topOffset, rightOffset, bottomOffset;
- margin = margin || 0;
- switch (align) {
- case 'left':
- leftOffset = margin;
- rightOffset = size[0] + margin;
- break;
- case 'center':
- case 'middle':
- leftOffset = -size[0] / 2;
- rightOffset = size[0] / 2;
- break;
- case 'right':
- leftOffset = -size[0] - margin;
- rightOffset = -margin;
- break;
- }
- switch (verticalAlign) {
- case 'bottom':
- topOffset = margin;
- bottomOffset = size[1] + margin;
- break;
- case 'middle':
- topOffset = -size[1] / 2;
- bottomOffset = size[1] / 2;
- break;
- case 'top':
- topOffset = -size[1] - margin;
- bottomOffset = -margin;
- break;
- }
- // 3----2
- // 0----1
- var vertexOffset = spriteOffset * 4;
- var offsetAttr = this.attributes.offset;
- offsetAttr.set(vertexOffset, [leftOffset, bottomOffset]);
- offsetAttr.set(vertexOffset + 1, [rightOffset, bottomOffset]);
- offsetAttr.set(vertexOffset + 2, [rightOffset, topOffset]);
- offsetAttr.set(vertexOffset + 3, [leftOffset, topOffset]);
- },
- /**
- * Add sprite
- * @param {Array.<number>} position
- * @param {Array.<number>} size [width, height]
- * @param {Array.<Array>} coords [leftBottom, rightTop]
- * @param {string} [align='left'] 'left' 'center' 'right'
- * @param {string} [verticalAlign='top'] 'top' 'middle' 'bottom'
- * @param {number} [screenMargin=0]
- */
- addSprite: function (position, size, coords, align, verticalAlign, screenMargin) {
- var vertexOffset = this._vertexOffset;
- this.setSprite(
- this._vertexOffset / 4, position, size, coords, align, verticalAlign, screenMargin
- )
- for (var i = 0; i < squareTriangles.length; i++) {
- this.indices[this._faceOffset * 3 + i] = squareTriangles[i] + vertexOffset;
- }
- this._faceOffset += 2;
- this._vertexOffset += 4;
- return vertexOffset / 4;
- },
- setSprite: function (spriteOffset, position, size, coords, align, verticalAlign, screenMargin) {
- var vertexOffset = spriteOffset * 4;
- var attributes = this.attributes;
- for (var i = 0; i < 4; i++) {
- attributes.position.set(vertexOffset + i, position);
- }
- // 3----2
- // 0----1
- var texcoordAttr = attributes.texcoord;
- texcoordAttr.set(vertexOffset, [coords[0][0], coords[0][1]]);
- texcoordAttr.set(vertexOffset + 1, [coords[1][0], coords[0][1]]);
- texcoordAttr.set(vertexOffset + 2, [coords[1][0], coords[1][1]]);
- texcoordAttr.set(vertexOffset + 3, [coords[0][0], coords[1][1]]);
- this.setSpriteAlign(spriteOffset, size, align, verticalAlign, screenMargin);
- }
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.defaults(SpritesGeometry.prototype, __WEBPACK_IMPORTED_MODULE_2__dynamicConvertMixin__["a" /* default */]);
- /* harmony default export */ __webpack_exports__["a"] = (SpritesGeometry);
- /***/
- }),
- /* 166 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.labels.vertex\n\nattribute vec3 position: POSITION;\nattribute vec2 texcoord: TEXCOORD_0;\nattribute vec2 offset;\n#ifdef VERTEX_COLOR\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n#endif\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n vec4 proj = worldViewProjection * vec4(position, 1.0);\n\n vec2 screen = (proj.xy / abs(proj.w) + 1.0) * 0.5 * viewport.zw;\n\n screen += offset;\n\n proj.xy = (screen / viewport.zw - 0.5) * 2.0 * abs(proj.w);\n gl_Position = proj;\n#ifdef VERTEX_COLOR\n v_Color = a_Color;\n#endif\n v_Texcoord = texcoord;\n}\n@end\n\n\n@export ecgl.labels.fragment\n\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform float alpha : 1.0;\nuniform sampler2D textureAtlas;\nuniform vec2 uvScale: [1.0, 1.0];\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\nvarying float v_Miter;\n\nvarying vec2 v_Texcoord;\n\nvoid main()\n{\n gl_FragColor = vec4(color, alpha) * texture2D(textureAtlas, v_Texcoord * uvScale);\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n#endif\n}\n\n@end");
- /***/
- }),
- /* 167 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__grid3D_Cartesian3D__ = __webpack_require__(168);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__grid3D_Axis3D__ = __webpack_require__(170);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_util_layout__ = __webpack_require__(47);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_util_layout___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_util_layout__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__core_ViewGL__ = __webpack_require__(22);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(2);
- function resizeCartesian3D(grid3DModel, api) {
- // Use left/top/width/height
- var boxLayoutOption = grid3DModel.getBoxLayoutParams();
- var viewport = __WEBPACK_IMPORTED_MODULE_3_echarts_lib_util_layout___default.a.getLayoutRect(boxLayoutOption, {
- width: api.getWidth(),
- height: api.getHeight()
- });
- // Flip Y
- viewport.y = api.getHeight() - viewport.y - viewport.height;
- this.viewGL.setViewport(viewport.x, viewport.y, viewport.width, viewport.height, api.getDevicePixelRatio());
- var boxWidth = grid3DModel.get('boxWidth');
- var boxHeight = grid3DModel.get('boxHeight');
- var boxDepth = grid3DModel.get('boxDepth');
- if (true) {
- ['x', 'y', 'z'].forEach(function (dim) {
- if (!this.getAxis(dim)) {
- throw new Error('Grid' + grid3DModel.id + ' don\'t have ' + dim + 'Axis');
- }
- }, this);
- }
- this.getAxis('x').setExtent(-boxWidth / 2, boxWidth / 2);
- // From near to far
- this.getAxis('y').setExtent(boxDepth / 2, -boxDepth / 2);
- this.getAxis('z').setExtent(-boxHeight / 2, boxHeight / 2);
- this.size = [boxWidth, boxHeight, boxDepth];
- }
- function updateCartesian3D(ecModel, api) {
- var dataExtents = {};
- function unionDataExtents(dim, extent) {
- dataExtents[dim] = dataExtents[dim] || [Infinity, -Infinity];
- dataExtents[dim][0] = Math.min(extent[0], dataExtents[dim][0]);
- dataExtents[dim][1] = Math.max(extent[1], dataExtents[dim][1]);
- }
- // Get data extents for scale.
- ecModel.eachSeries(function (seriesModel) {
- if (seriesModel.coordinateSystem !== this) {
- return;
- }
- var data = seriesModel.getData();
- ['x', 'y', 'z'].forEach(function (coordDim) {
- data.mapDimension(coordDim, true).forEach(function (dataDim) {
- unionDataExtents(
- coordDim, data.getDataExtent(dataDim, true)
- );
- });
- });
- }, this);
- ['xAxis3D', 'yAxis3D', 'zAxis3D'].forEach(function (axisType) {
- ecModel.eachComponent(axisType, function (axisModel) {
- var dim = axisType.charAt(0);
- var grid3DModel = axisModel.getReferringComponents('grid3D')[0];
- var cartesian3D = grid3DModel.coordinateSystem;
- if (cartesian3D !== this) {
- return;
- }
- var axis = cartesian3D.getAxis(dim);
- if (axis) {
- if (true) {
- console.warn('Can\'t have two %s in one grid3D', axisType);
- }
- return;
- }
- var scale = __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default.a.helper.createScale(
- dataExtents[dim] || [Infinity, -Infinity], axisModel
- );
- axis = new __WEBPACK_IMPORTED_MODULE_1__grid3D_Axis3D__["a" /* default */](dim, scale);
- axis.type = axisModel.get('type');
- var isCategory = axis.type === 'category';
- axis.onBand = isCategory && axisModel.get('boundaryGap');
- axis.inverse = axisModel.get('inverse');
- axisModel.axis = axis;
- axis.model = axisModel;
- // override `echarts/coord/Axis#getLabelModel`
- axis.getLabelModel = function () {
- return axisModel.getModel('axisLabel', grid3DModel.getModel('axisLabel'));
- };
- // override `echarts/coord/Axis#getTickModel`
- axis.getTickModel = function () {
- return axisModel.getModel('axisTick', grid3DModel.getModel('axisTick'));
- };
- cartesian3D.addAxis(axis);
- }, this);
- }, this);
- this.resize(this.model, api);
- }
- var grid3DCreator = {
- dimensions: __WEBPACK_IMPORTED_MODULE_0__grid3D_Cartesian3D__["a" /* default */].prototype.dimensions,
- create: function (ecModel, api) {
- var cartesian3DList = [];
- ecModel.eachComponent('grid3D', function (grid3DModel) {
- // FIXME
- grid3DModel.__viewGL = grid3DModel.__viewGL || new __WEBPACK_IMPORTED_MODULE_4__core_ViewGL__["a" /* default */]();
- var cartesian3D = new __WEBPACK_IMPORTED_MODULE_0__grid3D_Cartesian3D__["a" /* default */]();
- cartesian3D.model = grid3DModel;
- cartesian3D.viewGL = grid3DModel.__viewGL;
- grid3DModel.coordinateSystem = cartesian3D;
- cartesian3DList.push(cartesian3D);
- // Inject resize and update
- cartesian3D.resize = resizeCartesian3D;
- cartesian3D.update = updateCartesian3D;
- });
- var axesTypes = ['xAxis3D', 'yAxis3D', 'zAxis3D'];
- function findAxesModels(seriesModel, ecModel) {
- return axesTypes.map(function (axisType) {
- var axisModel = seriesModel.getReferringComponents(axisType)[0];
- if (axisModel == null) {
- axisModel = ecModel.getComponent(axisType);
- }
- if (true) {
- if (!axisModel) {
- throw new Error(axisType + ' "' + __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(
- seriesModel.get(axisType + 'Index'),
- seriesModel.get(axisType + 'Id'),
- 0
- ) + '" not found');
- }
- }
- return axisModel;
- });
- }
- ecModel.eachSeries(function (seriesModel) {
- if (seriesModel.get('coordinateSystem') !== 'cartesian3D') {
- return;
- }
- var firstGridModel = seriesModel.getReferringComponents('grid3D')[0];
- if (firstGridModel == null) {
- var axesModels = findAxesModels(seriesModel, ecModel);
- var firstGridModel = axesModels[0].getCoordSysModel();
- axesModels.forEach(function (axisModel) {
- var grid3DModel = axisModel.getCoordSysModel();
- if (true) {
- if (!grid3DModel) {
- throw new Error(
- 'grid3D "' + __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(
- axisModel.get('gridIndex'),
- axisModel.get('gridId'),
- 0
- ) + '" not found'
- );
- }
- if (grid3DModel !== firstGridModel) {
- throw new Error('xAxis3D, yAxis3D, zAxis3D must use the same grid');
- }
- }
- });
- }
- var coordSys = firstGridModel.coordinateSystem;
- seriesModel.coordinateSystem = coordSys;
- });
- return cartesian3DList;
- }
- };
- __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default.a.registerCoordinateSystem('grid3D', grid3DCreator);
- /* unused harmony default export */ var _unused_webpack_default_export = (grid3DCreator);
- /***/
- }),
- /* 168 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_coord_cartesian_Cartesian__ = __webpack_require__(169);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_coord_cartesian_Cartesian___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_coord_cartesian_Cartesian__);
- function Cartesian3D(name) {
- __WEBPACK_IMPORTED_MODULE_1_echarts_lib_coord_cartesian_Cartesian___default.a.call(this, name);
- this.size = [0, 0, 0];
- }
- Cartesian3D.prototype = {
- constructor: Cartesian3D,
- type: 'cartesian3D',
- dimensions: ['x', 'y', 'z'],
- model: null,
- containPoint: function (point) {
- return this.getAxis('x').contain(point[0])
- && this.getAxis('y').contain(point[2])
- && this.getAxis('z').contain(point[1]);
- },
- containData: function (data) {
- return this.getAxis('x').containData(data[0])
- && this.getAxis('y').containData(data[1])
- && this.getAxis('z').containData(data[2]);
- },
- dataToPoint: function (data, out, clamp) {
- out = out || [];
- out[0] = this.getAxis('x').dataToCoord(data[0], clamp);
- out[2] = this.getAxis('y').dataToCoord(data[1], clamp);
- out[1] = this.getAxis('z').dataToCoord(data[2], clamp);
- return out;
- },
- pointToData: function (point, out, clamp) {
- out = out || [];
- out[0] = this.getAxis('x').coordToData(point[0], clamp);
- out[1] = this.getAxis('y').coordToData(point[2], clamp);
- out[2] = this.getAxis('z').coordToData(point[1], clamp);
- return out;
- }
- };
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.inherits(Cartesian3D, __WEBPACK_IMPORTED_MODULE_1_echarts_lib_coord_cartesian_Cartesian___default.a);
- /* harmony default export */ __webpack_exports__["a"] = (Cartesian3D);
- /***/
- }),
- /* 169 */
- /***/ (function (module, exports, __webpack_require__) {
- var zrUtil = __webpack_require__(13);
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- /**
- * Cartesian coordinate system
- * @module echarts/coord/Cartesian
- *
- */
- function dimAxisMapper(dim) {
- return this._axes[dim];
- }
- /**
- * @alias module:echarts/coord/Cartesian
- * @constructor
- */
- var Cartesian = function (name) {
- this._axes = {};
- this._dimList = [];
- /**
- * @type {string}
- */
- this.name = name || '';
- };
- Cartesian.prototype = {
- constructor: Cartesian,
- type: 'cartesian',
- /**
- * Get axis
- * @param {number|string} dim
- * @return {module:echarts/coord/Cartesian~Axis}
- */
- getAxis: function (dim) {
- return this._axes[dim];
- },
- /**
- * Get axes list
- * @return {Array.<module:echarts/coord/Cartesian~Axis>}
- */
- getAxes: function () {
- return zrUtil.map(this._dimList, dimAxisMapper, this);
- },
- /**
- * Get axes list by given scale type
- */
- getAxesByScale: function (scaleType) {
- scaleType = scaleType.toLowerCase();
- return zrUtil.filter(this.getAxes(), function (axis) {
- return axis.scale.type === scaleType;
- });
- },
- /**
- * Add axis
- * @param {module:echarts/coord/Cartesian.Axis}
- */
- addAxis: function (axis) {
- var dim = axis.dim;
- this._axes[dim] = axis;
- this._dimList.push(dim);
- },
- /**
- * Convert data to coord in nd space
- * @param {Array.<number>|Object.<string, number>} val
- * @return {Array.<number>|Object.<string, number>}
- */
- dataToCoord: function (val) {
- return this._dataCoordConvert(val, 'dataToCoord');
- },
- /**
- * Convert coord in nd space to data
- * @param {Array.<number>|Object.<string, number>} val
- * @return {Array.<number>|Object.<string, number>}
- */
- coordToData: function (val) {
- return this._dataCoordConvert(val, 'coordToData');
- },
- _dataCoordConvert: function (input, method) {
- var dimList = this._dimList;
- var output = input instanceof Array ? [] : {};
- for (var i = 0; i < dimList.length; i++) {
- var dim = dimList[i];
- var axis = this._axes[dim];
- output[dim] = axis[method](input[dim]);
- }
- return output;
- }
- };
- var _default = Cartesian;
- module.exports = _default;
- /***/
- }),
- /* 170 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- function Axis3D(dim, scale, extent) {
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.Axis.call(this, dim, scale, extent);
- }
- Axis3D.prototype = {
- constructor: Axis3D,
- getExtentMin: function () {
- var extent = this._extent;
- return Math.min(extent[0], extent[1]);
- },
- getExtentMax: function () {
- var extent = this._extent;
- return Math.max(extent[0], extent[1]);
- },
- calculateCategoryInterval: function () {
- // TODO consider label length
- return Math.floor(this.scale.count() / 8);
- }
- };
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.inherits(Axis3D, __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.Axis);
- /* harmony default export */ __webpack_exports__["a"] = (Axis3D);
- /***/
- }),
- /* 171 */
- /***/ (function (module, exports, __webpack_require__) {
- var zrUtil = __webpack_require__(13);
- var textContain = __webpack_require__(172);
- var numberUtil = __webpack_require__(85);
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- /**
- * æ¯ä¸‰ä½é»˜è®¤åŠ ,æ ¼å¼åŒ–
- * @param {string|number} x
- * @return {string}
- */
- function addCommas(x) {
- if (isNaN(x)) {
- return '-';
- }
- x = (x + '').split('.');
- return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g, '$1,') + (x.length > 1 ? '.' + x[1] : '');
- }
- /**
- * @param {string} str
- * @param {boolean} [upperCaseFirst=false]
- * @return {string} str
- */
- function toCamelCase(str, upperCaseFirst) {
- str = (str || '').toLowerCase().replace(/-(.)/g, function (match, group1) {
- return group1.toUpperCase();
- });
- if (upperCaseFirst && str) {
- str = str.charAt(0).toUpperCase() + str.slice(1);
- }
- return str;
- }
- var normalizeCssArray = zrUtil.normalizeCssArray;
- var replaceReg = /([&<>"'])/g;
- var replaceMap = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- '\'': '''
- };
- function encodeHTML(source) {
- return source == null ? '' : (source + '').replace(replaceReg, function (str, c) {
- return replaceMap[c];
- });
- }
- var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
- var wrapVar = function (varName, seriesIdx) {
- return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}';
- };
- /**
- * Template formatter
- * @param {string} tpl
- * @param {Array.<Object>|Object} paramsList
- * @param {boolean} [encode=false]
- * @return {string}
- */
- function formatTpl(tpl, paramsList, encode) {
- if (!zrUtil.isArray(paramsList)) {
- paramsList = [paramsList];
- }
- var seriesLen = paramsList.length;
- if (!seriesLen) {
- return '';
- }
- var $vars = paramsList[0].$vars || [];
- for (var i = 0; i < $vars.length; i++) {
- var alias = TPL_VAR_ALIAS[i];
- tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0));
- }
- for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) {
- for (var k = 0; k < $vars.length; k++) {
- var val = paramsList[seriesIdx][$vars[k]];
- tpl = tpl.replace(wrapVar(TPL_VAR_ALIAS[k], seriesIdx), encode ? encodeHTML(val) : val);
- }
- }
- return tpl;
- }
- /**
- * simple Template formatter
- *
- * @param {string} tpl
- * @param {Object} param
- * @param {boolean} [encode=false]
- * @return {string}
- */
- function formatTplSimple(tpl, param, encode) {
- zrUtil.each(param, function (value, key) {
- tpl = tpl.replace('{' + key + '}', encode ? encodeHTML(value) : value);
- });
- return tpl;
- }
- /**
- * @param {Object|string} [opt] If string, means color.
- * @param {string} [opt.color]
- * @param {string} [opt.extraCssText]
- * @param {string} [opt.type='item'] 'item' or 'subItem'
- * @return {string}
- */
- function getTooltipMarker(opt, extraCssText) {
- opt = zrUtil.isString(opt) ? {
- color: opt,
- extraCssText: extraCssText
- } : opt || {};
- var color = opt.color;
- var type = opt.type;
- var extraCssText = opt.extraCssText;
- if (!color) {
- return '';
- }
- return type === 'subItem' ? '<span style="display:inline-block;vertical-align:middle;margin-right:8px;margin-left:3px;' + 'border-radius:4px;width:4px;height:4px;background-color:' + encodeHTML(color) + ';' + (extraCssText || '') + '"></span>' : '<span style="display:inline-block;margin-right:5px;' + 'border-radius:10px;width:10px;height:10px;background-color:' + encodeHTML(color) + ';' + (extraCssText || '') + '"></span>';
- }
- function pad(str, len) {
- str += '';
- return '0000'.substr(0, len - str.length) + str;
- }
- /**
- * ISO Date format
- * @param {string} tpl
- * @param {number} value
- * @param {boolean} [isUTC=false] Default in local time.
- * see `module:echarts/scale/Time`
- * and `module:echarts/util/number#parseDate`.
- * @inner
- */
- function formatTime(tpl, value, isUTC) {
- if (tpl === 'week' || tpl === 'month' || tpl === 'quarter' || tpl === 'half-year' || tpl === 'year') {
- tpl = 'MM-dd\nyyyy';
- }
- var date = numberUtil.parseDate(value);
- var utc = isUTC ? 'UTC' : '';
- var y = date['get' + utc + 'FullYear']();
- var M = date['get' + utc + 'Month']() + 1;
- var d = date['get' + utc + 'Date']();
- var h = date['get' + utc + 'Hours']();
- var m = date['get' + utc + 'Minutes']();
- var s = date['get' + utc + 'Seconds']();
- var S = date['get' + utc + 'Milliseconds']();
- tpl = tpl.replace('MM', pad(M, 2)).replace('M', M).replace('yyyy', y).replace('yy', y % 100).replace('dd', pad(d, 2)).replace('d', d).replace('hh', pad(h, 2)).replace('h', h).replace('mm', pad(m, 2)).replace('m', m).replace('ss', pad(s, 2)).replace('s', s).replace('SSS', pad(S, 3));
- return tpl;
- }
- /**
- * Capital first
- * @param {string} str
- * @return {string}
- */
- function capitalFirst(str) {
- return str ? str.charAt(0).toUpperCase() + str.substr(1) : str;
- }
- var truncateText = textContain.truncateText;
- var getTextRect = textContain.getBoundingRect;
- exports.addCommas = addCommas;
- exports.toCamelCase = toCamelCase;
- exports.normalizeCssArray = normalizeCssArray;
- exports.encodeHTML = encodeHTML;
- exports.formatTpl = formatTpl;
- exports.formatTplSimple = formatTplSimple;
- exports.getTooltipMarker = getTooltipMarker;
- exports.formatTime = formatTime;
- exports.capitalFirst = capitalFirst;
- exports.truncateText = truncateText;
- exports.getTextRect = getTextRect;
- /***/
- }),
- /* 172 */
- /***/ (function (module, exports, __webpack_require__) {
- var BoundingRect = __webpack_require__(82);
- var imageHelper = __webpack_require__(173);
- var _util = __webpack_require__(13);
- var getContext = _util.getContext;
- var extend = _util.extend;
- var retrieve2 = _util.retrieve2;
- var retrieve3 = _util.retrieve3;
- var trim = _util.trim;
- var textWidthCache = {};
- var textWidthCacheCounter = 0;
- var TEXT_CACHE_MAX = 5000;
- var STYLE_REG = /\{([a-zA-Z0-9_]+)\|([^}]*)\}/g;
- var DEFAULT_FONT = '12px sans-serif'; // Avoid assign to an exported variable, for transforming to cjs.
- var methods = {};
- function $override(name, fn) {
- methods[name] = fn;
- }
- /**
- * @public
- * @param {string} text
- * @param {string} font
- * @return {number} width
- */
- function getWidth(text, font) {
- font = font || DEFAULT_FONT;
- var key = text + ':' + font;
- if (textWidthCache[key]) {
- return textWidthCache[key];
- }
- var textLines = (text + '').split('\n');
- var width = 0;
- for (var i = 0, l = textLines.length; i < l; i++) {
- // textContain.measureText may be overrided in SVG or VML
- width = Math.max(measureText(textLines[i], font).width, width);
- }
- if (textWidthCacheCounter > TEXT_CACHE_MAX) {
- textWidthCacheCounter = 0;
- textWidthCache = {};
- }
- textWidthCacheCounter++;
- textWidthCache[key] = width;
- return width;
- }
- /**
- * @public
- * @param {string} text
- * @param {string} font
- * @param {string} [textAlign='left']
- * @param {string} [textVerticalAlign='top']
- * @param {Array.<number>} [textPadding]
- * @param {Object} [rich]
- * @param {Object} [truncate]
- * @return {Object} {x, y, width, height, lineHeight}
- */
- function getBoundingRect(text, font, textAlign, textVerticalAlign, textPadding, rich, truncate) {
- return rich ? getRichTextRect(text, font, textAlign, textVerticalAlign, textPadding, rich, truncate) : getPlainTextRect(text, font, textAlign, textVerticalAlign, textPadding, truncate);
- }
- function getPlainTextRect(text, font, textAlign, textVerticalAlign, textPadding, truncate) {
- var contentBlock = parsePlainText(text, font, textPadding, truncate);
- var outerWidth = getWidth(text, font);
- if (textPadding) {
- outerWidth += textPadding[1] + textPadding[3];
- }
- var outerHeight = contentBlock.outerHeight;
- var x = adjustTextX(0, outerWidth, textAlign);
- var y = adjustTextY(0, outerHeight, textVerticalAlign);
- var rect = new BoundingRect(x, y, outerWidth, outerHeight);
- rect.lineHeight = contentBlock.lineHeight;
- return rect;
- }
- function getRichTextRect(text, font, textAlign, textVerticalAlign, textPadding, rich, truncate) {
- var contentBlock = parseRichText(text, {
- rich: rich,
- truncate: truncate,
- font: font,
- textAlign: textAlign,
- textPadding: textPadding
- });
- var outerWidth = contentBlock.outerWidth;
- var outerHeight = contentBlock.outerHeight;
- var x = adjustTextX(0, outerWidth, textAlign);
- var y = adjustTextY(0, outerHeight, textVerticalAlign);
- return new BoundingRect(x, y, outerWidth, outerHeight);
- }
- /**
- * @public
- * @param {number} x
- * @param {number} width
- * @param {string} [textAlign='left']
- * @return {number} Adjusted x.
- */
- function adjustTextX(x, width, textAlign) {
- // FIXME Right to left language
- if (textAlign === 'right') {
- x -= width;
- } else if (textAlign === 'center') {
- x -= width / 2;
- }
- return x;
- }
- /**
- * @public
- * @param {number} y
- * @param {number} height
- * @param {string} [textVerticalAlign='top']
- * @return {number} Adjusted y.
- */
- function adjustTextY(y, height, textVerticalAlign) {
- if (textVerticalAlign === 'middle') {
- y -= height / 2;
- } else if (textVerticalAlign === 'bottom') {
- y -= height;
- }
- return y;
- }
- /**
- * @public
- * @param {stirng} textPosition
- * @param {Object} rect {x, y, width, height}
- * @param {number} distance
- * @return {Object} {x, y, textAlign, textVerticalAlign}
- */
- function adjustTextPositionOnRect(textPosition, rect, distance) {
- var x = rect.x;
- var y = rect.y;
- var height = rect.height;
- var width = rect.width;
- var halfHeight = height / 2;
- var textAlign = 'left';
- var textVerticalAlign = 'top';
- switch (textPosition) {
- case 'left':
- x -= distance;
- y += halfHeight;
- textAlign = 'right';
- textVerticalAlign = 'middle';
- break;
- case 'right':
- x += distance + width;
- y += halfHeight;
- textVerticalAlign = 'middle';
- break;
- case 'top':
- x += width / 2;
- y -= distance;
- textAlign = 'center';
- textVerticalAlign = 'bottom';
- break;
- case 'bottom':
- x += width / 2;
- y += height + distance;
- textAlign = 'center';
- break;
- case 'inside':
- x += width / 2;
- y += halfHeight;
- textAlign = 'center';
- textVerticalAlign = 'middle';
- break;
- case 'insideLeft':
- x += distance;
- y += halfHeight;
- textVerticalAlign = 'middle';
- break;
- case 'insideRight':
- x += width - distance;
- y += halfHeight;
- textAlign = 'right';
- textVerticalAlign = 'middle';
- break;
- case 'insideTop':
- x += width / 2;
- y += distance;
- textAlign = 'center';
- break;
- case 'insideBottom':
- x += width / 2;
- y += height - distance;
- textAlign = 'center';
- textVerticalAlign = 'bottom';
- break;
- case 'insideTopLeft':
- x += distance;
- y += distance;
- break;
- case 'insideTopRight':
- x += width - distance;
- y += distance;
- textAlign = 'right';
- break;
- case 'insideBottomLeft':
- x += distance;
- y += height - distance;
- textVerticalAlign = 'bottom';
- break;
- case 'insideBottomRight':
- x += width - distance;
- y += height - distance;
- textAlign = 'right';
- textVerticalAlign = 'bottom';
- break;
- }
- return {
- x: x,
- y: y,
- textAlign: textAlign,
- textVerticalAlign: textVerticalAlign
- };
- }
- /**
- * Show ellipsis if overflow.
- *
- * @public
- * @param {string} text
- * @param {string} containerWidth
- * @param {string} font
- * @param {number} [ellipsis='...']
- * @param {Object} [options]
- * @param {number} [options.maxIterations=3]
- * @param {number} [options.minChar=0] If truncate result are less
- * then minChar, ellipsis will not show, which is
- * better for user hint in some cases.
- * @param {number} [options.placeholder=''] When all truncated, use the placeholder.
- * @return {string}
- */
- function truncateText(text, containerWidth, font, ellipsis, options) {
- if (!containerWidth) {
- return '';
- }
- var textLines = (text + '').split('\n');
- options = prepareTruncateOptions(containerWidth, font, ellipsis, options); // FIXME
- // It is not appropriate that every line has '...' when truncate multiple lines.
- for (var i = 0, len = textLines.length; i < len; i++) {
- textLines[i] = truncateSingleLine(textLines[i], options);
- }
- return textLines.join('\n');
- }
- function prepareTruncateOptions(containerWidth, font, ellipsis, options) {
- options = extend({}, options);
- options.font = font;
- var ellipsis = retrieve2(ellipsis, '...');
- options.maxIterations = retrieve2(options.maxIterations, 2);
- var minChar = options.minChar = retrieve2(options.minChar, 0); // FIXME
- // Other languages?
- options.cnCharWidth = getWidth('国', font); // FIXME
- // Consider proportional font?
- var ascCharWidth = options.ascCharWidth = getWidth('a', font);
- options.placeholder = retrieve2(options.placeholder, ''); // Example 1: minChar: 3, text: 'asdfzxcv', truncate result: 'asdf', but not: 'a...'.
- // Example 2: minChar: 3, text: '维度', truncate result: '维', but not: '...'.
- var contentWidth = containerWidth = Math.max(0, containerWidth - 1); // Reserve some gap.
- for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) {
- contentWidth -= ascCharWidth;
- }
- var ellipsisWidth = getWidth(ellipsis);
- if (ellipsisWidth > contentWidth) {
- ellipsis = '';
- ellipsisWidth = 0;
- }
- contentWidth = containerWidth - ellipsisWidth;
- options.ellipsis = ellipsis;
- options.ellipsisWidth = ellipsisWidth;
- options.contentWidth = contentWidth;
- options.containerWidth = containerWidth;
- return options;
- }
- function truncateSingleLine(textLine, options) {
- var containerWidth = options.containerWidth;
- var font = options.font;
- var contentWidth = options.contentWidth;
- if (!containerWidth) {
- return '';
- }
- var lineWidth = getWidth(textLine, font);
- if (lineWidth <= containerWidth) {
- return textLine;
- }
- for (var j = 0; ; j++) {
- if (lineWidth <= contentWidth || j >= options.maxIterations) {
- textLine += options.ellipsis;
- break;
- }
- var subLength = j === 0 ? estimateLength(textLine, contentWidth, options.ascCharWidth, options.cnCharWidth) : lineWidth > 0 ? Math.floor(textLine.length * contentWidth / lineWidth) : 0;
- textLine = textLine.substr(0, subLength);
- lineWidth = getWidth(textLine, font);
- }
- if (textLine === '') {
- textLine = options.placeholder;
- }
- return textLine;
- }
- function estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {
- var width = 0;
- var i = 0;
- for (var len = text.length; i < len && width < contentWidth; i++) {
- var charCode = text.charCodeAt(i);
- width += 0 <= charCode && charCode <= 127 ? ascCharWidth : cnCharWidth;
- }
- return i;
- }
- /**
- * @public
- * @param {string} font
- * @return {number} line height
- */
- function getLineHeight(font) {
- // FIXME A rough approach.
- return getWidth('国', font);
- }
- /**
- * @public
- * @param {string} text
- * @param {string} font
- * @return {Object} width
- */
- function measureText(text, font) {
- return methods.measureText(text, font);
- } // Avoid assign to an exported variable, for transforming to cjs.
- methods.measureText = function (text, font) {
- var ctx = getContext();
- ctx.font = font || DEFAULT_FONT;
- return ctx.measureText(text);
- };
- /**
- * @public
- * @param {string} text
- * @param {string} font
- * @param {Object} [truncate]
- * @return {Object} block: {lineHeight, lines, height, outerHeight}
- * Notice: for performance, do not calculate outerWidth util needed.
- */
- function parsePlainText(text, font, padding, truncate) {
- text != null && (text += '');
- var lineHeight = getLineHeight(font);
- var lines = text ? text.split('\n') : [];
- var height = lines.length * lineHeight;
- var outerHeight = height;
- if (padding) {
- outerHeight += padding[0] + padding[2];
- }
- if (text && truncate) {
- var truncOuterHeight = truncate.outerHeight;
- var truncOuterWidth = truncate.outerWidth;
- if (truncOuterHeight != null && outerHeight > truncOuterHeight) {
- text = '';
- lines = [];
- } else if (truncOuterWidth != null) {
- var options = prepareTruncateOptions(truncOuterWidth - (padding ? padding[1] + padding[3] : 0), font, truncate.ellipsis, {
- minChar: truncate.minChar,
- placeholder: truncate.placeholder
- }); // FIXME
- // It is not appropriate that every line has '...' when truncate multiple lines.
- for (var i = 0, len = lines.length; i < len; i++) {
- lines[i] = truncateSingleLine(lines[i], options);
- }
- }
- }
- return {
- lines: lines,
- height: height,
- outerHeight: outerHeight,
- lineHeight: lineHeight
- };
- }
- /**
- * For example: 'some text {a|some text}other text{b|some text}xxx{c|}xxx'
- * Also consider 'bbbb{a|xxx\nzzz}xxxx\naaaa'.
- *
- * @public
- * @param {string} text
- * @param {Object} style
- * @return {Object} block
- * {
- * width,
- * height,
- * lines: [{
- * lineHeight,
- * width,
- * tokens: [[{
- * styleName,
- * text,
- * width, // include textPadding
- * height, // include textPadding
- * textWidth, // pure text width
- * textHeight, // pure text height
- * lineHeihgt,
- * font,
- * textAlign,
- * textVerticalAlign
- * }], [...], ...]
- * }, ...]
- * }
- * If styleName is undefined, it is plain text.
- */
- function parseRichText(text, style) {
- var contentBlock = {
- lines: [],
- width: 0,
- height: 0
- };
- text != null && (text += '');
- if (!text) {
- return contentBlock;
- }
- var lastIndex = STYLE_REG.lastIndex = 0;
- var result;
- while ((result = STYLE_REG.exec(text)) != null) {
- var matchedIndex = result.index;
- if (matchedIndex > lastIndex) {
- pushTokens(contentBlock, text.substring(lastIndex, matchedIndex));
- }
- pushTokens(contentBlock, result[2], result[1]);
- lastIndex = STYLE_REG.lastIndex;
- }
- if (lastIndex < text.length) {
- pushTokens(contentBlock, text.substring(lastIndex, text.length));
- }
- var lines = contentBlock.lines;
- var contentHeight = 0;
- var contentWidth = 0; // For `textWidth: 100%`
- var pendingList = [];
- var stlPadding = style.textPadding;
- var truncate = style.truncate;
- var truncateWidth = truncate && truncate.outerWidth;
- var truncateHeight = truncate && truncate.outerHeight;
- if (stlPadding) {
- truncateWidth != null && (truncateWidth -= stlPadding[1] + stlPadding[3]);
- truncateHeight != null && (truncateHeight -= stlPadding[0] + stlPadding[2]);
- } // Calculate layout info of tokens.
- for (var i = 0; i < lines.length; i++) {
- var line = lines[i];
- var lineHeight = 0;
- var lineWidth = 0;
- for (var j = 0; j < line.tokens.length; j++) {
- var token = line.tokens[j];
- var tokenStyle = token.styleName && style.rich[token.styleName] || {}; // textPadding should not inherit from style.
- var textPadding = token.textPadding = tokenStyle.textPadding; // textFont has been asigned to font by `normalizeStyle`.
- var font = token.font = tokenStyle.font || style.font; // textHeight can be used when textVerticalAlign is specified in token.
- var tokenHeight = token.textHeight = retrieve2( // textHeight should not be inherited, consider it can be specified
- // as box height of the block.
- tokenStyle.textHeight, getLineHeight(font));
- textPadding && (tokenHeight += textPadding[0] + textPadding[2]);
- token.height = tokenHeight;
- token.lineHeight = retrieve3(tokenStyle.textLineHeight, style.textLineHeight, tokenHeight);
- token.textAlign = tokenStyle && tokenStyle.textAlign || style.textAlign;
- token.textVerticalAlign = tokenStyle && tokenStyle.textVerticalAlign || 'middle';
- if (truncateHeight != null && contentHeight + token.lineHeight > truncateHeight) {
- return {
- lines: [],
- width: 0,
- height: 0
- };
- }
- token.textWidth = getWidth(token.text, font);
- var tokenWidth = tokenStyle.textWidth;
- var tokenWidthNotSpecified = tokenWidth == null || tokenWidth === 'auto'; // Percent width, can be `100%`, can be used in drawing separate
- // line when box width is needed to be auto.
- if (typeof tokenWidth === 'string' && tokenWidth.charAt(tokenWidth.length - 1) === '%') {
- token.percentWidth = tokenWidth;
- pendingList.push(token);
- tokenWidth = 0; // Do not truncate in this case, because there is no user case
- // and it is too complicated.
- } else {
- if (tokenWidthNotSpecified) {
- tokenWidth = token.textWidth; // FIXME: If image is not loaded and textWidth is not specified, calling
- // `getBoundingRect()` will not get correct result.
- var textBackgroundColor = tokenStyle.textBackgroundColor;
- var bgImg = textBackgroundColor && textBackgroundColor.image; // Use cases:
- // (1) If image is not loaded, it will be loaded at render phase and call
- // `dirty()` and `textBackgroundColor.image` will be replaced with the loaded
- // image, and then the right size will be calculated here at the next tick.
- // See `graphic/helper/text.js`.
- // (2) If image loaded, and `textBackgroundColor.image` is image src string,
- // use `imageHelper.findExistImage` to find cached image.
- // `imageHelper.findExistImage` will always be called here before
- // `imageHelper.createOrUpdateImage` in `graphic/helper/text.js#renderRichText`
- // which ensures that image will not be rendered before correct size calcualted.
- if (bgImg) {
- bgImg = imageHelper.findExistImage(bgImg);
- if (imageHelper.isImageReady(bgImg)) {
- tokenWidth = Math.max(tokenWidth, bgImg.width * tokenHeight / bgImg.height);
- }
- }
- }
- var paddingW = textPadding ? textPadding[1] + textPadding[3] : 0;
- tokenWidth += paddingW;
- var remianTruncWidth = truncateWidth != null ? truncateWidth - lineWidth : null;
- if (remianTruncWidth != null && remianTruncWidth < tokenWidth) {
- if (!tokenWidthNotSpecified || remianTruncWidth < paddingW) {
- token.text = '';
- token.textWidth = tokenWidth = 0;
- } else {
- token.text = truncateText(token.text, remianTruncWidth - paddingW, font, truncate.ellipsis, {
- minChar: truncate.minChar
- });
- token.textWidth = getWidth(token.text, font);
- tokenWidth = token.textWidth + paddingW;
- }
- }
- }
- lineWidth += token.width = tokenWidth;
- tokenStyle && (lineHeight = Math.max(lineHeight, token.lineHeight));
- }
- line.width = lineWidth;
- line.lineHeight = lineHeight;
- contentHeight += lineHeight;
- contentWidth = Math.max(contentWidth, lineWidth);
- }
- contentBlock.outerWidth = contentBlock.width = retrieve2(style.textWidth, contentWidth);
- contentBlock.outerHeight = contentBlock.height = retrieve2(style.textHeight, contentHeight);
- if (stlPadding) {
- contentBlock.outerWidth += stlPadding[1] + stlPadding[3];
- contentBlock.outerHeight += stlPadding[0] + stlPadding[2];
- }
- for (var i = 0; i < pendingList.length; i++) {
- var token = pendingList[i];
- var percentWidth = token.percentWidth; // Should not base on outerWidth, because token can not be placed out of padding.
- token.width = parseInt(percentWidth, 10) / 100 * contentWidth;
- }
- return contentBlock;
- }
- function pushTokens(block, str, styleName) {
- var isEmptyStr = str === '';
- var strs = str.split('\n');
- var lines = block.lines;
- for (var i = 0; i < strs.length; i++) {
- var text = strs[i];
- var token = {
- styleName: styleName,
- text: text,
- isLineHolder: !text && !isEmptyStr
- }; // The first token should be appended to the last line.
- if (!i) {
- var tokens = (lines[lines.length - 1] || (lines[0] = {
- tokens: []
- })).tokens; // Consider cases:
- // (1) ''.split('\n') => ['', '\n', ''], the '' at the first item
- // (which is a placeholder) should be replaced by new token.
- // (2) A image backage, where token likes {a|}.
- // (3) A redundant '' will affect textAlign in line.
- // (4) tokens with the same tplName should not be merged, because
- // they should be displayed in different box (with border and padding).
- var tokensLen = tokens.length;
- tokensLen === 1 && tokens[0].isLineHolder ? tokens[0] = token : // Consider text is '', only insert when it is the "lineHolder" or
- // "emptyStr". Otherwise a redundant '' will affect textAlign in line.
- (text || !tokensLen || isEmptyStr) && tokens.push(token);
- } // Other tokens always start a new line.
- else {
- // If there is '', insert it as a placeholder.
- lines.push({
- tokens: [token]
- });
- }
- }
- }
- function makeFont(style) {
- // FIXME in node-canvas fontWeight is before fontStyle
- // Use `fontSize` `fontFamily` to check whether font properties are defined.
- var font = (style.fontSize || style.fontFamily) && [style.fontStyle, style.fontWeight, (style.fontSize || 12) + 'px', // If font properties are defined, `fontFamily` should not be ignored.
- style.fontFamily || 'sans-serif'].join(' ');
- return font && trim(font) || style.textFont || style.font;
- }
- exports.DEFAULT_FONT = DEFAULT_FONT;
- exports.$override = $override;
- exports.getWidth = getWidth;
- exports.getBoundingRect = getBoundingRect;
- exports.adjustTextX = adjustTextX;
- exports.adjustTextY = adjustTextY;
- exports.adjustTextPositionOnRect = adjustTextPositionOnRect;
- exports.truncateText = truncateText;
- exports.getLineHeight = getLineHeight;
- exports.measureText = measureText;
- exports.parsePlainText = parsePlainText;
- exports.parseRichText = parseRichText;
- exports.makeFont = makeFont;
- /***/
- }),
- /* 173 */
- /***/ (function (module, exports, __webpack_require__) {
- var LRU = __webpack_require__(60);
- var globalImageCache = new LRU(50);
- /**
- * @param {string|HTMLImageElement|HTMLCanvasElement|Canvas} newImageOrSrc
- * @return {HTMLImageElement|HTMLCanvasElement|Canvas} image
- */
- function findExistImage(newImageOrSrc) {
- if (typeof newImageOrSrc === 'string') {
- var cachedImgObj = globalImageCache.get(newImageOrSrc);
- return cachedImgObj && cachedImgObj.image;
- } else {
- return newImageOrSrc;
- }
- }
- /**
- * Caution: User should cache loaded images, but not just count on LRU.
- * Consider if required images more than LRU size, will dead loop occur?
- *
- * @param {string|HTMLImageElement|HTMLCanvasElement|Canvas} newImageOrSrc
- * @param {HTMLImageElement|HTMLCanvasElement|Canvas} image Existent image.
- * @param {module:zrender/Element} [hostEl] For calling `dirty`.
- * @param {Function} [cb] params: (image, cbPayload)
- * @param {Object} [cbPayload] Payload on cb calling.
- * @return {HTMLImageElement|HTMLCanvasElement|Canvas} image
- */
- function createOrUpdateImage(newImageOrSrc, image, hostEl, cb, cbPayload) {
- if (!newImageOrSrc) {
- return image;
- } else if (typeof newImageOrSrc === 'string') {
- // Image should not be loaded repeatly.
- if (image && image.__zrImageSrc === newImageOrSrc || !hostEl) {
- return image;
- } // Only when there is no existent image or existent image src
- // is different, this method is responsible for load.
- var cachedImgObj = globalImageCache.get(newImageOrSrc);
- var pendingWrap = {
- hostEl: hostEl,
- cb: cb,
- cbPayload: cbPayload
- };
- if (cachedImgObj) {
- image = cachedImgObj.image;
- !isImageReady(image) && cachedImgObj.pending.push(pendingWrap);
- } else {
- !image && (image = new Image());
- image.onload = imageOnLoad;
- globalImageCache.put(newImageOrSrc, image.__cachedImgObj = {
- image: image,
- pending: [pendingWrap]
- });
- image.src = image.__zrImageSrc = newImageOrSrc;
- }
- return image;
- } // newImageOrSrc is an HTMLImageElement or HTMLCanvasElement or Canvas
- else {
- return newImageOrSrc;
- }
- }
- function imageOnLoad() {
- var cachedImgObj = this.__cachedImgObj;
- this.onload = this.__cachedImgObj = null;
- for (var i = 0; i < cachedImgObj.pending.length; i++) {
- var pendingWrap = cachedImgObj.pending[i];
- var cb = pendingWrap.cb;
- cb && cb(this, pendingWrap.cbPayload);
- pendingWrap.hostEl.dirty();
- }
- cachedImgObj.pending.length = 0;
- }
- function isImageReady(image) {
- return image && image.width && image.height;
- }
- exports.findExistImage = findExistImage;
- exports.createOrUpdateImage = createOrUpdateImage;
- exports.isImageReady = isImageReady;
- /***/
- }),
- /* 174 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__ = __webpack_require__(18);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__math_Frustum__ = __webpack_require__(59);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Renderer__ = __webpack_require__(52);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Material__ = __webpack_require__(19);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__FrameBuffer__ = __webpack_require__(10);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__TextureCube__ = __webpack_require__(27);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__ = __webpack_require__(41);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__camera_Orthographic__ = __webpack_require__(37);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__compositor_Pass__ = __webpack_require__(16);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__compositor_TexturePool__ = __webpack_require__(86);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__ = __webpack_require__(21);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__shader_source_shadowmap_glsl_js__ = __webpack_require__(175);
- var targets = ['px', 'nx', 'py', 'ny', 'pz', 'nz'];
- __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_18__shader_source_shadowmap_glsl_js__["a" /* default */]);
- function getDepthMaterialUniform(renderable, depthMaterial, symbol) {
- if (symbol === 'alphaMap') {
- return renderable.material.get('diffuseMap');
- }
- else if (symbol === 'alphaCutoff') {
- if (renderable.material.isDefined('fragment', 'ALPHA_TEST')
- && renderable.material.get('diffuseMap')
- ) {
- var alphaCutoff = renderable.material.get('alphaCutoff');
- return alphaCutoff || 0;
- }
- return 0;
- }
- else {
- return depthMaterial.get(symbol);
- }
- }
- function isDepthMaterialChanged(renderable, prevRenderable) {
- var matA = renderable.material;
- var matB = prevRenderable.material;
- return matA.get('diffuseMap') !== matB.get('diffuseMap')
- || (matA.get('alphaCutoff') || 0) !== (matB.get('alphaCutoff') || 0);
- }
- /**
- * Pass rendering shadow map.
- *
- * @constructor clay.prePass.ShadowMap
- * @extends clay.core.Base
- * @example
- * var shadowMapPass = new clay.prePass.ShadowMap({
- * softShadow: clay.prePass.ShadowMap.VSM
- * });
- * ...
- * animation.on('frame', function (frameTime) {
- * shadowMapPass.render(renderer, scene, camera);
- * renderer.render(scene, camera);
- * });
- */
- var ShadowMapPass = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () {
- return /** @lends clay.prePass.ShadowMap# */ {
- /**
- * Soft shadow technique.
- * Can be {@link clay.prePass.ShadowMap.PCF} or {@link clay.prePass.ShadowMap.VSM}
- * @type {number}
- */
- softShadow: ShadowMapPass.PCF,
- /**
- * Soft shadow blur size
- * @type {number}
- */
- shadowBlur: 1.0,
- lightFrustumBias: 'auto',
- kernelPCF: new Float32Array([
- 1, 0,
- 1, 1,
- -1, 1,
- 0, 1,
- -1, 0,
- -1, -1,
- 1, -1,
- 0, -1
- ]),
- precision: 'highp',
- _lastRenderNotCastShadow: false,
- _frameBuffer: new __WEBPACK_IMPORTED_MODULE_9__FrameBuffer__["a" /* default */](),
- _textures: {},
- _shadowMapNumber: {
- 'POINT_LIGHT': 0,
- 'DIRECTIONAL_LIGHT': 0,
- 'SPOT_LIGHT': 0
- },
- _depthMaterials: {},
- _distanceMaterials: {},
- _receivers: [],
- _lightsCastShadow: [],
- _lightCameras: {},
- _lightMaterials: {},
- _texturePool: new __WEBPACK_IMPORTED_MODULE_16__compositor_TexturePool__["a" /* default */]()
- };
- }, function () {
- // Gaussian filter pass for VSM
- this._gaussianPassH = new __WEBPACK_IMPORTED_MODULE_15__compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */].source('clay.compositor.gaussian_blur')
- });
- this._gaussianPassV = new __WEBPACK_IMPORTED_MODULE_15__compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */].source('clay.compositor.gaussian_blur')
- });
- this._gaussianPassH.setUniform('blurSize', this.shadowBlur);
- this._gaussianPassH.setUniform('blurDir', 0.0);
- this._gaussianPassV.setUniform('blurSize', this.shadowBlur);
- this._gaussianPassV.setUniform('blurDir', 1.0);
- this._outputDepthPass = new __WEBPACK_IMPORTED_MODULE_15__compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */].source('clay.sm.debug_depth')
- });
- }, {
- /**
- * Render scene to shadow textures
- * @param {clay.Renderer} renderer
- * @param {clay.Scene} scene
- * @param {clay.Camera} sceneCamera
- * @param {boolean} [notUpdateScene=false]
- * @memberOf clay.prePass.ShadowMap.prototype
- */
- render: function (renderer, scene, sceneCamera, notUpdateScene) {
- if (!sceneCamera) {
- sceneCamera = scene.getMainCamera();
- }
- this.trigger('beforerender', this, renderer, scene, sceneCamera);
- this._renderShadowPass(renderer, scene, sceneCamera, notUpdateScene);
- this.trigger('afterrender', this, renderer, scene, sceneCamera);
- },
- /**
- * Debug rendering of shadow textures
- * @param {clay.Renderer} renderer
- * @param {number} size
- * @memberOf clay.prePass.ShadowMap.prototype
- */
- renderDebug: function (renderer, size) {
- renderer.saveClear();
- var viewport = renderer.viewport;
- var x = 0, y = 0;
- var width = size || viewport.width / 4;
- var height = width;
- if (this.softShadow === ShadowMapPass.VSM) {
- this._outputDepthPass.material.define('fragment', 'USE_VSM');
- }
- else {
- this._outputDepthPass.material.undefine('fragment', 'USE_VSM');
- }
- for (var name in this._textures) {
- var texture = this._textures[name];
- renderer.setViewport(x, y, width * texture.width / texture.height, height);
- this._outputDepthPass.setUniform('depthMap', texture);
- this._outputDepthPass.render(renderer);
- x += width * texture.width / texture.height;
- }
- renderer.setViewport(viewport);
- renderer.restoreClear();
- },
- _updateReceivers: function (renderer, mesh) {
- if (mesh.receiveShadow) {
- this._receivers.push(mesh);
- mesh.material.set('shadowEnabled', 1);
- mesh.material.set('pcfKernel', this.kernelPCF);
- }
- else {
- mesh.material.set('shadowEnabled', 0);
- }
- if (this.softShadow === ShadowMapPass.VSM) {
- mesh.material.define('fragment', 'USE_VSM');
- mesh.material.undefine('fragment', 'PCF_KERNEL_SIZE');
- }
- else {
- mesh.material.undefine('fragment', 'USE_VSM');
- var kernelPCF = this.kernelPCF;
- if (kernelPCF && kernelPCF.length) {
- mesh.material.define('fragment', 'PCF_KERNEL_SIZE', kernelPCF.length / 2);
- }
- else {
- mesh.material.undefine('fragment', 'PCF_KERNEL_SIZE');
- }
- }
- },
- _update: function (renderer, scene) {
- var self = this;
- scene.traverse(function (renderable) {
- if (renderable.isRenderable()) {
- self._updateReceivers(renderer, renderable);
- }
- });
- for (var i = 0; i < scene.lights.length; i++) {
- var light = scene.lights[i];
- if (light.castShadow && !light.invisible) {
- this._lightsCastShadow.push(light);
- }
- }
- },
- _renderShadowPass: function (renderer, scene, sceneCamera, notUpdateScene) {
- // reset
- for (var name in this._shadowMapNumber) {
- this._shadowMapNumber[name] = 0;
- }
- this._lightsCastShadow.length = 0;
- this._receivers.length = 0;
- var _gl = renderer.gl;
- if (!notUpdateScene) {
- scene.update();
- }
- if (sceneCamera) {
- sceneCamera.update();
- }
- scene.updateLights();
- this._update(renderer, scene);
- // Needs to update the receivers again if shadows come from 1 to 0.
- if (!this._lightsCastShadow.length && this._lastRenderNotCastShadow) {
- return;
- }
- this._lastRenderNotCastShadow = this._lightsCastShadow === 0;
- _gl.enable(_gl.DEPTH_TEST);
- _gl.depthMask(true);
- _gl.disable(_gl.BLEND);
- // Clear with high-z, so the part not rendered will not been shadowed
- // TODO
- // TODO restore
- _gl.clearColor(1.0, 1.0, 1.0, 1.0);
- // Shadow uniforms
- var spotLightShadowMaps = [];
- var spotLightMatrices = [];
- var directionalLightShadowMaps = [];
- var directionalLightMatrices = [];
- var shadowCascadeClips = [];
- var pointLightShadowMaps = [];
- var dirLightHasCascade;
- // Create textures for shadow map
- for (var i = 0; i < this._lightsCastShadow.length; i++) {
- var light = this._lightsCastShadow[i];
- if (light.type === 'DIRECTIONAL_LIGHT') {
- if (dirLightHasCascade) {
- console.warn('Only one direectional light supported with shadow cascade');
- continue;
- }
- if (light.shadowCascade > 4) {
- console.warn('Support at most 4 cascade');
- continue;
- }
- if (light.shadowCascade > 1) {
- dirLightHasCascade = light;
- }
- this.renderDirectionalLightShadow(
- renderer,
- scene,
- sceneCamera,
- light,
- shadowCascadeClips,
- directionalLightMatrices,
- directionalLightShadowMaps
- );
- }
- else if (light.type === 'SPOT_LIGHT') {
- this.renderSpotLightShadow(
- renderer,
- scene,
- light,
- spotLightMatrices,
- spotLightShadowMaps
- );
- }
- else if (light.type === 'POINT_LIGHT') {
- this.renderPointLightShadow(
- renderer,
- scene,
- light,
- pointLightShadowMaps
- );
- }
- this._shadowMapNumber[light.type]++;
- }
- for (var lightType in this._shadowMapNumber) {
- var number = this._shadowMapNumber[lightType];
- var key = lightType + '_SHADOWMAP_COUNT';
- for (var i = 0; i < this._receivers.length; i++) {
- var mesh = this._receivers[i];
- var material = mesh.material;
- if (material.fragmentDefines[key] !== number) {
- if (number > 0) {
- material.define('fragment', key, number);
- }
- else if (material.isDefined('fragment', key)) {
- material.undefine('fragment', key);
- }
- }
- }
- }
- for (var i = 0; i < this._receivers.length; i++) {
- var mesh = this._receivers[i];
- var material = mesh.material;
- if (dirLightHasCascade) {
- material.define('fragment', 'SHADOW_CASCADE', dirLightHasCascade.shadowCascade);
- }
- else {
- material.undefine('fragment', 'SHADOW_CASCADE');
- }
- }
- var shadowUniforms = scene.shadowUniforms;
- function getSize(texture) {
- return texture.height;
- }
- if (directionalLightShadowMaps.length > 0) {
- var directionalLightShadowMapSizes = directionalLightShadowMaps.map(getSize);
- shadowUniforms.directionalLightShadowMaps = { value: directionalLightShadowMaps, type: 'tv' };
- shadowUniforms.directionalLightMatrices = { value: directionalLightMatrices, type: 'm4v' };
- shadowUniforms.directionalLightShadowMapSizes = { value: directionalLightShadowMapSizes, type: '1fv' };
- if (dirLightHasCascade) {
- var shadowCascadeClipsNear = shadowCascadeClips.slice();
- var shadowCascadeClipsFar = shadowCascadeClips.slice();
- shadowCascadeClipsNear.pop();
- shadowCascadeClipsFar.shift();
- // Iterate from far to near
- shadowCascadeClipsNear.reverse();
- shadowCascadeClipsFar.reverse();
- // directionalLightShadowMaps.reverse();
- directionalLightMatrices.reverse();
- shadowUniforms.shadowCascadeClipsNear = { value: shadowCascadeClipsNear, type: '1fv' };
- shadowUniforms.shadowCascadeClipsFar = { value: shadowCascadeClipsFar, type: '1fv' };
- }
- }
- if (spotLightShadowMaps.length > 0) {
- var spotLightShadowMapSizes = spotLightShadowMaps.map(getSize);
- var shadowUniforms = scene.shadowUniforms;
- shadowUniforms.spotLightShadowMaps = { value: spotLightShadowMaps, type: 'tv' };
- shadowUniforms.spotLightMatrices = { value: spotLightMatrices, type: 'm4v' };
- shadowUniforms.spotLightShadowMapSizes = { value: spotLightShadowMapSizes, type: '1fv' };
- }
- if (pointLightShadowMaps.length > 0) {
- shadowUniforms.pointLightShadowMaps = { value: pointLightShadowMaps, type: 'tv' };
- }
- },
- renderDirectionalLightShadow: (function () {
- var splitFrustum = new __WEBPACK_IMPORTED_MODULE_4__math_Frustum__["a" /* default */]();
- var splitProjMatrix = new __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__["a" /* default */]();
- var cropBBox = new __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__["a" /* default */]();
- var cropMatrix = new __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__["a" /* default */]();
- var lightViewMatrix = new __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__["a" /* default */]();
- var lightViewProjMatrix = new __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__["a" /* default */]();
- var lightProjMatrix = new __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__["a" /* default */]();
- return function (renderer, scene, sceneCamera, light, shadowCascadeClips, directionalLightMatrices, directionalLightShadowMaps) {
- var defaultShadowMaterial = this._getDepthMaterial(light);
- var passConfig = {
- getMaterial: function (renderable) {
- return renderable.shadowDepthMaterial || defaultShadowMaterial;
- },
- isMaterialChanged: isDepthMaterialChanged,
- getUniform: getDepthMaterialUniform,
- ifRender: function (renderable) {
- return renderable.castShadow;
- },
- sortCompare: __WEBPACK_IMPORTED_MODULE_6__Renderer__["a" /* default */].opaqueSortCompare
- };
- // First frame
- if (!scene.viewBoundingBoxLastFrame.isFinite()) {
- var boundingBox = scene.getBoundingBox();
- scene.viewBoundingBoxLastFrame
- .copy(boundingBox).applyTransform(sceneCamera.viewMatrix);
- }
- // Considering moving speed since the bounding box is from last frame
- // TODO: add a bias
- var clippedFar = Math.min(-scene.viewBoundingBoxLastFrame.min.z, sceneCamera.far);
- var clippedNear = Math.max(-scene.viewBoundingBoxLastFrame.max.z, sceneCamera.near);
- var lightCamera = this._getDirectionalLightCamera(light, scene, sceneCamera);
- var lvpMat4Arr = lightViewProjMatrix.array;
- lightProjMatrix.copy(lightCamera.projectionMatrix);
- __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].invert(lightViewMatrix.array, lightCamera.worldTransform.array);
- __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].multiply(lightViewMatrix.array, lightViewMatrix.array, sceneCamera.worldTransform.array);
- __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].multiply(lvpMat4Arr, lightProjMatrix.array, lightViewMatrix.array);
- var clipPlanes = [];
- var isPerspective = sceneCamera instanceof __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__["a" /* default */];
- var scaleZ = (sceneCamera.near + sceneCamera.far) / (sceneCamera.near - sceneCamera.far);
- var offsetZ = 2 * sceneCamera.near * sceneCamera.far / (sceneCamera.near - sceneCamera.far);
- for (var i = 0; i <= light.shadowCascade; i++) {
- var clog = clippedNear * Math.pow(clippedFar / clippedNear, i / light.shadowCascade);
- var cuni = clippedNear + (clippedFar - clippedNear) * i / light.shadowCascade;
- var c = clog * light.cascadeSplitLogFactor + cuni * (1 - light.cascadeSplitLogFactor);
- clipPlanes.push(c);
- shadowCascadeClips.push(-(-c * scaleZ + offsetZ) / -c);
- }
- var texture = this._getTexture(light, light.shadowCascade);
- directionalLightShadowMaps.push(texture);
- var viewport = renderer.viewport;
- var _gl = renderer.gl;
- this._frameBuffer.attach(texture);
- this._frameBuffer.bind(renderer);
- _gl.clear(_gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT);
- for (var i = 0; i < light.shadowCascade; i++) {
- // Get the splitted frustum
- var nearPlane = clipPlanes[i];
- var farPlane = clipPlanes[i + 1];
- if (isPerspective) {
- __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].perspective(splitProjMatrix.array, sceneCamera.fov / 180 * Math.PI, sceneCamera.aspect, nearPlane, farPlane);
- }
- else {
- __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].ortho(
- splitProjMatrix.array,
- sceneCamera.left, sceneCamera.right, sceneCamera.bottom, sceneCamera.top,
- nearPlane, farPlane
- );
- }
- splitFrustum.setFromProjection(splitProjMatrix);
- splitFrustum.getTransformedBoundingBox(cropBBox, lightViewMatrix);
- cropBBox.applyProjection(lightProjMatrix);
- var _min = cropBBox.min.array;
- var _max = cropBBox.max.array;
- _min[0] = Math.max(_min[0], -1);
- _min[1] = Math.max(_min[1], -1);
- _max[0] = Math.min(_max[0], 1);
- _max[1] = Math.min(_max[1], 1);
- cropMatrix.ortho(_min[0], _max[0], _min[1], _max[1], 1, -1);
- lightCamera.projectionMatrix.multiplyLeft(cropMatrix);
- var shadowSize = light.shadowResolution || 512;
- // Reversed, left to right => far to near
- renderer.setViewport((light.shadowCascade - i - 1) * shadowSize, 0, shadowSize, shadowSize, 1);
- var renderList = scene.updateRenderList(lightCamera);
- renderer.renderPass(renderList.opaque, lightCamera, passConfig);
- // Filter for VSM
- if (this.softShadow === ShadowMapPass.VSM) {
- this._gaussianFilter(renderer, texture, texture.width);
- }
- var matrix = new __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__["a" /* default */]();
- matrix.copy(lightCamera.viewMatrix)
- .multiplyLeft(lightCamera.projectionMatrix);
- directionalLightMatrices.push(matrix.array);
- lightCamera.projectionMatrix.copy(lightProjMatrix);
- }
- this._frameBuffer.unbind(renderer);
- renderer.setViewport(viewport);
- };
- })(),
- renderSpotLightShadow: function (renderer, scene, light, spotLightMatrices, spotLightShadowMaps) {
- var texture = this._getTexture(light);
- var lightCamera = this._getSpotLightCamera(light);
- var _gl = renderer.gl;
- this._frameBuffer.attach(texture);
- this._frameBuffer.bind(renderer);
- _gl.clear(_gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT);
- var defaultShadowMaterial = this._getDepthMaterial(light);
- var passConfig = {
- getMaterial: function (renderable) {
- return renderable.shadowDepthMaterial || defaultShadowMaterial;
- },
- isMaterialChanged: isDepthMaterialChanged,
- getUniform: getDepthMaterialUniform,
- ifRender: function (renderable) {
- return renderable.castShadow;
- },
- sortCompare: __WEBPACK_IMPORTED_MODULE_6__Renderer__["a" /* default */].opaqueSortCompare
- };
- var renderList = scene.updateRenderList(lightCamera);
- renderer.renderPass(renderList.opaque, lightCamera, passConfig);
- this._frameBuffer.unbind(renderer);
- // Filter for VSM
- if (this.softShadow === ShadowMapPass.VSM) {
- this._gaussianFilter(renderer, texture, texture.width);
- }
- var matrix = new __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__["a" /* default */]();
- matrix.copy(lightCamera.worldTransform)
- .invert()
- .multiplyLeft(lightCamera.projectionMatrix);
- spotLightShadowMaps.push(texture);
- spotLightMatrices.push(matrix.array);
- },
- renderPointLightShadow: function (renderer, scene, light, pointLightShadowMaps) {
- var texture = this._getTexture(light);
- var _gl = renderer.gl;
- pointLightShadowMaps.push(texture);
- var defaultShadowMaterial = this._getDepthMaterial(light);
- var passConfig = {
- getMaterial: function (renderable) {
- return renderable.shadowDepthMaterial || defaultShadowMaterial;
- },
- getUniform: getDepthMaterialUniform,
- sortCompare: __WEBPACK_IMPORTED_MODULE_6__Renderer__["a" /* default */].opaqueSortCompare
- };
- var renderListEachSide = {
- px: [], py: [], pz: [], nx: [], ny: [], nz: []
- };
- var bbox = new __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__["a" /* default */]();
- var lightWorldPosition = light.getWorldPosition().array;
- var lightBBox = new __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__["a" /* default */]();
- var range = light.range;
- lightBBox.min.setArray(lightWorldPosition);
- lightBBox.max.setArray(lightWorldPosition);
- var extent = new __WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */](range, range, range);
- lightBBox.max.add(extent);
- lightBBox.min.sub(extent);
- var targetsNeedRender = { px: false, py: false, pz: false, nx: false, ny: false, nz: false };
- scene.traverse(function (renderable) {
- if (renderable.isRenderable() && renderable.castShadow) {
- var geometry = renderable.geometry;
- if (!geometry.boundingBox) {
- for (var i = 0; i < targets.length; i++) {
- renderListEachSide[targets[i]].push(renderable);
- }
- return;
- }
- bbox.transformFrom(geometry.boundingBox, renderable.worldTransform);
- if (!bbox.intersectBoundingBox(lightBBox)) {
- return;
- }
- bbox.updateVertices();
- for (var i = 0; i < targets.length; i++) {
- targetsNeedRender[targets[i]] = false;
- }
- for (var i = 0; i < 8; i++) {
- var vtx = bbox.vertices[i];
- var x = vtx[0] - lightWorldPosition[0];
- var y = vtx[1] - lightWorldPosition[1];
- var z = vtx[2] - lightWorldPosition[2];
- var absx = Math.abs(x);
- var absy = Math.abs(y);
- var absz = Math.abs(z);
- if (absx > absy) {
- if (absx > absz) {
- targetsNeedRender[x > 0 ? 'px' : 'nx'] = true;
- }
- else {
- targetsNeedRender[z > 0 ? 'pz' : 'nz'] = true;
- }
- }
- else {
- if (absy > absz) {
- targetsNeedRender[y > 0 ? 'py' : 'ny'] = true;
- }
- else {
- targetsNeedRender[z > 0 ? 'pz' : 'nz'] = true;
- }
- }
- }
- for (var i = 0; i < targets.length; i++) {
- if (targetsNeedRender[targets[i]]) {
- renderListEachSide[targets[i]].push(renderable);
- }
- }
- }
- });
- for (var i = 0; i < 6; i++) {
- var target = targets[i];
- var camera = this._getPointLightCamera(light, target);
- this._frameBuffer.attach(texture, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i);
- this._frameBuffer.bind(renderer);
- _gl.clear(_gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT);
- renderer.renderPass(renderListEachSide[target], camera, passConfig);
- }
- this._frameBuffer.unbind(renderer);
- },
- _getDepthMaterial: function (light) {
- var shadowMaterial = this._lightMaterials[light.__uid__];
- var isPointLight = light.type === 'POINT_LIGHT';
- if (!shadowMaterial) {
- var shaderPrefix = isPointLight ? 'clay.sm.distance.' : 'clay.sm.depth.';
- shadowMaterial = new __WEBPACK_IMPORTED_MODULE_8__Material__["a" /* default */]({
- precision: this.precision,
- shader: new __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */](__WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */].source(shaderPrefix + 'vertex'), __WEBPACK_IMPORTED_MODULE_7__Shader__["a" /* default */].source(shaderPrefix + 'fragment'))
- });
- this._lightMaterials[light.__uid__] = shadowMaterial;
- }
- if (light.shadowSlopeScale != null) {
- shadowMaterial.setUniform('slopeScale', light.shadowSlopeScale);
- }
- if (light.shadowBias != null) {
- shadowMaterial.setUniform('bias', light.shadowBias);
- }
- if (this.softShadow === ShadowMapPass.VSM) {
- shadowMaterial.define('fragment', 'USE_VSM');
- }
- else {
- shadowMaterial.undefine('fragment', 'USE_VSM');
- }
- if (isPointLight) {
- shadowMaterial.set('lightPosition', light.getWorldPosition().array);
- shadowMaterial.set('range', light.range);
- }
- return shadowMaterial;
- },
- _gaussianFilter: function (renderer, texture, size) {
- var parameter = {
- width: size,
- height: size,
- type: __WEBPACK_IMPORTED_MODULE_10__Texture__["a" /* default */].FLOAT
- };
- var tmpTexture = this._texturePool.get(parameter);
- this._frameBuffer.attach(tmpTexture);
- this._frameBuffer.bind(renderer);
- this._gaussianPassH.setUniform('texture', texture);
- this._gaussianPassH.setUniform('textureWidth', size);
- this._gaussianPassH.render(renderer);
- this._frameBuffer.attach(texture);
- this._gaussianPassV.setUniform('texture', tmpTexture);
- this._gaussianPassV.setUniform('textureHeight', size);
- this._gaussianPassV.render(renderer);
- this._frameBuffer.unbind(renderer);
- this._texturePool.put(tmpTexture);
- },
- _getTexture: function (light, cascade) {
- var key = light.__uid__;
- var texture = this._textures[key];
- var resolution = light.shadowResolution || 512;
- cascade = cascade || 1;
- if (!texture) {
- if (light.type === 'POINT_LIGHT') {
- texture = new __WEBPACK_IMPORTED_MODULE_12__TextureCube__["a" /* default */]();
- }
- else {
- texture = new __WEBPACK_IMPORTED_MODULE_11__Texture2D__["a" /* default */]();
- }
- // At most 4 cascade
- // TODO share with height ?
- texture.width = resolution * cascade;
- texture.height = resolution;
- if (this.softShadow === ShadowMapPass.VSM) {
- texture.type = __WEBPACK_IMPORTED_MODULE_10__Texture__["a" /* default */].FLOAT;
- texture.anisotropic = 4;
- }
- else {
- texture.minFilter = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST;
- texture.magFilter = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].NEAREST;
- texture.useMipmap = false;
- }
- this._textures[key] = texture;
- }
- return texture;
- },
- _getPointLightCamera: function (light, target) {
- if (!this._lightCameras.point) {
- this._lightCameras.point = {
- px: new __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__["a" /* default */](),
- nx: new __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__["a" /* default */](),
- py: new __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__["a" /* default */](),
- ny: new __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__["a" /* default */](),
- pz: new __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__["a" /* default */](),
- nz: new __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__["a" /* default */]()
- };
- }
- var camera = this._lightCameras.point[target];
- camera.far = light.range;
- camera.fov = 90;
- camera.position.set(0, 0, 0);
- switch (target) {
- case 'px':
- camera.lookAt(__WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].POSITIVE_X, __WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].NEGATIVE_Y);
- break;
- case 'nx':
- camera.lookAt(__WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].NEGATIVE_X, __WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].NEGATIVE_Y);
- break;
- case 'py':
- camera.lookAt(__WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].POSITIVE_Y, __WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].POSITIVE_Z);
- break;
- case 'ny':
- camera.lookAt(__WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].NEGATIVE_Y, __WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].NEGATIVE_Z);
- break;
- case 'pz':
- camera.lookAt(__WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].POSITIVE_Z, __WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].NEGATIVE_Y);
- break;
- case 'nz':
- camera.lookAt(__WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].NEGATIVE_Z, __WEBPACK_IMPORTED_MODULE_2__math_Vector3__["a" /* default */].NEGATIVE_Y);
- break;
- }
- light.getWorldPosition(camera.position);
- camera.update();
- return camera;
- },
- _getDirectionalLightCamera: (function () {
- var lightViewMatrix = new __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__["a" /* default */]();
- var sceneViewBoundingBox = new __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__["a" /* default */]();
- var lightViewBBox = new __WEBPACK_IMPORTED_MODULE_3__math_BoundingBox__["a" /* default */]();
- // Camera of directional light will be adjusted
- // to contain the view frustum and scene bounding box as tightly as possible
- return function (light, scene, sceneCamera) {
- if (!this._lightCameras.directional) {
- this._lightCameras.directional = new __WEBPACK_IMPORTED_MODULE_14__camera_Orthographic__["a" /* default */]();
- }
- var camera = this._lightCameras.directional;
- sceneViewBoundingBox.copy(scene.viewBoundingBoxLastFrame);
- sceneViewBoundingBox.intersection(sceneCamera.frustum.boundingBox);
- // Move to the center of frustum(in world space)
- camera.position
- .copy(sceneViewBoundingBox.min)
- .add(sceneViewBoundingBox.max)
- .scale(0.5)
- .transformMat4(sceneCamera.worldTransform);
- camera.rotation.copy(light.rotation);
- camera.scale.copy(light.scale);
- camera.updateWorldTransform();
- // Transform to light view space
- __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__["a" /* default */].invert(lightViewMatrix, camera.worldTransform);
- __WEBPACK_IMPORTED_MODULE_5__math_Matrix4__["a" /* default */].multiply(lightViewMatrix, lightViewMatrix, sceneCamera.worldTransform);
- lightViewBBox.copy(sceneViewBoundingBox).applyTransform(lightViewMatrix);
- var min = lightViewBBox.min.array;
- var max = lightViewBBox.max.array;
- // Move camera to adjust the near to 0
- camera.position.set((min[0] + max[0]) / 2, (min[1] + max[1]) / 2, max[2])
- .transformMat4(camera.worldTransform);
- camera.near = 0;
- camera.far = -min[2] + max[2];
- // Make sure receivers not in the frustum will stil receive the shadow.
- if (isNaN(this.lightFrustumBias)) {
- camera.far *= 4;
- }
- else {
- camera.far += this.lightFrustumBias;
- }
- camera.left = min[0];
- camera.right = max[0];
- camera.top = max[1];
- camera.bottom = min[1];
- camera.update(true);
- return camera;
- };
- })(),
- _getSpotLightCamera: function (light) {
- if (!this._lightCameras.spot) {
- this._lightCameras.spot = new __WEBPACK_IMPORTED_MODULE_13__camera_Perspective__["a" /* default */]();
- }
- var camera = this._lightCameras.spot;
- // Update properties
- camera.fov = light.penumbraAngle * 2;
- camera.far = light.range;
- camera.worldTransform.copy(light.worldTransform);
- camera.updateProjectionMatrix();
- __WEBPACK_IMPORTED_MODULE_17__glmatrix_mat4__["a" /* default */].invert(camera.viewMatrix.array, camera.worldTransform.array);
- return camera;
- },
- /**
- * @param {clay.Renderer|WebGLRenderingContext} [renderer]
- * @memberOf clay.prePass.ShadowMap.prototype
- */
- // PENDING Renderer or WebGLRenderingContext
- dispose: function (renderer) {
- var _gl = renderer.gl || renderer;
- if (this._frameBuffer) {
- this._frameBuffer.dispose(_gl);
- }
- for (var name in this._textures) {
- this._textures[name].dispose(_gl);
- }
- this._texturePool.clear(renderer.gl);
- this._depthMaterials = {};
- this._distanceMaterials = {};
- this._textures = {};
- this._lightCameras = {};
- this._shadowMapNumber = {
- 'POINT_LIGHT': 0,
- 'DIRECTIONAL_LIGHT': 0,
- 'SPOT_LIGHT': 0
- };
- this._meshMaterials = {};
- for (var i = 0; i < this._receivers.length; i++) {
- var mesh = this._receivers[i];
- // Mesh may be disposed
- if (mesh.material) {
- var material = mesh.material;
- material.undefine('fragment', 'POINT_LIGHT_SHADOW_COUNT');
- material.undefine('fragment', 'DIRECTIONAL_LIGHT_SHADOW_COUNT');
- material.undefine('fragment', 'AMBIENT_LIGHT_SHADOW_COUNT');
- material.set('shadowEnabled', 0);
- }
- }
- this._receivers = [];
- this._lightsCastShadow = [];
- }
- });
- /**
- * @name clay.prePass.ShadowMap.VSM
- * @type {number}
- */
- ShadowMapPass.VSM = 1;
- /**
- * @name clay.prePass.ShadowMap.PCF
- * @type {number}
- */
- ShadowMapPass.PCF = 2;
- /* harmony default export */ __webpack_exports__["a"] = (ShadowMapPass);
- /***/
- }),
- /* 175 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.sm.depth.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nattribute vec2 texcoord : TEXCOORD_0;\n@import clay.chunk.skinning_header\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nvoid main(){\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n v_ViewPosition = worldViewProjection * vec4(skinnedPosition, 1.0);\n gl_Position = v_ViewPosition;\n v_Texcoord = texcoord;\n}\n@end\n@export clay.sm.depth.fragment\nvarying vec4 v_ViewPosition;\nvarying vec2 v_Texcoord;\nuniform float bias : 0.001;\nuniform float slopeScale : 1.0;\nuniform sampler2D alphaMap;\nuniform float alphaCutoff: 0.0;\n@import clay.util.encode_float\nvoid main(){\n float depth = v_ViewPosition.z / v_ViewPosition.w;\n if (alphaCutoff > 0.0) {\n if (texture2D(alphaMap, v_Texcoord).a <= alphaCutoff) {\n discard;\n }\n }\n#ifdef USE_VSM\n depth = depth * 0.5 + 0.5;\n float moment1 = depth;\n float moment2 = depth * depth;\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n moment2 += 0.25*(dx*dx+dy*dy);\n gl_FragColor = vec4(moment1, moment2, 0.0, 1.0);\n#else\n float dx = dFdx(depth);\n float dy = dFdy(depth);\n depth += sqrt(dx*dx + dy*dy) * slopeScale + bias;\n gl_FragColor = encodeFloat(depth * 0.5 + 0.5);\n#endif\n}\n@end\n@export clay.sm.debug_depth\nuniform sampler2D depthMap;\nvarying vec2 v_Texcoord;\n@import clay.util.decode_float\nvoid main() {\n vec4 tex = texture2D(depthMap, v_Texcoord);\n#ifdef USE_VSM\n gl_FragColor = vec4(tex.rgb, 1.0);\n#else\n float depth = decodeFloat(tex);\n gl_FragColor = vec4(depth, depth, depth, 1.0);\n#endif\n}\n@end\n@export clay.sm.distance.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform mat4 world : WORLD;\nattribute vec3 position : POSITION;\n@import clay.chunk.skinning_header\nvarying vec3 v_WorldPosition;\nvoid main (){\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import clay.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n gl_Position = worldViewProjection * vec4(skinnedPosition , 1.0);\n v_WorldPosition = (world * vec4(skinnedPosition, 1.0)).xyz;\n}\n@end\n@export clay.sm.distance.fragment\nuniform vec3 lightPosition;\nuniform float range : 100;\nvarying vec3 v_WorldPosition;\n@import clay.util.encode_float\nvoid main(){\n float dist = distance(lightPosition, v_WorldPosition);\n#ifdef USE_VSM\n gl_FragColor = vec4(dist, dist * dist, 0.0, 0.0);\n#else\n dist = dist / range;\n gl_FragColor = encodeFloat(dist);\n#endif\n}\n@end\n@export clay.plugin.shadow_map_common\n@import clay.util.decode_float\nfloat tapShadowMap(sampler2D map, vec2 uv, float z){\n vec4 tex = texture2D(map, uv);\n return step(z, decodeFloat(tex) * 2.0 - 1.0);\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize, vec2 scale) {\n float shadowContrib = tapShadowMap(map, uv, z);\n vec2 offset = vec2(1.0 / textureSize) * scale;\n#ifdef PCF_KERNEL_SIZE\n for (int _idx_ = 0; _idx_ < PCF_KERNEL_SIZE; _idx_++) {{\n shadowContrib += tapShadowMap(map, uv + offset * pcfKernel[_idx_], z);\n }}\n return shadowContrib / float(PCF_KERNEL_SIZE + 1);\n#else\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, 0.0), z);\n shadowContrib += tapShadowMap(map, uv+vec2(-offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(offset.x, -offset.y), z);\n shadowContrib += tapShadowMap(map, uv+vec2(0.0, -offset.y), z);\n return shadowContrib / 9.0;\n#endif\n}\nfloat pcf(sampler2D map, vec2 uv, float z, float textureSize) {\n return pcf(map, uv, z, textureSize, vec2(1.0));\n}\nfloat chebyshevUpperBound(vec2 moments, float z){\n float p = 0.0;\n z = z * 0.5 + 0.5;\n if (z <= moments.x) {\n p = 1.0;\n }\n float variance = moments.y - moments.x * moments.x;\n variance = max(variance, 0.0000001);\n float mD = moments.x - z;\n float pMax = variance / (variance + mD * mD);\n pMax = clamp((pMax-0.4)/(1.0-0.4), 0.0, 1.0);\n return max(p, pMax);\n}\nfloat computeShadowContrib(\n sampler2D map, mat4 lightVPM, vec3 position, float textureSize, vec2 scale, vec2 offset\n) {\n vec4 posInLightSpace = lightVPM * vec4(position, 1.0);\n posInLightSpace.xyz /= posInLightSpace.w;\n float z = posInLightSpace.z;\n if(all(greaterThan(posInLightSpace.xyz, vec3(-0.99, -0.99, -1.0))) &&\n all(lessThan(posInLightSpace.xyz, vec3(0.99, 0.99, 1.0)))){\n vec2 uv = (posInLightSpace.xy+1.0) / 2.0;\n #ifdef USE_VSM\n vec2 moments = texture2D(map, uv * scale + offset).xy;\n return chebyshevUpperBound(moments, z);\n #else\n return pcf(map, uv * scale + offset, z, textureSize, scale);\n #endif\n }\n return 1.0;\n}\nfloat computeShadowContrib(sampler2D map, mat4 lightVPM, vec3 position, float textureSize) {\n return computeShadowContrib(map, lightVPM, position, textureSize, vec2(1.0), vec2(0.0));\n}\nfloat computeShadowContribOmni(samplerCube map, vec3 direction, float range)\n{\n float dist = length(direction);\n vec4 shadowTex = textureCube(map, direction);\n#ifdef USE_VSM\n vec2 moments = shadowTex.xy;\n float variance = moments.y - moments.x * moments.x;\n float mD = moments.x - dist;\n float p = variance / (variance + mD * mD);\n if(moments.x + 0.001 < dist){\n return clamp(p, 0.0, 1.0);\n }else{\n return 1.0;\n }\n#else\n return step(dist, (decodeFloat(shadowTex) + 0.0002) * range);\n#endif\n}\n@end\n@export clay.plugin.compute_shadow_map\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT) || defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT) || defined(POINT_LIGHT_SHADOWMAP_COUNT)\n#ifdef SPOT_LIGHT_SHADOWMAP_COUNT\nuniform sampler2D spotLightShadowMaps[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 spotLightMatrices[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float spotLightShadowMapSizes[SPOT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#ifdef DIRECTIONAL_LIGHT_SHADOWMAP_COUNT\n#if defined(SHADOW_CASCADE)\nuniform sampler2D directionalLightShadowMaps[1]:unconfigurable;\nuniform mat4 directionalLightMatrices[SHADOW_CASCADE]:unconfigurable;\nuniform float directionalLightShadowMapSizes[1]:unconfigurable;\nuniform float shadowCascadeClipsNear[SHADOW_CASCADE]:unconfigurable;\nuniform float shadowCascadeClipsFar[SHADOW_CASCADE]:unconfigurable;\n#else\nuniform sampler2D directionalLightShadowMaps[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform mat4 directionalLightMatrices[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\nuniform float directionalLightShadowMapSizes[DIRECTIONAL_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\n#endif\n#ifdef POINT_LIGHT_SHADOWMAP_COUNT\nuniform samplerCube pointLightShadowMaps[POINT_LIGHT_SHADOWMAP_COUNT]:unconfigurable;\n#endif\nuniform bool shadowEnabled : true;\n#ifdef PCF_KERNEL_SIZE\nuniform vec2 pcfKernel[PCF_KERNEL_SIZE];\n#endif\n@import clay.plugin.shadow_map_common\n#if defined(SPOT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfSpotLights(vec3 position, inout float shadowContribs[SPOT_LIGHT_COUNT] ) {\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < SPOT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n spotLightShadowMaps[_idx_], spotLightMatrices[_idx_], position,\n spotLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = SPOT_LIGHT_SHADOWMAP_COUNT; _idx_ < SPOT_LIGHT_COUNT; _idx_++){{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n#ifdef SHADOW_CASCADE\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float depth = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far)\n / (gl_DepthRange.far - gl_DepthRange.near);\n float shadowContrib;\n shadowContribs[0] = 1.0;\n for (int _idx_ = 0; _idx_ < SHADOW_CASCADE; _idx_++) {{\n if (\n depth >= shadowCascadeClipsNear[_idx_] &&\n depth <= shadowCascadeClipsFar[_idx_]\n ) {\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[0], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[0],\n vec2(1.0 / float(SHADOW_CASCADE), 1.0),\n vec2(float(_idx_) / float(SHADOW_CASCADE), 0.0)\n );\n shadowContribs[0] = shadowContrib;\n }\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#else\nvoid computeShadowOfDirectionalLights(vec3 position, inout float shadowContribs[DIRECTIONAL_LIGHT_COUNT]){\n float shadowContrib;\n for(int _idx_ = 0; _idx_ < DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n shadowContrib = computeShadowContrib(\n directionalLightShadowMaps[_idx_], directionalLightMatrices[_idx_], position,\n directionalLightShadowMapSizes[_idx_]\n );\n shadowContribs[_idx_] = shadowContrib;\n }}\n for(int _idx_ = DIRECTIONAL_LIGHT_SHADOWMAP_COUNT; _idx_ < DIRECTIONAL_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n#if defined(POINT_LIGHT_SHADOWMAP_COUNT)\nvoid computeShadowOfPointLights(vec3 position, inout float shadowContribs[POINT_LIGHT_COUNT] ){\n vec3 lightPosition;\n vec3 direction;\n for(int _idx_ = 0; _idx_ < POINT_LIGHT_SHADOWMAP_COUNT; _idx_++) {{\n lightPosition = pointLightPosition[_idx_];\n direction = position - lightPosition;\n shadowContribs[_idx_] = computeShadowContribOmni(pointLightShadowMaps[_idx_], direction, pointLightRange[_idx_]);\n }}\n for(int _idx_ = POINT_LIGHT_SHADOWMAP_COUNT; _idx_ < POINT_LIGHT_COUNT; _idx_++) {{\n shadowContribs[_idx_] = 1.0;\n }}\n}\n#endif\n#endif\n@end");
- /***/
- }),
- /* 176 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_FrameBuffer__ = __webpack_require__(10);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_createCompositor__ = __webpack_require__(177);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__SSAOPass__ = __webpack_require__(189);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__SSRPass__ = __webpack_require__(191);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__poissonKernel__ = __webpack_require__(193);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__NormalPass__ = __webpack_require__(194);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__EdgePass__ = __webpack_require__(196);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11_claygl_src_math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__composite_js__ = __webpack_require__(197);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13_claygl_src_shader_source_compositor_blur_glsl_js__ = __webpack_require__(87);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14_claygl_src_shader_source_compositor_lut_glsl_js__ = __webpack_require__(88);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_15_claygl_src_shader_source_compositor_output_glsl_js__ = __webpack_require__(89);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_16_claygl_src_shader_source_compositor_bright_glsl_js__ = __webpack_require__(90);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_17_claygl_src_shader_source_compositor_downsample_glsl_js__ = __webpack_require__(91);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_18_claygl_src_shader_source_compositor_upsample_glsl_js__ = __webpack_require__(92);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_19_claygl_src_shader_source_compositor_hdr_glsl_js__ = __webpack_require__(93);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_20_claygl_src_shader_source_compositor_blend_glsl_js__ = __webpack_require__(94);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_21_claygl_src_shader_source_compositor_fxaa_glsl_js__ = __webpack_require__(95);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__DOF_glsl_js__ = __webpack_require__(198);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__edge_glsl_js__ = __webpack_require__(199);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_13_claygl_src_shader_source_compositor_blur_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_14_claygl_src_shader_source_compositor_lut_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_15_claygl_src_shader_source_compositor_output_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_16_claygl_src_shader_source_compositor_bright_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_17_claygl_src_shader_source_compositor_downsample_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_18_claygl_src_shader_source_compositor_upsample_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_19_claygl_src_shader_source_compositor_hdr_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_20_claygl_src_shader_source_compositor_blend_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_21_claygl_src_shader_source_compositor_fxaa_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_22__DOF_glsl_js__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_23__edge_glsl_js__["a" /* default */]);
- var commonOutputs = {
- color: {
- parameters: {
- width: function (renderer) {
- return renderer.getWidth();
- },
- height: function (renderer) {
- return renderer.getHeight();
- }
- }
- }
- }
- var FINAL_NODES_CHAIN = ['composite', 'FXAA'];
- function EffectCompositor() {
- this._sourceTexture = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture2D__["a" /* default */]({
- type: __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture__["a" /* default */].HALF_FLOAT
- });
- this._depthTexture = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture2D__["a" /* default */]({
- format: __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture__["a" /* default */].DEPTH_COMPONENT,
- type: __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture__["a" /* default */].UNSIGNED_INT
- });
- this._framebuffer = new __WEBPACK_IMPORTED_MODULE_3_claygl_src_FrameBuffer__["a" /* default */]();
- this._framebuffer.attach(this._sourceTexture);
- this._framebuffer.attach(this._depthTexture, __WEBPACK_IMPORTED_MODULE_3_claygl_src_FrameBuffer__["a" /* default */].DEPTH_ATTACHMENT);
- this._normalPass = new __WEBPACK_IMPORTED_MODULE_9__NormalPass__["a" /* default */]();
- this._compositor = Object(__WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_createCompositor__["a" /* default */])(__WEBPACK_IMPORTED_MODULE_12__composite_js__["a" /* default */]);
- var sourceNode = this._compositor.getNodeByName('source');
- sourceNode.texture = this._sourceTexture;
- var cocNode = this._compositor.getNodeByName('coc');
- this._sourceNode = sourceNode;
- this._cocNode = cocNode;
- this._compositeNode = this._compositor.getNodeByName('composite');
- this._fxaaNode = this._compositor.getNodeByName('FXAA');
- this._dofBlurNodes = ['dof_far_blur', 'dof_near_blur', 'dof_coc_blur'].map(function (name) {
- return this._compositor.getNodeByName(name);
- }, this);
- this._dofBlurKernel = 0;
- this._dofBlurKernelSize = new Float32Array(0);
- this._finalNodesChain = FINAL_NODES_CHAIN.map(function (name) {
- return this._compositor.getNodeByName(name);
- }, this);
- var gBufferObj = {
- normalTexture: this._normalPass.getNormalTexture(),
- depthTexture: this._normalPass.getDepthTexture()
- };
- this._ssaoPass = new __WEBPACK_IMPORTED_MODULE_5__SSAOPass__["a" /* default */](gBufferObj);
- this._ssrPass = new __WEBPACK_IMPORTED_MODULE_6__SSRPass__["a" /* default */](gBufferObj);
- this._edgePass = new __WEBPACK_IMPORTED_MODULE_10__EdgePass__["a" /* default */](gBufferObj);
- }
- EffectCompositor.prototype.resize = function (width, height, dpr) {
- dpr = dpr || 1;
- var width = width * dpr;
- var height = height * dpr;
- var sourceTexture = this._sourceTexture;
- var depthTexture = this._depthTexture;
- sourceTexture.width = width;
- sourceTexture.height = height;
- depthTexture.width = width;
- depthTexture.height = height;
- };
- EffectCompositor.prototype._ifRenderNormalPass = function () {
- return this._enableSSAO || this._enableEdge || this._enableSSR;
- };
- EffectCompositor.prototype._getPrevNode = function (node) {
- var idx = FINAL_NODES_CHAIN.indexOf(node.name) - 1;
- var prevNode = this._finalNodesChain[idx];
- while (prevNode && !this._compositor.getNodeByName(prevNode.name)) {
- idx -= 1;
- prevNode = this._finalNodesChain[idx];
- }
- return prevNode;
- };
- EffectCompositor.prototype._getNextNode = function (node) {
- var idx = FINAL_NODES_CHAIN.indexOf(node.name) + 1;
- var nextNode = this._finalNodesChain[idx];
- while (nextNode && !this._compositor.getNodeByName(nextNode.name)) {
- idx += 1;
- nextNode = this._finalNodesChain[idx];
- }
- return nextNode;
- };
- EffectCompositor.prototype._addChainNode = function (node) {
- var prevNode = this._getPrevNode(node);
- var nextNode = this._getNextNode(node);
- if (!prevNode) {
- return;
- }
- prevNode.outputs = commonOutputs;
- node.inputs.texture = prevNode.name;
- if (nextNode) {
- node.outputs = commonOutputs;
- nextNode.inputs.texture = node.name;
- }
- else {
- node.outputs = null;
- }
- this._compositor.addNode(node);
- };
- EffectCompositor.prototype._removeChainNode = function (node) {
- var prevNode = this._getPrevNode(node);
- var nextNode = this._getNextNode(node);
- if (!prevNode) {
- return;
- }
- if (nextNode) {
- prevNode.outputs = commonOutputs;
- nextNode.inputs.texture = prevNode.name;
- }
- else {
- prevNode.outputs = null;
- }
- this._compositor.removeNode(node);
- };
- /**
- * Update normal
- */
- EffectCompositor.prototype.updateNormal = function (renderer, scene, camera, frame) {
- if (this._ifRenderNormalPass()) {
- this._normalPass.update(renderer, scene, camera);
- }
- };
- /**
- * Render SSAO after render the scene, before compositing
- */
- EffectCompositor.prototype.updateSSAO = function (renderer, scene, camera, frame) {
- this._ssaoPass.update(renderer, camera, frame);
- };
- /**
- * Enable SSAO effect
- */
- EffectCompositor.prototype.enableSSAO = function () {
- this._enableSSAO = true;
- };
- /**
- * Disable SSAO effect
- */
- EffectCompositor.prototype.disableSSAO = function () {
- this._enableSSAO = false;
- };
- /**
- * Enable SSR effect
- */
- EffectCompositor.prototype.enableSSR = function () {
- this._enableSSR = true;
- // this._normalPass.enableTargetTexture3 = true;
- };
- /**
- * Disable SSR effect
- */
- EffectCompositor.prototype.disableSSR = function () {
- this._enableSSR = false;
- // this._normalPass.enableTargetTexture3 = false;
- };
- /**
- * Render SSAO after render the scene, before compositing
- */
- EffectCompositor.prototype.getSSAOTexture = function () {
- return this._ssaoPass.getTargetTexture();
- };
- /**
- * @return {clay.FrameBuffer}
- */
- EffectCompositor.prototype.getSourceFrameBuffer = function () {
- return this._framebuffer;
- };
- /**
- * @return {clay.Texture2D}
- */
- EffectCompositor.prototype.getSourceTexture = function () {
- return this._sourceTexture;
- };
- /**
- * Disable fxaa effect
- */
- EffectCompositor.prototype.disableFXAA = function () {
- this._removeChainNode(this._fxaaNode);
- };
- /**
- * Enable fxaa effect
- */
- EffectCompositor.prototype.enableFXAA = function () {
- this._addChainNode(this._fxaaNode);
- };
- /**
- * Enable bloom effect
- */
- EffectCompositor.prototype.enableBloom = function () {
- this._compositeNode.inputs.bloom = 'bloom_composite';
- this._compositor.dirty();
- };
- /**
- * Disable bloom effect
- */
- EffectCompositor.prototype.disableBloom = function () {
- this._compositeNode.inputs.bloom = null;
- this._compositor.dirty();
- };
- /**
- * Enable depth of field effect
- */
- EffectCompositor.prototype.enableDOF = function () {
- this._compositeNode.inputs.texture = 'dof_composite';
- this._compositor.dirty();
- };
- /**
- * Disable depth of field effect
- */
- EffectCompositor.prototype.disableDOF = function () {
- this._compositeNode.inputs.texture = 'source';
- this._compositor.dirty();
- };
- /**
- * Enable color correction
- */
- EffectCompositor.prototype.enableColorCorrection = function () {
- this._compositeNode.define('COLOR_CORRECTION');
- this._enableColorCorrection = true;
- };
- /**
- * Disable color correction
- */
- EffectCompositor.prototype.disableColorCorrection = function () {
- this._compositeNode.undefine('COLOR_CORRECTION');
- this._enableColorCorrection = false;
- };
- /**
- * Enable edge detection
- */
- EffectCompositor.prototype.enableEdge = function () {
- this._enableEdge = true;
- };
- /**
- * Disable edge detection
- */
- EffectCompositor.prototype.disableEdge = function () {
- this._enableEdge = false;
- };
- /**
- * Set bloom intensity
- * @param {number} value
- */
- EffectCompositor.prototype.setBloomIntensity = function (value) {
- this._compositeNode.setParameter('bloomIntensity', value);
- };
- EffectCompositor.prototype.setSSAOParameter = function (name, value) {
- switch (name) {
- case 'quality':
- // PENDING
- var kernelSize = ({
- low: 6,
- medium: 12,
- high: 32,
- ultra: 62
- })[value] || 12;
- this._ssaoPass.setParameter('kernelSize', kernelSize);
- break;
- case 'radius':
- this._ssaoPass.setParameter(name, value);
- this._ssaoPass.setParameter('bias', value / 200);
- break;
- case 'intensity':
- this._ssaoPass.setParameter(name, value);
- break;
- default:
- if (true) {
- console.warn('Unkown SSAO parameter ' + name);
- }
- }
- };
- EffectCompositor.prototype.setDOFParameter = function (name, value) {
- switch (name) {
- case 'focalDistance':
- case 'focalRange':
- case 'fstop':
- this._cocNode.setParameter(name, value);
- break;
- case 'blurRadius':
- for (var i = 0; i < this._dofBlurNodes.length; i++) {
- this._dofBlurNodes[i].setParameter('blurRadius', value);
- }
- break;
- case 'quality':
- var kernelSize = ({
- low: 4, medium: 8, high: 16, ultra: 32
- })[value] || 8;
- this._dofBlurKernelSize = kernelSize;
- for (var i = 0; i < this._dofBlurNodes.length; i++) {
- this._dofBlurNodes[i].pass.material.define('POISSON_KERNEL_SIZE', kernelSize);
- }
- this._dofBlurKernel = new Float32Array(kernelSize * 2);
- break;
- default:
- if (true) {
- console.warn('Unkown DOF parameter ' + name);
- }
- }
- };
- EffectCompositor.prototype.setSSRParameter = function (name, value) {
- if (value == null) {
- return;
- }
- switch (name) {
- case 'quality':
- // PENDING
- var maxIteration = ({
- low: 10,
- medium: 15,
- high: 30,
- ultra: 80
- })[value] || 20;
- var pixelStride = ({
- low: 32,
- medium: 16,
- high: 8,
- ultra: 4
- })[value] || 16;
- this._ssrPass.setParameter('maxIteration', maxIteration);
- this._ssrPass.setParameter('pixelStride', pixelStride);
- break;
- case 'maxRoughness':
- this._ssrPass.setParameter('minGlossiness', Math.max(Math.min(1.0 - value, 1.0), 0.0));
- break;
- case 'physical':
- this.setPhysicallyCorrectSSR(value);
- break;
- default:
- console.warn('Unkown SSR parameter ' + name);
- }
- };
- EffectCompositor.prototype.setPhysicallyCorrectSSR = function (physical) {
- this._ssrPass.setPhysicallyCorrect(physical);
- };
- /**
- * Set color of edge
- */
- EffectCompositor.prototype.setEdgeColor = function (value) {
- var color = __WEBPACK_IMPORTED_MODULE_8__util_graphicGL__["a" /* default */].parseColor(value);
- this._edgePass.setParameter('edgeColor', color);
- };
- EffectCompositor.prototype.setExposure = function (value) {
- this._compositeNode.setParameter('exposure', Math.pow(2, value));
- };
- EffectCompositor.prototype.setColorLookupTexture = function (image, api) {
- this._compositeNode.pass.material.setTextureImage('lut', this._enableColorCorrection ? image : 'none', api, {
- minFilter: __WEBPACK_IMPORTED_MODULE_8__util_graphicGL__["a" /* default */].Texture.NEAREST,
- magFilter: __WEBPACK_IMPORTED_MODULE_8__util_graphicGL__["a" /* default */].Texture.NEAREST,
- flipY: false
- });
- };
- EffectCompositor.prototype.setColorCorrection = function (type, value) {
- this._compositeNode.setParameter(type, value);
- };
- EffectCompositor.prototype.isSSREnabled = function () {
- return this._enableSSR;
- };
- EffectCompositor.prototype.composite = function (renderer, scene, camera, framebuffer, frame) {
- var sourceTexture = this._sourceTexture;
- var targetTexture = sourceTexture;
- if (this._enableEdge) {
- this._edgePass.update(renderer, camera, sourceTexture, frame);
- sourceTexture = targetTexture = this._edgePass.getTargetTexture();
- }
- if (this._enableSSR) {
- this._ssrPass.update(renderer, camera, sourceTexture, frame);
- targetTexture = this._ssrPass.getTargetTexture();
- this._ssrPass.setSSAOTexture(
- this._enableSSAO ? this._ssaoPass.getTargetTexture() : null
- );
- // var lights = scene.getLights();
- // for (var i = 0; i < lights.length; i++) {
- // if (lights[i].cubemap) {
- // this._ssrPass.setAmbientCubemap(lights[i].cubemap, lights[i].intensity);
- // }
- // }
- }
- this._sourceNode.texture = targetTexture;
- this._cocNode.setParameter('depth', this._depthTexture);
- var blurKernel = this._dofBlurKernel;
- var blurKernelSize = this._dofBlurKernelSize;
- var frameAll = Math.floor(__WEBPACK_IMPORTED_MODULE_7__poissonKernel__["a" /* default */].length / 2 / blurKernelSize);
- var kernelOffset = frame % frameAll;
- for (var i = 0; i < blurKernelSize * 2; i++) {
- blurKernel[i] = __WEBPACK_IMPORTED_MODULE_7__poissonKernel__["a" /* default */][i + kernelOffset * blurKernelSize * 2];
- }
- for (var i = 0; i < this._dofBlurNodes.length; i++) {
- this._dofBlurNodes[i].setParameter('percent', frame / 30.0);
- this._dofBlurNodes[i].setParameter('poissonKernel', blurKernel);
- }
- this._cocNode.setParameter('zNear', camera.near);
- this._cocNode.setParameter('zFar', camera.far);
- this._compositor.render(renderer, framebuffer);
- };
- EffectCompositor.prototype.dispose = function (renderer) {
- this._sourceTexture.dispose(renderer);
- this._depthTexture.dispose(renderer);
- this._framebuffer.dispose(renderer);
- this._compositor.dispose(renderer);
- this._normalPass.dispose(renderer);
- this._ssaoPass.dispose(renderer);
- };
- /* harmony default export */ __webpack_exports__["a"] = (EffectCompositor);
- /***/
- }),
- /* 177 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__createCompositor__ = __webpack_require__(178);
- // DEPRECATED
- /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_0__createCompositor__["a" /* default */]);
- /***/
- }),
- /* 178 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_util__ = __webpack_require__(23);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__compositor_Compositor__ = __webpack_require__(179);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__compositor_SceneNode__ = __webpack_require__(181);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__compositor_TextureNode__ = __webpack_require__(182);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__compositor_FilterNode__ = __webpack_require__(183);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__TextureCube__ = __webpack_require__(27);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__shader_registerBuiltinCompositor__ = __webpack_require__(184);
- Object(__WEBPACK_IMPORTED_MODULE_9__shader_registerBuiltinCompositor__["a" /* default */])(__WEBPACK_IMPORTED_MODULE_5__Shader__["a" /* default */]);
- var shaderSourceReg = /^#source\((.*?)\)/;
- /**
- * @name clay.createCompositor
- * @function
- * @param {Object} json
- * @param {Object} [opts]
- * @return {clay.compositor.Compositor}
- */
- function createCompositor(json, opts) {
- var compositor = new __WEBPACK_IMPORTED_MODULE_1__compositor_Compositor__["a" /* default */]();
- opts = opts || {};
- var lib = {
- textures: {},
- parameters: {}
- };
- var afterLoad = function (shaderLib, textureLib) {
- for (var i = 0; i < json.nodes.length; i++) {
- var nodeInfo = json.nodes[i];
- var node = createNode(nodeInfo, lib, opts);
- if (node) {
- compositor.addNode(node);
- }
- }
- };
- for (var name in json.parameters) {
- var paramInfo = json.parameters[name];
- lib.parameters[name] = convertParameter(paramInfo);
- }
- // TODO load texture asynchronous
- loadTextures(json, lib, opts, function (textureLib) {
- lib.textures = textureLib;
- afterLoad();
- });
- return compositor;
- }
- function createNode(nodeInfo, lib, opts) {
- var type = nodeInfo.type || 'filter';
- var shaderSource;
- var inputs;
- var outputs;
- if (type === 'filter') {
- var shaderExp = nodeInfo.shader.trim();
- var res = shaderSourceReg.exec(shaderExp);
- if (res) {
- shaderSource = __WEBPACK_IMPORTED_MODULE_5__Shader__["a" /* default */].source(res[1].trim());
- }
- else if (shaderExp.charAt(0) === '#') {
- shaderSource = lib.shaders[shaderExp.substr(1)];
- }
- if (!shaderSource) {
- shaderSource = shaderExp;
- }
- if (!shaderSource) {
- return;
- }
- }
- if (nodeInfo.inputs) {
- inputs = {};
- for (var name in nodeInfo.inputs) {
- if (typeof nodeInfo.inputs[name] === 'string') {
- inputs[name] = nodeInfo.inputs[name];
- }
- else {
- inputs[name] = {
- node: nodeInfo.inputs[name].node,
- pin: nodeInfo.inputs[name].pin
- };
- }
- }
- }
- if (nodeInfo.outputs) {
- outputs = {};
- for (var name in nodeInfo.outputs) {
- var outputInfo = nodeInfo.outputs[name];
- outputs[name] = {};
- if (outputInfo.attachment != null) {
- outputs[name].attachment = outputInfo.attachment;
- }
- if (outputInfo.keepLastFrame != null) {
- outputs[name].keepLastFrame = outputInfo.keepLastFrame;
- }
- if (outputInfo.outputLastFrame != null) {
- outputs[name].outputLastFrame = outputInfo.outputLastFrame;
- }
- if (outputInfo.parameters) {
- outputs[name].parameters = convertParameter(outputInfo.parameters);
- }
- }
- }
- var node;
- if (type === 'scene') {
- node = new __WEBPACK_IMPORTED_MODULE_2__compositor_SceneNode__["a" /* default */]({
- name: nodeInfo.name,
- scene: opts.scene,
- camera: opts.camera,
- outputs: outputs
- });
- }
- else if (type === 'texture') {
- node = new __WEBPACK_IMPORTED_MODULE_3__compositor_TextureNode__["a" /* default */]({
- name: nodeInfo.name,
- outputs: outputs
- });
- }
- // Default is filter
- else {
- node = new __WEBPACK_IMPORTED_MODULE_4__compositor_FilterNode__["a" /* default */]({
- name: nodeInfo.name,
- shader: shaderSource,
- inputs: inputs,
- outputs: outputs
- });
- }
- if (node) {
- if (nodeInfo.parameters) {
- for (var name in nodeInfo.parameters) {
- var val = nodeInfo.parameters[name];
- if (typeof (val) === 'string') {
- val = val.trim();
- if (val.charAt(0) === '#') {
- val = lib.textures[val.substr(1)];
- }
- else {
- node.on(
- 'beforerender', createSizeSetHandler(
- name, tryConvertExpr(val)
- )
- );
- }
- }
- node.setParameter(name, val);
- }
- }
- if (nodeInfo.defines && node.pass) {
- for (var name in nodeInfo.defines) {
- var val = nodeInfo.defines[name];
- node.pass.material.define('fragment', name, val);
- }
- }
- }
- return node;
- }
- function defaultWidthFunc(width, height) {
- return width;
- }
- function defaultHeightFunc(width, height) {
- return height;
- }
- function convertParameter(paramInfo) {
- var param = {};
- if (!paramInfo) {
- return param;
- }
- ['type', 'minFilter', 'magFilter', 'wrapS', 'wrapT', 'flipY', 'useMipmap']
- .forEach(function (name) {
- var val = paramInfo[name];
- if (val != null) {
- // Convert string to enum
- if (typeof val === 'string') {
- val = __WEBPACK_IMPORTED_MODULE_6__Texture__["a" /* default */][val];
- }
- param[name] = val;
- }
- });
- var sizeScale = paramInfo.scale || 1;
- ['width', 'height']
- .forEach(function (name) {
- if (paramInfo[name] != null) {
- var val = paramInfo[name];
- if (typeof val === 'string') {
- val = val.trim();
- param[name] = createSizeParser(
- name, tryConvertExpr(val), sizeScale
- );
- }
- else {
- param[name] = val;
- }
- }
- });
- if (!param.width) {
- param.width = defaultWidthFunc;
- }
- if (!param.height) {
- param.height = defaultHeightFunc;
- }
- if (paramInfo.useMipmap != null) {
- param.useMipmap = paramInfo.useMipmap;
- }
- return param;
- }
- function loadTextures(json, lib, opts, callback) {
- if (!json.textures) {
- callback({});
- return;
- }
- var textures = {};
- var loading = 0;
- var cbd = false;
- var textureRootPath = opts.textureRootPath;
- __WEBPACK_IMPORTED_MODULE_0__core_util__["a" /* default */].each(json.textures, function (textureInfo, name) {
- var texture;
- var path = textureInfo.path;
- var parameters = convertParameter(textureInfo.parameters);
- if (Array.isArray(path) && path.length === 6) {
- if (textureRootPath) {
- path = path.map(function (item) {
- return __WEBPACK_IMPORTED_MODULE_0__core_util__["a" /* default */].relative2absolute(item, textureRootPath);
- });
- }
- texture = new __WEBPACK_IMPORTED_MODULE_8__TextureCube__["a" /* default */](parameters);
- }
- else if (typeof path === 'string') {
- if (textureRootPath) {
- path = __WEBPACK_IMPORTED_MODULE_0__core_util__["a" /* default */].relative2absolute(path, textureRootPath);
- }
- texture = new __WEBPACK_IMPORTED_MODULE_7__Texture2D__["a" /* default */](parameters);
- }
- else {
- return;
- }
- texture.load(path);
- loading++;
- texture.once('success', function () {
- textures[name] = texture;
- loading--;
- if (loading === 0) {
- callback(textures);
- cbd = true;
- }
- });
- });
- if (loading === 0 && !cbd) {
- callback(textures);
- }
- }
- function createSizeSetHandler(name, exprFunc) {
- return function (renderer) {
- // PENDING viewport size or window size
- var dpr = renderer.getDevicePixelRatio();
- // PENDING If multiply dpr ?
- var width = renderer.getWidth();
- var height = renderer.getHeight();
- var result = exprFunc(width, height, dpr);
- this.setParameter(name, result);
- };
- }
- function createSizeParser(name, exprFunc, scale) {
- scale = scale || 1;
- return function (renderer) {
- var dpr = renderer.getDevicePixelRatio();
- var width = renderer.getWidth() * scale;
- var height = renderer.getHeight() * scale;
- return exprFunc(width, height, dpr);
- };
- }
- function tryConvertExpr(string) {
- // PENDING
- var exprRes = /^expr\((.*)\)$/.exec(string);
- if (exprRes) {
- try {
- var func = new Function('width', 'height', 'dpr', 'return ' + exprRes[1]);
- // Try run t
- func(1, 1);
- return func;
- }
- catch (e) {
- throw new Error('Invalid expression.');
- }
- }
- }
- /* harmony default export */ __webpack_exports__["a"] = (createCompositor);
- /***/
- }),
- /* 179 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Graph__ = __webpack_require__(180);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__TexturePool__ = __webpack_require__(86);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__FrameBuffer__ = __webpack_require__(10);
- /**
- * Compositor provide graph based post processing
- *
- * @constructor clay.compositor.Compositor
- * @extends clay.compositor.Graph
- *
- */
- var Compositor = __WEBPACK_IMPORTED_MODULE_0__Graph__["a" /* default */].extend(function () {
- return {
- // Output node
- _outputs: [],
- _texturePool: new __WEBPACK_IMPORTED_MODULE_1__TexturePool__["a" /* default */](),
- _frameBuffer: new __WEBPACK_IMPORTED_MODULE_2__FrameBuffer__["a" /* default */]({
- depthBuffer: false
- })
- };
- },
- /** @lends clay.compositor.Compositor.prototype */
- {
- addNode: function (node) {
- __WEBPACK_IMPORTED_MODULE_0__Graph__["a" /* default */].prototype.addNode.call(this, node);
- node._compositor = this;
- },
- /**
- * @param {clay.Renderer} renderer
- */
- render: function (renderer, frameBuffer) {
- if (this._dirty) {
- this.update();
- this._dirty = false;
- this._outputs.length = 0;
- for (var i = 0; i < this.nodes.length; i++) {
- if (!this.nodes[i].outputs) {
- this._outputs.push(this.nodes[i]);
- }
- }
- }
- for (var i = 0; i < this.nodes.length; i++) {
- // Update the reference number of each output texture
- this.nodes[i].beforeFrame();
- }
- for (var i = 0; i < this._outputs.length; i++) {
- this._outputs[i].updateReference();
- }
- for (var i = 0; i < this._outputs.length; i++) {
- this._outputs[i].render(renderer, frameBuffer);
- }
- for (var i = 0; i < this.nodes.length; i++) {
- // Clear up
- this.nodes[i].afterFrame();
- }
- },
- allocateTexture: function (parameters) {
- return this._texturePool.get(parameters);
- },
- releaseTexture: function (parameters) {
- this._texturePool.put(parameters);
- },
- getFrameBuffer: function () {
- return this._frameBuffer;
- },
- /**
- * Dispose compositor
- * @param {clay.Renderer} renderer
- */
- dispose: function (renderer) {
- this._texturePool.clear(renderer);
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Compositor);
- /***/
- }),
- /* 180 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CompositorNode__ = __webpack_require__(48);
- /**
- * @constructor clay.compositor.Graph
- * @extends clay.core.Base
- */
- var Graph = __WEBPACK_IMPORTED_MODULE_0__core_Base__["a" /* default */].extend(function () {
- return /** @lends clay.compositor.Graph# */ {
- /**
- * @type {Array.<clay.compositor.CompositorNode>}
- */
- nodes: []
- };
- },
- /** @lends clay.compositor.Graph.prototype */
- {
- /**
- * Mark to update
- */
- dirty: function () {
- this._dirty = true;
- },
- /**
- * @param {clay.compositor.CompositorNode} node
- */
- addNode: function (node) {
- if (this.nodes.indexOf(node) >= 0) {
- return;
- }
- this.nodes.push(node);
- this._dirty = true;
- },
- /**
- * @param {clay.compositor.CompositorNode|string} node
- */
- removeNode: function (node) {
- if (typeof node === 'string') {
- node = this.getNodeByName(node);
- }
- var idx = this.nodes.indexOf(node);
- if (idx >= 0) {
- this.nodes.splice(idx, 1);
- this._dirty = true;
- }
- },
- /**
- * @param {string} name
- * @return {clay.compositor.CompositorNode}
- */
- getNodeByName: function (name) {
- for (var i = 0; i < this.nodes.length; i++) {
- if (this.nodes[i].name === name) {
- return this.nodes[i];
- }
- }
- },
- /**
- * Update links of graph
- */
- update: function () {
- for (var i = 0; i < this.nodes.length; i++) {
- this.nodes[i].clear();
- }
- // Traverse all the nodes and build the graph
- for (var i = 0; i < this.nodes.length; i++) {
- var node = this.nodes[i];
- if (!node.inputs) {
- continue;
- }
- for (var inputName in node.inputs) {
- if (!node.inputs[inputName]) {
- continue;
- }
- if (node.pass && !node.pass.material.isUniformEnabled(inputName)) {
- console.warn('Pin ' + node.name + '.' + inputName + ' not used.');
- continue;
- }
- var fromPinInfo = node.inputs[inputName];
- var fromPin = this.findPin(fromPinInfo);
- if (fromPin) {
- node.link(inputName, fromPin.node, fromPin.pin);
- }
- else {
- if (typeof fromPinInfo === 'string') {
- console.warn('Node ' + fromPinInfo + ' not exist');
- }
- else {
- console.warn('Pin of ' + fromPinInfo.node + '.' + fromPinInfo.pin + ' not exist');
- }
- }
- }
- }
- },
- findPin: function (input) {
- var node;
- // Try to take input as a directly a node
- if (typeof input === 'string' || input instanceof __WEBPACK_IMPORTED_MODULE_1__CompositorNode__["a" /* default */]) {
- input = {
- node: input
- };
- }
- if (typeof input.node === 'string') {
- for (var i = 0; i < this.nodes.length; i++) {
- var tmp = this.nodes[i];
- if (tmp.name === input.node) {
- node = tmp;
- }
- }
- }
- else {
- node = input.node;
- }
- if (node) {
- var inputPin = input.pin;
- if (!inputPin) {
- // Use first pin defaultly
- if (node.outputs) {
- inputPin = Object.keys(node.outputs)[0];
- }
- }
- if (node.outputs[inputPin]) {
- return {
- node: node,
- pin: inputPin
- };
- }
- }
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Graph);
- /***/
- }),
- /* 181 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CompositorNode__ = __webpack_require__(48);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__core_glenum__ = __webpack_require__(11);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__FrameBuffer__ = __webpack_require__(10);
- /**
- * @constructor clay.compositor.SceneNode
- * @extends clay.compositor.CompositorNode
- */
- var SceneNode = __WEBPACK_IMPORTED_MODULE_0__CompositorNode__["a" /* default */].extend(
- /** @lends clay.compositor.SceneNode# */
- {
- name: 'scene',
- /**
- * @type {clay.Scene}
- */
- scene: null,
- /**
- * @type {clay.Camera}
- */
- camera: null,
- /**
- * @type {boolean}
- */
- autoUpdateScene: true,
- /**
- * @type {boolean}
- */
- preZ: false
- }, function () {
- this.frameBuffer = new __WEBPACK_IMPORTED_MODULE_2__FrameBuffer__["a" /* default */]();
- }, {
- render: function (renderer) {
- this._rendering = true;
- var _gl = renderer.gl;
- this.trigger('beforerender');
- var renderInfo;
- if (!this.outputs) {
- renderInfo = renderer.render(this.scene, this.camera, !this.autoUpdateScene, this.preZ);
- }
- else {
- var frameBuffer = this.frameBuffer;
- for (var name in this.outputs) {
- var parameters = this.updateParameter(name, renderer);
- var outputInfo = this.outputs[name];
- var texture = this._compositor.allocateTexture(parameters);
- this._outputTextures[name] = texture;
- var attachment = outputInfo.attachment || _gl.COLOR_ATTACHMENT0;
- if (typeof (attachment) == 'string') {
- attachment = _gl[attachment];
- }
- frameBuffer.attach(texture, attachment);
- }
- frameBuffer.bind(renderer);
- // MRT Support in chrome
- // https://www.khronos.org/registry/webgl/sdk/tests/conformance/extensions/ext-draw-buffers.html
- var ext = renderer.getGLExtension('EXT_draw_buffers');
- if (ext) {
- var bufs = [];
- for (var attachment in this.outputs) {
- attachment = parseInt(attachment);
- if (attachment >= _gl.COLOR_ATTACHMENT0 && attachment <= _gl.COLOR_ATTACHMENT0 + 8) {
- bufs.push(attachment);
- }
- }
- ext.drawBuffersEXT(bufs);
- }
- // Always clear
- // PENDING
- renderer.saveClear();
- renderer.clearBit = __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].DEPTH_BUFFER_BIT | __WEBPACK_IMPORTED_MODULE_1__core_glenum__["a" /* default */].COLOR_BUFFER_BIT;
- renderInfo = renderer.render(this.scene, this.camera, !this.autoUpdateScene, this.preZ);
- renderer.restoreClear();
- frameBuffer.unbind(renderer);
- }
- this.trigger('afterrender', renderInfo);
- this._rendering = false;
- this._rendered = true;
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (SceneNode);
- /***/
- }),
- /* 182 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CompositorNode__ = __webpack_require__(48);
- /**
- * @constructor clay.compositor.TextureNode
- * @extends clay.compositor.CompositorNode
- */
- var TextureNode = __WEBPACK_IMPORTED_MODULE_0__CompositorNode__["a" /* default */].extend(function () {
- return /** @lends clay.compositor.TextureNode# */ {
- /**
- * @type {clay.Texture2D}
- */
- texture: null,
- // Texture node must have output without parameters
- outputs: {
- color: {}
- }
- };
- }, function () {
- }, {
- getOutput: function (renderer, name) {
- return this.texture;
- },
- // Do nothing
- beforeFrame: function () { },
- afterFrame: function () { }
- });
- /* harmony default export */ __webpack_exports__["a"] = (TextureNode);
- /***/
- }),
- /* 183 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Pass__ = __webpack_require__(16);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CompositorNode__ = __webpack_require__(48);
- // TODO Shader library
- // TODO curlnoise demo wrong
- // PENDING
- // Use topological sort ?
- /**
- * Filter node
- *
- * @constructor clay.compositor.FilterNode
- * @extends clay.compositor.CompositorNode
- *
- * @example
- var node = new clay.compositor.FilterNode({
- name: 'fxaa',
- shader: clay.Shader.source('clay.compositor.fxaa'),
- inputs: {
- texture: {
- node: 'scene',
- pin: 'color'
- }
- },
- // Multiple outputs is preserved for MRT support in WebGL2.0
- outputs: {
- color: {
- attachment: clay.FrameBuffer.COLOR_ATTACHMENT0
- parameters: {
- format: clay.Texture.RGBA,
- width: 512,
- height: 512
- },
- // Node will keep the RTT rendered in last frame
- keepLastFrame: true,
- // Force the node output the RTT rendered in last frame
- outputLastFrame: true
- }
- }
- });
- *
- */
- var FilterNode = __WEBPACK_IMPORTED_MODULE_1__CompositorNode__["a" /* default */].extend(function () {
- return /** @lends clay.compositor.FilterNode# */ {
- /**
- * @type {string}
- */
- name: '',
- /**
- * @type {Object}
- */
- inputs: {},
- /**
- * @type {Object}
- */
- outputs: null,
- /**
- * @type {string}
- */
- shader: '',
- /**
- * Input links, will be updated by the graph
- * @example:
- * inputName: {
- * node: someNode,
- * pin: 'xxxx'
- * }
- * @type {Object}
- */
- inputLinks: {},
- /**
- * Output links, will be updated by the graph
- * @example:
- * outputName: {
- * node: someNode,
- * pin: 'xxxx'
- * }
- * @type {Object}
- */
- outputLinks: {},
- /**
- * @type {clay.compositor.Pass}
- */
- pass: null,
- // Save the output texture of previous frame
- // Will be used when there exist a circular reference
- _prevOutputTextures: {},
- _outputTextures: {},
- // Example: { name: 2 }
- _outputReferences: {},
- _rendering: false,
- // If rendered in this frame
- _rendered: false,
- _compositor: null
- };
- }, function () {
- var pass = new __WEBPACK_IMPORTED_MODULE_0__Pass__["a" /* default */]({
- fragment: this.shader
- });
- this.pass = pass;
- },
- /** @lends clay.compositor.FilterNode.prototype */
- {
- /**
- * @param {clay.Renderer} renderer
- */
- render: function (renderer, frameBuffer) {
- this.trigger('beforerender', renderer);
- this._rendering = true;
- var _gl = renderer.gl;
- for (var inputName in this.inputLinks) {
- var link = this.inputLinks[inputName];
- var inputTexture = link.node.getOutput(renderer, link.pin);
- this.pass.setUniform(inputName, inputTexture);
- }
- // Output
- if (!this.outputs) {
- this.pass.outputs = null;
- this._compositor.getFrameBuffer().unbind(renderer);
- this.pass.render(renderer, frameBuffer);
- }
- else {
- this.pass.outputs = {};
- var attachedTextures = {};
- for (var name in this.outputs) {
- var parameters = this.updateParameter(name, renderer);
- if (isNaN(parameters.width)) {
- this.updateParameter(name, renderer);
- }
- var outputInfo = this.outputs[name];
- var texture = this._compositor.allocateTexture(parameters);
- this._outputTextures[name] = texture;
- var attachment = outputInfo.attachment || _gl.COLOR_ATTACHMENT0;
- if (typeof (attachment) === 'string') {
- attachment = _gl[attachment];
- }
- attachedTextures[attachment] = texture;
- }
- this._compositor.getFrameBuffer().bind(renderer);
- for (var attachment in attachedTextures) {
- // FIXME attachment changes in different nodes
- this._compositor.getFrameBuffer().attach(
- attachedTextures[attachment], attachment
- );
- }
- this.pass.render(renderer);
- // Because the data of texture is changed over time,
- // Here update the mipmaps of texture each time after rendered;
- this._compositor.getFrameBuffer().updateMipmap(renderer);
- }
- for (var inputName in this.inputLinks) {
- var link = this.inputLinks[inputName];
- link.node.removeReference(link.pin);
- }
- this._rendering = false;
- this._rendered = true;
- this.trigger('afterrender', renderer);
- },
- // TODO Remove parameter function callback
- updateParameter: function (outputName, renderer) {
- var outputInfo = this.outputs[outputName];
- var parameters = outputInfo.parameters;
- var parametersCopy = outputInfo._parametersCopy;
- if (!parametersCopy) {
- parametersCopy = outputInfo._parametersCopy = {};
- }
- if (parameters) {
- for (var key in parameters) {
- if (key !== 'width' && key !== 'height') {
- parametersCopy[key] = parameters[key];
- }
- }
- }
- var width, height;
- if (parameters.width instanceof Function) {
- width = parameters.width.call(this, renderer);
- }
- else {
- width = parameters.width;
- }
- if (parameters.height instanceof Function) {
- height = parameters.height.call(this, renderer);
- }
- else {
- height = parameters.height;
- }
- width = Math.ceil(width);
- height = Math.ceil(height);
- if (
- parametersCopy.width !== width
- || parametersCopy.height !== height
- ) {
- if (this._outputTextures[outputName]) {
- this._outputTextures[outputName].dispose(renderer);
- }
- }
- parametersCopy.width = width;
- parametersCopy.height = height;
- return parametersCopy;
- },
- /**
- * Set parameter
- * @param {string} name
- * @param {} value
- */
- setParameter: function (name, value) {
- this.pass.setUniform(name, value);
- },
- /**
- * Get parameter value
- * @param {string} name
- * @return {}
- */
- getParameter: function (name) {
- return this.pass.getUniform(name);
- },
- /**
- * Set parameters
- * @param {Object} obj
- */
- setParameters: function (obj) {
- for (var name in obj) {
- this.setParameter(name, obj[name]);
- }
- },
- // /**
- // * Set shader code
- // * @param {string} shaderStr
- // */
- // setShader: function (shaderStr) {
- // var material = this.pass.material;
- // material.shader.setFragment(shaderStr);
- // material.attachShader(material.shader, true);
- // },
- /**
- * Proxy of pass.material.define('fragment', xxx);
- * @param {string} symbol
- * @param {number} [val]
- */
- define: function (symbol, val) {
- this.pass.material.define('fragment', symbol, val);
- },
- /**
- * Proxy of pass.material.undefine('fragment', xxx)
- * @param {string} symbol
- */
- undefine: function (symbol) {
- this.pass.material.undefine('fragment', symbol);
- },
- removeReference: function (outputName) {
- this._outputReferences[outputName]--;
- if (this._outputReferences[outputName] === 0) {
- var outputInfo = this.outputs[outputName];
- if (outputInfo.keepLastFrame) {
- if (this._prevOutputTextures[outputName]) {
- this._compositor.releaseTexture(this._prevOutputTextures[outputName]);
- }
- this._prevOutputTextures[outputName] = this._outputTextures[outputName];
- }
- else {
- // Output of this node have alreay been used by all other nodes
- // Put the texture back to the pool.
- this._compositor.releaseTexture(this._outputTextures[outputName]);
- }
- }
- },
- clear: function () {
- __WEBPACK_IMPORTED_MODULE_1__CompositorNode__["a" /* default */].prototype.clear.call(this);
- // Default disable all texture
- this.pass.material.disableTexturesAll();
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (FilterNode);
- /***/
- }),
- /* 184 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony export (immutable) */ __webpack_exports__["a"] = register;
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__source_compositor_coloradjust_glsl_js__ = __webpack_require__(185);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__source_compositor_blur_glsl_js__ = __webpack_require__(87);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__source_compositor_lum_glsl_js__ = __webpack_require__(186);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__source_compositor_lut_glsl_js__ = __webpack_require__(88);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__source_compositor_vignette_glsl_js__ = __webpack_require__(187);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__source_compositor_output_glsl_js__ = __webpack_require__(89);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__source_compositor_bright_glsl_js__ = __webpack_require__(90);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__source_compositor_downsample_glsl_js__ = __webpack_require__(91);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__source_compositor_upsample_glsl_js__ = __webpack_require__(92);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__source_compositor_hdr_glsl_js__ = __webpack_require__(93);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__source_compositor_lensflare_glsl_js__ = __webpack_require__(188);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__source_compositor_blend_glsl_js__ = __webpack_require__(94);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__source_compositor_fxaa_glsl_js__ = __webpack_require__(95);
- // import fxaa3Essl from './source/compositor/fxaa3.glsl.js';
- // TODO Must export a module and be used in the other modules. Or it will be tree shaked
- function register(Shader) {
- // Some build in shaders
- Shader['import'](__WEBPACK_IMPORTED_MODULE_0__source_compositor_coloradjust_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_1__source_compositor_blur_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_2__source_compositor_lum_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_3__source_compositor_lut_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_4__source_compositor_vignette_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_5__source_compositor_output_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_6__source_compositor_bright_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_7__source_compositor_downsample_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_8__source_compositor_upsample_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_9__source_compositor_hdr_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_10__source_compositor_lensflare_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_11__source_compositor_blend_glsl_js__["a" /* default */]);
- Shader['import'](__WEBPACK_IMPORTED_MODULE_12__source_compositor_fxaa_glsl_js__["a" /* default */]);
- }
- /***/
- }),
- /* 185 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.coloradjust\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float exposure : 0.0;\nuniform float gamma : 1.0;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = clamp(tex.rgb + vec3(brightness), 0.0, 1.0);\n color = clamp( (color-vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n color = clamp( color * pow(2.0, exposure), 0.0, 1.0);\n color = clamp( pow(color, vec3(gamma)), 0.0, 1.0);\n float luminance = dot( color, w );\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.brightness\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float brightness : 0.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = tex.rgb + vec3(brightness);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.contrast\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float contrast : 1.0;\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord);\n vec3 color = (tex.rgb-vec3(0.5))*contrast+vec3(0.5);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.exposure\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float exposure : 0.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb * pow(2.0, exposure);\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.gamma\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float gamma : 1.0;\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = pow(tex.rgb, vec3(gamma));\n gl_FragColor = vec4(color, tex.a);\n}\n@end\n@export clay.compositor.saturation\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float saturation : 1.0;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D(texture, v_Texcoord);\n vec3 color = tex.rgb;\n float luminance = dot(color, w);\n color = mix(vec3(luminance), color, saturation);\n gl_FragColor = vec4(color, tex.a);\n}\n@end");
- /***/
- }),
- /* 186 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.hdr.log_lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\n@import clay.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n float luminance = dot(tex.rgb, w);\n luminance = log(luminance + 0.001);\n gl_FragColor = encodeHDR(vec4(vec3(luminance), 1.0));\n}\n@end\n@export clay.compositor.hdr.lum_adaption\nvarying vec2 v_Texcoord;\nuniform sampler2D adaptedLum;\nuniform sampler2D currentLum;\nuniform float frameTime : 0.02;\n@import clay.util.rgbm\nvoid main()\n{\n float fAdaptedLum = decodeHDR(texture2D(adaptedLum, vec2(0.5, 0.5))).r;\n float fCurrentLum = exp(encodeHDR(texture2D(currentLum, vec2(0.5, 0.5))).r);\n fAdaptedLum += (fCurrentLum - fAdaptedLum) * (1.0 - pow(0.98, 30.0 * frameTime));\n gl_FragColor = encodeHDR(vec4(vec3(fAdaptedLum), 1.0));\n}\n@end\n@export clay.compositor.lum\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nconst vec3 w = vec3(0.2125, 0.7154, 0.0721);\nvoid main()\n{\n vec4 tex = texture2D( texture, v_Texcoord );\n float luminance = dot(tex.rgb, w);\n gl_FragColor = vec4(vec3(luminance), 1.0);\n}\n@end");
- /***/
- }),
- /* 187 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.vignette\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\nuniform float darkness: 1;\nuniform float offset: 1;\n@import clay.util.rgbm\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = texel.rgb;\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(offset);\n gl_FragColor = encodeHDR(vec4(mix(texel.rgb, vec3(1.0 - darkness), dot(uv, uv)), texel.a));\n}\n@end");
- /***/
- }),
- /* 188 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export clay.compositor.lensflare\n#define SAMPLE_NUMBER 8\nuniform sampler2D texture;\nuniform sampler2D lenscolor;\nuniform vec2 textureSize : [512, 512];\nuniform float dispersal : 0.3;\nuniform float haloWidth : 0.4;\nuniform float distortion : 1.0;\nvarying vec2 v_Texcoord;\n@import clay.util.rgbm\nvec4 textureDistorted(\n in vec2 texcoord,\n in vec2 direction,\n in vec3 distortion\n) {\n return vec4(\n decodeHDR(texture2D(texture, texcoord + direction * distortion.r)).r,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.g)).g,\n decodeHDR(texture2D(texture, texcoord + direction * distortion.b)).b,\n 1.0\n );\n}\nvoid main()\n{\n vec2 texcoord = -v_Texcoord + vec2(1.0); vec2 textureOffset = 1.0 / textureSize;\n vec2 ghostVec = (vec2(0.5) - texcoord) * dispersal;\n vec2 haloVec = normalize(ghostVec) * haloWidth;\n vec3 distortion = vec3(-textureOffset.x * distortion, 0.0, textureOffset.x * distortion);\n vec4 result = vec4(0.0);\n for (int i = 0; i < SAMPLE_NUMBER; i++)\n {\n vec2 offset = fract(texcoord + ghostVec * float(i));\n float weight = length(vec2(0.5) - offset) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n }\n result *= texture2D(lenscolor, vec2(length(vec2(0.5) - texcoord)) / length(vec2(0.5)));\n float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));\n weight = pow(1.0 - weight, 10.0);\n vec2 offset = fract(texcoord + haloVec);\n result += textureDistorted(offset, normalize(ghostVec), distortion) * weight;\n gl_FragColor = result;\n}\n@end");
- /***/
- }),
- /* 189 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__ = __webpack_require__(16);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_FrameBuffer__ = __webpack_require__(10);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__halton__ = __webpack_require__(49);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__SSAO_glsl_js__ = __webpack_require__(190);
- __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_8__SSAO_glsl_js__["a" /* default */]);
- function generateNoiseData(size) {
- var data = new Uint8Array(size * size * 4);
- var n = 0;
- var v3 = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__["a" /* default */]();
- for (var i = 0; i < size; i++) {
- for (var j = 0; j < size; j++) {
- v3.set(Math.random() * 2 - 1, Math.random() * 2 - 1, 0).normalize();
- data[n++] = (v3.x * 0.5 + 0.5) * 255;
- data[n++] = (v3.y * 0.5 + 0.5) * 255;
- data[n++] = 0;
- data[n++] = 255;
- }
- }
- return data;
- }
- function generateNoiseTexture(size) {
- return new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]({
- pixels: generateNoiseData(size),
- wrapS: __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].REPEAT,
- wrapT: __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].REPEAT,
- width: size,
- height: size
- });
- }
- function generateKernel(size, offset, hemisphere) {
- var kernel = new Float32Array(size * 3);
- offset = offset || 0;
- for (var i = 0; i < size; i++) {
- var phi = Object(__WEBPACK_IMPORTED_MODULE_7__halton__["a" /* default */])(i + offset, 2) * (hemisphere ? 1 : 2) * Math.PI;
- var theta = Object(__WEBPACK_IMPORTED_MODULE_7__halton__["a" /* default */])(i + offset, 3) * Math.PI;
- var r = Math.random();
- var x = Math.cos(phi) * Math.sin(theta) * r;
- var y = Math.cos(theta) * r;
- var z = Math.sin(phi) * Math.sin(theta) * r;
- kernel[i * 3] = x;
- kernel[i * 3 + 1] = y;
- kernel[i * 3 + 2] = z;
- }
- return kernel;
- // var kernel = new Float32Array(size * 3);
- // var v3 = new Vector3();
- // for (var i = 0; i < size; i++) {
- // v3.set(Math.random() * 2 - 1, Math.random() * 2 - 1, Math.random())
- // .normalize().scale(Math.random());
- // kernel[i * 3] = v3.x;
- // kernel[i * 3 + 1] = v3.y;
- // kernel[i * 3 + 2] = v3.z;
- // }
- // return kernel;
- }
- function SSAOPass(opt) {
- opt = opt || {};
- this._ssaoPass = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__["a" /* default */].source('ecgl.ssao.estimate')
- });
- this._blurPass = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__["a" /* default */].source('ecgl.ssao.blur')
- });
- this._framebuffer = new __WEBPACK_IMPORTED_MODULE_6_claygl_src_FrameBuffer__["a" /* default */]({
- depthBuffer: false
- });
- this._ssaoTexture = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]();
- this._blurTexture = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]();
- this._blurTexture2 = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]();
- this._depthTex = opt.depthTexture;
- this._normalTex = opt.normalTexture;
- this.setNoiseSize(4);
- this.setKernelSize(opt.kernelSize || 12);
- if (opt.radius != null) {
- this.setParameter('radius', opt.radius);
- }
- if (opt.power != null) {
- this.setParameter('power', opt.power);
- }
- if (!this._normalTex) {
- this._ssaoPass.material.disableTexture('normalTex');
- this._blurPass.material.disableTexture('normalTex');
- }
- if (!this._depthTex) {
- this._blurPass.material.disableTexture('depthTex');
- }
- this._blurPass.material.setUniform('normalTex', this._normalTex);
- this._blurPass.material.setUniform('depthTex', this._depthTex);
- }
- SSAOPass.prototype.setDepthTexture = function (depthTex) {
- this._depthTex = depthTex;
- };
- SSAOPass.prototype.setNormalTexture = function (normalTex) {
- this._normalTex = normalTex;
- this._ssaoPass.material[normalTex ? 'enableTexture' : 'disableTexture']('normalTex');
- // Switch between hemisphere and shere kernel.
- this.setKernelSize(this._kernelSize);
- };
- SSAOPass.prototype.update = function (renderer, camera, frame) {
- var width = renderer.getWidth();
- var height = renderer.getHeight();
- var ssaoPass = this._ssaoPass;
- var blurPass = this._blurPass;
- ssaoPass.setUniform('kernel', this._kernels[frame % this._kernels.length]);
- ssaoPass.setUniform('depthTex', this._depthTex);
- if (this._normalTex != null) {
- ssaoPass.setUniform('normalTex', this._normalTex);
- }
- ssaoPass.setUniform('depthTexSize', [this._depthTex.width, this._depthTex.height]);
- var viewInverseTranspose = new __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__["a" /* default */]();
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__["a" /* default */].transpose(viewInverseTranspose, camera.worldTransform);
- ssaoPass.setUniform('projection', camera.projectionMatrix.array);
- ssaoPass.setUniform('projectionInv', camera.invProjectionMatrix.array);
- ssaoPass.setUniform('viewInverseTranspose', viewInverseTranspose.array);
- var ssaoTexture = this._ssaoTexture;
- var blurTexture = this._blurTexture;
- var blurTexture2 = this._blurTexture2;
- ssaoTexture.width = width / 2;
- ssaoTexture.height = height / 2;
- blurTexture.width = width;
- blurTexture.height = height;
- blurTexture2.width = width;
- blurTexture2.height = height;
- this._framebuffer.attach(ssaoTexture);
- this._framebuffer.bind(renderer);
- renderer.gl.clearColor(1, 1, 1, 1);
- renderer.gl.clear(renderer.gl.COLOR_BUFFER_BIT);
- ssaoPass.render(renderer);
- blurPass.setUniform('textureSize', [width / 2, height / 2]);
- blurPass.setUniform('projection', camera.projectionMatrix.array);
- this._framebuffer.attach(blurTexture);
- blurPass.setUniform('direction', 0);
- blurPass.setUniform('ssaoTexture', ssaoTexture);
- blurPass.render(renderer);
- this._framebuffer.attach(blurTexture2);
- blurPass.setUniform('textureSize', [width, height]);
- blurPass.setUniform('direction', 1);
- blurPass.setUniform('ssaoTexture', blurTexture);
- blurPass.render(renderer);
- this._framebuffer.unbind(renderer);
- // Restore clear
- var clearColor = renderer.clearColor;
- renderer.gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
- };
- SSAOPass.prototype.getTargetTexture = function () {
- return this._blurTexture2;
- }
- SSAOPass.prototype.setParameter = function (name, val) {
- if (name === 'noiseTexSize') {
- this.setNoiseSize(val);
- }
- else if (name === 'kernelSize') {
- this.setKernelSize(val);
- }
- else if (name === 'intensity') {
- this._ssaoPass.material.set('intensity', val);
- }
- else {
- this._ssaoPass.setUniform(name, val);
- }
- };
- SSAOPass.prototype.setKernelSize = function (size) {
- this._kernelSize = size;
- this._ssaoPass.material.define('fragment', 'KERNEL_SIZE', size);
- this._kernels = this._kernels || [];
- for (var i = 0; i < 30; i++) {
- this._kernels[i] = generateKernel(size, i * size, !!this._normalTex);
- }
- };
- SSAOPass.prototype.setNoiseSize = function (size) {
- var texture = this._ssaoPass.getUniform('noiseTex');
- if (!texture) {
- texture = generateNoiseTexture(size);
- this._ssaoPass.setUniform('noiseTex', generateNoiseTexture(size));
- }
- else {
- texture.data = generateNoiseData(size);
- texture.width = texture.height = size;
- texture.dirty();
- }
- this._ssaoPass.setUniform('noiseTexSize', [size, size]);
- };
- SSAOPass.prototype.dispose = function (renderer) {
- this._blurTexture.dispose(renderer);
- this._ssaoTexture.dispose(renderer);
- this._blurTexture2.dispose(renderer);
- };
- /* harmony default export */ __webpack_exports__["a"] = (SSAOPass);
- /***/
- }),
- /* 190 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.ssao.estimate\n\nuniform sampler2D depthTex;\n\nuniform sampler2D normalTex;\n\nuniform sampler2D noiseTex;\n\nuniform vec2 depthTexSize;\n\nuniform vec2 noiseTexSize;\n\nuniform mat4 projection;\n\nuniform mat4 projectionInv;\n\nuniform mat4 viewInverseTranspose;\n\nuniform vec3 kernel[KERNEL_SIZE];\n\nuniform float radius : 1;\n\nuniform float power : 1;\n\nuniform float bias: 1e-2;\n\nuniform float intensity: 1.0;\n\nvarying vec2 v_Texcoord;\n\nfloat ssaoEstimator(in vec3 originPos, in mat3 kernelBasis) {\n float occlusion = 0.0;\n\n for (int i = 0; i < KERNEL_SIZE; i++) {\n vec3 samplePos = kernel[i];\n#ifdef NORMALTEX_ENABLED\n samplePos = kernelBasis * samplePos;\n#endif\n samplePos = samplePos * radius + originPos;\n\n vec4 texCoord = projection * vec4(samplePos, 1.0);\n texCoord.xy /= texCoord.w;\n\n vec4 depthTexel = texture2D(depthTex, texCoord.xy * 0.5 + 0.5);\n\n float sampleDepth = depthTexel.r * 2.0 - 1.0;\n if (projection[3][3] == 0.0) {\n sampleDepth = projection[3][2] / (sampleDepth * projection[2][3] - projection[2][2]);\n }\n else {\n sampleDepth = (sampleDepth - projection[3][2]) / projection[2][2];\n }\n \n float rangeCheck = smoothstep(0.0, 1.0, radius / abs(originPos.z - sampleDepth));\n occlusion += rangeCheck * step(samplePos.z, sampleDepth - bias);\n }\n#ifdef NORMALTEX_ENABLED\n occlusion = 1.0 - occlusion / float(KERNEL_SIZE);\n#else\n occlusion = 1.0 - clamp((occlusion / float(KERNEL_SIZE) - 0.6) * 2.5, 0.0, 1.0);\n#endif\n return pow(occlusion, power);\n}\n\nvoid main()\n{\n\n vec4 depthTexel = texture2D(depthTex, v_Texcoord);\n\n#ifdef NORMALTEX_ENABLED\n vec4 tex = texture2D(normalTex, v_Texcoord);\n if (dot(tex.rgb, tex.rgb) == 0.0) {\n gl_FragColor = vec4(1.0);\n return;\n }\n vec3 N = tex.rgb * 2.0 - 1.0;\n N = (viewInverseTranspose * vec4(N, 0.0)).xyz;\n\n vec2 noiseTexCoord = depthTexSize / vec2(noiseTexSize) * v_Texcoord;\n vec3 rvec = texture2D(noiseTex, noiseTexCoord).rgb * 2.0 - 1.0;\n vec3 T = normalize(rvec - N * dot(rvec, N));\n vec3 BT = normalize(cross(N, T));\n mat3 kernelBasis = mat3(T, BT, N);\n#else\n if (depthTexel.r > 0.99999) {\n gl_FragColor = vec4(1.0);\n return;\n }\n mat3 kernelBasis;\n#endif\n\n float z = depthTexel.r * 2.0 - 1.0;\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * projectedPos;\n\n vec3 position = p4.xyz / p4.w;\n\n float ao = ssaoEstimator(position, kernelBasis);\n ao = clamp(1.0 - (1.0 - ao) * intensity, 0.0, 1.0);\n gl_FragColor = vec4(vec3(ao), 1.0);\n}\n\n@end\n\n\n@export ecgl.ssao.blur\n#define SHADER_NAME SSAO_BLUR\n\nuniform sampler2D ssaoTexture;\n\n#ifdef NORMALTEX_ENABLED\nuniform sampler2D normalTex;\n#endif\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\nuniform int direction: 0.0;\n\n#ifdef DEPTHTEX_ENABLED\nuniform sampler2D depthTex;\nuniform mat4 projection;\nuniform float depthRange : 0.5;\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(depthTex, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n#endif\n\nvoid main()\n{\n float kernel[5];\n kernel[0] = 0.122581;\n kernel[1] = 0.233062;\n kernel[2] = 0.288713;\n kernel[3] = 0.233062;\n kernel[4] = 0.122581;\n\n vec2 off = vec2(0.0);\n if (direction == 0) {\n off[0] = blurSize / textureSize.x;\n }\n else {\n off[1] = blurSize / textureSize.y;\n }\n\n vec2 coord = v_Texcoord;\n\n float sum = 0.0;\n float weightAll = 0.0;\n\n#ifdef NORMALTEX_ENABLED\n vec3 centerNormal = texture2D(normalTex, v_Texcoord).rgb * 2.0 - 1.0;\n#endif\n#if defined(DEPTHTEX_ENABLED)\n float centerDepth = getLinearDepth(v_Texcoord);\n#endif\n\n for (int i = 0; i < 5; i++) {\n vec2 coord = clamp(v_Texcoord + vec2(float(i) - 2.0) * off, vec2(0.0), vec2(1.0));\n\n float w = kernel[i];\n#ifdef NORMALTEX_ENABLED\n vec3 normal = texture2D(normalTex, coord).rgb * 2.0 - 1.0;\n w *= clamp(dot(normal, centerNormal), 0.0, 1.0);\n#endif\n#ifdef DEPTHTEX_ENABLED\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(centerDepth - d) / depthRange, 0.0, 1.0));\n#endif\n\n weightAll += w;\n sum += texture2D(ssaoTexture, coord).r * w;\n }\n\n gl_FragColor = vec4(vec3(sum / weightAll), 1.0);\n}\n\n@end\n");
- /***/
- }),
- /* 191 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__ = __webpack_require__(16);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_FrameBuffer__ = __webpack_require__(10);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__halton__ = __webpack_require__(49);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_claygl_src_util_cubemap__ = __webpack_require__(77);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__SSR_glsl_js__ = __webpack_require__(192);
- __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_9__SSR_glsl_js__["a" /* default */]);
- function SSRPass(opt) {
- opt = opt || {};
- this._ssrPass = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__["a" /* default */].source('ecgl.ssr.main'),
- clearColor: [0, 0, 0, 0]
- });
- this._blurPass1 = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__["a" /* default */].source('ecgl.ssr.blur'),
- clearColor: [0, 0, 0, 0]
- });
- this._blurPass2 = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__["a" /* default */].source('ecgl.ssr.blur'),
- clearColor: [0, 0, 0, 0]
- });
- this._blendPass = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__["a" /* default */].source('clay.compositor.blend')
- });
- this._blendPass.material.disableTexturesAll();
- this._blendPass.material.enableTexture(['texture1', 'texture2']);
- this._ssrPass.setUniform('gBufferTexture1', opt.normalTexture);
- this._ssrPass.setUniform('gBufferTexture2', opt.depthTexture);
- // this._ssrPass.setUniform('gBufferTexture3', opt.albedoTexture);
- this._blurPass1.setUniform('gBufferTexture1', opt.normalTexture);
- this._blurPass1.setUniform('gBufferTexture2', opt.depthTexture);
- this._blurPass2.setUniform('gBufferTexture1', opt.normalTexture);
- this._blurPass2.setUniform('gBufferTexture2', opt.depthTexture);
- this._blurPass2.material.define('fragment', 'VERTICAL');
- this._blurPass2.material.define('fragment', 'BLEND');
- this._ssrTexture = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]({
- type: __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].HALF_FLOAT
- });
- this._texture2 = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]({
- type: __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].HALF_FLOAT
- });
- this._texture3 = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]({
- type: __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].HALF_FLOAT
- });
- this._prevTexture = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]({
- type: __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].HALF_FLOAT
- });
- this._currentTexture = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]({
- type: __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].HALF_FLOAT
- });
- this._frameBuffer = new __WEBPACK_IMPORTED_MODULE_6_claygl_src_FrameBuffer__["a" /* default */]({
- depthBuffer: false
- });
- this._normalDistribution = null;
- this._totalSamples = 256;
- this._samplePerFrame = 4;
- this._ssrPass.material.define('fragment', 'SAMPLE_PER_FRAME', this._samplePerFrame);
- this._ssrPass.material.define('fragment', 'TOTAL_SAMPLES', this._totalSamples);
- this._downScale = 1;
- }
- SSRPass.prototype.setAmbientCubemap = function (specularCubemap, specularIntensity) {
- this._ssrPass.material.set('specularCubemap', specularCubemap);
- this._ssrPass.material.set('specularIntensity', specularIntensity);
- var enableSpecularMap = specularCubemap && specularIntensity;
- this._ssrPass.material[enableSpecularMap ? 'enableTexture' : 'disableTexture']('specularCubemap');
- };
- SSRPass.prototype.update = function (renderer, camera, sourceTexture, frame) {
- var width = renderer.getWidth();
- var height = renderer.getHeight();
- var ssrTexture = this._ssrTexture;
- var texture2 = this._texture2;
- var texture3 = this._texture3;
- ssrTexture.width = this._prevTexture.width = this._currentTexture.width = width / this._downScale;
- ssrTexture.height = this._prevTexture.height = this._currentTexture.height = height / this._downScale;
- texture2.width = texture3.width = width;
- texture2.height = texture3.height = height;
- var frameBuffer = this._frameBuffer;
- var ssrPass = this._ssrPass;
- var blurPass1 = this._blurPass1;
- var blurPass2 = this._blurPass2;
- var blendPass = this._blendPass;
- var toViewSpace = new __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__["a" /* default */]();
- var toWorldSpace = new __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__["a" /* default */]();
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__["a" /* default */].transpose(toViewSpace, camera.worldTransform);
- __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__["a" /* default */].transpose(toWorldSpace, camera.viewMatrix);
- ssrPass.setUniform('sourceTexture', sourceTexture);
- ssrPass.setUniform('projection', camera.projectionMatrix.array);
- ssrPass.setUniform('projectionInv', camera.invProjectionMatrix.array);
- ssrPass.setUniform('toViewSpace', toViewSpace.array);
- ssrPass.setUniform('toWorldSpace', toWorldSpace.array);
- ssrPass.setUniform('nearZ', camera.near);
- var percent = frame / this._totalSamples * this._samplePerFrame;
- ssrPass.setUniform('jitterOffset', percent);
- ssrPass.setUniform('sampleOffset', frame * this._samplePerFrame);
- blurPass1.setUniform('textureSize', [ssrTexture.width, ssrTexture.height]);
- blurPass2.setUniform('textureSize', [width, height]);
- blurPass2.setUniform('sourceTexture', sourceTexture);
- blurPass1.setUniform('projection', camera.projectionMatrix.array);
- blurPass2.setUniform('projection', camera.projectionMatrix.array);
- frameBuffer.attach(ssrTexture);
- frameBuffer.bind(renderer);
- ssrPass.render(renderer);
- if (this._physicallyCorrect) {
- frameBuffer.attach(this._currentTexture);
- blendPass.setUniform('texture1', this._prevTexture);
- blendPass.setUniform('texture2', ssrTexture);
- blendPass.material.set({
- 'weight1': frame >= 1 ? 0.95 : 0,
- 'weight2': frame >= 1 ? 0.05 : 1
- // weight1: frame >= 1 ? 1 : 0,
- // weight2: 1
- });
- blendPass.render(renderer);
- }
- frameBuffer.attach(texture2);
- blurPass1.setUniform('texture', this._physicallyCorrect ? this._currentTexture : ssrTexture);
- blurPass1.render(renderer);
- frameBuffer.attach(texture3);
- blurPass2.setUniform('texture', texture2);
- blurPass2.render(renderer);
- frameBuffer.unbind(renderer);
- if (this._physicallyCorrect) {
- var tmp = this._prevTexture;
- this._prevTexture = this._currentTexture;
- this._currentTexture = tmp;
- }
- };
- SSRPass.prototype.getTargetTexture = function () {
- return this._texture3;
- };
- SSRPass.prototype.setParameter = function (name, val) {
- if (name === 'maxIteration') {
- this._ssrPass.material.define('fragment', 'MAX_ITERATION', val);
- }
- else {
- this._ssrPass.setUniform(name, val);
- }
- };
- SSRPass.prototype.setPhysicallyCorrect = function (isPhysicallyCorrect) {
- if (isPhysicallyCorrect) {
- if (!this._normalDistribution) {
- this._normalDistribution = __WEBPACK_IMPORTED_MODULE_8_claygl_src_util_cubemap__["a" /* default */].generateNormalDistribution(64, this._totalSamples);
- }
- this._ssrPass.material.define('fragment', 'PHYSICALLY_CORRECT');
- this._ssrPass.material.set('normalDistribution', this._normalDistribution);
- this._ssrPass.material.set('normalDistributionSize', [64, this._totalSamples]);
- }
- else {
- this._ssrPass.material.undefine('fragment', 'PHYSICALLY_CORRECT');
- }
- this._physicallyCorrect = isPhysicallyCorrect;
- };
- SSRPass.prototype.setSSAOTexture = function (texture) {
- var blendPass = this._blurPass2;
- if (texture) {
- blendPass.material.enableTexture('ssaoTex');
- blendPass.material.set('ssaoTex', texture);
- }
- else {
- blendPass.material.disableTexture('ssaoTex');
- }
- };
- SSRPass.prototype.isFinished = function (frame) {
- if (this._physicallyCorrect) {
- return frame > (this._totalSamples / this._samplePerFrame);
- }
- else {
- return true;
- }
- };
- SSRPass.prototype.dispose = function (renderer) {
- this._ssrTexture.dispose(renderer);
- this._texture2.dispose(renderer);
- this._texture3.dispose(renderer);
- this._prevTexture.dispose(renderer);
- this._currentTexture.dispose(renderer);
- this._frameBuffer.dispose(renderer);
- };
- /* harmony default export */ __webpack_exports__["a"] = (SSRPass);
- /***/
- }),
- /* 192 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.ssr.main\n\n#define SHADER_NAME SSR\n#define MAX_ITERATION 20;\n#define SAMPLE_PER_FRAME 5;\n#define TOTAL_SAMPLES 128;\n\nuniform sampler2D sourceTexture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform sampler2D gBufferTexture3;\nuniform samplerCube specularCubemap;\nuniform float specularIntensity: 1;\n\nuniform mat4 projection;\nuniform mat4 projectionInv;\nuniform mat4 toViewSpace;\nuniform mat4 toWorldSpace;\n\nuniform float maxRayDistance: 200;\n\nuniform float pixelStride: 16;\nuniform float pixelStrideZCutoff: 50; \nuniform float screenEdgeFadeStart: 0.9; \nuniform float eyeFadeStart : 0.2; uniform float eyeFadeEnd: 0.8; \nuniform float minGlossiness: 0.2; uniform float zThicknessThreshold: 1;\n\nuniform float nearZ;\nuniform vec2 viewportSize : VIEWPORT_SIZE;\n\nuniform float jitterOffset: 0;\n\nvarying vec2 v_Texcoord;\n\n#ifdef DEPTH_DECODE\n@import clay.util.decode_float\n#endif\n\n#ifdef PHYSICALLY_CORRECT\nuniform sampler2D normalDistribution;\nuniform float sampleOffset: 0;\nuniform vec2 normalDistributionSize;\n\nvec3 transformNormal(vec3 H, vec3 N) {\n vec3 upVector = N.y > 0.999 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);\n vec3 tangentX = normalize(cross(N, upVector));\n vec3 tangentZ = cross(N, tangentX);\n return normalize(tangentX * H.x + N * H.y + tangentZ * H.z);\n}\nvec3 importanceSampleNormalGGX(float i, float roughness, vec3 N) {\n float p = fract((i + sampleOffset) / float(TOTAL_SAMPLES));\n vec3 H = texture2D(normalDistribution,vec2(roughness, p)).rgb;\n return transformNormal(H, N);\n}\nfloat G_Smith(float g, float ndv, float ndl) {\n float roughness = 1.0 - g;\n float k = roughness * roughness / 2.0;\n float G1V = ndv / (ndv * (1.0 - k) + k);\n float G1L = ndl / (ndl * (1.0 - k) + k);\n return G1L * G1V;\n}\nvec3 F_Schlick(float ndv, vec3 spec) {\n return spec + (1.0 - spec) * pow(1.0 - ndv, 5.0);\n}\n#endif\n\nfloat fetchDepth(sampler2D depthTexture, vec2 uv)\n{\n vec4 depthTexel = texture2D(depthTexture, uv);\n return depthTexel.r * 2.0 - 1.0;\n}\n\nfloat linearDepth(float depth)\n{\n if (projection[3][3] == 0.0) {\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n }\n else {\n return (depth - projection[3][2]) / projection[2][2];\n }\n}\n\nbool rayIntersectDepth(float rayZNear, float rayZFar, vec2 hitPixel)\n{\n if (rayZFar > rayZNear)\n {\n float t = rayZFar; rayZFar = rayZNear; rayZNear = t;\n }\n float cameraZ = linearDepth(fetchDepth(gBufferTexture2, hitPixel));\n return rayZFar <= cameraZ && rayZNear >= cameraZ - zThicknessThreshold;\n}\n\n\nbool traceScreenSpaceRay(\n vec3 rayOrigin, vec3 rayDir, float jitter,\n out vec2 hitPixel, out vec3 hitPoint, out float iterationCount\n)\n{\n float rayLength = ((rayOrigin.z + rayDir.z * maxRayDistance) > -nearZ)\n ? (-nearZ - rayOrigin.z) / rayDir.z : maxRayDistance;\n\n vec3 rayEnd = rayOrigin + rayDir * rayLength;\n\n vec4 H0 = projection * vec4(rayOrigin, 1.0);\n vec4 H1 = projection * vec4(rayEnd, 1.0);\n\n float k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\n\n vec3 Q0 = rayOrigin * k0, Q1 = rayEnd * k1;\n\n vec2 P0 = (H0.xy * k0 * 0.5 + 0.5) * viewportSize;\n vec2 P1 = (H1.xy * k1 * 0.5 + 0.5) * viewportSize;\n\n P1 += dot(P1 - P0, P1 - P0) < 0.0001 ? 0.01 : 0.0;\n vec2 delta = P1 - P0;\n\n bool permute = false;\n if (abs(delta.x) < abs(delta.y)) {\n permute = true;\n delta = delta.yx;\n P0 = P0.yx;\n P1 = P1.yx;\n }\n float stepDir = sign(delta.x);\n float invdx = stepDir / delta.x;\n\n vec3 dQ = (Q1 - Q0) * invdx;\n float dk = (k1 - k0) * invdx;\n\n vec2 dP = vec2(stepDir, delta.y * invdx);\n\n float strideScaler = 1.0 - min(1.0, -rayOrigin.z / pixelStrideZCutoff);\n float pixStride = 1.0 + strideScaler * pixelStride;\n\n dP *= pixStride; dQ *= pixStride; dk *= pixStride;\n\n vec4 pqk = vec4(P0, Q0.z, k0);\n vec4 dPQK = vec4(dP, dQ.z, dk);\n\n pqk += dPQK * jitter;\n float rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n float rayZNear;\n\n bool intersect = false;\n\n vec2 texelSize = 1.0 / viewportSize;\n\n iterationCount = 0.0;\n\n for (int i = 0; i < MAX_ITERATION; i++)\n {\n pqk += dPQK;\n\n rayZNear = rayZFar;\n rayZFar = (dPQK.z * 0.5 + pqk.z) / (dPQK.w * 0.5 + pqk.w);\n\n hitPixel = permute ? pqk.yx : pqk.xy;\n hitPixel *= texelSize;\n\n intersect = rayIntersectDepth(rayZNear, rayZFar, hitPixel);\n\n iterationCount += 1.0;\n\n dPQK *= 1.2;\n\n if (intersect) {\n break;\n }\n }\n\n Q0.xy += dQ.xy * iterationCount;\n Q0.z = pqk.z;\n hitPoint = Q0 / pqk.w;\n\n return intersect;\n}\n\nfloat calculateAlpha(\n float iterationCount, float reflectivity,\n vec2 hitPixel, vec3 hitPoint, float dist, vec3 rayDir\n)\n{\n float alpha = clamp(reflectivity, 0.0, 1.0);\n alpha *= 1.0 - (iterationCount / float(MAX_ITERATION));\n vec2 hitPixelNDC = hitPixel * 2.0 - 1.0;\n float maxDimension = min(1.0, max(abs(hitPixelNDC.x), abs(hitPixelNDC.y)));\n alpha *= 1.0 - max(0.0, maxDimension - screenEdgeFadeStart) / (1.0 - screenEdgeFadeStart);\n\n float _eyeFadeStart = eyeFadeStart;\n float _eyeFadeEnd = eyeFadeEnd;\n if (_eyeFadeStart > _eyeFadeEnd) {\n float tmp = _eyeFadeEnd;\n _eyeFadeEnd = _eyeFadeStart;\n _eyeFadeStart = tmp;\n }\n\n float eyeDir = clamp(rayDir.z, _eyeFadeStart, _eyeFadeEnd);\n alpha *= 1.0 - (eyeDir - _eyeFadeStart) / (_eyeFadeEnd - _eyeFadeStart);\n\n alpha *= 1.0 - clamp(dist / maxRayDistance, 0.0, 1.0);\n\n return alpha;\n}\n\n@import clay.util.rand\n\n@import clay.util.rgbm\n\nvoid main()\n{\n vec4 normalAndGloss = texture2D(gBufferTexture1, v_Texcoord);\n\n if (dot(normalAndGloss.rgb, vec3(1.0)) == 0.0) {\n discard;\n }\n\n float g = normalAndGloss.a;\n#if !defined(PHYSICALLY_CORRECT)\n if (g <= minGlossiness) {\n discard;\n }\n#endif\n\n float reflectivity = (g - minGlossiness) / (1.0 - minGlossiness);\n\n vec3 N = normalize(normalAndGloss.rgb * 2.0 - 1.0);\n N = normalize((toViewSpace * vec4(N, 0.0)).xyz);\n\n vec4 projectedPos = vec4(v_Texcoord * 2.0 - 1.0, fetchDepth(gBufferTexture2, v_Texcoord), 1.0);\n vec4 pos = projectionInv * projectedPos;\n vec3 rayOrigin = pos.xyz / pos.w;\n vec3 V = -normalize(rayOrigin);\n\n float ndv = clamp(dot(N, V), 0.0, 1.0);\n float iterationCount;\n float jitter = rand(fract(v_Texcoord + jitterOffset));\n\n#ifdef PHYSICALLY_CORRECT\n vec4 color = vec4(vec3(0.0), 1.0);\n vec4 albedoMetalness = texture2D(gBufferTexture3, v_Texcoord);\n vec3 albedo = albedoMetalness.rgb;\n float m = albedoMetalness.a;\n vec3 diffuseColor = albedo * (1.0 - m);\n vec3 spec = mix(vec3(0.04), albedo, m);\n\n float jitter2 = rand(fract(v_Texcoord)) * float(TOTAL_SAMPLES);\n\n for (int i = 0; i < SAMPLE_PER_FRAME; i++) {\n vec3 H = importanceSampleNormalGGX(float(i) + jitter2, 1.0 - g, N);\n vec3 rayDir = normalize(reflect(-V, H));\n#else\n vec3 rayDir = normalize(reflect(-V, N));\n#endif\n vec2 hitPixel;\n vec3 hitPoint;\n\n bool intersect = traceScreenSpaceRay(rayOrigin, rayDir, jitter, hitPixel, hitPoint, iterationCount);\n\n float dist = distance(rayOrigin, hitPoint);\n\n vec3 hitNormal = texture2D(gBufferTexture1, hitPixel).rgb * 2.0 - 1.0;\n hitNormal = normalize((toViewSpace * vec4(hitNormal, 0.0)).xyz);\n#ifdef PHYSICALLY_CORRECT\n float ndl = clamp(dot(N, rayDir), 0.0, 1.0);\n float vdh = clamp(dot(V, H), 0.0, 1.0);\n float ndh = clamp(dot(N, H), 0.0, 1.0);\n vec3 litTexel = vec3(0.0);\n if (dot(hitNormal, rayDir) < 0.0 && intersect) {\n litTexel = texture2D(sourceTexture, hitPixel).rgb;\n litTexel *= pow(clamp(1.0 - dist / 200.0, 0.0, 1.0), 3.0);\n\n }\n else {\n #ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n litTexel = RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, 0.0), 8.12).rgb * specularIntensity;\n#endif\n }\n color.rgb += ndl * litTexel * (\n F_Schlick(ndl, spec) * G_Smith(g, ndv, ndl) * vdh / (ndh * ndv + 0.001)\n );\n }\n color.rgb /= float(SAMPLE_PER_FRAME);\n#else\n #if !defined(SPECULARCUBEMAP_ENABLED)\n if (dot(hitNormal, rayDir) >= 0.0) {\n discard;\n }\n if (!intersect) {\n discard;\n }\n#endif\n float alpha = clamp(calculateAlpha(iterationCount, reflectivity, hitPixel, hitPoint, dist, rayDir), 0.0, 1.0);\n vec4 color = texture2D(sourceTexture, hitPixel);\n color.rgb *= alpha;\n\n#ifdef SPECULARCUBEMAP_ENABLED\n vec3 rayDirW = normalize(toWorldSpace * vec4(rayDir, 0.0)).rgb;\n alpha = alpha * (intersect ? 1.0 : 0.0);\n float bias = (1.0 -g) * 5.0;\n color.rgb += (1.0 - alpha)\n * RGBMDecode(textureCubeLodEXT(specularCubemap, rayDirW, bias), 8.12).rgb\n * specularIntensity;\n#endif\n\n#endif\n\n gl_FragColor = encodeHDR(color);\n}\n@end\n\n@export ecgl.ssr.blur\n\nuniform sampler2D texture;\nuniform sampler2D gBufferTexture1;\nuniform sampler2D gBufferTexture2;\nuniform mat4 projection;\nuniform float depthRange : 0.05;\n\nvarying vec2 v_Texcoord;\n\nuniform vec2 textureSize;\nuniform float blurSize : 1.0;\n\n#ifdef BLEND\n #ifdef SSAOTEX_ENABLED\nuniform sampler2D ssaoTex;\n #endif\nuniform sampler2D sourceTexture;\n#endif\n\nfloat getLinearDepth(vec2 coord)\n{\n float depth = texture2D(gBufferTexture2, coord).r * 2.0 - 1.0;\n return projection[3][2] / (depth * projection[2][3] - projection[2][2]);\n}\n\n@import clay.util.rgbm\n\n\nvoid main()\n{\n @import clay.compositor.kernel.gaussian_9\n\n vec4 centerNTexel = texture2D(gBufferTexture1, v_Texcoord);\n float g = centerNTexel.a;\n float maxBlurSize = clamp(1.0 - g, 0.0, 1.0) * blurSize;\n#ifdef VERTICAL\n vec2 off = vec2(0.0, maxBlurSize / textureSize.y);\n#else\n vec2 off = vec2(maxBlurSize / textureSize.x, 0.0);\n#endif\n\n vec2 coord = v_Texcoord;\n\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n\n vec3 cN = centerNTexel.rgb * 2.0 - 1.0;\n float cD = getLinearDepth(v_Texcoord);\n for (int i = 0; i < 9; i++) {\n vec2 coord = clamp((float(i) - 4.0) * off + v_Texcoord, vec2(0.0), vec2(1.0));\n float w = gaussianKernel[i]\n * clamp(dot(cN, texture2D(gBufferTexture1, coord).rgb * 2.0 - 1.0), 0.0, 1.0);\n float d = getLinearDepth(coord);\n w *= (1.0 - smoothstep(abs(cD - d) / depthRange, 0.0, 1.0));\n\n weightAll += w;\n sum += decodeHDR(texture2D(texture, coord)) * w;\n }\n\n#ifdef BLEND\n float aoFactor = 1.0;\n #ifdef SSAOTEX_ENABLED\n aoFactor = texture2D(ssaoTex, v_Texcoord).r;\n #endif\n gl_FragColor = encodeHDR(\n sum / weightAll * aoFactor + decodeHDR(texture2D(sourceTexture, v_Texcoord))\n );\n#else\n gl_FragColor = encodeHDR(sum / weightAll);\n#endif\n}\n\n@end");
- /***/
- }),
- /* 193 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- // Based on https://bl.ocks.org/mbostock/19168c663618b707158
- /* harmony default export */ __webpack_exports__["a"] = ([
- 0.0, 0.0,
- -0.321585265978, -0.154972575841,
- 0.458126042375, 0.188473391593,
- 0.842080129861, 0.527766490688,
- 0.147304551086, -0.659453822776,
- -0.331943915203, -0.940619700594,
- 0.0479226680259, 0.54812163202,
- 0.701581552186, -0.709825561388,
- -0.295436780218, 0.940589268233,
- -0.901489676764, 0.237713156085,
- 0.973570876096, -0.109899459384,
- -0.866792314779, -0.451805525005,
- 0.330975007087, 0.800048655954,
- -0.344275183665, 0.381779221166,
- -0.386139432542, -0.437418421534,
- -0.576478634965, -0.0148463392551,
- 0.385798197415, -0.262426961053,
- -0.666302061145, 0.682427250835,
- -0.628010632582, -0.732836215494,
- 0.10163141741, -0.987658134403,
- 0.711995289051, -0.320024291314,
- 0.0296005138058, 0.950296523438,
- 0.0130612307608, -0.351024443122,
- -0.879596633704, -0.10478487883,
- 0.435712737232, 0.504254490347,
- 0.779203817497, 0.206477676721,
- 0.388264289969, -0.896736162545,
- -0.153106280781, -0.629203242522,
- -0.245517550697, 0.657969239148,
- 0.126830499058, 0.26862328493,
- -0.634888119007, -0.302301223431,
- 0.617074219636, 0.779817204925
- ]);
- /***/
- }),
- /* 194 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_FrameBuffer__ = __webpack_require__(10);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_Material__ = __webpack_require__(19);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_compositor_Pass__ = __webpack_require__(16);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_util_texture__ = __webpack_require__(61);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__util_shader_normal_glsl_js__ = __webpack_require__(195);
- // NormalPass will generate normal and depth data.
- // TODO Animation
- __WEBPACK_IMPORTED_MODULE_2_claygl_src_Shader__["a" /* default */].import(__WEBPACK_IMPORTED_MODULE_7__util_shader_normal_glsl_js__["a" /* default */]);
- function attachTextureToSlot(renderer, program, symbol, texture, slot) {
- var gl = renderer.gl;
- program.setUniform(gl, '1i', symbol, slot);
- gl.activeTexture(gl.TEXTURE0 + slot);
- // Maybe texture is not loaded yet;
- if (texture.isRenderable()) {
- texture.bind(renderer);
- }
- else {
- // Bind texture to null
- texture.unbind(renderer);
- }
- }
- // TODO Use globalShader insteadof globalMaterial?
- function getBeforeRenderHook(renderer, defaultNormalMap, defaultBumpMap, defaultRoughnessMap, normalMaterial) {
- var previousNormalMap;
- var previousBumpMap;
- var previousRoughnessMap;
- var previousRenderable;
- var gl = renderer.gl;
- return function (renderable, normalMaterial, prevNormalMaterial) {
- // Material not change
- if (previousRenderable && previousRenderable.material === renderable.material) {
- return;
- }
- var material = renderable.material;
- var program = renderable.__program;
- var roughness = material.get('roughness');
- if (roughness == null) {
- roughness = 1;
- }
- var normalMap = material.get('normalMap') || defaultNormalMap;
- var roughnessMap = material.get('roughnessMap');
- var bumpMap = material.get('bumpMap');
- var uvRepeat = material.get('uvRepeat');
- var uvOffset = material.get('uvOffset');
- var detailUvRepeat = material.get('detailUvRepeat');
- var detailUvOffset = material.get('detailUvOffset');
- var useBumpMap = !!bumpMap && material.isTextureEnabled('bumpMap');
- var useRoughnessMap = !!roughnessMap && material.isTextureEnabled('roughnessMap');
- var doubleSide = material.isDefined('fragment', 'DOUBLE_SIDED');
- bumpMap = bumpMap || defaultBumpMap;
- roughnessMap = roughnessMap || defaultRoughnessMap;
- if (prevNormalMaterial !== normalMaterial) {
- normalMaterial.set('normalMap', normalMap);
- normalMaterial.set('bumpMap', bumpMap);
- normalMaterial.set('roughnessMap', roughnessMap);
- normalMaterial.set('useBumpMap', useBumpMap);
- normalMaterial.set('useRoughnessMap', useRoughnessMap);
- normalMaterial.set('doubleSide', doubleSide);
- uvRepeat != null && normalMaterial.set('uvRepeat', uvRepeat);
- uvOffset != null && normalMaterial.set('uvOffset', uvOffset);
- detailUvRepeat != null && normalMaterial.set('detailUvRepeat', detailUvRepeat);
- detailUvOffset != null && normalMaterial.set('detailUvOffset', detailUvOffset);
- normalMaterial.set('roughness', roughness);
- }
- else {
- program.setUniform(gl, '1f', 'roughness', roughness);
- if (previousNormalMap !== normalMap) {
- attachTextureToSlot(renderer, program, 'normalMap', normalMap, 0);
- }
- if (previousBumpMap !== bumpMap && bumpMap) {
- attachTextureToSlot(renderer, program, 'bumpMap', bumpMap, 1);
- }
- if (previousRoughnessMap !== roughnessMap && roughnessMap) {
- attachTextureToSlot(renderer, program, 'roughnessMap', roughnessMap, 2);
- }
- if (uvRepeat != null) {
- program.setUniform(gl, '2f', 'uvRepeat', uvRepeat);
- }
- if (uvOffset != null) {
- program.setUniform(gl, '2f', 'uvOffset', uvOffset);
- }
- if (detailUvRepeat != null) {
- program.setUniform(gl, '2f', 'detailUvRepeat', detailUvRepeat);
- }
- if (detailUvOffset != null) {
- program.setUniform(gl, '2f', 'detailUvOffset', detailUvOffset);
- }
- program.setUniform(gl, '1i', 'useBumpMap', +useBumpMap);
- program.setUniform(gl, '1i', 'useRoughnessMap', +useRoughnessMap);
- program.setUniform(gl, '1i', 'doubleSide', +doubleSide);
- }
- previousNormalMap = normalMap;
- previousBumpMap = bumpMap;
- previousRoughnessMap = roughnessMap;
- previousRenderable = renderable;
- };
- }
- function NormalPass(opt) {
- opt = opt || {};
- this._depthTex = new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Texture2D__["a" /* default */]({
- format: __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__["a" /* default */].DEPTH_COMPONENT,
- type: __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__["a" /* default */].UNSIGNED_INT
- });
- this._normalTex = new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Texture2D__["a" /* default */]({
- type: __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__["a" /* default */].HALF_FLOAT
- });
- this._framebuffer = new __WEBPACK_IMPORTED_MODULE_3_claygl_src_FrameBuffer__["a" /* default */]();
- this._framebuffer.attach(this._normalTex);
- this._framebuffer.attach(this._depthTex, __WEBPACK_IMPORTED_MODULE_3_claygl_src_FrameBuffer__["a" /* default */].DEPTH_ATTACHMENT);
- this._normalMaterial = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_Material__["a" /* default */]({
- shader: new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Shader__["a" /* default */](
- __WEBPACK_IMPORTED_MODULE_2_claygl_src_Shader__["a" /* default */].source('ecgl.normal.vertex'),
- __WEBPACK_IMPORTED_MODULE_2_claygl_src_Shader__["a" /* default */].source('ecgl.normal.fragment')
- )
- });
- this._normalMaterial.enableTexture(['normalMap', 'bumpMap', 'roughnessMap']);
- this._defaultNormalMap = __WEBPACK_IMPORTED_MODULE_6_claygl_src_util_texture__["a" /* default */].createBlank('#000');
- this._defaultBumpMap = __WEBPACK_IMPORTED_MODULE_6_claygl_src_util_texture__["a" /* default */].createBlank('#000');
- this._defaultRoughessMap = __WEBPACK_IMPORTED_MODULE_6_claygl_src_util_texture__["a" /* default */].createBlank('#000');
- this._debugPass = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_2_claygl_src_Shader__["a" /* default */].source('clay.compositor.output')
- });
- this._debugPass.setUniform('texture', this._normalTex);
- this._debugPass.material.undefine('fragment', 'OUTPUT_ALPHA');
- }
- NormalPass.prototype.getDepthTexture = function () {
- return this._depthTex;
- };
- NormalPass.prototype.getNormalTexture = function () {
- return this._normalTex;
- };
- NormalPass.prototype.update = function (renderer, scene, camera) {
- var width = renderer.getWidth();
- var height = renderer.getHeight();
- var depthTexture = this._depthTex;
- var normalTexture = this._normalTex;
- var normalMaterial = this._normalMaterial;
- depthTexture.width = width;
- depthTexture.height = height;
- normalTexture.width = width;
- normalTexture.height = height;
- var opaqueList = scene.getRenderList(camera).opaque;
- this._framebuffer.bind(renderer);
- renderer.gl.clearColor(0, 0, 0, 0);
- renderer.gl.clear(renderer.gl.COLOR_BUFFER_BIT | renderer.gl.DEPTH_BUFFER_BIT);
- renderer.gl.disable(renderer.gl.BLEND);
- renderer.renderPass(opaqueList, camera, {
- getMaterial: function () {
- return normalMaterial;
- },
- ifRender: function (object) {
- return object.renderNormal;
- },
- beforeRender: getBeforeRenderHook(
- renderer, this._defaultNormalMap, this._defaultBumpMap, this._defaultRoughessMap, this._normalMaterial
- ),
- sort: renderer.opaqueSortCompare
- });
- this._framebuffer.unbind(renderer);
- };
- NormalPass.prototype.renderDebug = function (renderer) {
- this._debugPass.render(renderer);
- };
- NormalPass.prototype.dispose = function (renderer) {
- this._depthTex.dispose(renderer);
- this._normalTex.dispose(renderer);
- }
- /* harmony default export */ __webpack_exports__["a"] = (NormalPass);
- /***/
- }),
- /* 195 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.normal.vertex\n\n@import ecgl.common.transformUniforms\n\n@import ecgl.common.uv.header\n\n@import ecgl.common.attributes\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\n@import ecgl.common.normalMap.vertexHeader\n\n@import ecgl.common.vertexAnimation.header\n\nvoid main()\n{\n\n @import ecgl.common.vertexAnimation.main\n\n @import ecgl.common.uv.main\n\n v_Normal = normalize((worldInverseTranspose * vec4(normal, 0.0)).xyz);\n v_WorldPosition = (world * vec4(pos, 1.0)).xyz;\n\n @import ecgl.common.normalMap.vertexMain\n\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n\n}\n\n\n@end\n\n\n@export ecgl.normal.fragment\n\n#define ROUGHNESS_CHANEL 0\n\nuniform bool useBumpMap;\nuniform bool useRoughnessMap;\nuniform bool doubleSide;\nuniform float roughness;\n\n@import ecgl.common.uv.fragmentHeader\n\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform mat4 viewInverse : VIEWINVERSE;\n\n@import ecgl.common.normalMap.fragmentHeader\n@import ecgl.common.bumpMap.header\n\nuniform sampler2D roughnessMap;\n\nvoid main()\n{\n vec3 N = v_Normal;\n \n bool flipNormal = false;\n if (doubleSide) {\n vec3 eyePos = viewInverse[3].xyz;\n vec3 V = normalize(eyePos - v_WorldPosition);\n\n if (dot(N, V) < 0.0) {\n flipNormal = true;\n }\n }\n\n @import ecgl.common.normalMap.fragmentMain\n\n if (useBumpMap) {\n N = bumpNormal(v_WorldPosition, v_Normal, N);\n }\n\n float g = 1.0 - roughness;\n\n if (useRoughnessMap) {\n float g2 = 1.0 - texture2D(roughnessMap, v_DetailTexcoord)[ROUGHNESS_CHANEL];\n g = clamp(g2 + (g - 0.5) * 2.0, 0.0, 1.0);\n }\n\n if (flipNormal) {\n N = -N;\n }\n\n gl_FragColor.rgb = (N.xyz + 1.0) * 0.5;\n gl_FragColor.a = g;\n}\n@end");
- /***/
- }),
- /* 196 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__ = __webpack_require__(16);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_FrameBuffer__ = __webpack_require__(10);
- function EdgePass(opt) {
- opt = opt || {};
- this._edgePass = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_5_claygl_src_Shader__["a" /* default */].source('ecgl.edge')
- });
- this._edgePass.setUniform('normalTexture', opt.normalTexture);
- this._edgePass.setUniform('depthTexture', opt.depthTexture);
- this._targetTexture = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Texture2D__["a" /* default */]({
- type: __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture__["a" /* default */].HALF_FLOAT
- });
- this._frameBuffer = new __WEBPACK_IMPORTED_MODULE_6_claygl_src_FrameBuffer__["a" /* default */]();
- this._frameBuffer.attach(this._targetTexture);
- }
- EdgePass.prototype.update = function (renderer, camera, sourceTexture, frame) {
- var width = renderer.getWidth();
- var height = renderer.getHeight();
- var texture = this._targetTexture;
- texture.width = width;
- texture.height = height;
- var frameBuffer = this._frameBuffer;
- frameBuffer.bind(renderer);
- this._edgePass.setUniform('projectionInv', camera.invProjectionMatrix.array);
- this._edgePass.setUniform('textureSize', [width, height]);
- this._edgePass.setUniform('texture', sourceTexture);
- this._edgePass.render(renderer);
- frameBuffer.unbind(renderer);
- };
- EdgePass.prototype.getTargetTexture = function () {
- return this._targetTexture;
- };
- EdgePass.prototype.setParameter = function (name, val) {
- this._edgePass.setUniform(name, val);
- };
- EdgePass.prototype.dispose = function (renderer) {
- this._targetTexture.dispose(renderer);
- this._frameBuffer.dispose(renderer);
- };
- /* harmony default export */ __webpack_exports__["a"] = (EdgePass);
- /***/
- }),
- /* 197 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ({
- 'type': 'compositor',
- 'nodes': [
- {
- 'name': 'source',
- 'type': 'texture',
- 'outputs': {
- 'color': {}
- }
- },
- {
- 'name': 'source_half',
- 'shader': '#source(clay.compositor.downsample)',
- 'inputs': {
- 'texture': 'source'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 2)',
- 'height': 'expr(height * 1.0 / 2)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'textureSize': 'expr( [width * 1.0, height * 1.0] )'
- }
- },
- {
- 'name': 'bright',
- 'shader': '#source(clay.compositor.bright)',
- 'inputs': {
- 'texture': 'source_half'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 2)',
- 'height': 'expr(height * 1.0 / 2)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'threshold': 2,
- 'scale': 4,
- 'textureSize': 'expr([width * 1.0 / 2, height / 2])'
- }
- },
- {
- 'name': 'bright_downsample_4',
- 'shader': '#source(clay.compositor.downsample)',
- 'inputs': {
- 'texture': 'bright'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 4)',
- 'height': 'expr(height * 1.0 / 4)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'textureSize': 'expr( [width * 1.0 / 2, height / 2] )'
- }
- },
- {
- 'name': 'bright_downsample_8',
- 'shader': '#source(clay.compositor.downsample)',
- 'inputs': {
- 'texture': 'bright_downsample_4'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 8)',
- 'height': 'expr(height * 1.0 / 8)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'textureSize': 'expr( [width * 1.0 / 4, height / 4] )'
- }
- },
- {
- 'name': 'bright_downsample_16',
- 'shader': '#source(clay.compositor.downsample)',
- 'inputs': {
- 'texture': 'bright_downsample_8'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 16)',
- 'height': 'expr(height * 1.0 / 16)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'textureSize': 'expr( [width * 1.0 / 8, height / 8] )'
- }
- },
- {
- 'name': 'bright_downsample_32',
- 'shader': '#source(clay.compositor.downsample)',
- 'inputs': {
- 'texture': 'bright_downsample_16'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 32)',
- 'height': 'expr(height * 1.0 / 32)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'textureSize': 'expr( [width * 1.0 / 16, height / 16] )'
- }
- },
- {
- 'name': 'bright_upsample_16_blur_h',
- 'shader': '#source(clay.compositor.gaussian_blur)',
- 'inputs': {
- 'texture': 'bright_downsample_32'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 16)',
- 'height': 'expr(height * 1.0 / 16)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'blurSize': 1,
- 'blurDir': 0.0,
- 'textureSize': 'expr( [width * 1.0 / 32, height / 32] )'
- }
- },
- {
- 'name': 'bright_upsample_16_blur_v',
- 'shader': '#source(clay.compositor.gaussian_blur)',
- 'inputs': {
- 'texture': 'bright_upsample_16_blur_h'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 16)',
- 'height': 'expr(height * 1.0 / 16)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'blurSize': 1,
- 'blurDir': 1.0,
- 'textureSize': 'expr( [width * 1.0 / 16, height * 1.0 / 16] )'
- }
- },
- {
- 'name': 'bright_upsample_8_blur_h',
- 'shader': '#source(clay.compositor.gaussian_blur)',
- 'inputs': {
- 'texture': 'bright_downsample_16'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 8)',
- 'height': 'expr(height * 1.0 / 8)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'blurSize': 1,
- 'blurDir': 0.0,
- 'textureSize': 'expr( [width * 1.0 / 16, height * 1.0 / 16] )'
- }
- },
- {
- 'name': 'bright_upsample_8_blur_v',
- 'shader': '#source(clay.compositor.gaussian_blur)',
- 'inputs': {
- 'texture': 'bright_upsample_8_blur_h'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 8)',
- 'height': 'expr(height * 1.0 / 8)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'blurSize': 1,
- 'blurDir': 1.0,
- 'textureSize': 'expr( [width * 1.0 / 8, height * 1.0 / 8] )'
- }
- },
- {
- 'name': 'bright_upsample_8_blend',
- 'shader': '#source(clay.compositor.blend)',
- 'inputs': {
- 'texture1': 'bright_upsample_8_blur_v',
- 'texture2': 'bright_upsample_16_blur_v'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 8)',
- 'height': 'expr(height * 1.0 / 8)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'weight1': 0.3,
- 'weight2': 0.7
- }
- },
- {
- 'name': 'bright_upsample_4_blur_h',
- 'shader': '#source(clay.compositor.gaussian_blur)',
- 'inputs': {
- 'texture': 'bright_downsample_8'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 4)',
- 'height': 'expr(height * 1.0 / 4)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'blurSize': 1,
- 'blurDir': 0.0,
- 'textureSize': 'expr( [width * 1.0 / 8, height * 1.0 / 8] )'
- }
- },
- {
- 'name': 'bright_upsample_4_blur_v',
- 'shader': '#source(clay.compositor.gaussian_blur)',
- 'inputs': {
- 'texture': 'bright_upsample_4_blur_h'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 4)',
- 'height': 'expr(height * 1.0 / 4)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'blurSize': 1,
- 'blurDir': 1.0,
- 'textureSize': 'expr( [width * 1.0 / 4, height * 1.0 / 4] )'
- }
- },
- {
- 'name': 'bright_upsample_4_blend',
- 'shader': '#source(clay.compositor.blend)',
- 'inputs': {
- 'texture1': 'bright_upsample_4_blur_v',
- 'texture2': 'bright_upsample_8_blend'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 4)',
- 'height': 'expr(height * 1.0 / 4)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'weight1': 0.3,
- 'weight2': 0.7
- }
- },
- {
- 'name': 'bright_upsample_2_blur_h',
- 'shader': '#source(clay.compositor.gaussian_blur)',
- 'inputs': {
- 'texture': 'bright_downsample_4'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 2)',
- 'height': 'expr(height * 1.0 / 2)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'blurSize': 1,
- 'blurDir': 0.0,
- 'textureSize': 'expr( [width * 1.0 / 4, height * 1.0 / 4] )'
- }
- },
- {
- 'name': 'bright_upsample_2_blur_v',
- 'shader': '#source(clay.compositor.gaussian_blur)',
- 'inputs': {
- 'texture': 'bright_upsample_2_blur_h'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 2)',
- 'height': 'expr(height * 1.0 / 2)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'blurSize': 1,
- 'blurDir': 1.0,
- 'textureSize': 'expr( [width * 1.0 / 2, height * 1.0 / 2] )'
- }
- },
- {
- 'name': 'bright_upsample_2_blend',
- 'shader': '#source(clay.compositor.blend)',
- 'inputs': {
- 'texture1': 'bright_upsample_2_blur_v',
- 'texture2': 'bright_upsample_4_blend'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0 / 2)',
- 'height': 'expr(height * 1.0 / 2)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'weight1': 0.3,
- 'weight2': 0.7
- }
- },
- {
- 'name': 'bright_upsample_full_blur_h',
- 'shader': '#source(clay.compositor.gaussian_blur)',
- 'inputs': {
- 'texture': 'bright'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0)',
- 'height': 'expr(height * 1.0)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'blurSize': 1,
- 'blurDir': 0.0,
- 'textureSize': 'expr( [width * 1.0 / 2, height * 1.0 / 2] )'
- }
- },
- {
- 'name': 'bright_upsample_full_blur_v',
- 'shader': '#source(clay.compositor.gaussian_blur)',
- 'inputs': {
- 'texture': 'bright_upsample_full_blur_h'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0)',
- 'height': 'expr(height * 1.0)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'blurSize': 1,
- 'blurDir': 1.0,
- 'textureSize': 'expr( [width * 1.0, height * 1.0] )'
- }
- },
- {
- 'name': 'bloom_composite',
- 'shader': '#source(clay.compositor.blend)',
- 'inputs': {
- 'texture1': 'bright_upsample_full_blur_v',
- 'texture2': 'bright_upsample_2_blend'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0)',
- 'height': 'expr(height * 1.0)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'weight1': 0.3,
- 'weight2': 0.7
- }
- },
- {
- 'name': 'coc',
- 'shader': '#source(ecgl.dof.coc)',
- 'outputs': {
- 'color': {
- 'parameters': {
- 'minFilter': 'NEAREST',
- 'magFilter': 'NEAREST',
- 'width': 'expr(width * 1.0)',
- 'height': 'expr(height * 1.0)'
- }
- }
- },
- 'parameters': {
- 'focalDist': 50,
- 'focalRange': 30
- }
- },
- {
- 'name': 'dof_far_blur',
- 'shader': '#source(ecgl.dof.diskBlur)',
- 'inputs': {
- 'texture': 'source',
- 'coc': 'coc'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0)',
- 'height': 'expr(height * 1.0)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'textureSize': 'expr( [width * 1.0, height * 1.0] )'
- }
- },
- {
- 'name': 'dof_near_blur',
- 'shader': '#source(ecgl.dof.diskBlur)',
- 'inputs': {
- 'texture': 'source',
- 'coc': 'coc'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0)',
- 'height': 'expr(height * 1.0)',
- 'type': 'HALF_FLOAT'
- }
- }
- },
- 'parameters': {
- 'textureSize': 'expr( [width * 1.0, height * 1.0] )'
- },
- 'defines': {
- 'BLUR_NEARFIELD': null
- }
- },
- {
- 'name': 'dof_coc_blur',
- 'shader': '#source(ecgl.dof.diskBlur)',
- 'inputs': {
- 'texture': 'coc'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'minFilter': 'NEAREST',
- 'magFilter': 'NEAREST',
- 'width': 'expr(width * 1.0)',
- 'height': 'expr(height * 1.0)'
- }
- }
- },
- 'parameters': {
- 'textureSize': 'expr( [width * 1.0, height * 1.0] )'
- },
- 'defines': {
- 'BLUR_COC': null
- }
- },
- {
- 'name': 'dof_composite',
- 'shader': '#source(ecgl.dof.composite)',
- 'inputs': {
- 'original': 'source',
- 'blurred': 'dof_far_blur',
- 'nearfield': 'dof_near_blur',
- 'coc': 'coc',
- 'nearcoc': 'dof_coc_blur'
- },
- 'outputs': {
- 'color': {
- 'parameters': {
- 'width': 'expr(width * 1.0)',
- 'height': 'expr(height * 1.0)',
- 'type': 'HALF_FLOAT'
- }
- }
- }
- },
- {
- 'name': 'composite',
- 'shader': '#source(clay.compositor.hdr.composite)',
- 'inputs': {
- 'texture': 'source',
- 'bloom': 'bloom_composite'
- },
- 'defines': {
- // Images are all premultiplied alpha before composite because of blending.
- // 'PREMULTIPLY_ALPHA': null,
- // 'DEBUG': 2
- }
- },
- {
- 'name': 'FXAA',
- 'shader': '#source(clay.compositor.fxaa)',
- 'inputs': {
- 'texture': 'composite'
- }
- }
- ]
- });
- /***/
- }),
- /* 198 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import clay.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import clay.util.rgbm\n@import clay.util.float\n\nvoid main()\n{\n vec4 blurredColor = texture2D(blurred, v_Texcoord);\n vec4 originalColor = texture2D(original, v_Texcoord);\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = texture2D(nearfield, v_Texcoord);\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import clay.util.rgbm\n@import clay.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = texel;\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n texel.rgb *= texel.a;\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n color.rgb /= (color.a + 0.0001);\n gl_FragColor = color;\n#endif\n}\n\n@end");
- /***/
- }),
- /* 199 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end");
- /***/
- }),
- /* 200 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__halton__ = __webpack_require__(49);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_compositor_Pass__ = __webpack_require__(16);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_FrameBuffer__ = __webpack_require__(10);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__ = __webpack_require__(9);
- // Temporal Super Sample for static Scene
- function TemporalSuperSampling(frames) {
- var haltonSequence = [];
- for (var i = 0; i < 30; i++) {
- haltonSequence.push([Object(__WEBPACK_IMPORTED_MODULE_0__halton__["a" /* default */])(i, 2), Object(__WEBPACK_IMPORTED_MODULE_0__halton__["a" /* default */])(i, 3)]);
- }
- this._haltonSequence = haltonSequence;
- this._frame = 0;
- this._sourceTex = new __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture2D__["a" /* default */]();
- this._sourceFb = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_FrameBuffer__["a" /* default */]();
- this._sourceFb.attach(this._sourceTex);
- // Frame texture before temporal supersampling
- this._prevFrameTex = new __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture2D__["a" /* default */]();
- this._outputTex = new __WEBPACK_IMPORTED_MODULE_3_claygl_src_Texture2D__["a" /* default */]();
- var blendPass = this._blendPass = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source('clay.compositor.blend')
- });
- blendPass.material.disableTexturesAll();
- blendPass.material.enableTexture(['texture1', 'texture2']);
- this._blendFb = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_FrameBuffer__["a" /* default */]({
- depthBuffer: false
- });
- this._outputPass = new __WEBPACK_IMPORTED_MODULE_1_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source('clay.compositor.output'),
- // TODO, alpha is premultiplied?
- blendWithPrevious: true
- });
- this._outputPass.material.define('fragment', 'OUTPUT_ALPHA');
- this._outputPass.material.blend = function (_gl) {
- // FIXME.
- // Output is premultiplied alpha when BLEND is enabled ?
- // http://stackoverflow.com/questions/2171085/opengl-blending-with-previous-contents-of-framebuffer
- _gl.blendEquationSeparate(_gl.FUNC_ADD, _gl.FUNC_ADD);
- _gl.blendFuncSeparate(_gl.ONE, _gl.ONE_MINUS_SRC_ALPHA, _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA);
- };
- }
- TemporalSuperSampling.prototype = {
- constructor: TemporalSuperSampling,
- /**
- * Jitter camera projectionMatrix
- * @parma {clay.Renderer} renderer
- * @param {clay.Camera} camera
- */
- jitterProjection: function (renderer, camera) {
- var viewport = renderer.viewport;
- var dpr = viewport.devicePixelRatio || renderer.getDevicePixelRatio();
- var width = viewport.width * dpr;
- var height = viewport.height * dpr;
- var offset = this._haltonSequence[this._frame % this._haltonSequence.length];
- var translationMat = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */]();
- translationMat.array[12] = (offset[0] * 2.0 - 1.0) / width;
- translationMat.array[13] = (offset[1] * 2.0 - 1.0) / height;
- __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */].mul(camera.projectionMatrix, translationMat, camera.projectionMatrix);
- __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Matrix4__["a" /* default */].invert(camera.invProjectionMatrix, camera.projectionMatrix);
- },
- /**
- * Reset accumulating frame
- */
- resetFrame: function () {
- this._frame = 0;
- },
- /**
- * Return current frame
- */
- getFrame: function () {
- return this._frame;
- },
- /**
- * Get source framebuffer for usage
- */
- getSourceFrameBuffer: function () {
- return this._sourceFb;
- },
- getOutputTexture: function () {
- return this._outputTex;
- },
- resize: function (width, height) {
- this._prevFrameTex.width = width;
- this._prevFrameTex.height = height;
- this._outputTex.width = width;
- this._outputTex.height = height;
- this._sourceTex.width = width;
- this._sourceTex.height = height;
- this._prevFrameTex.dirty();
- this._outputTex.dirty();
- this._sourceTex.dirty();
- },
- isFinished: function () {
- return this._frame >= this._haltonSequence.length;
- },
- render: function (renderer, sourceTex, notOutput) {
- var blendPass = this._blendPass;
- if (this._frame === 0) {
- // Direct output
- blendPass.setUniform('weight1', 0);
- blendPass.setUniform('weight2', 1);
- }
- else {
- blendPass.setUniform('weight1', 0.9);
- blendPass.setUniform('weight2', 0.1);
- }
- blendPass.setUniform('texture1', this._prevFrameTex);
- blendPass.setUniform('texture2', sourceTex || this._sourceTex);
- this._blendFb.attach(this._outputTex);
- this._blendFb.bind(renderer);
- blendPass.render(renderer);
- this._blendFb.unbind(renderer);
- if (!notOutput) {
- this._outputPass.setUniform('texture', this._outputTex);
- this._outputPass.render(renderer);
- }
- // Swap texture
- var tmp = this._prevFrameTex;
- this._prevFrameTex = this._outputTex;
- this._outputTex = tmp;
- this._frame++;
- },
- dispose: function (renderer) {
- this._sourceFb.dispose(renderer);
- this._blendFb.dispose(renderer);
- this._prevFrameTex.dispose(renderer);
- this._outputTex.dispose(renderer);
- this._sourceTex.dispose(renderer);
- this._outputPass.dispose(renderer);
- this._blendPass.dispose(renderer);
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (TemporalSuperSampling);
- /***/
- }),
- /* 201 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__geo3D_Geo3DModel__ = __webpack_require__(202);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__geo3D_Geo3DView__ = __webpack_require__(203);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__coord_geo3DCreator__ = __webpack_require__(98);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'geo3DChangeCamera',
- event: 'geo3dcamerachanged',
- update: 'series:updateCamera'
- }, function (payload, ecModel) {
- ecModel.eachComponent({
- mainType: 'geo3D', query: payload
- }, function (componentModel) {
- componentModel.setView(payload);
- });
- });
- /***/
- }),
- /* 202 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__ = __webpack_require__(44);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__ = __webpack_require__(28);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__ = __webpack_require__(29);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_componentShadingMixin__ = __webpack_require__(31);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__coord_geo3D_geo3DModelMixin__ = __webpack_require__(96);
- var Geo3DModel = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendComponentModel({
- type: 'geo3D',
- layoutMode: 'box',
- coordinateSystem: null,
- optionUpdated: function () {
- var option = this.option;
- option.regions = this.getFilledRegions(option.regions, option.map);
- var dimensions = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.completeDimensions(['value'], option.data, {
- encodeDef: this.get('encode'),
- dimsDef: this.get('dimensions')
- });
- var list = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.List(dimensions, this);
- list.initData(option.regions);
- var regionModelMap = {};
- list.each(function (idx) {
- var name = list.getName(idx);
- var itemModel = list.getItemModel(idx);
- regionModelMap[name] = itemModel;
- });
- this._regionModelMap = regionModelMap;
- this._data = list;
- },
- getData: function () {
- return this._data;
- },
- getRegionModel: function (idx) {
- var name = this.getData().getName(idx);
- return this._regionModelMap[name] || new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.Model(null, this);
- },
- getRegionPolygonCoords: function (idx) {
- var name = this.getData().getName(idx);
- var region = this.coordinateSystem.getRegion(name);
- return region ? region.geometries : [];
- },
- /**
- * Format label
- * @param {string} name Region name
- * @param {string} [status='normal'] 'normal' or 'emphasis'
- * @return {string}
- */
- getFormattedLabel: function (dataIndex, status) {
- var name = this._data.getName(dataIndex);
- var regionModel = this.getRegionModel(name);
- var formatter = regionModel.get(status === 'normal' ? ['label', 'formatter'] : ['emphasis', 'label', 'formatter']);
- if (formatter == null) {
- formatter = regionModel.get(['label', 'formatter']);
- }
- var params = {
- name: name
- };
- if (typeof formatter === 'function') {
- params.status = status;
- return formatter(params);
- }
- else if (typeof formatter === 'string') {
- var serName = params.seriesName;
- return formatter.replace('{a}', serName != null ? serName : '');
- }
- else {
- return name;
- }
- },
- defaultOption: {
- // itemStyle: {},
- // height,
- // label: {}
- // realisticMaterial
- regions: []
- }
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Geo3DModel.prototype, __WEBPACK_IMPORTED_MODULE_5__coord_geo3D_geo3DModelMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Geo3DModel.prototype, __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Geo3DModel.prototype, __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Geo3DModel.prototype, __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Geo3DModel.prototype, __WEBPACK_IMPORTED_MODULE_4__common_componentShadingMixin__["a" /* default */]);
- /* unused harmony default export */ var _unused_webpack_default_export = (Geo3DModel);
- /***/
- }),
- /* 203 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_Geo3DBuilder__ = __webpack_require__(64);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_OrbitControl__ = __webpack_require__(45);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_SceneHelper__ = __webpack_require__(30);
- /* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.extendComponentView({
- type: 'geo3D',
- __ecgl__: true,
- init: function (ecModel, api) {
- this._geo3DBuilder = new __WEBPACK_IMPORTED_MODULE_0__common_Geo3DBuilder__["a" /* default */](api);
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Node();
- this._lightRoot = new __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Node();
- this._sceneHelper = new __WEBPACK_IMPORTED_MODULE_4__common_SceneHelper__["a" /* default */](this._lightRoot);
- this._sceneHelper.initLight(this._lightRoot);
- this._control = new __WEBPACK_IMPORTED_MODULE_3__util_OrbitControl__["a" /* default */]({
- zr: api.getZr()
- });
- this._control.init();
- },
- render: function (geo3DModel, ecModel, api) {
- this.groupGL.add(this._geo3DBuilder.rootNode);
- var geo3D = geo3DModel.coordinateSystem;
- if (!geo3D || !geo3D.viewGL) {
- return;
- }
- // Always have light.
- geo3D.viewGL.add(this._lightRoot);
- if (geo3DModel.get('show')) {
- geo3D.viewGL.add(this.groupGL);
- }
- else {
- geo3D.viewGL.remove(this.groupGL);
- }
- var control = this._control;
- control.setViewGL(geo3D.viewGL);
- var viewControlModel = geo3DModel.getModel('viewControl');
- control.setFromViewControlModel(viewControlModel, 0);
- this._sceneHelper.setScene(geo3D.viewGL.scene);
- this._sceneHelper.updateLight(geo3DModel);
- // Set post effect
- geo3D.viewGL.setPostEffect(geo3DModel.getModel('postEffect'), api);
- geo3D.viewGL.setTemporalSuperSampling(geo3DModel.getModel('temporalSuperSampling'));
- // Must update after geo3D.viewGL.setPostEffect
- this._geo3DBuilder.update(geo3DModel, ecModel, api, 0, geo3DModel.getData().count());
- var srgbDefineMethod = geo3D.viewGL.isLinearSpace() ? 'define' : 'undefine';
- this._geo3DBuilder.rootNode.traverse(function (mesh) {
- if (mesh.material) {
- mesh.material[srgbDefineMethod]('fragment', 'SRGB_DECODE');
- }
- });
- control.off('update');
- control.on('update', function () {
- api.dispatchAction({
- type: 'geo3DChangeCamera',
- alpha: control.getAlpha(),
- beta: control.getBeta(),
- distance: control.getDistance(),
- center: control.getCenter(),
- from: this.uid,
- geo3DId: geo3DModel.id
- });
- });
- control.update();
- },
- afterRender: function (geo3DModel, ecModel, api, layerGL) {
- var renderer = layerGL.renderer;
- this._sceneHelper.updateAmbientCubemap(renderer, geo3DModel, api);
- this._sceneHelper.updateSkybox(renderer, geo3DModel, api);
- },
- dispose: function () {
- this._control.dispose();
- }
- }));
- /***/
- }),
- /* 204 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- // https://github.com/mapbox/earcut/blob/master/src/earcut.js
- /* harmony default export */ __webpack_exports__["a"] = (earcut);
- function earcut(data, holeIndices, dim) {
- dim = dim || 2;
- var hasHoles = holeIndices && holeIndices.length,
- outerLen = hasHoles ? holeIndices[0] * dim : data.length,
- outerNode = linkedList(data, 0, outerLen, dim, true),
- triangles = [];
- if (!outerNode) return triangles;
- var minX, minY, maxX, maxY, x, y, size;
- if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
- // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
- if (data.length > 80 * dim) {
- minX = maxX = data[0];
- minY = maxY = data[1];
- for (var i = dim; i < outerLen; i += dim) {
- x = data[i];
- y = data[i + 1];
- if (x < minX) minX = x;
- if (y < minY) minY = y;
- if (x > maxX) maxX = x;
- if (y > maxY) maxY = y;
- }
- // minX, minY and size are later used to transform coords into integers for z-order calculation
- size = Math.max(maxX - minX, maxY - minY);
- }
- earcutLinked(outerNode, triangles, dim, minX, minY, size);
- return triangles;
- }
- // create a circular doubly linked list from polygon points in the specified winding order
- function linkedList(data, start, end, dim, clockwise) {
- var i, last;
- if (clockwise === (signedArea(data, start, end, dim) > 0)) {
- for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
- } else {
- for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
- }
- if (last && equals(last, last.next)) {
- removeNode(last);
- last = last.next;
- }
- return last;
- }
- // eliminate colinear or duplicate points
- function filterPoints(start, end) {
- if (!start) return start;
- if (!end) end = start;
- var p = start,
- again;
- do {
- again = false;
- if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
- removeNode(p);
- p = end = p.prev;
- if (p === p.next) return null;
- again = true;
- } else {
- p = p.next;
- }
- } while (again || p !== end);
- return end;
- }
- // main ear slicing loop which triangulates a polygon (given as a linked list)
- function earcutLinked(ear, triangles, dim, minX, minY, size, pass) {
- if (!ear) return;
- // interlink polygon nodes in z-order
- if (!pass && size) indexCurve(ear, minX, minY, size);
- var stop = ear,
- prev, next;
- // iterate through ears, slicing them one by one
- while (ear.prev !== ear.next) {
- prev = ear.prev;
- next = ear.next;
- if (size ? isEarHashed(ear, minX, minY, size) : isEar(ear)) {
- // cut off the triangle
- triangles.push(prev.i / dim);
- triangles.push(ear.i / dim);
- triangles.push(next.i / dim);
- removeNode(ear);
- // skipping the next vertice leads to less sliver triangles
- ear = next.next;
- stop = next.next;
- continue;
- }
- ear = next;
- // if we looped through the whole remaining polygon and can't find any more ears
- if (ear === stop) {
- // try filtering points and slicing again
- if (!pass) {
- earcutLinked(filterPoints(ear), triangles, dim, minX, minY, size, 1);
- // if this didn't work, try curing all small self-intersections locally
- } else if (pass === 1) {
- ear = cureLocalIntersections(ear, triangles, dim);
- earcutLinked(ear, triangles, dim, minX, minY, size, 2);
- // as a last resort, try splitting the remaining polygon into two
- } else if (pass === 2) {
- splitEarcut(ear, triangles, dim, minX, minY, size);
- }
- break;
- }
- }
- }
- // check whether a polygon node forms a valid ear with adjacent nodes
- function isEar(ear) {
- var a = ear.prev,
- b = ear,
- c = ear.next;
- if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
- // now make sure we don't have other points inside the potential ear
- var p = ear.next.next;
- while (p !== ear.prev) {
- if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
- area(p.prev, p, p.next) >= 0) return false;
- p = p.next;
- }
- return true;
- }
- function isEarHashed(ear, minX, minY, size) {
- var a = ear.prev,
- b = ear,
- c = ear.next;
- if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
- // triangle bbox; min & max are calculated like this for speed
- var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x),
- minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y),
- maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x),
- maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y);
- // z-order range for the current triangle bbox;
- var minZ = zOrder(minTX, minTY, minX, minY, size),
- maxZ = zOrder(maxTX, maxTY, minX, minY, size);
- // first look for points inside the triangle in increasing z-order
- var p = ear.nextZ;
- while (p && p.z <= maxZ) {
- if (p !== ear.prev && p !== ear.next &&
- pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
- area(p.prev, p, p.next) >= 0) return false;
- p = p.nextZ;
- }
- // then look for points in decreasing z-order
- p = ear.prevZ;
- while (p && p.z >= minZ) {
- if (p !== ear.prev && p !== ear.next &&
- pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
- area(p.prev, p, p.next) >= 0) return false;
- p = p.prevZ;
- }
- return true;
- }
- // go through all polygon nodes and cure small local self-intersections
- function cureLocalIntersections(start, triangles, dim) {
- var p = start;
- do {
- var a = p.prev,
- b = p.next.next;
- if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
- triangles.push(a.i / dim);
- triangles.push(p.i / dim);
- triangles.push(b.i / dim);
- // remove two nodes involved
- removeNode(p);
- removeNode(p.next);
- p = start = b;
- }
- p = p.next;
- } while (p !== start);
- return p;
- }
- // try splitting polygon into two and triangulate them independently
- function splitEarcut(start, triangles, dim, minX, minY, size) {
- // look for a valid diagonal that divides the polygon into two
- var a = start;
- do {
- var b = a.next.next;
- while (b !== a.prev) {
- if (a.i !== b.i && isValidDiagonal(a, b)) {
- // split the polygon in two by the diagonal
- var c = splitPolygon(a, b);
- // filter colinear points around the cuts
- a = filterPoints(a, a.next);
- c = filterPoints(c, c.next);
- // run earcut on each half
- earcutLinked(a, triangles, dim, minX, minY, size);
- earcutLinked(c, triangles, dim, minX, minY, size);
- return;
- }
- b = b.next;
- }
- a = a.next;
- } while (a !== start);
- }
- // link every hole into the outer loop, producing a single-ring polygon without holes
- function eliminateHoles(data, holeIndices, outerNode, dim) {
- var queue = [],
- i, len, start, end, list;
- for (i = 0, len = holeIndices.length; i < len; i++) {
- start = holeIndices[i] * dim;
- end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
- list = linkedList(data, start, end, dim, false);
- if (list === list.next) list.steiner = true;
- queue.push(getLeftmost(list));
- }
- queue.sort(compareX);
- // process holes from left to right
- for (i = 0; i < queue.length; i++) {
- eliminateHole(queue[i], outerNode);
- outerNode = filterPoints(outerNode, outerNode.next);
- }
- return outerNode;
- }
- function compareX(a, b) {
- return a.x - b.x;
- }
- // find a bridge between vertices that connects hole with an outer ring and and link it
- function eliminateHole(hole, outerNode) {
- outerNode = findHoleBridge(hole, outerNode);
- if (outerNode) {
- var b = splitPolygon(outerNode, hole);
- filterPoints(b, b.next);
- }
- }
- // David Eberly's algorithm for finding a bridge between hole and outer polygon
- function findHoleBridge(hole, outerNode) {
- var p = outerNode,
- hx = hole.x,
- hy = hole.y,
- qx = -Infinity,
- m;
- // find a segment intersected by a ray from the hole's leftmost point to the left;
- // segment's endpoint with lesser x will be potential connection point
- do {
- if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
- var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
- if (x <= hx && x > qx) {
- qx = x;
- if (x === hx) {
- if (hy === p.y) return p;
- if (hy === p.next.y) return p.next;
- }
- m = p.x < p.next.x ? p : p.next;
- }
- }
- p = p.next;
- } while (p !== outerNode);
- if (!m) return null;
- if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint
- // look for points inside the triangle of hole point, segment intersection and endpoint;
- // if there are no points found, we have a valid connection;
- // otherwise choose the point of the minimum angle with the ray as connection point
- var stop = m,
- mx = m.x,
- my = m.y,
- tanMin = Infinity,
- tan;
- p = m.next;
- while (p !== stop) {
- if (hx >= p.x && p.x >= mx && hx !== p.x &&
- pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
- tan = Math.abs(hy - p.y) / (hx - p.x); // tangential
- if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) {
- m = p;
- tanMin = tan;
- }
- }
- p = p.next;
- }
- return m;
- }
- // interlink polygon nodes in z-order
- function indexCurve(start, minX, minY, size) {
- var p = start;
- do {
- if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, size);
- p.prevZ = p.prev;
- p.nextZ = p.next;
- p = p.next;
- } while (p !== start);
- p.prevZ.nextZ = null;
- p.prevZ = null;
- sortLinked(p);
- }
- // Simon Tatham's linked list merge sort algorithm
- // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
- function sortLinked(list) {
- var i, p, q, e, tail, numMerges, pSize, qSize,
- inSize = 1;
- do {
- p = list;
- list = null;
- tail = null;
- numMerges = 0;
- while (p) {
- numMerges++;
- q = p;
- pSize = 0;
- for (i = 0; i < inSize; i++) {
- pSize++;
- q = q.nextZ;
- if (!q) break;
- }
- qSize = inSize;
- while (pSize > 0 || (qSize > 0 && q)) {
- if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
- e = p;
- p = p.nextZ;
- pSize--;
- } else {
- e = q;
- q = q.nextZ;
- qSize--;
- }
- if (tail) tail.nextZ = e;
- else list = e;
- e.prevZ = tail;
- tail = e;
- }
- p = q;
- }
- tail.nextZ = null;
- inSize *= 2;
- } while (numMerges > 1);
- return list;
- }
- // z-order of a point given coords and size of the data bounding box
- function zOrder(x, y, minX, minY, size) {
- // coords are transformed into non-negative 15-bit integer range
- x = 32767 * (x - minX) / size;
- y = 32767 * (y - minY) / size;
- x = (x | (x << 8)) & 0x00FF00FF;
- x = (x | (x << 4)) & 0x0F0F0F0F;
- x = (x | (x << 2)) & 0x33333333;
- x = (x | (x << 1)) & 0x55555555;
- y = (y | (y << 8)) & 0x00FF00FF;
- y = (y | (y << 4)) & 0x0F0F0F0F;
- y = (y | (y << 2)) & 0x33333333;
- y = (y | (y << 1)) & 0x55555555;
- return x | (y << 1);
- }
- // find the leftmost node of a polygon ring
- function getLeftmost(start) {
- var p = start,
- leftmost = start;
- do {
- if (p.x < leftmost.x) leftmost = p;
- p = p.next;
- } while (p !== start);
- return leftmost;
- }
- // check if a point lies within a convex triangle
- function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
- return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
- (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
- (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
- }
- // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
- function isValidDiagonal(a, b) {
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) &&
- locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b);
- }
- // signed area of a triangle
- function area(p, q, r) {
- return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
- }
- // check if two points are equal
- function equals(p1, p2) {
- return p1.x === p2.x && p1.y === p2.y;
- }
- // check if two segments intersect
- function intersects(p1, q1, p2, q2) {
- if ((equals(p1, q1) && equals(p2, q2)) ||
- (equals(p1, q2) && equals(p2, q1))) return true;
- return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 &&
- area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
- }
- // check if a polygon diagonal intersects any polygon segments
- function intersectsPolygon(a, b) {
- var p = a;
- do {
- if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
- intersects(p, p.next, a, b)) return true;
- p = p.next;
- } while (p !== a);
- return false;
- }
- // check if a polygon diagonal is locally inside the polygon
- function locallyInside(a, b) {
- return area(a.prev, a, a.next) < 0 ?
- area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
- area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
- }
- // check if the middle point of a polygon diagonal is inside the polygon
- function middleInside(a, b) {
- var p = a,
- inside = false,
- px = (a.x + b.x) / 2,
- py = (a.y + b.y) / 2;
- do {
- if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
- (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
- inside = !inside;
- p = p.next;
- } while (p !== a);
- return inside;
- }
- // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
- // if one belongs to the outer ring and another to a hole, it merges it into a single ring
- function splitPolygon(a, b) {
- var a2 = new Node(a.i, a.x, a.y),
- b2 = new Node(b.i, b.x, b.y),
- an = a.next,
- bp = b.prev;
- a.next = b;
- b.prev = a;
- a2.next = an;
- an.prev = a2;
- b2.next = a2;
- a2.prev = b2;
- bp.next = b2;
- b2.prev = bp;
- return b2;
- }
- // create a node and optionally link it with previous one (in a circular doubly linked list)
- function insertNode(i, x, y, last) {
- var p = new Node(i, x, y);
- if (!last) {
- p.prev = p;
- p.next = p;
- } else {
- p.next = last.next;
- p.prev = last;
- last.next.prev = p;
- last.next = p;
- }
- return p;
- }
- function removeNode(p) {
- p.next.prev = p.prev;
- p.prev.next = p.next;
- if (p.prevZ) p.prevZ.nextZ = p.nextZ;
- if (p.nextZ) p.nextZ.prevZ = p.prevZ;
- }
- function Node(i, x, y) {
- // vertice index in coordinates array
- this.i = i;
- // vertex coordinates
- this.x = x;
- this.y = y;
- // previous and next vertice nodes in a polygon ring
- this.prev = null;
- this.next = null;
- // z-order curve value
- this.z = null;
- // previous and next nodes in z-order
- this.prevZ = null;
- this.nextZ = null;
- // indicates whether this is a steiner point
- this.steiner = false;
- }
- // return a percentage difference between the polygon area and its triangulation area;
- // used to verify correctness of triangulation
- earcut.deviation = function (data, holeIndices, dim, triangles) {
- var hasHoles = holeIndices && holeIndices.length;
- var outerLen = hasHoles ? holeIndices[0] * dim : data.length;
- var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
- if (hasHoles) {
- for (var i = 0, len = holeIndices.length; i < len; i++) {
- var start = holeIndices[i] * dim;
- var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
- polygonArea -= Math.abs(signedArea(data, start, end, dim));
- }
- }
- var trianglesArea = 0;
- for (i = 0; i < triangles.length; i += 3) {
- var a = triangles[i] * dim;
- var b = triangles[i + 1] * dim;
- var c = triangles[i + 2] * dim;
- trianglesArea += Math.abs(
- (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
- (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
- }
- return polygonArea === 0 && trianglesArea === 0 ? 0 :
- Math.abs((trianglesArea - polygonArea) / polygonArea);
- };
- function signedArea(data, start, end, dim) {
- var sum = 0;
- for (var i = start, j = end - dim; i < end; i += dim) {
- sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
- j = i;
- }
- return sum;
- }
- /***/
- }),
- /* 205 */
- /***/ (function (module, exports, __webpack_require__) {
- var zrUtil = __webpack_require__(13);
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- var coordsOffsetMap = {
- 'å—æµ·è¯¸å²›': [32, 80],
- // 全国
- '广东': [0, -10],
- '香港': [10, 5],
- '澳门': [-10, 10],
- //'北京': [-10, 0],
- '天津': [5, 5]
- };
- function _default(geo) {
- zrUtil.each(geo.regions, function (region) {
- var coordFix = coordsOffsetMap[region.name];
- if (coordFix) {
- var cp = region.center;
- cp[0] += coordFix[0] / 10.5;
- cp[1] += -coordFix[1] / (10.5 / 0.75);
- }
- });
- }
- module.exports = _default;
- /***/
- }),
- /* 206 */
- /***/ (function (module, exports, __webpack_require__) {
- var zrUtil = __webpack_require__(13);
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- var geoCoordMap = {
- 'Russia': [100, 60],
- 'United States': [-99, 38],
- 'United States of America': [-99, 38]
- };
- function _default(geo) {
- zrUtil.each(geo.regions, function (region) {
- var geoCoord = geoCoordMap[region.name];
- if (geoCoord) {
- var cp = region.center;
- cp[0] = geoCoord[0];
- cp[1] = geoCoord[1];
- }
- });
- }
- module.exports = _default;
- /***/
- }),
- /* 207 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__globe_GlobeModel__ = __webpack_require__(208);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__globe_GlobeView__ = __webpack_require__(209);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__coord_globeCreator__ = __webpack_require__(211);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'globeChangeCamera',
- event: 'globecamerachanged',
- update: 'series:updateCamera'
- }, function (payload, ecModel) {
- ecModel.eachComponent({
- mainType: 'globe', query: payload
- }, function (componentModel) {
- componentModel.setView(payload);
- });
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'globeUpdateDisplacment',
- event: 'globedisplacementupdated',
- update: 'update'
- }, function (payload, ecModel) {
- // Noop
- });
- /***/
- }),
- /* 208 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__ = __webpack_require__(44);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__ = __webpack_require__(28);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__ = __webpack_require__(29);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_componentShadingMixin__ = __webpack_require__(31);
- function defaultId(option, idx) {
- option.id = option.id || option.name || (idx + '');
- }
- var GlobeModel = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendComponentModel({
- type: 'globe',
- layoutMode: 'box',
- coordinateSystem: null,
- init: function () {
- GlobeModel.superApply(this, 'init', arguments);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.each(this.option.layers, function (layerOption, idx) {
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(layerOption, this.defaultLayerOption);
- defaultId(layerOption, idx);
- }, this);
- },
- mergeOption: function (option) {
- // TODO test
- var oldLayers = this.option.layers;
- this.option.layers = null;
- GlobeModel.superApply(this, 'mergeOption', arguments);
- function createLayerMap(layers) {
- return __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.reduce(layers, function (obj, layerOption, idx) {
- defaultId(layerOption, idx);
- obj[layerOption.id] = layerOption;
- return obj;
- }, {});
- }
- if (oldLayers && oldLayers.length) {
- var newLayerMap = createLayerMap(option.layers);
- var oldLayerMap = createLayerMap(oldLayers);
- for (var id in newLayerMap) {
- if (oldLayerMap[id]) {
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(oldLayerMap[id], newLayerMap[id], true);
- }
- else {
- oldLayers.push(option.layers[id]);
- }
- }
- // Copy back
- this.option.layers = oldLayers;
- }
- // else overwrite
- // Set default
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.each(this.option.layers, function (layerOption) {
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(layerOption, this.defaultLayerOption);
- }, this);
- },
- optionUpdated: function () {
- this.updateDisplacementHash();
- },
- defaultLayerOption: {
- show: true,
- type: 'overlay'
- },
- defaultOption: {
- show: true,
- zlevel: -10,
- // Layout used for viewport
- left: 0,
- top: 0,
- width: '100%',
- height: '100%',
- environment: 'auto',
- baseColor: '#fff',
- // Base albedo texture
- baseTexture: '',
- // Height texture for bump mapping and vertex displacement
- heightTexture: '',
- // Texture for vertex displacement, default use heightTexture
- displacementTexture: '',
- // Scale of vertex displacement, available only if displacementTexture is set.
- displacementScale: 0,
- // Detail of displacement. 'low', 'medium', 'high', 'ultra'
- displacementQuality: 'medium',
- // Globe radius
- globeRadius: 100,
- // Globe outer radius. Which is max of altitude.
- globeOuterRadius: 150,
- // Shading of globe
- shading: 'lambert',
- // Extend light
- light: {
- // Main sun light
- main: {
- // Time, default it will use system time
- time: ''
- }
- },
- // light
- // postEffect
- // temporalSuperSampling
- viewControl: {
- autoRotate: true,
- panSensitivity: 0,
- targetCoord: null
- },
- // {
- // show: true,
- // name: 'cloud',
- // type: 'overlay',
- // shading: 'lambert',
- // distance: 10,
- // texture: ''
- // }
- // {
- // type: 'blend',
- // blendTo: 'albedo'
- // blendType: 'source-over'
- // }
- layers: []
- },
- setDisplacementData: function (data, width, height) {
- this.displacementData = data;
- this.displacementWidth = width;
- this.displacementHeight = height;
- },
- getDisplacementTexture: function () {
- return this.get('displacementTexture') || this.get('heightTexture');
- },
- getDisplacemenScale: function () {
- var displacementTexture = this.getDisplacementTexture();
- var displacementScale = this.get('displacementScale');
- if (!displacementTexture || displacementTexture === 'none') {
- displacementScale = 0;
- }
- return displacementScale;
- },
- hasDisplacement: function () {
- return this.getDisplacemenScale() > 0;
- },
- _displacementChanged: true,
- _displacementScale: 0,
- updateDisplacementHash: function () {
- var displacementTexture = this.getDisplacementTexture();
- var displacementScale = this.getDisplacemenScale();
- this._displacementChanged =
- this._displacementTexture !== displacementTexture
- || this._displacementScale !== displacementScale;
- this._displacementTexture = displacementTexture;
- this._displacementScale = displacementScale;
- },
- isDisplacementChanged: function () {
- return this._displacementChanged;
- }
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(GlobeModel.prototype, __WEBPACK_IMPORTED_MODULE_1__common_componentViewControlMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(GlobeModel.prototype, __WEBPACK_IMPORTED_MODULE_2__common_componentPostEffectMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(GlobeModel.prototype, __WEBPACK_IMPORTED_MODULE_3__common_componentLightMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(GlobeModel.prototype, __WEBPACK_IMPORTED_MODULE_4__common_componentShadingMixin__["a" /* default */]);
- /* unused harmony default export */ var _unused_webpack_default_export = (GlobeModel);
- /***/
- }),
- /* 209 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__ = __webpack_require__(45);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_SceneHelper__ = __webpack_require__(30);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_sunCalc__ = __webpack_require__(210);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(2);
- /* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendComponentView({
- type: 'globe',
- __ecgl__: true,
- _displacementScale: 0,
- init: function (ecModel, api) {
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- /**
- * @type {clay.geometry.Sphere}
- * @private
- */
- this._sphereGeometry = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].SphereGeometry({
- widthSegments: 200,
- heightSegments: 100,
- dynamic: true
- });
- this._overlayGeometry = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].SphereGeometry({
- widthSegments: 80,
- heightSegments: 40
- });
- /**
- * @type {clay.geometry.Plane}
- */
- this._planeGeometry = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].PlaneGeometry();
- /**
- * @type {clay.geometry.Mesh}
- */
- this._earthMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- renderNormal: true
- });
- this._lightRoot = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- this._sceneHelper = new __WEBPACK_IMPORTED_MODULE_3__common_SceneHelper__["a" /* default */]();
- this._sceneHelper.initLight(this._lightRoot);
- this.groupGL.add(this._earthMesh);
- this._control = new __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__["a" /* default */]({
- zr: api.getZr()
- });
- this._control.init();
- this._layerMeshes = {};
- },
- render: function (globeModel, ecModel, api) {
- var coordSys = globeModel.coordinateSystem;
- var shading = globeModel.get('shading');
- // Always have light.
- coordSys.viewGL.add(this._lightRoot);
- if (globeModel.get('show')) {
- // Add self to scene;
- coordSys.viewGL.add(this.groupGL);
- }
- else {
- coordSys.viewGL.remove(this.groupGL);
- }
- this._sceneHelper.setScene(coordSys.viewGL.scene);
- // Set post effect
- coordSys.viewGL.setPostEffect(globeModel.getModel('postEffect'), api);
- coordSys.viewGL.setTemporalSuperSampling(globeModel.getModel('temporalSuperSampling'));
- var earthMesh = this._earthMesh;
- earthMesh.geometry = this._sphereGeometry;
- var shadingPrefix = 'ecgl.' + shading;
- if (!earthMesh.material || earthMesh.material.shader.name !== shadingPrefix) {
- earthMesh.material = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createMaterial(shadingPrefix);
- }
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].setMaterialFromModel(
- shading, earthMesh.material, globeModel, api
- );
- ['roughnessMap', 'metalnessMap', 'detailMap', 'normalMap'].forEach(function (texName) {
- var texture = earthMesh.material.get(texName);
- if (texture) {
- texture.flipY = false;
- }
- })
- earthMesh.material.set('color', __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(
- globeModel.get('baseColor')
- ));
- // shrink a little
- var scale = coordSys.radius * 0.99;
- earthMesh.scale.set(scale, scale, scale);
- var diffuseTexture = earthMesh.material.setTextureImage('diffuseMap', globeModel.get('baseTexture'), api, {
- flipY: false,
- anisotropic: 8
- });
- if (diffuseTexture && diffuseTexture.surface) {
- diffuseTexture.surface.attachToMesh(earthMesh);
- }
- // Update bump map
- var bumpTexture = earthMesh.material.setTextureImage('bumpMap', globeModel.get('heightTexture'), api, {
- flipY: false,
- anisotropic: 8
- });
- if (bumpTexture && bumpTexture.surface) {
- bumpTexture.surface.attachToMesh(earthMesh);
- }
- earthMesh.material[globeModel.get('postEffect.enable') ? 'define' : 'undefine']('fragment', 'SRGB_DECODE');
- this._updateLight(globeModel, api);
- this._displaceVertices(globeModel, api);
- this._updateViewControl(globeModel, api);
- this._updateLayers(globeModel, api);
- },
- afterRender: function (globeModel, ecModel, api, layerGL) {
- // Create ambient cubemap after render because we need to know the renderer.
- // TODO
- var renderer = layerGL.renderer;
- this._sceneHelper.updateAmbientCubemap(renderer, globeModel, api);
- this._sceneHelper.updateSkybox(renderer, globeModel, api);
- },
- _updateLayers: function (globeModel, api) {
- var coordSys = globeModel.coordinateSystem;
- var layers = globeModel.get('layers');
- var lastDistance = coordSys.radius;
- var layerDiffuseTextures = [];
- var layerDiffuseIntensity = [];
- var layerEmissiveTextures = [];
- var layerEmissionIntensity = [];
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.each(layers, function (layerOption) {
- var layerModel = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.Model(layerOption);
- var layerType = layerModel.get('type');
- var texture = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].loadTexture(layerModel.get('texture'), api, {
- flipY: false,
- anisotropic: 8
- });
- if (texture.surface) {
- texture.surface.attachToMesh(this._earthMesh);
- }
- if (layerType === 'blend') {
- var blendTo = layerModel.get('blendTo');
- var intensity = __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(layerModel.get('intensity'), 1.0);
- if (blendTo === 'emission') {
- layerEmissiveTextures.push(texture);
- layerEmissionIntensity.push(intensity);
- }
- else { // Default is albedo
- layerDiffuseTextures.push(texture);
- layerDiffuseIntensity.push(intensity);
- }
- }
- else { // Default use overlay
- var id = layerModel.get('id');
- var overlayMesh = this._layerMeshes[id];
- if (!overlayMesh) {
- overlayMesh = this._layerMeshes[id] = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: this._overlayGeometry,
- castShadow: false,
- ignorePicking: true
- });
- }
- var shading = layerModel.get('shading');
- if (shading === 'lambert') {
- overlayMesh.material = overlayMesh.__lambertMaterial || new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- autoUpdateTextureStatus: false,
- shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.lambert'),
- transparent: true,
- depthMask: false
- });
- overlayMesh.__lambertMaterial = overlayMesh.material;
- }
- else { // color
- overlayMesh.material = overlayMesh.__colorMaterial || new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- autoUpdateTextureStatus: false,
- shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.color'),
- transparent: true,
- depthMask: false
- });
- overlayMesh.__colorMaterial = overlayMesh.material;
- }
- // overlay should be transparent if texture is not loaded yet.
- overlayMesh.material.enableTexture('diffuseMap');
- var distance = layerModel.get('distance');
- // Based on distance of last layer
- var radius = lastDistance + (distance == null ? coordSys.radius / 100 : distance);
- overlayMesh.scale.set(radius, radius, radius);
- lastDistance = radius;
- // FIXME Exists blink.
- var blankTexture = this._blankTexture || (this._blankTexture = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createBlankTexture('rgba(255, 255, 255, 0)'));
- overlayMesh.material.set('diffuseMap', blankTexture);
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].loadTexture(layerModel.get('texture'), api, {
- flipY: false,
- anisotropic: 8
- }, function (texture) {
- if (texture.surface) {
- texture.surface.attachToMesh(overlayMesh);
- }
- overlayMesh.material.set('diffuseMap', texture);
- api.getZr().refresh();
- });
- layerModel.get('show') ? this.groupGL.add(overlayMesh) : this.groupGL.remove(overlayMesh);
- }
- }, this);
- var earthMaterial = this._earthMesh.material;
- earthMaterial.define('fragment', 'LAYER_DIFFUSEMAP_COUNT', layerDiffuseTextures.length);
- earthMaterial.define('fragment', 'LAYER_EMISSIVEMAP_COUNT', layerEmissiveTextures.length);
- earthMaterial.set('layerDiffuseMap', layerDiffuseTextures);
- earthMaterial.set('layerDiffuseIntensity', layerDiffuseIntensity);
- earthMaterial.set('layerEmissiveMap', layerEmissiveTextures);
- earthMaterial.set('layerEmissionIntensity', layerEmissionIntensity);
- var debugWireframeModel = globeModel.getModel('debug.wireframe');
- if (debugWireframeModel.get('show')) {
- earthMaterial.define('both', 'WIREFRAME_TRIANGLE');
- var color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(
- debugWireframeModel.get('lineStyle.color') || 'rgba(0,0,0,0.5)'
- );
- var width = __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(
- debugWireframeModel.get('lineStyle.width'), 1
- );
- earthMaterial.set('wireframeLineWidth', width);
- earthMaterial.set('wireframeLineColor', color);
- }
- else {
- earthMaterial.undefine('both', 'WIREFRAME_TRIANGLE');
- }
- },
- _updateViewControl: function (globeModel, api) {
- var coordSys = globeModel.coordinateSystem;
- // Update camera
- var viewControlModel = globeModel.getModel('viewControl');
- var camera = coordSys.viewGL.camera;
- var self = this;
- function makeAction() {
- return {
- type: 'globeChangeCamera',
- alpha: control.getAlpha(),
- beta: control.getBeta(),
- distance: control.getDistance() - coordSys.radius,
- center: control.getCenter(),
- from: self.uid,
- globeId: globeModel.id
- };
- }
- // Update control
- var control = this._control;
- control.setViewGL(coordSys.viewGL);
- var coord = viewControlModel.get('targetCoord');
- var alpha, beta;
- if (coord != null) {
- beta = coord[0] + 90;
- alpha = coord[1];
- }
- control.setFromViewControlModel(viewControlModel, {
- baseDistance: coordSys.radius,
- alpha: alpha,
- beta: beta
- });
- control.off('update');
- control.on('update', function () {
- api.dispatchAction(makeAction());
- });
- },
- _displaceVertices: function (globeModel, api) {
- var displacementQuality = globeModel.get('displacementQuality');
- var showDebugWireframe = globeModel.get('debug.wireframe.show');
- var globe = globeModel.coordinateSystem;
- if (!globeModel.isDisplacementChanged()
- && displacementQuality === this._displacementQuality
- && showDebugWireframe === this._showDebugWireframe
- ) {
- return;
- }
- this._displacementQuality = displacementQuality;
- this._showDebugWireframe = showDebugWireframe;
- var geometry = this._sphereGeometry;
- var widthSegments = ({
- low: 100,
- medium: 200,
- high: 400,
- ultra: 800
- })[displacementQuality] || 200;
- var heightSegments = widthSegments / 2;
- if (geometry.widthSegments !== widthSegments || showDebugWireframe) {
- geometry.widthSegments = widthSegments;
- geometry.heightSegments = heightSegments;
- geometry.build();
- }
- this._doDisplaceVertices(geometry, globe);
- if (showDebugWireframe) {
- geometry.generateBarycentric();
- }
- },
- _doDisplaceVertices: function (geometry, globe) {
- var positionArr = geometry.attributes.position.value;
- var uvArr = geometry.attributes.texcoord0.value;
- var originalPositionArr = geometry.__originalPosition;
- if (!originalPositionArr || originalPositionArr.length !== positionArr.length) {
- originalPositionArr = new Float32Array(positionArr.length);
- originalPositionArr.set(positionArr);
- geometry.__originalPosition = originalPositionArr;
- }
- var width = globe.displacementWidth;
- var height = globe.displacementHeight;
- var data = globe.displacementData;
- for (var i = 0; i < geometry.vertexCount; i++) {
- var i3 = i * 3;
- var i2 = i * 2;
- var x = originalPositionArr[i3 + 1];
- var y = originalPositionArr[i3 + 2];
- var z = originalPositionArr[i3 + 3];
- var u = uvArr[i2++];
- var v = uvArr[i2++];
- var j = Math.round(u * (width - 1));
- var k = Math.round(v * (height - 1));
- var idx = k * width + j;
- var scale = data ? data[idx] : 0;
- positionArr[i3 + 1] = x + x * scale;
- positionArr[i3 + 2] = y + y * scale;
- positionArr[i3 + 3] = z + z * scale;
- }
- geometry.generateVertexNormals();
- geometry.dirty();
- geometry.updateBoundingBox();
- },
- _updateLight: function (globeModel, api) {
- var earthMesh = this._earthMesh;
- this._sceneHelper.updateLight(globeModel);
- var mainLight = this._sceneHelper.mainLight;
- // Put sun in the right position
- var time = globeModel.get('light.main.time') || new Date();
- // http://en.wikipedia.org/wiki/Azimuth
- var pos = __WEBPACK_IMPORTED_MODULE_4__util_sunCalc__["a" /* default */].getPosition(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.number.parseDate(time), 0, 0);
- var r0 = Math.cos(pos.altitude);
- // FIXME How to calculate the y ?
- mainLight.position.y = -r0 * Math.cos(pos.azimuth);
- mainLight.position.x = Math.sin(pos.altitude);
- mainLight.position.z = r0 * Math.sin(pos.azimuth);
- mainLight.lookAt(earthMesh.getWorldPosition());
- },
- dispose: function (ecModel, api) {
- this.groupGL.removeAll();
- this._control.dispose();
- }
- }));
- /***/
- }),
- /* 210 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /*
- (c) 2011-2014, Vladimir Agafonkin
- SunCalc is a JavaScript library for calculating sun/mooon position and light phases.
- https://github.com/mourner/suncalc
- */
- // shortcuts for easier to read formulas
- var PI = Math.PI,
- sin = Math.sin,
- cos = Math.cos,
- tan = Math.tan,
- asin = Math.asin,
- atan = Math.atan2,
- rad = PI / 180;
- // sun calculations are based on http://aa.quae.nl/en/reken/zonpositie.html formulas
- // date/time constants and conversions
- var dayMs = 1000 * 60 * 60 * 24,
- J1970 = 2440588,
- J2000 = 2451545;
- function toJulian(date) { return date.valueOf() / dayMs - 0.5 + J1970; }
- function toDays(date) { return toJulian(date) - J2000; }
- // general calculations for position
- var e = rad * 23.4397; // obliquity of the Earth
- function rightAscension(l, b) { return atan(sin(l) * cos(e) - tan(b) * sin(e), cos(l)); }
- function declination(l, b) { return asin(sin(b) * cos(e) + cos(b) * sin(e) * sin(l)); }
- function azimuth(H, phi, dec) { return atan(sin(H), cos(H) * sin(phi) - tan(dec) * cos(phi)); }
- function altitude(H, phi, dec) { return asin(sin(phi) * sin(dec) + cos(phi) * cos(dec) * cos(H)); }
- function siderealTime(d, lw) { return rad * (280.16 + 360.9856235 * d) - lw; }
- // general sun calculations
- function solarMeanAnomaly(d) { return rad * (357.5291 + 0.98560028 * d); }
- function eclipticLongitude(M) {
- var C = rad * (1.9148 * sin(M) + 0.02 * sin(2 * M) + 0.0003 * sin(3 * M)), // equation of center
- P = rad * 102.9372; // perihelion of the Earth
- return M + C + P + PI;
- }
- function sunCoords(d) {
- var M = solarMeanAnomaly(d),
- L = eclipticLongitude(M);
- return {
- dec: declination(L, 0),
- ra: rightAscension(L, 0)
- };
- }
- var SunCalc = {};
- // calculates sun position for a given date and latitude/longitude
- SunCalc.getPosition = function (date, lat, lng) {
- var lw = rad * -lng,
- phi = rad * lat,
- d = toDays(date),
- c = sunCoords(d),
- H = siderealTime(d, lw) - c.ra;
- return {
- azimuth: azimuth(H, phi, c.dec),
- altitude: altitude(H, phi, c.dec)
- };
- };
- /* harmony default export */ __webpack_exports__["a"] = (SunCalc);
- /***/
- }),
- /* 211 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__globe_Globe__ = __webpack_require__(212);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout__ = __webpack_require__(47);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(22);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_graphicGL__ = __webpack_require__(1);
- function getDisplacementData(img, displacementScale) {
- var canvas = document.createElement('canvas');
- var ctx = canvas.getContext('2d');
- var width = img.width;
- var height = img.height;
- canvas.width = width;
- canvas.height = height;
- ctx.drawImage(img, 0, 0, width, height);
- var rgbaArr = ctx.getImageData(0, 0, width, height).data;
- var displacementArr = new Float32Array(rgbaArr.length / 4);
- for (var i = 0; i < rgbaArr.length / 4; i++) {
- var x = rgbaArr[i * 4];
- displacementArr[i] = x / 255 * displacementScale;
- }
- return {
- data: displacementArr,
- width: width,
- height: height
- };
- }
- function resizeGlobe(globeModel, api) {
- // Use left/top/width/height
- var boxLayoutOption = globeModel.getBoxLayoutParams();
- var viewport = __WEBPACK_IMPORTED_MODULE_2_echarts_lib_util_layout___default.a.getLayoutRect(boxLayoutOption, {
- width: api.getWidth(),
- height: api.getHeight()
- });
- // Flip Y
- viewport.y = api.getHeight() - viewport.y - viewport.height;
- this.viewGL.setViewport(viewport.x, viewport.y, viewport.width, viewport.height, api.getDevicePixelRatio());
- this.radius = globeModel.get('globeRadius');
- var outerRadius = globeModel.get('globeOuterRadius');
- if (this.altitudeAxis) {
- this.altitudeAxis.setExtent(0, outerRadius - this.radius);
- }
- }
- function updateGlobe(ecModel, api) {
- var altitudeDataExtent = [Infinity, -Infinity]
- ecModel.eachSeries(function (seriesModel) {
- if (seriesModel.coordinateSystem !== this) {
- return;
- }
- // Get altitude data extent.
- var data = seriesModel.getData();
- var altDims = seriesModel.coordDimToDataDim('alt');
- var altDim = altDims && altDims[0];
- if (altDim) {
- // TODO altitiude is in coords of lines.
- var dataExtent = data.getDataExtent(altDim, true);
- altitudeDataExtent[0] = Math.min(
- altitudeDataExtent[0], dataExtent[0]
- );
- altitudeDataExtent[1] = Math.max(
- altitudeDataExtent[1], dataExtent[1]
- );
- }
- }, this);
- // Create altitude axis
- if (altitudeDataExtent && isFinite(altitudeDataExtent[1] - altitudeDataExtent[0])) {
- var scale = __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.helper.createScale(
- altitudeDataExtent, {
- type: 'value',
- // PENDING
- min: 'dataMin',
- max: 'dataMax'
- }
- );
- this.altitudeAxis = new __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.Axis('altitude', scale);
- // Resize again
- this.resize(this.model, api);
- }
- }
- var globeCreator = {
- dimensions: __WEBPACK_IMPORTED_MODULE_0__globe_Globe__["a" /* default */].prototype.dimensions,
- create: function (ecModel, api) {
- var globeList = [];
- ecModel.eachComponent('globe', function (globeModel) {
- // FIXME
- globeModel.__viewGL = globeModel.__viewGL || new __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__["a" /* default */]();
- var globe = new __WEBPACK_IMPORTED_MODULE_0__globe_Globe__["a" /* default */]();
- globe.viewGL = globeModel.__viewGL;
- globeModel.coordinateSystem = globe;
- globe.model = globeModel;
- globeList.push(globe);
- // Inject resize
- globe.resize = resizeGlobe;
- globe.resize(globeModel, api);
- globe.update = updateGlobe;
- });
- ecModel.eachSeries(function (seriesModel) {
- if (seriesModel.get('coordinateSystem') === 'globe') {
- var globeModel = seriesModel.getReferringComponents('globe')[0];
- if (!globeModel) {
- globeModel = ecModel.getComponent('globe');
- }
- if (!globeModel) {
- throw new Error('globe "' + __WEBPACK_IMPORTED_MODULE_4__util_retrieve__["a" /* default */].firstNotNull(
- seriesModel.get('globe3DIndex'),
- seriesModel.get('globe3DId'),
- 0
- ) + '" not found');
- }
- var coordSys = globeModel.coordinateSystem;
- seriesModel.coordinateSystem = coordSys;
- }
- });
- ecModel.eachComponent('globe', function (globeModel, idx) {
- var globe = globeModel.coordinateSystem;
- // Update displacement data
- var displacementTextureValue = globeModel.getDisplacementTexture();
- var displacementScale = globeModel.getDisplacemenScale();
- if (globeModel.isDisplacementChanged()) {
- if (globeModel.hasDisplacement()) {
- var immediateLoaded = true;
- __WEBPACK_IMPORTED_MODULE_5__util_graphicGL__["a" /* default */].loadTexture(displacementTextureValue, api, function (texture) {
- var img = texture.image;
- var displacementData = getDisplacementData(img, displacementScale);
- globeModel.setDisplacementData(displacementData.data, displacementData.width, displacementData.height);
- if (!immediateLoaded) {
- // Update layouts
- api.dispatchAction({
- type: 'globeUpdateDisplacment'
- });
- }
- });
- immediateLoaded = false;
- }
- else {
- globe.setDisplacementData(null, 0, 0);
- }
- globe.setDisplacementData(
- globeModel.displacementData, globeModel.displacementWidth, globeModel.displacementHeight
- );
- }
- });
- return globeList;
- }
- };
- __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.registerCoordinateSystem('globe', globeCreator);
- /* unused harmony default export */ var _unused_webpack_default_export = (globeCreator);
- /***/
- }),
- /* 212 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- var vec3 = __WEBPACK_IMPORTED_MODULE_0_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- function Globe(radius) {
- this.radius = radius;
- this.viewGL = null;
- this.altitudeAxis;
- // Displacement data provided by texture.
- this.displacementData = null;
- this.displacementWidth;
- this.displacementHeight;
- }
- Globe.prototype = {
- constructor: Globe,
- dimensions: ['lng', 'lat', 'alt'],
- type: 'globe',
- containPoint: function () { },
- setDisplacementData: function (data, width, height) {
- this.displacementData = data;
- this.displacementWidth = width;
- this.displacementHeight = height;
- },
- _getDisplacementScale: function (lng, lat) {
- var i = (lng + 180) / 360 * (this.displacementWidth - 1);
- var j = (90 - lat) / 180 * (this.displacementHeight - 1);
- // NEAREST SAMPLING
- // TODO Better bilinear sampling
- var idx = Math.round(i) + Math.round(j) * this.displacementWidth;
- return this.displacementData[idx];
- },
- dataToPoint: function (data, out) {
- var lng = data[0];
- var lat = data[1];
- // Default have 0 altitude
- var altVal = data[2] || 0;
- var r = this.radius;
- if (this.displacementData) {
- r *= 1 + this._getDisplacementScale(lng, lat);
- }
- if (this.altitudeAxis) {
- r += this.altitudeAxis.dataToCoord(altVal);
- }
- lng = lng * Math.PI / 180;
- lat = lat * Math.PI / 180;
- var r0 = Math.cos(lat) * r;
- out = out || [];
- // PENDING
- out[0] = -r0 * Math.cos(lng + Math.PI);
- out[1] = Math.sin(lat) * r;
- out[2] = r0 * Math.sin(lng + Math.PI);
- return out;
- },
- pointToData: function (point, out) {
- var x = point[0];
- var y = point[1];
- var z = point[2];
- var len = vec3.len(point);
- x /= len;
- y /= len;
- z /= len;
- var theta = Math.asin(y);
- var phi = Math.atan2(z, -x);
- if (phi < 0) {
- phi = Math.PI * 2 + phi;
- }
- var lat = theta * 180 / Math.PI;
- var lng = phi * 180 / Math.PI - 180;
- out = out || [];
- out[0] = lng;
- out[1] = lat;
- out[2] = len - this.radius;
- if (this.altitudeAxis) {
- out[2] = this.altitudeAxis.coordToData(out[2]);
- }
- return out;
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (Globe);
- /***/
- }),
- /* 213 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__coord_mapbox3DCreator__ = __webpack_require__(214);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__mapbox3D_Mapbox3DModel__ = __webpack_require__(216);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__mapbox3D_Mapbox3DView__ = __webpack_require__(217);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'mapbox3DChangeCamera',
- event: 'mapbox3dcamerachanged',
- update: 'mapbox3D:updateCamera'
- }, function (payload, ecModel) {
- ecModel.eachComponent({
- mainType: 'mapbox3D', query: payload
- }, function (componentModel) {
- componentModel.setMapboxCameraOption(payload);
- });
- });
- /***/
- }),
- /* 214 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mapbox3D_Mapbox3D__ = __webpack_require__(215);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__mapServiceCommon_createMapService3DCreator__ = __webpack_require__(101);
- var mapbox3DCreator = Object(__WEBPACK_IMPORTED_MODULE_2__mapServiceCommon_createMapService3DCreator__["a" /* default */])('mapbox3D', __WEBPACK_IMPORTED_MODULE_0__mapbox3D_Mapbox3D__["a" /* default */], function (mapbox3DList) {
- mapbox3DList.forEach(function (mapbox3D) {
- mapbox3D.setCameraOption(mapbox3D.model.getMapboxCameraOption());
- });
- });
- __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.registerCoordinateSystem('mapbox3D', mapbox3DCreator);
- /* unused harmony default export */ var _unused_webpack_default_export = (mapbox3DCreator);
- /***/
- }),
- /* 215 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mapServiceCommon_MapService3D__ = __webpack_require__(100);
- function Mapbox3D() {
- __WEBPACK_IMPORTED_MODULE_0__mapServiceCommon_MapService3D__["a" /* default */].apply(this, arguments);
- }
- Mapbox3D.prototype = new __WEBPACK_IMPORTED_MODULE_0__mapServiceCommon_MapService3D__["a" /* default */]();
- Mapbox3D.prototype.constructor = Mapbox3D;
- Mapbox3D.prototype.type = 'mapbox3D';
- /* harmony default export */ __webpack_exports__["a"] = (Mapbox3D);
- /***/
- }),
- /* 216 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentPostEffectMixin__ = __webpack_require__(28);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentLightMixin__ = __webpack_require__(29);
- var MAPBOX_CAMERA_OPTION = ['zoom', 'center', 'pitch', 'bearing'];
- var Mapbox3DModel = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendComponentModel({
- type: 'mapbox3D',
- layoutMode: 'box',
- coordinateSystem: null,
- defaultOption: {
- zlevel: -10,
- style: 'mapbox://styles/mapbox/light-v9',
- center: [0, 0],
- zoom: 0,
- pitch: 0,
- bearing: 0,
- light: {
- main: {
- alpha: 20,
- beta: 30
- }
- },
- altitudeScale: 1,
- // Default depend on altitudeScale
- boxHeight: 'auto'
- },
- getMapboxCameraOption: function () {
- var self = this;
- return MAPBOX_CAMERA_OPTION.reduce(function (obj, key) {
- obj[key] = self.get(key);
- return obj;
- }, {});
- },
- setMapboxCameraOption: function (option) {
- if (option != null) {
- MAPBOX_CAMERA_OPTION.forEach(function (key) {
- if (option[key] != null) {
- this.option[key] = option[key];
- }
- }, this);
- }
- },
- /**
- * Get mapbox instance
- */
- getMapbox: function () {
- return this._mapbox;
- },
- setMapbox: function (mapbox) {
- this._mapbox = mapbox;
- }
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Mapbox3DModel.prototype, __WEBPACK_IMPORTED_MODULE_1__common_componentPostEffectMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Mapbox3DModel.prototype, __WEBPACK_IMPORTED_MODULE_2__common_componentLightMixin__["a" /* default */]);
- /* unused harmony default export */ var _unused_webpack_default_export = (Mapbox3DModel);
- /***/
- }),
- /* 217 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Mapbox3DLayer__ = __webpack_require__(218);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_SceneHelper__ = __webpack_require__(30);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_shader_displayShadow_glsl_js__ = __webpack_require__(102);
- __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_4__util_shader_displayShadow_glsl_js__["a" /* default */]);
- var TILE_SIZE = 512;
- /* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendComponentView({
- type: 'mapbox3D',
- __ecgl__: true,
- init: function (ecModel, api) {
- var zr = api.getZr();
- this._zrLayer = new __WEBPACK_IMPORTED_MODULE_1__Mapbox3DLayer__["a" /* default */]('mapbox3D', zr);
- zr.painter.insertLayer(-1000, this._zrLayer);
- this._lightRoot = new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Node();
- this._sceneHelper = new __WEBPACK_IMPORTED_MODULE_2__common_SceneHelper__["a" /* default */](this._lightRoot);
- this._sceneHelper.initLight(this._lightRoot);
- var mapbox = this._zrLayer.getMapbox();
- var dispatchInteractAction = this._dispatchInteractAction.bind(this, api, mapbox);
- // PENDING
- ['zoom', 'rotate', 'drag', 'pitch', 'rotate', 'move'].forEach(function (eName) {
- mapbox.on(eName, dispatchInteractAction);
- });
- this._groundMesh = new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].PlaneGeometry(),
- material: new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Material({
- shader: new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Shader({
- vertex: __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Shader.source('ecgl.displayShadow.vertex'),
- fragment: __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Shader.source('ecgl.displayShadow.fragment')
- }),
- depthMask: false
- }),
- // Render first
- renderOrder: -100,
- culling: false,
- castShadow: false,
- $ignorePicking: true,
- renderNormal: true
- });
- },
- render: function (mapbox3DModel, ecModel, api) {
- var mapbox = this._zrLayer.getMapbox();
- var styleDesc = mapbox3DModel.get('style');
- var styleStr = JSON.stringify(styleDesc);
- if (styleStr !== this._oldStyleStr) {
- if (styleDesc) {
- mapbox.setStyle(styleDesc);
- }
- }
- this._oldStyleStr = styleStr;
- mapbox.setCenter(mapbox3DModel.get('center'));
- mapbox.setZoom(mapbox3DModel.get('zoom'));
- mapbox.setPitch(mapbox3DModel.get('pitch'));
- mapbox.setBearing(mapbox3DModel.get('bearing'));
- mapbox3DModel.setMapbox(mapbox);
- var coordSys = mapbox3DModel.coordinateSystem;
- // Not add to rootNode. Or light direction will be stretched by rootNode scale
- coordSys.viewGL.scene.add(this._lightRoot);
- coordSys.viewGL.add(this._groundMesh);
- this._updateGroundMesh();
- // Update lights
- this._sceneHelper.setScene(coordSys.viewGL.scene);
- this._sceneHelper.updateLight(mapbox3DModel);
- // Update post effects
- coordSys.viewGL.setPostEffect(mapbox3DModel.getModel('postEffect'), api);
- coordSys.viewGL.setTemporalSuperSampling(mapbox3DModel.getModel('temporalSuperSampling'));
- this._mapbox3DModel = mapbox3DModel;
- },
- afterRender: function (mapbox3DModel, ecModel, api, layerGL) {
- var renderer = layerGL.renderer;
- this._sceneHelper.updateAmbientCubemap(renderer, mapbox3DModel, api);
- this._sceneHelper.updateSkybox(renderer, mapbox3DModel, api);
- // FIXME If other series changes coordinate system.
- // FIXME When doing progressive rendering.
- mapbox3DModel.coordinateSystem.viewGL.scene.traverse(function (mesh) {
- if (mesh.material) {
- mesh.material.define('fragment', 'NORMAL_UP_AXIS', 2);
- mesh.material.define('fragment', 'NORMAL_FRONT_AXIS', 1);
- }
- });
- },
- updateCamera: function (mapbox3DModel, ecModel, api, payload) {
- mapbox3DModel.coordinateSystem.setCameraOption(payload);
- this._updateGroundMesh();
- api.getZr().refresh();
- },
- _dispatchInteractAction: function (api, mapbox, mapbox3DModel) {
- api.dispatchAction({
- type: 'mapbox3DChangeCamera',
- pitch: mapbox.getPitch(),
- zoom: mapbox.getZoom(),
- center: mapbox.getCenter().toArray(),
- bearing: mapbox.getBearing(),
- mapbox3DId: this._mapbox3DModel && this._mapbox3DModel.id
- });
- },
- _updateGroundMesh: function () {
- if (this._mapbox3DModel) {
- var coordSys = this._mapbox3DModel.coordinateSystem;
- var pt = coordSys.dataToPoint(coordSys.center);
- this._groundMesh.position.set(pt[0], pt[1], -0.001);
- var plane = new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Plane(new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Vector3(0, 0, 1), 0);
- var ray1 = coordSys.viewGL.camera.castRay(new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Vector2(-1, -1));
- var ray2 = coordSys.viewGL.camera.castRay(new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Vector2(1, 1));
- var pos0 = ray1.intersectPlane(plane);
- var pos1 = ray2.intersectPlane(plane);
- var scale = pos0.dist(pos1) / coordSys.viewGL.rootNode.scale.x;
- this._groundMesh.scale.set(scale, scale, 1);
- }
- },
- dispose: function (ecModel, api) {
- if (this._zrLayer) {
- this._zrLayer.dispose();
- }
- api.getZr().painter.delLayer(-1000);
- }
- }));
- /***/
- }),
- /* 218 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * @constructor
- * @alias module:echarts-gl/component/mapbox3D/Mapbox3DLayer
- * @param {string} id Layer ID
- * @param {module:zrender/ZRender} zr
- */
- function Mapbox3DLayer(id, zr) {
- this.id = id;
- this.zr = zr;
- this.dom = document.createElement('div');
- this.dom.style.cssText = 'position:absolute;left:0;right:0;top:0;bottom:0;';
- // FIXME If in module environment.
- if (!mapboxgl) {
- throw new Error('Mapbox GL library must be included. See https://www.mapbox.com/mapbox-gl-js/api/');
- }
- this._mapbox = new mapboxgl.Map({
- container: this.dom
- });
- // Proxy events
- this._initEvents();
- }
- Mapbox3DLayer.prototype.resize = function () {
- this._mapbox.resize();
- };
- Mapbox3DLayer.prototype.getMapbox = function () {
- return this._mapbox;
- };
- Mapbox3DLayer.prototype.clear = function () { };
- Mapbox3DLayer.prototype.refresh = function () {
- this._mapbox.resize();
- };
- var EVENTS = ['mousedown', 'mouseup', 'click', 'dblclick', 'mousemove',
- 'mousewheel', 'wheel',
- 'touchstart', 'touchend', 'touchmove', 'touchcancel'
- ];
- Mapbox3DLayer.prototype._initEvents = function () {
- // Event is bound on canvas container.
- var mapboxRoot = this._mapbox.getCanvasContainer();
- this._handlers = this._handlers || {
- contextmenu: function (e) {
- e.preventDefault();
- return false;
- }
- };
- EVENTS.forEach(function (eName) {
- this._handlers[eName] = function (e) {
- var obj = {};
- for (var name in e) {
- obj[name] = e[name];
- }
- obj.bubbles = false;
- var newE = new e.constructor(e.type, obj);
- mapboxRoot.dispatchEvent(newE);
- };
- this.zr.dom.addEventListener(eName, this._handlers[eName]);
- }, this);
- // PENDING
- this.zr.dom.addEventListener('contextmenu', this._handlers.contextmenu);
- };
- Mapbox3DLayer.prototype.dispose = function () {
- EVENTS.forEach(function (eName) {
- this.zr.dom.removeEventListener(eName, this._handlers[eName]);
- }, this);
- };
- /* harmony default export */ __webpack_exports__["a"] = (Mapbox3DLayer);
- /***/
- }),
- /* 219 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__coord_maptalks3DCreator__ = __webpack_require__(220);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__maptalks3D_Maptalks3DModel__ = __webpack_require__(222);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__maptalks3D_Maptalks3DView__ = __webpack_require__(223);
- // Thanks to https://gitee.com/iverson_hu/maptalks-echarts-gl
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'maptalks3DChangeCamera',
- event: 'maptalks3dcamerachanged',
- update: 'maptalks3D:updateCamera'
- }, function (payload, ecModel) {
- ecModel.eachComponent({
- mainType: 'maptalks3D', query: payload
- }, function (componentModel) {
- componentModel.setMaptalksCameraOption(payload);
- });
- });
- /***/
- }),
- /* 220 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__maptalks3D_Maptalks3D__ = __webpack_require__(221);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__mapServiceCommon_createMapService3DCreator__ = __webpack_require__(101);
- var maptalks3DCreator = Object(__WEBPACK_IMPORTED_MODULE_2__mapServiceCommon_createMapService3DCreator__["a" /* default */])('maptalks3D', __WEBPACK_IMPORTED_MODULE_0__maptalks3D_Maptalks3D__["a" /* default */], function (maptalks3DList) {
- maptalks3DList.forEach(function (maptalks3D) {
- maptalks3D.setCameraOption(maptalks3D.model.getMaptalksCameraOption());
- });
- });
- __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default.a.registerCoordinateSystem('maptalks3D', maptalks3DCreator);
- /* unused harmony default export */ var _unused_webpack_default_export = (maptalks3DCreator);
- /***/
- }),
- /* 221 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mapServiceCommon_MapService3D__ = __webpack_require__(100);
- function Maptalks3D() {
- __WEBPACK_IMPORTED_MODULE_0__mapServiceCommon_MapService3D__["a" /* default */].apply(this, arguments);
- this.maxPitch = 85;
- this.zoomOffset = 1;
- }
- Maptalks3D.prototype = new __WEBPACK_IMPORTED_MODULE_0__mapServiceCommon_MapService3D__["a" /* default */]();
- Maptalks3D.prototype.constructor = Maptalks3D;
- Maptalks3D.prototype.type = 'maptalks3D';
- /* harmony default export */ __webpack_exports__["a"] = (Maptalks3D);
- /***/
- }),
- /* 222 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_componentPostEffectMixin__ = __webpack_require__(28);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_componentLightMixin__ = __webpack_require__(29);
- var MAPTALKS_CAMERA_OPTION = ['zoom', 'center', 'pitch', 'bearing'];
- var Maptalks3DModel = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendComponentModel({
- type: 'maptalks3D',
- layoutMode: 'box',
- coordinateSystem: null,
- defaultOption: {
- zlevel: -10,
- urlTemplate: 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
- attribution: '© <a href="http://osm.org">OpenStreetMap</a> contributors, © <a href="https://carto.com/">CARTO</a>',
- center: [0, 0],
- zoom: 0,
- pitch: 0,
- bearing: 0,
- light: {
- main: {
- alpha: 20,
- beta: 30
- }
- },
- altitudeScale: 1,
- // Default depend on altitudeScale
- boxHeight: 'auto'
- },
- getMaptalksCameraOption: function () {
- var self = this;
- return MAPTALKS_CAMERA_OPTION.reduce(function (obj, key) {
- obj[key] = self.get(key);
- return obj;
- }, {});
- },
- setMaptalksCameraOption: function (option) {
- if (option != null) {
- MAPTALKS_CAMERA_OPTION.forEach(function (key) {
- if (option[key] != null) {
- this.option[key] = option[key];
- }
- }, this);
- }
- },
- /**
- * Get maptalks instance
- */
- getMaptalks: function () {
- return this._maptalks;
- },
- setMaptalks: function (maptalks) {
- this._maptalks = maptalks;
- }
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Maptalks3DModel.prototype, __WEBPACK_IMPORTED_MODULE_1__common_componentPostEffectMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Maptalks3DModel.prototype, __WEBPACK_IMPORTED_MODULE_2__common_componentLightMixin__["a" /* default */]);
- /* unused harmony default export */ var _unused_webpack_default_export = (Maptalks3DModel);
- /***/
- }),
- /* 223 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Maptalks3DLayer__ = __webpack_require__(224);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_SceneHelper__ = __webpack_require__(30);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_shader_displayShadow_glsl_js__ = __webpack_require__(102);
- __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_4__util_shader_displayShadow_glsl_js__["a" /* default */]);
- /* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendComponentView({
- type: 'maptalks3D',
- __ecgl__: true,
- init: function (ecModel, api) {
- this._groundMesh = new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].PlaneGeometry(),
- material: new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Material({
- shader: new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Shader({
- vertex: __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Shader.source('ecgl.displayShadow.vertex'),
- fragment: __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Shader.source('ecgl.displayShadow.fragment')
- }),
- depthMask: false
- }),
- // Render first
- renderOrder: -100,
- culling: false,
- castShadow: false,
- $ignorePicking: true,
- renderNormal: true
- });
- },
- _initMaptalksLayer: function (mapbox3DModel, api) {
- var zr = api.getZr();
- this._zrLayer = new __WEBPACK_IMPORTED_MODULE_1__Maptalks3DLayer__["a" /* default */]('maptalks3D', zr, mapbox3DModel.get('center'), mapbox3DModel.get('zoom'));
- zr.painter.insertLayer(-1000, this._zrLayer);
- this._lightRoot = new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Node();
- this._sceneHelper = new __WEBPACK_IMPORTED_MODULE_2__common_SceneHelper__["a" /* default */](this._lightRoot);
- this._sceneHelper.initLight(this._lightRoot);
- var maptalks = this._zrLayer.getMaptalks();
- var dispatchInteractAction = this._dispatchInteractAction.bind(this, api, maptalks);
- // PENDING
- ['zoomend', 'zooming', 'zoomstart', 'dragrotating', 'pitch', 'pitchend', 'movestart',
- 'moving', 'moveend', 'resize', 'touchstart', 'touchmove', 'touchend'].forEach(function (eName) {
- maptalks.on(eName, dispatchInteractAction);
- });
- },
- render: function (maptalks3DModel, ecModel, api) {
- if (!this._zrLayer) {
- this._initMaptalksLayer(maptalks3DModel, api);
- }
- var mtks = this._zrLayer.getMaptalks();
- var urlTemplate = maptalks3DModel.get('urlTemplate');
- var baseLayer = mtks.getBaseLayer();
- if (urlTemplate !== this._oldUrlTemplate) {
- if (!baseLayer) {
- baseLayer = new maptalks.TileLayer('maptalks-echarts-gl-baselayer', {
- urlTemplate: urlTemplate,
- // used sequentially to help with browser parallel requests per domain limitation
- subdomains: ['a', 'b', 'c'],
- attribution: maptalks3DModel.get('attribution')
- });
- mtks.setBaseLayer(baseLayer);
- }
- else {
- // PENDING setOptions may not work?
- baseLayer.setOptions({
- urlTemplate: urlTemplate,
- attribution: maptalks3DModel.get('attribution')
- });
- }
- }
- this._oldUrlTemplate = urlTemplate;
- mtks.setCenter(maptalks3DModel.get('center'));
- mtks.setZoom(maptalks3DModel.get('zoom'), { animation: false });
- mtks.setPitch(maptalks3DModel.get('pitch'));
- mtks.setBearing(maptalks3DModel.get('bearing'));
- maptalks3DModel.setMaptalks(mtks);
- var coordSys = maptalks3DModel.coordinateSystem;
- // Not add to rootNode. Or light direction will be stretched by rootNode scale
- coordSys.viewGL.scene.add(this._lightRoot);
- coordSys.viewGL.add(this._groundMesh);
- this._updateGroundMesh();
- // Update lights
- this._sceneHelper.setScene(coordSys.viewGL.scene);
- this._sceneHelper.updateLight(maptalks3DModel);
- // Update post effects
- coordSys.viewGL.setPostEffect(maptalks3DModel.getModel('postEffect'), api);
- coordSys.viewGL.setTemporalSuperSampling(maptalks3DModel.getModel('temporalSuperSampling'));
- this._maptalks3DModel = maptalks3DModel;
- },
- afterRender: function (maptalks3DModel, ecModel, api, layerGL) {
- var renderer = layerGL.renderer;
- this._sceneHelper.updateAmbientCubemap(renderer, maptalks3DModel, api);
- this._sceneHelper.updateSkybox(renderer, maptalks3DModel, api);
- // FIXME If other series changes coordinate system.
- // FIXME When doing progressive rendering.
- maptalks3DModel.coordinateSystem.viewGL.scene.traverse(function (mesh) {
- if (mesh.material) {
- mesh.material.define('fragment', 'NORMAL_UP_AXIS', 2);
- mesh.material.define('fragment', 'NORMAL_FRONT_AXIS', 1);
- }
- });
- },
- updateCamera: function (maptalks3DModel, ecModel, api, payload) {
- maptalks3DModel.coordinateSystem.setCameraOption(payload);
- this._updateGroundMesh();
- api.getZr().refresh();
- },
- _dispatchInteractAction: function (api, maptalks, maptalks3DModel) {
- api.dispatchAction({
- type: 'maptalks3DChangeCamera',
- pitch: maptalks.getPitch(),
- zoom: maptalks.getZoom(),
- center: maptalks.getCenter().toArray(),
- bearing: maptalks.getBearing(),
- maptalks3DId: this._maptalks3DModel && this._maptalks3DModel.id
- });
- },
- _updateGroundMesh: function () {
- if (this._maptalks3DModel) {
- var coordSys = this._maptalks3DModel.coordinateSystem;
- var pt = coordSys.dataToPoint(coordSys.center);
- this._groundMesh.position.set(pt[0], pt[1], -0.001);
- var plane = new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Plane(new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Vector3(0, 0, 1), 0);
- var ray1 = coordSys.viewGL.camera.castRay(new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Vector2(-1, -1));
- var ray2 = coordSys.viewGL.camera.castRay(new __WEBPACK_IMPORTED_MODULE_3__util_graphicGL__["a" /* default */].Vector2(1, 1));
- var pos0 = ray1.intersectPlane(plane);
- var pos1 = ray2.intersectPlane(plane);
- var scale = pos0.dist(pos1) / coordSys.viewGL.rootNode.scale.x;
- this._groundMesh.scale.set(scale, scale, 1);
- }
- },
- dispose: function (ecModel, api) {
- if (this._zrLayer) {
- this._zrLayer.dispose();
- }
- api.getZr().painter.delLayer(-1000);
- }
- }));
- /***/
- }),
- /* 224 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /**
- * @constructor
- * @alias module:echarts-gl/component/maptalks/Maptalks3DLayer
- * @param {string} id Layer ID
- * @param {module:zrender/ZRender} zr
- */
- function Maptalks3DLayer(id, zr, defaultCenter, defaultZoom) {
- this.id = id;
- this.zr = zr;
- this.dom = document.createElement('div');
- this.dom.style.cssText = 'position:absolute;left:0;right:0;top:0;bottom:0;';
- // FIXME If in module environment.
- if (!maptalks) {
- throw new Error('Maptalks library must be included. See https://maptalks.org');
- }
- this._maptalks = new maptalks.Map(this.dom, {
- center: defaultCenter,
- zoom: defaultZoom,
- fog: false
- // fogColor: [0, 0, 0]
- });
- // Proxy events
- this._initEvents();
- }
- Maptalks3DLayer.prototype.resize = function () {
- this._maptalks.checkSize();
- };
- Maptalks3DLayer.prototype.getMaptalks = function () {
- return this._maptalks;
- };
- Maptalks3DLayer.prototype.clear = function () { };
- Maptalks3DLayer.prototype.refresh = function () {
- this._maptalks.checkSize();
- };
- var EVENTS = ['mousedown', 'mouseup', 'click', 'dblclick', 'mousemove',
- 'mousewheel', 'DOMMouseScroll',
- 'touchstart', 'touchend', 'touchmove', 'touchcancel'
- ];
- Maptalks3DLayer.prototype._initEvents = function () {
- // Event is bound on canvas container.
- var maptalksRoot = this.dom;
- this._handlers = this._handlers || {
- contextmenu: function (e) {
- e.preventDefault();
- return false;
- }
- };
- EVENTS.forEach(function (eName) {
- this._handlers[eName] = function (e) {
- var obj = {};
- for (var name in e) {
- obj[name] = e[name];
- }
- obj.bubbles = false;
- var newE = new e.constructor(e.type, obj);
- if (eName === 'mousewheel' || eName === 'DOMMouseScroll') {
- // maptalks listens events to different elements?
- maptalksRoot.dispatchEvent(newE);
- }
- else {
- maptalksRoot.firstElementChild.dispatchEvent(newE);
- }
- };
- this.zr.dom.addEventListener(eName, this._handlers[eName]);
- }, this);
- // PENDING
- this.zr.dom.addEventListener('contextmenu', this._handlers.contextmenu);
- };
- Maptalks3DLayer.prototype.dispose = function () {
- EVENTS.forEach(function (eName) {
- this.zr.dom.removeEventListener(eName, this._handlers[eName]);
- }, this);
- this._maptalks.remove();
- };
- /* harmony default export */ __webpack_exports__["a"] = (Maptalks3DLayer);
- /***/
- }),
- /* 225 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__bar3D_bar3DLayout__ = __webpack_require__(226);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__bar3D_Bar3DView__ = __webpack_require__(229);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__bar3D_Bar3DSeries__ = __webpack_require__(231);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__["a" /* default */])('bar3D'));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerProcessor(function (ecModel, api) {
- ecModel.eachSeriesByType('bar3d', function (seriesModel) {
- var data = seriesModel.getData();
- data.filterSelf(function (idx) {
- return data.hasValue(idx);
- });
- });
- });
- /***/
- }),
- /* 226 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__cartesian3DLayout__ = __webpack_require__(227);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__evaluateBarSparseness__ = __webpack_require__(228);
- var vec3 = __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- var isDimensionStacked = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.dataStack.isDimensionStacked;
- function globeLayout(seriesModel, coordSys) {
- var data = seriesModel.getData();
- var barMinHeight = seriesModel.get('minHeight') || 0;
- var barSize = seriesModel.get('barSize');
- var dims = ['lng', 'lat', 'alt'].map(function (coordDimName) {
- return seriesModel.coordDimToDataDim(coordDimName)[0];
- });
- if (barSize == null) {
- var perimeter = coordSys.radius * Math.PI;
- var fillRatio = Object(__WEBPACK_IMPORTED_MODULE_4__evaluateBarSparseness__["a" /* default */])(data, dims[0], dims[1]);
- barSize = [
- perimeter / Math.sqrt(data.count() / fillRatio),
- perimeter / Math.sqrt(data.count() / fillRatio)
- ];
- }
- else if (!__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(barSize)) {
- barSize = [barSize, barSize];
- }
- var valueDim = getValueDimension(data, dims);
- data.each(dims, function (lng, lat, val, idx) {
- var stackedValue = data.get(valueDim.dimension, idx);
- var baseValue = valueDim.isStacked ? (stackedValue - val) : coordSys.altitudeAxis.scale.getExtent()[0];
- // TODO Stacked with minHeight.
- var height = Math.max(coordSys.altitudeAxis.dataToCoord(val), barMinHeight);
- var start = coordSys.dataToPoint([lng, lat, baseValue]);
- var end = coordSys.dataToPoint([lng, lat, stackedValue]);
- var dir = vec3.sub([], end, start);
- vec3.normalize(dir, dir);
- var size = [barSize[0], height, barSize[1]];
- data.setItemLayout(idx, [start, dir, size]);
- });
- data.setLayout('orient', __WEBPACK_IMPORTED_MODULE_1_claygl_src_math_Vector3__["a" /* default */].UP.array);
- }
- function geo3DLayout(seriesModel, coordSys) {
- var data = seriesModel.getData();
- var barSize = seriesModel.get('barSize');
- var barMinHeight = seriesModel.get('minHeight') || 0;
- var dims = ['lng', 'lat', 'alt'].map(function (coordDimName) {
- return seriesModel.coordDimToDataDim(coordDimName)[0];
- });
- if (barSize == null) {
- var size = Math.min(coordSys.size[0], coordSys.size[2]);
- var fillRatio = Object(__WEBPACK_IMPORTED_MODULE_4__evaluateBarSparseness__["a" /* default */])(data, dims[0], dims[1]);
- barSize = [
- size / Math.sqrt(data.count() / fillRatio),
- size / Math.sqrt(data.count() / fillRatio)
- ];
- }
- else if (!__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(barSize)) {
- barSize = [barSize, barSize];
- }
- var dir = [0, 1, 0];
- var valueDim = getValueDimension(data, dims);
- data.each(dims, function (lng, lat, val, idx) {
- var stackedValue = data.get(valueDim.dimension, idx);
- var baseValue = valueDim.isStacked ? (stackedValue - val) : coordSys.altitudeAxis.scale.getExtent()[0];
- var height = Math.max(coordSys.altitudeAxis.dataToCoord(val), barMinHeight);
- var start = coordSys.dataToPoint([lng, lat, baseValue]);
- var size = [barSize[0], height, barSize[1]];
- data.setItemLayout(idx, [start, dir, size]);
- });
- data.setLayout('orient', [1, 0, 0]);
- }
- function mapService3DLayout(seriesModel, coordSys) {
- var data = seriesModel.getData();
- var dimLng = seriesModel.coordDimToDataDim('lng')[0];
- var dimLat = seriesModel.coordDimToDataDim('lat')[0];
- var dimAlt = seriesModel.coordDimToDataDim('alt')[0];
- var barSize = seriesModel.get('barSize');
- var barMinHeight = seriesModel.get('minHeight') || 0;
- if (barSize == null) {
- var xExtent = data.getDataExtent(dimLng);
- var yExtent = data.getDataExtent(dimLat);
- var corner0 = coordSys.dataToPoint([xExtent[0], yExtent[0]]);
- var corner1 = coordSys.dataToPoint([xExtent[1], yExtent[1]]);
- var size = Math.min(
- Math.abs(corner0[0] - corner1[0]),
- Math.abs(corner0[1] - corner1[1])
- ) || 1;
- var fillRatio = Object(__WEBPACK_IMPORTED_MODULE_4__evaluateBarSparseness__["a" /* default */])(data, dimLng, dimLat);
- // PENDING, data density
- barSize = [
- size / Math.sqrt(data.count() / fillRatio),
- size / Math.sqrt(data.count() / fillRatio)
- ];
- }
- else {
- if (!__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(barSize)) {
- barSize = [barSize, barSize];
- }
- barSize[0] /= coordSys.getScale() / 16;
- barSize[1] /= coordSys.getScale() / 16;
- }
- var dir = [0, 0, 1];
- var dims = [dimLng, dimLat, dimAlt];
- var valueDim = getValueDimension(data, dims);
- data.each(dims, function (lng, lat, val, idx) {
- var stackedValue = data.get(valueDim.dimension, idx);
- var baseValue = valueDim.isStacked ? (stackedValue - val) : 0;
- var start = coordSys.dataToPoint([lng, lat, baseValue]);
- var end = coordSys.dataToPoint([lng, lat, stackedValue]);
- var height = Math.max(end[2] - start[2], barMinHeight);
- var size = [barSize[0], height, barSize[1]];
- data.setItemLayout(idx, [start, dir, size]);
- });
- data.setLayout('orient', [1, 0, 0]);
- }
- function getValueDimension(data, dataDims) {
- var isStacked = isDimensionStacked(data, dataDims[2]);
- return {
- dimension: isStacked
- ? data.getCalculationInfo('stackResultDimension')
- : dataDims[2],
- isStacked: isStacked
- };
- }
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout(function (ecModel, api) {
- ecModel.eachSeriesByType('bar3D', function (seriesModel) {
- var coordSys = seriesModel.coordinateSystem;
- var coordSysType = coordSys && coordSys.type;
- if (coordSysType === 'globe') {
- globeLayout(seriesModel, coordSys);
- }
- else if (coordSysType === 'cartesian3D') {
- Object(__WEBPACK_IMPORTED_MODULE_3__cartesian3DLayout__["a" /* default */])(seriesModel, coordSys);
- }
- else if (coordSysType === 'geo3D') {
- geo3DLayout(seriesModel, coordSys);
- }
- else if (coordSysType === 'mapbox3D' || coordSysType === 'maptalks3D') {
- mapService3DLayout(seriesModel, coordSys);
- }
- else {
- if (true) {
- if (!coordSys) {
- throw new Error('bar3D doesn\'t have coordinate system.');
- }
- else {
- throw new Error('bar3D doesn\'t support coordinate system ' + coordSys.type);
- }
- }
- }
- });
- });
- /***/
- }),
- /* 227 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- var isDimensionStacked = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.dataStack.isDimensionStacked;
- function ifCrossZero(extent) {
- var min = extent[0];
- var max = extent[1];
- return !((min > 0 && max > 0) || (min < 0 && max < 0));
- };
- function cartesian3DLayout(seriesModel, coordSys) {
- var data = seriesModel.getData();
- // var barOnPlane = seriesModel.get('onGridPlane');
- var barSize = seriesModel.get('barSize');
- if (barSize == null) {
- var size = coordSys.size;
- var barWidth;
- var barDepth;
- var xAxis = coordSys.getAxis('x');
- var yAxis = coordSys.getAxis('y');
- if (xAxis.type === 'category') {
- barWidth = xAxis.getBandWidth() * 0.7;
- }
- else {
- // PENDING
- barWidth = Math.round(size[0] / Math.sqrt(data.count())) * 0.6;
- }
- if (yAxis.type === 'category') {
- barDepth = yAxis.getBandWidth() * 0.7;
- }
- else {
- barDepth = Math.round(size[1] / Math.sqrt(data.count())) * 0.6;
- }
- barSize = [barWidth, barDepth];
- }
- else if (!__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(barSize)) {
- barSize = [barSize, barSize];
- }
- var zAxisExtent = coordSys.getAxis('z').scale.getExtent();
- var ifZAxisCrossZero = ifCrossZero(zAxisExtent);
- var dims = ['x', 'y', 'z'].map(function (coordDimName) {
- return seriesModel.coordDimToDataDim(coordDimName)[0];
- });
- var isStacked = isDimensionStacked(data, dims[2]);
- var valueDim = isStacked
- ? data.getCalculationInfo('stackResultDimension')
- : dims[2];
- data.each(dims, function (x, y, z, idx) {
- // TODO zAxis is inversed
- // TODO On different plane.
- var stackedValue = data.get(valueDim, idx);
- var baseValue = isStacked ? (stackedValue - z)
- : (ifZAxisCrossZero ? 0 : zAxisExtent[0]);
- var start = coordSys.dataToPoint([x, y, baseValue]);
- var end = coordSys.dataToPoint([x, y, stackedValue]);
- var height = vec3.dist(start, end);
- // PENDING When zAxis is not cross zero.
- var dir = [0, end[1] < start[1] ? -1 : 1, 0];
- if (Math.abs(height) === 0) {
- // TODO
- height = 0.1;
- }
- var size = [barSize[0], height, barSize[1]];
- data.setItemLayout(idx, [start, dir, size]);
- });
- data.setLayout('orient', [1, 0, 0]);
- }
- /* harmony default export */ __webpack_exports__["a"] = (cartesian3DLayout);
- /***/
- }),
- /* 228 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = (function (data, dimX, dimY) {
- var xExtent = data.getDataExtent(dimX);
- var yExtent = data.getDataExtent(dimY);
- // TODO Handle one data situation
- var xSpan = (xExtent[1] - xExtent[0]) || xExtent[0];
- var ySpan = (yExtent[1] - yExtent[0]) || yExtent[0];
- var dimSize = 50;
- var tmp = new Uint8Array(dimSize * dimSize);
- for (var i = 0; i < data.count(); i++) {
- var x = data.get(dimX, i);
- var y = data.get(dimY, i);
- var xIdx = Math.floor((x - xExtent[0]) / xSpan * (dimSize - 1));
- var yIdx = Math.floor((y - yExtent[0]) / ySpan * (dimSize - 1));
- var idx = yIdx * dimSize + xIdx;
- tmp[idx] = tmp[idx] || 1;
- }
- var filledCount = 0;
- for (var i = 0; i < tmp.length; i++) {
- if (tmp[i]) {
- filledCount++;
- }
- }
- return filledCount / tmp.length;
- });;
- /***/
- }),
- /* 229 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_format__ = __webpack_require__(32);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_Bars3DGeometry__ = __webpack_require__(230);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__component_common_LabelsBuilder__ = __webpack_require__(66);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- var vec3 = __WEBPACK_IMPORTED_MODULE_6_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- /* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({
- type: 'bar3D',
- __ecgl__: true,
- init: function (ecModel, api) {
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- this._api = api;
- this._labelsBuilder = new __WEBPACK_IMPORTED_MODULE_5__component_common_LabelsBuilder__["a" /* default */](256, 256, api);
- var self = this;
- this._labelsBuilder.getLabelPosition = function (dataIndex, position, distance) {
- if (self._data) {
- var layout = self._data.getItemLayout(dataIndex);
- var start = layout[0];
- var dir = layout[1];
- var height = layout[2][1];
- return vec3.scaleAndAdd([], start, dir, distance + height);
- }
- else {
- return [0, 0];
- }
- };
- // Give a large render order.
- this._labelsBuilder.getMesh().renderOrder = 100;
- },
- render: function (seriesModel, ecModel, api) {
- // Swap barMesh
- var tmp = this._prevBarMesh;
- this._prevBarMesh = this._barMesh;
- this._barMesh = tmp;
- if (!this._barMesh) {
- this._barMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_4__util_geometry_Bars3DGeometry__["a" /* default */](),
- shadowDepthMaterial: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- shader: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader(
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('ecgl.sm.depth.vertex'),
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('ecgl.sm.depth.fragment')
- )
- }),
- // Only cartesian3D enable culling
- // FIXME Performance
- culling: seriesModel.coordinateSystem.type === 'cartesian3D',
- // Render after axes
- renderOrder: 10,
- // Render normal in normal pass
- renderNormal: true
- });
- }
- this.groupGL.remove(this._prevBarMesh);
- this.groupGL.add(this._barMesh);
- this.groupGL.add(this._labelsBuilder.getMesh());
- var coordSys = seriesModel.coordinateSystem;
- this._doRender(seriesModel, api);
- if (coordSys && coordSys.viewGL) {
- coordSys.viewGL.add(this.groupGL);
- var methodName = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine';
- this._barMesh.material[methodName]('fragment', 'SRGB_DECODE');
- }
- this._data = seriesModel.getData();
- this._labelsBuilder.updateData(this._data);
- this._labelsBuilder.updateLabels();
- this._updateAnimation(seriesModel);
- },
- _updateAnimation: function (seriesModel) {
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].updateVertexAnimation(
- [['prevPosition', 'position'],
- ['prevNormal', 'normal']],
- this._prevBarMesh,
- this._barMesh,
- seriesModel
- );
- },
- _doRender: function (seriesModel, api) {
- var data = seriesModel.getData();
- var shading = seriesModel.get('shading');
- var enableNormal = shading !== 'color';
- var self = this;
- var barMesh = this._barMesh;
- var shadingPrefix = 'ecgl.' + shading;
- if (!barMesh.material || barMesh.material.shader.name !== shadingPrefix) {
- barMesh.material = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createMaterial(shadingPrefix, ['VERTEX_COLOR']);
- }
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].setMaterialFromModel(
- shading, barMesh.material, seriesModel, api
- );
- barMesh.geometry.enableNormal = enableNormal;
- barMesh.geometry.resetOffset();
- // Bevel settings
- var bevelSize = seriesModel.get('bevelSize');
- var bevelSegments = seriesModel.get('bevelSmoothness');
- barMesh.geometry.bevelSegments = bevelSegments;
- barMesh.geometry.bevelSize = bevelSize;
- var colorArr = [];
- var vertexColors = new Float32Array(data.count() * 4);
- var colorOffset = 0;
- var barCount = 0;
- var hasTransparent = false;
- data.each(function (idx) {
- if (!data.hasValue(idx)) {
- return;
- }
- var color = data.getItemVisual(idx, 'color');
- var opacity = data.getItemVisual(idx, 'opacity');
- if (opacity == null) {
- opacity = 1;
- }
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color, colorArr);
- colorArr[3] *= opacity;
- vertexColors[colorOffset++] = colorArr[0];
- vertexColors[colorOffset++] = colorArr[1];
- vertexColors[colorOffset++] = colorArr[2];
- vertexColors[colorOffset++] = colorArr[3];
- if (colorArr[3] > 0) {
- barCount++;
- if (colorArr[3] < 0.99) {
- hasTransparent = true;
- }
- }
- });
- barMesh.geometry.setBarCount(barCount);
- var orient = data.getLayout('orient');
- // Map of dataIndex and barIndex.
- var barIndexOfData = this._barIndexOfData = new Int32Array(data.count());
- var barCount = 0;
- data.each(function (idx) {
- if (!data.hasValue(idx)) {
- barIndexOfData[idx] = -1;
- return;
- }
- var layout = data.getItemLayout(idx);
- var start = layout[0];
- var dir = layout[1];
- var size = layout[2];
- var idx4 = idx * 4;
- colorArr[0] = vertexColors[idx4++];
- colorArr[1] = vertexColors[idx4++];
- colorArr[2] = vertexColors[idx4++];
- colorArr[3] = vertexColors[idx4++];
- if (colorArr[3] > 0) {
- self._barMesh.geometry.addBar(start, dir, orient, size, colorArr, idx);
- barIndexOfData[idx] = barCount++;
- }
- });
- barMesh.geometry.dirty();
- barMesh.geometry.updateBoundingBox();
- var material = barMesh.material;
- material.transparent = hasTransparent;
- material.depthMask = !hasTransparent;
- barMesh.geometry.sortTriangles = hasTransparent;
- this._initHandler(seriesModel, api);
- },
- _initHandler: function (seriesModel, api) {
- var data = seriesModel.getData();
- var barMesh = this._barMesh;
- var isCartesian3D = seriesModel.coordinateSystem.type === 'cartesian3D';
- barMesh.seriesIndex = seriesModel.seriesIndex;
- var lastDataIndex = -1;
- barMesh.off('mousemove');
- barMesh.off('mouseout');
- barMesh.on('mousemove', function (e) {
- var dataIndex = barMesh.geometry.getDataIndexOfVertex(e.triangle[0]);
- if (dataIndex !== lastDataIndex) {
- this._downplay(lastDataIndex);
- this._highlight(dataIndex);
- this._labelsBuilder.updateLabels([dataIndex]);
- if (isCartesian3D) {
- api.dispatchAction({
- type: 'grid3DShowAxisPointer',
- value: [data.get('x', dataIndex), data.get('y', dataIndex), data.get('z', dataIndex, true)]
- });
- }
- }
- lastDataIndex = dataIndex;
- barMesh.dataIndex = dataIndex;
- }, this);
- barMesh.on('mouseout', function (e) {
- this._downplay(lastDataIndex);
- this._labelsBuilder.updateLabels();
- lastDataIndex = -1;
- barMesh.dataIndex = -1;
- if (isCartesian3D) {
- api.dispatchAction({
- type: 'grid3DHideAxisPointer'
- });
- }
- }, this);
- },
- _highlight: function (dataIndex) {
- var data = this._data;
- if (!data) {
- return;
- }
- var barIndex = this._barIndexOfData[dataIndex];
- if (barIndex < 0) {
- return;
- }
- var itemModel = data.getItemModel(dataIndex);
- var emphasisItemStyleModel = itemModel.getModel('emphasis.itemStyle');
- var emphasisColor = emphasisItemStyleModel.get('color');
- var emphasisOpacity = emphasisItemStyleModel.get('opacity');
- if (emphasisColor == null) {
- var color = data.getItemVisual(dataIndex, 'color');
- emphasisColor = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.color.lift(color, -0.4);
- }
- if (emphasisOpacity == null) {
- emphasisOpacity = data.getItemVisual(dataIndex, 'opacity');
- }
- var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(emphasisColor);
- colorArr[3] *= emphasisOpacity;
- this._barMesh.geometry.setColor(barIndex, colorArr);
- this._api.getZr().refresh();
- },
- _downplay: function (dataIndex) {
- var data = this._data;
- if (!data) {
- return;
- }
- var barIndex = this._barIndexOfData[dataIndex];
- if (barIndex < 0) {
- return;
- }
- var color = data.getItemVisual(dataIndex, 'color');
- var opacity = data.getItemVisual(dataIndex, 'opacity');
- var colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color);
- colorArr[3] *= opacity;
- this._barMesh.geometry.setColor(barIndex, colorArr);
- this._api.getZr().refresh();
- },
- highlight: function (seriesModel, ecModel, api, payload) {
- this._toggleStatus('highlight', seriesModel, ecModel, api, payload);
- },
- downplay: function (seriesModel, ecModel, api, payload) {
- this._toggleStatus('downplay', seriesModel, ecModel, api, payload);
- },
- _toggleStatus: function (status, seriesModel, ecModel, api, payload) {
- var data = seriesModel.getData();
- var dataIndex = __WEBPACK_IMPORTED_MODULE_2__util_retrieve__["a" /* default */].queryDataIndex(data, payload);
- var self = this;
- if (dataIndex != null) {
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.each(__WEBPACK_IMPORTED_MODULE_3__util_format__["a" /* default */].normalizeToArray(dataIndex), function (dataIdx) {
- status === 'highlight' ? this._highlight(dataIdx) : this._downplay(dataIdx);
- }, this);
- }
- else {
- data.each(function (dataIdx) {
- status === 'highlight' ? self._highlight(dataIdx) : self._downplay(dataIdx);
- });
- }
- },
- remove: function () {
- this.groupGL.removeAll();
- },
- dispose: function () {
- this.groupGL.removeAll();
- }
- }));
- /***/
- }),
- /* 230 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__dynamicConvertMixin__ = __webpack_require__(38);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__trianglesSortMixin__ = __webpack_require__(65);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Geometry__ = __webpack_require__(15);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /**
- * Geometry collecting bars data
- *
- * @module echarts-gl/chart/bars/BarsGeometry
- * @author Yi Shen(http://github.com/pissang)
- */
- var vec3 = __WEBPACK_IMPORTED_MODULE_4_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- var mat3 = __WEBPACK_IMPORTED_MODULE_4_claygl_src_dep_glmatrix__["a" /* default */].mat3;
- /**
- * @constructor
- * @alias module:echarts-gl/chart/bars/BarsGeometry
- * @extends clay.Geometry
- */
- var BarsGeometry = __WEBPACK_IMPORTED_MODULE_3_claygl_src_Geometry__["a" /* default */].extend(function () {
- return {
- attributes: {
- position: new __WEBPACK_IMPORTED_MODULE_3_claygl_src_Geometry__["a" /* default */].Attribute('position', 'float', 3, 'POSITION'),
- normal: new __WEBPACK_IMPORTED_MODULE_3_claygl_src_Geometry__["a" /* default */].Attribute('normal', 'float', 3, 'NORMAL'),
- color: new __WEBPACK_IMPORTED_MODULE_3_claygl_src_Geometry__["a" /* default */].Attribute('color', 'float', 4, 'COLOR'),
- prevPosition: new __WEBPACK_IMPORTED_MODULE_3_claygl_src_Geometry__["a" /* default */].Attribute('prevPosition', 'float', 3),
- prevNormal: new __WEBPACK_IMPORTED_MODULE_3_claygl_src_Geometry__["a" /* default */].Attribute('prevNormal', 'float', 3)
- },
- dynamic: true,
- enableNormal: false,
- bevelSize: 1,
- bevelSegments: 0,
- // Map from vertexIndex to dataIndex.
- _dataIndices: null,
- _vertexOffset: 0,
- _triangleOffset: 0
- };
- },
- /** @lends module:echarts-gl/chart/bars/BarsGeometry.prototype */
- {
- resetOffset: function () {
- this._vertexOffset = 0;
- this._triangleOffset = 0;
- },
- setBarCount: function (barCount) {
- var enableNormal = this.enableNormal;
- var vertexCount = this.getBarVertexCount() * barCount;
- var triangleCount = this.getBarTriangleCount() * barCount;
- if (this.vertexCount !== vertexCount) {
- this.attributes.position.init(vertexCount);
- if (enableNormal) {
- this.attributes.normal.init(vertexCount);
- }
- else {
- this.attributes.normal.value = null;
- }
- this.attributes.color.init(vertexCount);
- }
- if (this.triangleCount !== triangleCount) {
- this.indices = vertexCount > 0xffff ? new Uint32Array(triangleCount * 3) : new Uint16Array(triangleCount * 3);
- this._dataIndices = new Uint32Array(vertexCount);
- }
- },
- getBarVertexCount: function () {
- var bevelSegments = this.bevelSize > 0 ? this.bevelSegments : 0;
- return bevelSegments > 0 ? this._getBevelBarVertexCount(bevelSegments)
- : (this.enableNormal ? 24 : 8);
- },
- getBarTriangleCount: function () {
- var bevelSegments = this.bevelSize > 0 ? this.bevelSegments : 0;
- return bevelSegments > 0 ? this._getBevelBarTriangleCount(bevelSegments)
- : 12;
- },
- _getBevelBarVertexCount: function (bevelSegments) {
- return (bevelSegments + 1) * 4 * (bevelSegments + 1) * 2;
- },
- _getBevelBarTriangleCount: function (bevelSegments) {
- var widthSegments = bevelSegments * 4 + 3;
- var heightSegments = bevelSegments * 2 + 1;
- return (widthSegments + 1) * heightSegments * 2 + 4;
- },
- setColor: function (idx, color) {
- var vertexCount = this.getBarVertexCount();
- var start = vertexCount * idx;
- var end = vertexCount * (idx + 1);
- for (var i = start; i < end; i++) {
- this.attributes.color.set(i, color);
- }
- this.dirtyAttribute('color');
- },
- /**
- * Get dataIndex of vertex.
- * @param {number} vertexIndex
- */
- getDataIndexOfVertex: function (vertexIndex) {
- return this._dataIndices ? this._dataIndices[vertexIndex] : null;
- },
- /**
- * Add a bar
- * @param {Array.<number>} start
- * @param {Array.<number>} end
- * @param {Array.<number>} orient right direction
- * @param {Array.<number>} size size on x and z
- * @param {Array.<number>} color
- */
- addBar: (function () {
- var v3Create = vec3.create;
- var v3ScaleAndAdd = vec3.scaleAndAdd;
- var end = v3Create();
- var px = v3Create();
- var py = v3Create();
- var pz = v3Create();
- var nx = v3Create();
- var ny = v3Create();
- var nz = v3Create();
- var pts = [];
- var normals = [];
- for (var i = 0; i < 8; i++) {
- pts[i] = v3Create();
- }
- var cubeFaces4 = [
- // PX
- [0, 1, 5, 4],
- // NX
- [2, 3, 7, 6],
- // PY
- [4, 5, 6, 7],
- // NY
- [3, 2, 1, 0],
- // PZ
- [0, 4, 7, 3],
- // NZ
- [1, 2, 6, 5]
- ];
- var face4To3 = [
- 0, 1, 2, 0, 2, 3
- ];
- var cubeFaces3 = [];
- for (var i = 0; i < cubeFaces4.length; i++) {
- var face4 = cubeFaces4[i];
- for (var j = 0; j < 2; j++) {
- var face = [];
- for (var k = 0; k < 3; k++) {
- face.push(face4[face4To3[j * 3 + k]]);
- }
- cubeFaces3.push(face);
- }
- }
- return function (start, dir, leftDir, size, color, dataIndex) {
- // Use vertex, triangle maybe sorted.
- var startVertex = this._vertexOffset;
- if (this.bevelSize > 0 && this.bevelSegments > 0) {
- this._addBevelBar(start, dir, leftDir, size, this.bevelSize, this.bevelSegments, color);
- }
- else {
- vec3.copy(py, dir);
- vec3.normalize(py, py);
- // x * y => z
- vec3.cross(pz, leftDir, py);
- vec3.normalize(pz, pz);
- // y * z => x
- vec3.cross(px, py, pz);
- vec3.normalize(pz, pz);
- vec3.negate(nx, px);
- vec3.negate(ny, py);
- vec3.negate(nz, pz);
- v3ScaleAndAdd(pts[0], start, px, size[0] / 2);
- v3ScaleAndAdd(pts[0], pts[0], pz, size[2] / 2);
- v3ScaleAndAdd(pts[1], start, px, size[0] / 2);
- v3ScaleAndAdd(pts[1], pts[1], nz, size[2] / 2);
- v3ScaleAndAdd(pts[2], start, nx, size[0] / 2);
- v3ScaleAndAdd(pts[2], pts[2], nz, size[2] / 2);
- v3ScaleAndAdd(pts[3], start, nx, size[0] / 2);
- v3ScaleAndAdd(pts[3], pts[3], pz, size[2] / 2);
- v3ScaleAndAdd(end, start, py, size[1]);
- v3ScaleAndAdd(pts[4], end, px, size[0] / 2);
- v3ScaleAndAdd(pts[4], pts[4], pz, size[2] / 2);
- v3ScaleAndAdd(pts[5], end, px, size[0] / 2);
- v3ScaleAndAdd(pts[5], pts[5], nz, size[2] / 2);
- v3ScaleAndAdd(pts[6], end, nx, size[0] / 2);
- v3ScaleAndAdd(pts[6], pts[6], nz, size[2] / 2);
- v3ScaleAndAdd(pts[7], end, nx, size[0] / 2);
- v3ScaleAndAdd(pts[7], pts[7], pz, size[2] / 2);
- var attributes = this.attributes;
- if (this.enableNormal) {
- normals[0] = px;
- normals[1] = nx;
- normals[2] = py;
- normals[3] = ny;
- normals[4] = pz;
- normals[5] = nz;
- var vertexOffset = this._vertexOffset;
- for (var i = 0; i < cubeFaces4.length; i++) {
- var idx3 = this._triangleOffset * 3;
- for (var k = 0; k < 6; k++) {
- this.indices[idx3++] = vertexOffset + face4To3[k];
- }
- vertexOffset += 4;
- this._triangleOffset += 2;
- }
- for (var i = 0; i < cubeFaces4.length; i++) {
- var normal = normals[i];
- for (var k = 0; k < 4; k++) {
- var idx = cubeFaces4[i][k];
- attributes.position.set(this._vertexOffset, pts[idx]);
- attributes.normal.set(this._vertexOffset, normal);
- attributes.color.set(this._vertexOffset++, color);
- }
- }
- }
- else {
- for (var i = 0; i < cubeFaces3.length; i++) {
- var idx3 = this._triangleOffset * 3;
- for (var k = 0; k < 3; k++) {
- this.indices[idx3 + k] = cubeFaces3[i][k] + this._vertexOffset;
- }
- this._triangleOffset++;
- }
- for (var i = 0; i < pts.length; i++) {
- attributes.position.set(this._vertexOffset, pts[i]);
- attributes.color.set(this._vertexOffset++, color);
- }
- }
- }
- var endVerex = this._vertexOffset;
- for (var i = startVertex; i < endVerex; i++) {
- this._dataIndices[i] = dataIndex;
- }
- };
- })(),
- /**
- * Add a bar with bevel
- * @param {Array.<number>} start
- * @param {Array.<number>} end
- * @param {Array.<number>} orient right direction
- * @param {Array.<number>} size size on x and z
- * @param {number} bevelSize
- * @param {number} bevelSegments
- * @param {Array.<number>} color
- */
- _addBevelBar: (function () {
- var px = vec3.create();
- var py = vec3.create();
- var pz = vec3.create();
- var rotateMat = mat3.create();
- var bevelStartSize = [];
- var xOffsets = [1, -1, -1, 1];
- var zOffsets = [1, 1, -1, -1];
- var yOffsets = [2, 0];
- return function (start, dir, leftDir, size, bevelSize, bevelSegments, color) {
- vec3.copy(py, dir);
- vec3.normalize(py, py);
- // x * y => z
- vec3.cross(pz, leftDir, py);
- vec3.normalize(pz, pz);
- // y * z => x
- vec3.cross(px, py, pz);
- vec3.normalize(pz, pz);
- rotateMat[0] = px[0]; rotateMat[1] = px[1]; rotateMat[2] = px[2];
- rotateMat[3] = py[0]; rotateMat[4] = py[1]; rotateMat[5] = py[2];
- rotateMat[6] = pz[0]; rotateMat[7] = pz[1]; rotateMat[8] = pz[2];
- bevelSize = Math.min(size[0], size[2]) / 2 * bevelSize;
- for (var i = 0; i < 3; i++) {
- bevelStartSize[i] = Math.max(size[i] - bevelSize * 2, 0);
- }
- var rx = (size[0] - bevelStartSize[0]) / 2;
- var ry = (size[1] - bevelStartSize[1]) / 2;
- var rz = (size[2] - bevelStartSize[2]) / 2;
- var pos = [];
- var normal = [];
- var vertexOffset = this._vertexOffset;
- var endIndices = [];
- for (var i = 0; i < 2; i++) {
- endIndices[i] = endIndices[i] = [];
- for (var m = 0; m <= bevelSegments; m++) {
- for (var j = 0; j < 4; j++) {
- if ((m === 0 && i === 0) || (i === 1 && m === bevelSegments)) {
- endIndices[i].push(vertexOffset);
- }
- for (var n = 0; n <= bevelSegments; n++) {
- var phi = n / bevelSegments * Math.PI / 2 + Math.PI / 2 * j;
- var theta = m / bevelSegments * Math.PI / 2 + Math.PI / 2 * i;
- // var r = rx < ry ? (rz < rx ? rz : rx) : (rz < ry ? rz : ry);
- normal[0] = rx * Math.cos(phi) * Math.sin(theta);
- normal[1] = ry * Math.cos(theta);
- normal[2] = rz * Math.sin(phi) * Math.sin(theta);
- pos[0] = normal[0] + xOffsets[j] * bevelStartSize[0] / 2;
- pos[1] = (normal[1] + ry) + yOffsets[i] * bevelStartSize[1] / 2;
- pos[2] = normal[2] + zOffsets[j] * bevelStartSize[2] / 2;
- // Normal is not right if rx, ry, rz not equal.
- if (!(Math.abs(rx - ry) < 1e-6 && Math.abs(ry - rz) < 1e-6)) {
- normal[0] /= rx * rx;
- normal[1] /= ry * ry;
- normal[2] /= rz * rz;
- }
- vec3.normalize(normal, normal);
- vec3.transformMat3(pos, pos, rotateMat);
- vec3.transformMat3(normal, normal, rotateMat);
- vec3.add(pos, pos, start);
- this.attributes.position.set(vertexOffset, pos);
- if (this.enableNormal) {
- this.attributes.normal.set(vertexOffset, normal);
- }
- this.attributes.color.set(vertexOffset, color);
- vertexOffset++;
- }
- }
- }
- }
- var widthSegments = bevelSegments * 4 + 3;
- var heightSegments = bevelSegments * 2 + 1;
- var len = widthSegments + 1;
- for (var j = 0; j < heightSegments; j++) {
- for (var i = 0; i <= widthSegments; i++) {
- var i2 = j * len + i + this._vertexOffset;
- var i1 = (j * len + (i + 1) % len) + this._vertexOffset;
- var i4 = (j + 1) * len + (i + 1) % len + this._vertexOffset;
- var i3 = (j + 1) * len + i + this._vertexOffset;
- this.setTriangleIndices(this._triangleOffset++, [i4, i2, i1]);
- this.setTriangleIndices(this._triangleOffset++, [i4, i3, i2]);
- }
- }
- // Close top and bottom
- this.setTriangleIndices(this._triangleOffset++, [endIndices[0][0], endIndices[0][2], endIndices[0][1]]);
- this.setTriangleIndices(this._triangleOffset++, [endIndices[0][0], endIndices[0][3], endIndices[0][2]]);
- this.setTriangleIndices(this._triangleOffset++, [endIndices[1][0], endIndices[1][1], endIndices[1][2]]);
- this.setTriangleIndices(this._triangleOffset++, [endIndices[1][0], endIndices[1][2], endIndices[1][3]]);
- this._vertexOffset = vertexOffset;
- };
- })()
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.defaults(BarsGeometry.prototype, __WEBPACK_IMPORTED_MODULE_1__dynamicConvertMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.defaults(BarsGeometry.prototype, __WEBPACK_IMPORTED_MODULE_2__trianglesSortMixin__["a" /* default */]);
- /* harmony default export */ __webpack_exports__["a"] = (BarsGeometry);
- /***/
- }),
- /* 231 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__ = __webpack_require__(31);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_format__ = __webpack_require__(32);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_formatTooltip__ = __webpack_require__(39);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_createList__ = __webpack_require__(50);
- var Bar3DSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({
- type: 'series.bar3D',
- dependencies: ['globe'],
- visualColorAccessPath: 'itemStyle.color',
- getInitialData: function (option, ecModel) {
- return Object(__WEBPACK_IMPORTED_MODULE_4__common_createList__["a" /* default */])(this);
- },
- getFormattedLabel: function (dataIndex, status, dataType, dimIndex) {
- var text = __WEBPACK_IMPORTED_MODULE_2__util_format__["a" /* default */].getFormattedLabel(this, dataIndex, status, dataType, dimIndex);
- if (text == null) {
- text = this.getData().get('z', dataIndex);
- }
- return text;
- },
- formatTooltip: function (dataIndex) {
- return Object(__WEBPACK_IMPORTED_MODULE_3__common_formatTooltip__["a" /* default */])(this, dataIndex);
- },
- defaultOption: {
- coordinateSystem: 'cartesian3D',
- globeIndex: 0,
- grid3DIndex: 0,
- zlevel: -10,
- // bevelSize, 0 has no bevel
- bevelSize: 0,
- // higher is smoother
- bevelSmoothness: 2,
- // Bar width and depth
- // barSize: [1, 1],
- // On grid plane when coordinateSystem is cartesian3D
- onGridPlane: 'xy',
- // Shading of globe
- shading: 'color',
- minHeight: 0,
- itemStyle: {
- opacity: 1
- },
- label: {
- show: false,
- distance: 2,
- textStyle: {
- fontSize: 14,
- color: '#000',
- backgroundColor: 'rgba(255,255,255,0.7)',
- padding: 3,
- borderRadius: 3
- }
- },
- emphasis: {
- label: {
- show: true
- }
- },
- animationDurationUpdate: 500
- }
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Bar3DSeries.prototype, __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__["a" /* default */]);
- /* unused harmony default export */ var _unused_webpack_default_export = (Bar3DSeries);
- /***/
- }),
- /* 232 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__line3D_Line3DSeries__ = __webpack_require__(233);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__line3D_Line3DView__ = __webpack_require__(234);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(51);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default()('line3D', 'circle', null));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__["a" /* default */])('line3D'));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout(function (ecModel, api) {
- ecModel.eachSeriesByType('line3D', function (seriesModel) {
- var data = seriesModel.getData();
- var coordSys = seriesModel.coordinateSystem;
- if (coordSys) {
- if (coordSys.type !== 'cartesian3D') {
- if (true) {
- console.error('line3D needs cartesian3D coordinateSystem');
- }
- return;
- }
- var points = new Float32Array(data.count() * 3);
- var item = [];
- var out = [];
- var coordDims = coordSys.dimensions;
- var dims = coordDims.map(function (coordDim) {
- return seriesModel.coordDimToDataDim(coordDim)[0];
- });
- if (coordSys) {
- data.each(dims, function (x, y, z, idx) {
- item[0] = x;
- item[1] = y;
- item[2] = z;
- coordSys.dataToPoint(item, out);
- points[idx * 3] = out[0];
- points[idx * 3 + 1] = out[1];
- points[idx * 3 + 2] = out[2];
- });
- }
- data.setLayout('points', points);
- }
- });
- });
- /***/
- }),
- /* 233 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__common_formatTooltip__ = __webpack_require__(39);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_createList__ = __webpack_require__(50);
- var Line3DSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({
- type: 'series.line3D',
- dependencies: ['grid3D'],
- visualColorAccessPath: 'lineStyle.color',
- getInitialData: function (option, ecModel) {
- return Object(__WEBPACK_IMPORTED_MODULE_2__common_createList__["a" /* default */])(this);
- },
- formatTooltip: function (dataIndex) {
- return Object(__WEBPACK_IMPORTED_MODULE_1__common_formatTooltip__["a" /* default */])(this, dataIndex);
- },
- defaultOption: {
- coordinateSystem: 'cartesian3D',
- zlevel: -10,
- // Cartesian coordinate system
- grid3DIndex: 0,
- lineStyle: {
- width: 2
- },
- animationDurationUpdate: 500
- }
- });
- /* unused harmony default export */ var _unused_webpack_default_export = (Line3DSeries);
- /***/
- }),
- /* 234 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(25);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_math_Matrix4__ = __webpack_require__(9);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Vector3__ = __webpack_require__(3);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_zrender_lib_contain_line__ = __webpack_require__(235);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_zrender_lib_contain_line___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_6_zrender_lib_contain_line__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__util_shader_lines3D_glsl_js__ = __webpack_require__(46);
- var vec3 = __WEBPACK_IMPORTED_MODULE_7_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_8__util_shader_lines3D_glsl_js__["a" /* default */]);
- /* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({
- type: 'line3D',
- __ecgl__: true,
- init: function (ecModel, api) {
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- this._api = api;
- },
- render: function (seriesModel, ecModel, api) {
- var tmp = this._prevLine3DMesh;
- this._prevLine3DMesh = this._line3DMesh;
- this._line3DMesh = tmp;
- if (!this._line3DMesh) {
- this._line3DMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__["a" /* default */]({
- useNativeLine: false,
- sortTriangles: true
- }),
- material: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.meshLines3D')
- }),
- // Render after axes
- renderOrder: 10
- });
- this._line3DMesh.geometry.pick = this._pick.bind(this);
- }
- this.groupGL.remove(this._prevLine3DMesh);
- this.groupGL.add(this._line3DMesh);
- var coordSys = seriesModel.coordinateSystem;
- if (coordSys && coordSys.viewGL) {
- coordSys.viewGL.add(this.groupGL);
- // TODO
- var methodName = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine';
- this._line3DMesh.material[methodName]('fragment', 'SRGB_DECODE');
- }
- this._doRender(seriesModel, api);
- this._data = seriesModel.getData();
- this._camera = coordSys.viewGL.camera;
- this.updateCamera();
- this._updateAnimation(seriesModel);
- },
- updateCamera: function () {
- this._updateNDCPosition();
- },
- _doRender: function (seriesModel, api) {
- var data = seriesModel.getData();
- var lineMesh = this._line3DMesh;
- lineMesh.geometry.resetOffset();
- var points = data.getLayout('points');
- var colorArr = [];
- var vertexColors = new Float32Array(points.length / 3 * 4);
- var colorOffset = 0;
- var hasTransparent = false;
- data.each(function (idx) {
- var color = data.getItemVisual(idx, 'color');
- var opacity = data.getItemVisual(idx, 'opacity');
- if (opacity == null) {
- opacity = 1;
- }
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color, colorArr);
- colorArr[3] *= opacity;
- vertexColors[colorOffset++] = colorArr[0];
- vertexColors[colorOffset++] = colorArr[1];
- vertexColors[colorOffset++] = colorArr[2];
- vertexColors[colorOffset++] = colorArr[3];
- if (colorArr[3] < 0.99) {
- hasTransparent = true;
- }
- });
- lineMesh.geometry.setVertexCount(
- lineMesh.geometry.getPolylineVertexCount(points)
- );
- lineMesh.geometry.setTriangleCount(
- lineMesh.geometry.getPolylineTriangleCount(points)
- );
- lineMesh.geometry.addPolyline(
- points, vertexColors,
- __WEBPACK_IMPORTED_MODULE_2__util_retrieve__["a" /* default */].firstNotNull(seriesModel.get('lineStyle.width'), 1)
- );
- lineMesh.geometry.dirty();
- lineMesh.geometry.updateBoundingBox();
- var material = lineMesh.material;
- material.transparent = hasTransparent;
- material.depthMask = !hasTransparent;
- var debugWireframeModel = seriesModel.getModel('debug.wireframe');
- if (debugWireframeModel.get('show')) {
- lineMesh.geometry.createAttribute('barycentric', 'float', 3);
- lineMesh.geometry.generateBarycentric();
- lineMesh.material.set('both', 'WIREFRAME_TRIANGLE');
- lineMesh.material.set(
- 'wireframeLineColor', __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(
- debugWireframeModel.get('lineStyle.color') || 'rgba(0,0,0,0.5)'
- )
- );
- lineMesh.material.set(
- 'wireframeLineWidth', __WEBPACK_IMPORTED_MODULE_2__util_retrieve__["a" /* default */].firstNotNull(
- debugWireframeModel.get('lineStyle.width'), 1
- )
- );
- }
- else {
- lineMesh.material.set('both', 'WIREFRAME_TRIANGLE');
- }
- this._points = points;
- this._initHandler(seriesModel, api);
- },
- _updateAnimation: function (seriesModel) {
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].updateVertexAnimation(
- [['prevPosition', 'position'],
- ['prevPositionPrev', 'positionPrev'],
- ['prevPositionNext', 'positionNext']],
- this._prevLine3DMesh,
- this._line3DMesh,
- seriesModel
- );
- },
- _initHandler: function (seriesModel, api) {
- var data = seriesModel.getData();
- var coordSys = seriesModel.coordinateSystem;
- var lineMesh = this._line3DMesh;
- var lastDataIndex = -1;
- lineMesh.seriesIndex = seriesModel.seriesIndex;
- lineMesh.off('mousemove');
- lineMesh.off('mouseout');
- lineMesh.on('mousemove', function (e) {
- var value = coordSys.pointToData(e.point.array);
- var dataIndex = data.indicesOfNearest('x', value[0])[0];
- if (dataIndex !== lastDataIndex) {
- // this._downplay(lastDataIndex);
- // this._highlight(dataIndex);
- api.dispatchAction({
- type: 'grid3DShowAxisPointer',
- value: [data.get('x', dataIndex), data.get('y', dataIndex), data.get('z', dataIndex)]
- });
- lineMesh.dataIndex = dataIndex;
- }
- lastDataIndex = dataIndex;
- }, this);
- lineMesh.on('mouseout', function (e) {
- // this._downplay(lastDataIndex);
- lastDataIndex = -1;
- lineMesh.dataIndex = -1;
- api.dispatchAction({
- type: 'grid3DHideAxisPointer'
- });
- }, this);
- },
- // _highlight: function (dataIndex) {
- // var data = this._data;
- // if (!data) {
- // return;
- // }
- // },
- // _downplay: function (dataIndex) {
- // var data = this._data;
- // if (!data) {
- // return;
- // }
- // },
- _updateNDCPosition: function () {
- var worldViewProjection = new __WEBPACK_IMPORTED_MODULE_4_claygl_src_math_Matrix4__["a" /* default */]();
- var camera = this._camera;
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_math_Matrix4__["a" /* default */].multiply(worldViewProjection, camera.projectionMatrix, camera.viewMatrix);
- var positionNDC = this._positionNDC;
- var points = this._points;
- var nPoints = points.length / 3;
- if (!positionNDC || positionNDC.length / 2 !== nPoints) {
- positionNDC = this._positionNDC = new Float32Array(nPoints * 2);
- }
- var pos = [];
- for (var i = 0; i < nPoints; i++) {
- var i3 = i * 3;
- var i2 = i * 2;
- pos[0] = points[i3];
- pos[1] = points[i3 + 1];
- pos[2] = points[i3 + 2];
- pos[3] = 1;
- vec3.transformMat4(pos, pos, worldViewProjection.array);
- positionNDC[i2] = pos[0] / pos[3];
- positionNDC[i2 + 1] = pos[1] / pos[3];
- }
- },
- _pick: function (x, y, renderer, camera, renderable, out) {
- var positionNDC = this._positionNDC;
- var seriesModel = this._data.hostModel;
- var lineWidth = seriesModel.get('lineStyle.width');
- var dataIndex = -1;
- var width = renderer.viewport.width;
- var height = renderer.viewport.height;
- var halfWidth = width * 0.5;
- var halfHeight = height * 0.5;
- x = (x + 1) * halfWidth;
- y = (y + 1) * halfHeight;
- for (var i = 1; i < positionNDC.length / 2; i++) {
- var x0 = (positionNDC[(i - 1) * 2] + 1) * halfWidth;
- var y0 = (positionNDC[(i - 1) * 2 + 1] + 1) * halfHeight;
- var x1 = (positionNDC[i * 2] + 1) * halfWidth;
- var y1 = (positionNDC[i * 2 + 1] + 1) * halfHeight;
- if (__WEBPACK_IMPORTED_MODULE_6_zrender_lib_contain_line___default.a.containStroke(x0, y0, x1, y1, lineWidth, x, y)) {
- var dist0 = (x0 - x) * (x0 - x) + (y0 - y) * (y0 - y);
- var dist1 = (x1 - x) * (x1 - x) + (y1 - y) * (y1 - y);
- // Nearest point.
- dataIndex = dist0 < dist1 ? (i - 1) : i;
- }
- }
- if (dataIndex >= 0) {
- var i3 = dataIndex * 3;
- var point = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_math_Vector3__["a" /* default */](
- this._points[i3],
- this._points[i3 + 1],
- this._points[i3 + 2]
- );
- out.push({
- dataIndex: dataIndex,
- point: point,
- pointWorld: point.clone(),
- target: this._line3DMesh,
- distance: this._camera.getWorldPosition().dist(point)
- });
- }
- },
- remove: function () {
- this.groupGL.removeAll();
- },
- dispose: function () {
- this.groupGL.removeAll();
- }
- }));
- /***/
- }),
- /* 235 */
- /***/ (function (module, exports) {
- /**
- * 线段包å«åˆ¤æ–
- * @param {number} x0
- * @param {number} y0
- * @param {number} x1
- * @param {number} y1
- * @param {number} lineWidth
- * @param {number} x
- * @param {number} y
- * @return {boolean}
- */
- function containStroke(x0, y0, x1, y1, lineWidth, x, y) {
- if (lineWidth === 0) {
- return false;
- }
- var _l = lineWidth;
- var _a = 0;
- var _b = x0; // Quick reject
- if (y > y0 + _l && y > y1 + _l || y < y0 - _l && y < y1 - _l || x > x0 + _l && x > x1 + _l || x < x0 - _l && x < x1 - _l) {
- return false;
- }
- if (x0 !== x1) {
- _a = (y0 - y1) / (x0 - x1);
- _b = (x0 * y1 - x1 * y0) / (x0 - x1);
- } else {
- return Math.abs(x - x0) <= _l / 2;
- }
- var tmp = _a * x - y + _b;
- var _s = tmp * tmp / (_a * _a + 1);
- return _s <= _l / 2 * _l / 2;
- }
- exports.containStroke = containStroke;
- /***/
- }),
- /* 236 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__scatter3D_Scatter3DSeries__ = __webpack_require__(237);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__scatter3D_Scatter3DView__ = __webpack_require__(238);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(51);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default()('scatter3D', 'circle', null));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__["a" /* default */])('scatter3D'));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout({
- seriesType: 'scatter3D',
- reset: function (seriesModel) {
- var coordSys = seriesModel.coordinateSystem;
- if (coordSys) {
- var coordDims = coordSys.dimensions;
- if (coordDims.length < 3) {
- if (true) {
- console.error('scatter3D needs 3D coordinateSystem');
- }
- return;
- }
- var dims = coordDims.map(function (coordDim) {
- return seriesModel.coordDimToDataDim(coordDim)[0];
- });
- var item = [];
- var out = [];
- return {
- progress: function (params, data) {
- var points = new Float32Array((params.end - params.start) * 3);
- for (var idx = params.start; idx < params.end; idx++) {
- var idx3 = (idx - params.start) * 3;
- item[0] = data.get(dims[0], idx);
- item[1] = data.get(dims[1], idx);
- item[2] = data.get(dims[2], idx);
- coordSys.dataToPoint(item, out);
- points[idx3] = out[0];
- points[idx3 + 1] = out[1];
- points[idx3 + 2] = out[2];
- }
- data.setLayout('points', points);
- }
- };
- }
- }
- });
- /***/
- }),
- /* 237 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_format__ = __webpack_require__(32);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_formatTooltip__ = __webpack_require__(39);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_createList__ = __webpack_require__(50);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({
- type: 'series.scatter3D',
- dependencies: ['globe', 'grid3D', 'geo3D'],
- visualColorAccessPath: 'itemStyle.color',
- getInitialData: function (option, ecModel) {
- return Object(__WEBPACK_IMPORTED_MODULE_3__common_createList__["a" /* default */])(this);
- },
- getFormattedLabel: function (dataIndex, status, dataType, dimIndex) {
- var text = __WEBPACK_IMPORTED_MODULE_1__util_format__["a" /* default */].getFormattedLabel(this, dataIndex, status, dataType, dimIndex);
- if (text == null) {
- var data = this.getData();
- var lastDim = data.dimensions[data.dimensions.length - 1];
- text = data.get(lastDim, dataIndex);
- }
- return text;
- },
- formatTooltip: function (dataIndex) {
- return Object(__WEBPACK_IMPORTED_MODULE_2__common_formatTooltip__["a" /* default */])(this, dataIndex);
- },
- defaultOption: {
- coordinateSystem: 'cartesian3D',
- zlevel: -10,
- progressive: 1e5,
- progressiveThreshold: 1e5,
- // Cartesian coordinate system
- grid3DIndex: 0,
- globeIndex: 0,
- symbol: 'circle',
- symbolSize: 10,
- // Support source-over, lighter
- blendMode: 'source-over',
- label: {
- show: false,
- position: 'right',
- // Screen space distance
- distance: 5,
- textStyle: {
- fontSize: 14,
- color: '#000',
- backgroundColor: 'rgba(255,255,255,0.7)',
- padding: 3,
- borderRadius: 3
- }
- },
- itemStyle: {
- opacity: 0.8
- },
- emphasis: {
- label: {
- show: true
- }
- },
- animationDurationUpdate: 500
- }
- });
- /***/
- }),
- /* 238 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_format__ = __webpack_require__(32);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_PointsBuilder__ = __webpack_require__(67);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({
- type: 'scatter3D',
- __ecgl__: true,
- init: function (ecModel, api) {
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- this._pointsBuilderList = [];
- this._currentStep = 0;
- },
- render: function (seriesModel, ecModel, api) {
- this.groupGL.removeAll();
- if (!seriesModel.getData().count()) {
- return;
- }
- var coordSys = seriesModel.coordinateSystem;
- if (coordSys && coordSys.viewGL) {
- coordSys.viewGL.add(this.groupGL);
- this._camera = coordSys.viewGL.camera;
- var pointsBuilder = this._pointsBuilderList[0];
- if (!pointsBuilder) {
- pointsBuilder = this._pointsBuilderList[0] = new __WEBPACK_IMPORTED_MODULE_4__common_PointsBuilder__["a" /* default */](false, api);
- }
- this._pointsBuilderList.length = 1;
- this.groupGL.add(pointsBuilder.rootNode);
- pointsBuilder.update(seriesModel, ecModel, api);
- pointsBuilder.updateView(coordSys.viewGL.camera);
- }
- else {
- if (true) {
- throw new Error('Invalid coordinate system');
- }
- }
- },
- incrementalPrepareRender: function (seriesModel, ecModel, api) {
- var coordSys = seriesModel.coordinateSystem;
- if (coordSys && coordSys.viewGL) {
- coordSys.viewGL.add(this.groupGL);
- this._camera = coordSys.viewGL.camera;
- }
- else {
- if (true) {
- throw new Error('Invalid coordinate system');
- }
- }
- this.groupGL.removeAll();
- this._currentStep = 0;
- },
- incrementalRender: function (params, seriesModel, ecModel, api) {
- // TODO Sort transparency.
- if (params.end <= params.start) {
- return;
- }
- var pointsBuilder = this._pointsBuilderList[this._currentStep];
- if (!pointsBuilder) {
- pointsBuilder = new __WEBPACK_IMPORTED_MODULE_4__common_PointsBuilder__["a" /* default */](false, api);
- this._pointsBuilderList[this._currentStep] = pointsBuilder;
- }
- this.groupGL.add(pointsBuilder.rootNode);
- pointsBuilder.update(seriesModel, ecModel, api, params.start, params.end);
- pointsBuilder.updateView(seriesModel.coordinateSystem.viewGL.camera);
- this._currentStep++;
- },
- updateCamera: function () {
- this._pointsBuilderList.forEach(function (pointsBuilder) {
- pointsBuilder.updateView(this._camera);
- }, this);
- },
- highlight: function (seriesModel, ecModel, api, payload) {
- this._toggleStatus('highlight', seriesModel, ecModel, api, payload);
- },
- downplay: function (seriesModel, ecModel, api, payload) {
- this._toggleStatus('downplay', seriesModel, ecModel, api, payload);
- },
- _toggleStatus: function (status, seriesModel, ecModel, api, payload) {
- var data = seriesModel.getData();
- var dataIndex = __WEBPACK_IMPORTED_MODULE_2__util_retrieve__["a" /* default */].queryDataIndex(data, payload);
- var isHighlight = status === 'highlight';
- if (dataIndex != null) {
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.each(__WEBPACK_IMPORTED_MODULE_3__util_format__["a" /* default */].normalizeToArray(dataIndex), function (dataIdx) {
- for (var i = 0; i < this._pointsBuilderList.length; i++) {
- var pointsBuilder = this._pointsBuilderList[i];
- isHighlight ? pointsBuilder.highlight(data, dataIdx) : pointsBuilder.downplay(data, dataIdx);
- }
- }, this);
- }
- else {
- // PENDING, OPTIMIZE
- data.each(function (dataIdx) {
- for (var i = 0; i < this._pointsBuilderList.length; i++) {
- var pointsBuilder = this._pointsBuilderList[i];
- isHighlight ? pointsBuilder.highlight(data, dataIdx) : pointsBuilder.downplay(data, dataIdx);
- }
- });
- }
- },
- dispose: function () {
- this.groupGL.removeAll();
- },
- remove: function () {
- this.groupGL.removeAll();
- }
- });
- /***/
- }),
- /* 239 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- function makeSprite(size, canvas, draw) {
- // http://simonsarris.com/blog/346-how-you-clear-your-canvas-matters
- // http://jsperf.com/canvasclear
- // Set width and height is fast
- // And use the exist canvas if possible
- // http://jsperf.com/create-canvas-vs-set-width-height/2
- var canvas = canvas || document.createElement('canvas');
- canvas.width = size;
- canvas.height = size;
- var ctx = canvas.getContext('2d');
- draw && draw(ctx);
- return canvas;
- }
- function makePath(symbol, symbolSize, style, marginBias) {
- if (!__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.isArray(symbolSize)) {
- symbolSize = [symbolSize, symbolSize];
- }
- var margin = spriteUtil.getMarginByStyle(style, marginBias);
- var width = symbolSize[0] + margin.left + margin.right;
- var height = symbolSize[1] + margin.top + margin.bottom;
- var path = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.createSymbol(symbol, 0, 0, symbolSize[0], symbolSize[1]);
- var size = Math.max(width, height);
- path.position = [margin.left, margin.top];
- if (width > height) {
- path.position[1] += (size - height) / 2;
- }
- else {
- path.position[0] += (size - width) / 2;
- }
- var rect = path.getBoundingRect();
- path.position[0] -= rect.x;
- path.position[1] -= rect.y;
- path.setStyle(style);
- path.update();
- path.__size = size;
- return path;
- }
- // http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf
- function generateSDF(ctx, sourceImageData, range) {
- var sourceWidth = sourceImageData.width;
- var sourceHeight = sourceImageData.height;
- var width = ctx.canvas.width;
- var height = ctx.canvas.height;
- var scaleX = sourceWidth / width;
- var scaleY = sourceHeight / height;
- function sign(r) {
- return r < 128 ? 1 : -1;
- }
- function searchMinDistance(x, y) {
- var minDistSqr = Infinity;
- x = Math.floor(x * scaleX);
- y = Math.floor(y * scaleY);
- var i = y * sourceWidth + x;
- var r = sourceImageData.data[i * 4];
- var a = sign(r);
- // Search for min distance
- for (var y2 = Math.max(y - range, 0); y2 < Math.min(y + range, sourceHeight); y2++) {
- for (var x2 = Math.max(x - range, 0); x2 < Math.min(x + range, sourceWidth); x2++) {
- var i = y2 * sourceWidth + x2;
- var r2 = sourceImageData.data[i * 4];
- var b = sign(r2);
- var dx = x2 - x;
- var dy = y2 - y;
- if (a !== b) {
- var distSqr = dx * dx + dy * dy;
- if (distSqr < minDistSqr) {
- minDistSqr = distSqr;
- }
- }
- }
- }
- return a * Math.sqrt(minDistSqr);
- }
- var sdfImageData = ctx.createImageData(width, height);
- for (var y = 0; y < height; y++) {
- for (var x = 0; x < width; x++) {
- var dist = searchMinDistance(x, y);
- var normalized = dist / range * 0.5 + 0.5;
- var i = (y * width + x) * 4;
- sdfImageData.data[i++] = (1.0 - normalized) * 255;
- sdfImageData.data[i++] = (1.0 - normalized) * 255;
- sdfImageData.data[i++] = (1.0 - normalized) * 255;
- sdfImageData.data[i++] = 255;
- }
- }
- return sdfImageData;
- }
- var spriteUtil = {
- getMarginByStyle: function (style) {
- var minMargin = style.minMargin || 0;
- var lineWidth = 0;
- if (style.stroke && style.stroke !== 'none') {
- lineWidth = style.lineWidth == null ? 1 : style.lineWidth;
- }
- var shadowBlurSize = style.shadowBlur || 0;
- var shadowOffsetX = style.shadowOffsetX || 0;
- var shadowOffsetY = style.shadowOffsetY || 0;
- var margin = {};
- margin.left = Math.max(lineWidth / 2, -shadowOffsetX + shadowBlurSize, minMargin);
- margin.right = Math.max(lineWidth / 2, shadowOffsetX + shadowBlurSize, minMargin);
- margin.top = Math.max(lineWidth / 2, -shadowOffsetY + shadowBlurSize, minMargin);
- margin.bottom = Math.max(lineWidth / 2, shadowOffsetY + shadowBlurSize, minMargin);
- return margin;
- },
- // TODO Not consider shadowOffsetX, shadowOffsetY.
- /**
- * @param {string} symbol
- * @param {number | Array.<number>} symbolSize
- * @param {Object} style
- */
- createSymbolSprite: function (symbol, symbolSize, style, canvas) {
- var path = makePath(symbol, symbolSize, style);
- var margin = spriteUtil.getMarginByStyle(style);
- return {
- image: makeSprite(path.__size, canvas, function (ctx) {
- path.brush(ctx);
- }),
- margin: margin
- };
- },
- createSDFFromCanvas: function (canvas, size, range, outCanvas) {
- // TODO Create a low resolution SDF from high resolution image.
- return makeSprite(size, outCanvas, function (outCtx) {
- var ctx = canvas.getContext('2d');
- var imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
- outCtx.putImageData(generateSDF(outCtx, imgData, range), 0, 0);
- });
- },
- createSimpleSprite: function (size, canvas) {
- return makeSprite(size, canvas, function (ctx) {
- var halfSize = size / 2;
- ctx.beginPath();
- ctx.arc(halfSize, halfSize, 60, 0, Math.PI * 2, false);
- ctx.closePath();
- var gradient = ctx.createRadialGradient(
- halfSize, halfSize, 0, halfSize, halfSize, halfSize
- );
- gradient.addColorStop(0, 'rgba(255, 255, 255, 1)');
- gradient.addColorStop(0.5, 'rgba(255, 255, 255, 0.5)');
- gradient.addColorStop(1, 'rgba(255, 255, 255, 0)');
- ctx.fillStyle = gradient;
- ctx.fill();
- });
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (spriteUtil);
- /***/
- }),
- /* 240 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_geometry_verticesSortMixin__ = __webpack_require__(241);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__sdfSprite_glsl_js__ = __webpack_require__(242);
- var vec4 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__["a" /* default */].vec4;
- __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_4__sdfSprite_glsl_js__["a" /* default */]);
- var PointsMesh = __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Mesh.extend(function () {
- var geometry = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Geometry({
- dynamic: true,
- attributes: {
- color: new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Geometry.Attribute('color', 'float', 4, 'COLOR'),
- position: new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Geometry.Attribute('position', 'float', 3, 'POSITION'),
- size: new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Geometry.Attribute('size', 'float', 1),
- prevPosition: new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Geometry.Attribute('prevPosition', 'float', 3),
- prevSize: new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Geometry.Attribute('prevSize', 'float', 1)
- }
- });
- __WEBPACK_IMPORTED_MODULE_2_echarts_lib_echarts___default.a.util.extend(geometry, __WEBPACK_IMPORTED_MODULE_1__util_geometry_verticesSortMixin__["a" /* default */]);
- var material = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Material({
- shader: __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].createShader('ecgl.sdfSprite'),
- transparent: true,
- depthMask: false
- });
- material.enableTexture('sprite');
- material.define('both', 'VERTEX_COLOR');
- material.define('both', 'VERTEX_SIZE');
- var sdfTexture = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Texture2D({
- image: document.createElement('canvas'),
- flipY: false
- });
- material.set('sprite', sdfTexture);
- // Custom pick methods.
- geometry.pick = this._pick.bind(this);
- return {
- geometry: geometry,
- material: material,
- mode: __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Mesh.POINTS,
- sizeScale: 1
- };
- }, {
- _pick: function (x, y, renderer, camera, renderable, out) {
- var positionNDC = this._positionNDC;
- if (!positionNDC) {
- return;
- }
- var viewport = renderer.viewport;
- var ndcScaleX = 2 / viewport.width;
- var ndcScaleY = 2 / viewport.height;
- // From near to far. indices have been sorted.
- for (var i = this.geometry.vertexCount - 1; i >= 0; i--) {
- var idx;
- if (!this.geometry.indices) {
- idx = i;
- }
- else {
- idx = this.geometry.indices[i];
- }
- var cx = positionNDC[idx * 2];
- var cy = positionNDC[idx * 2 + 1];
- var size = this.geometry.attributes.size.get(idx) / this.sizeScale;
- var halfSize = size / 2;
- if (
- x > (cx - halfSize * ndcScaleX) && x < (cx + halfSize * ndcScaleX)
- && y > (cy - halfSize * ndcScaleY) && y < (cy + halfSize * ndcScaleY)
- ) {
- var point = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Vector3();
- var pointWorld = new __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Vector3();
- this.geometry.attributes.position.get(idx, point.array);
- __WEBPACK_IMPORTED_MODULE_0__util_graphicGL__["a" /* default */].Vector3.transformMat4(pointWorld, point, this.worldTransform);
- out.push({
- vertexIndex: idx,
- point: point,
- pointWorld: pointWorld,
- target: this,
- distance: pointWorld.distance(camera.getWorldPosition())
- });
- }
- }
- },
- updateNDCPosition: function (worldViewProjection, is2D, api) {
- var positionNDC = this._positionNDC;
- var geometry = this.geometry;
- if (!positionNDC || positionNDC.length / 2 !== geometry.vertexCount) {
- positionNDC = this._positionNDC = new Float32Array(geometry.vertexCount * 2);
- }
- var pos = vec4.create();
- for (var i = 0; i < geometry.vertexCount; i++) {
- geometry.attributes.position.get(i, pos);
- pos[3] = 1;
- vec4.transformMat4(pos, pos, worldViewProjection.array);
- vec4.scale(pos, pos, 1 / pos[3]);
- positionNDC[i * 2] = pos[0];
- positionNDC[i * 2 + 1] = pos[1];
- }
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (PointsMesh);
- /***/
- }),
- /* 241 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__ = __webpack_require__(97);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- /* harmony default export */ __webpack_exports__["a"] = ({
- needsSortVertices: function () {
- return this.sortVertices;
- },
- needsSortVerticesProgressively: function () {
- return this.needsSortVertices() && this.vertexCount >= 2e4;
- },
- doSortVertices: function (cameraPos, frame) {
- var indices = this.indices;
- var p = vec3.create();
- if (!indices) {
- indices = this.indices = this.vertexCount > 0xffff ? new Uint32Array(this.vertexCount) : new Uint16Array(this.vertexCount);
- for (var i = 0; i < indices.length; i++) {
- indices[i] = i;
- }
- }
- // Do progressive quick sort.
- if (frame === 0) {
- var posAttr = this.attributes.position;
- var cameraPos = cameraPos.array;
- var noneCount = 0;
- if (!this._zList || this._zList.length !== this.vertexCount) {
- this._zList = new Float32Array(this.vertexCount);
- }
- var firstZ;
- for (var i = 0; i < this.vertexCount; i++) {
- posAttr.get(i, p);
- // Camera position is in object space
- var z = vec3.sqrDist(p, cameraPos);
- if (isNaN(z)) {
- // Put far away, NaN value may cause sort slow
- z = 1e7;
- noneCount++;
- }
- if (i === 0) {
- firstZ = z;
- z = 0;
- }
- else {
- // Only store the difference to avoid the precision issue.
- z = z - firstZ;
- }
- this._zList[i] = z;
- }
- this._noneCount = noneCount;
- }
- if (this.vertexCount < 2e4) {
- // Use simple native sort for simple geometries.
- if (frame === 0) {
- this._simpleSort(this._noneCount / this.vertexCount > 0.05);
- }
- }
- else {
- for (var i = 0; i < 3; i++) {
- this._progressiveQuickSort(frame * 3 + i);
- }
- }
- this.dirtyIndices();
- },
- _simpleSort: function (useNativeQuickSort) {
- var zList = this._zList;
- var indices = this.indices;
- function compare(a, b) {
- // Sort from far to near. which is descending order
- return zList[b] - zList[a];
- }
- // When too much value are equal, using native quick sort with three partition..
- // or the simple quick sort will be nearly O(n*n)
- // http://stackoverflow.com/questions/5126586/quicksort-complexity-when-all-the-elements-are-same
- // Otherwise simple quicksort is more effecient than v8 native quick sort when data all different.
- if (useNativeQuickSort) {
- Array.prototype.sort.call(indices, compare);
- }
- else {
- __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__["a" /* default */].sort(indices, compare, 0, indices.length - 1);
- }
- },
- _progressiveQuickSort: function (frame) {
- var zList = this._zList;
- var indices = this.indices;
- this._quickSort = this._quickSort || new __WEBPACK_IMPORTED_MODULE_0__ProgressiveQuickSort__["a" /* default */]();
- this._quickSort.step(indices, function (a, b) {
- return zList[b] - zList[a];
- }, frame);
- }
- });
- /***/
- }),
- /* 242 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.sdfSprite.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform float elapsedTime : 0;\n\nattribute vec3 position : POSITION;\n\n#ifdef VERTEX_SIZE\nattribute float size;\n#else\nuniform float u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\nattribute vec4 a_FillColor: COLOR;\nvarying vec4 v_Color;\n#endif\n\n#ifdef VERTEX_ANIMATION\nattribute vec3 prevPosition;\nattribute float prevSize;\nuniform float percent : 1.0;\n#endif\n\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvarying float v_Size;\n\nvoid main()\n{\n\n#ifdef POSITIONTEXTURE_ENABLED\n gl_Position = worldViewProjection * vec4(texture2D(positionTexture, position.xy).xy, -10.0, 1.0);\n#else\n\n #ifdef VERTEX_ANIMATION\n vec3 pos = mix(prevPosition, position, percent);\n #else\n vec3 pos = position;\n #endif\n gl_Position = worldViewProjection * vec4(pos, 1.0);\n#endif\n\n#ifdef VERTEX_SIZE\n#ifdef VERTEX_ANIMATION\n v_Size = mix(prevSize, size, percent);\n#else\n v_Size = size;\n#endif\n#else\n v_Size = u_Size;\n#endif\n\n#ifdef VERTEX_COLOR\n v_Color = a_FillColor;\n #endif\n\n gl_PointSize = v_Size;\n}\n\n@end\n\n@export ecgl.sdfSprite.fragment\n\nuniform vec4 color: [1, 1, 1, 1];\nuniform vec4 strokeColor: [1, 1, 1, 1];\nuniform float smoothing: 0.07;\n\nuniform float lineWidth: 0.0;\n\n#ifdef VERTEX_COLOR\nvarying vec4 v_Color;\n#endif\n\nvarying float v_Size;\n\nuniform sampler2D sprite;\n\n@import clay.util.srgb\n\nvoid main()\n{\n gl_FragColor = color;\n\n vec4 _strokeColor = strokeColor;\n\n#ifdef VERTEX_COLOR\n gl_FragColor *= v_Color;\n #endif\n\n#ifdef SPRITE_ENABLED\n float d = texture2D(sprite, gl_PointCoord).r;\n gl_FragColor.a *= smoothstep(0.5 - smoothing, 0.5 + smoothing, d);\n\n if (lineWidth > 0.0) {\n float sLineWidth = lineWidth / 2.0;\n\n float outlineMaxValue0 = 0.5 + sLineWidth;\n float outlineMaxValue1 = 0.5 + sLineWidth + smoothing;\n float outlineMinValue0 = 0.5 - sLineWidth - smoothing;\n float outlineMinValue1 = 0.5 - sLineWidth;\n\n if (d <= outlineMaxValue1 && d >= outlineMinValue0) {\n float a = _strokeColor.a;\n if (d <= outlineMinValue1) {\n a = a * smoothstep(outlineMinValue0, outlineMinValue1, d);\n }\n else {\n a = a * smoothstep(outlineMaxValue1, outlineMaxValue0, d);\n }\n gl_FragColor.rgb = mix(gl_FragColor.rgb * gl_FragColor.a, _strokeColor.rgb, a);\n gl_FragColor.a = gl_FragColor.a * (1.0 - a) + a;\n }\n }\n#endif\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(gl_FragColor);\n#endif\n}\n@end");
- /***/
- }),
- /* 243 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__lines3D_lines3DLayout__ = __webpack_require__(244);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__lines3D_Lines3DView__ = __webpack_require__(245);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__lines3D_Lines3DSeries__ = __webpack_require__(248);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__["a" /* default */])('lines3D'));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'lines3DPauseEffect',
- event: 'lines3deffectpaused',
- update: 'series.lines3D:pauseEffect'
- }, function () { });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'lines3DResumeEffect',
- event: 'lines3deffectresumed',
- update: 'series.lines3D:resumeEffect'
- }, function () { });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'lines3DToggleEffect',
- event: 'lines3deffectchanged',
- update: 'series.lines3D:toggleEffect'
- }, function () { });
- /***/
- }),
- /* 244 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- var vec3 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- var vec2 = __WEBPACK_IMPORTED_MODULE_1_claygl_src_dep_glmatrix__["a" /* default */].vec2;
- var normalize = vec3.normalize;
- var cross = vec3.cross;
- var sub = vec3.sub;
- var add = vec3.add;
- var create = vec3.create;
- var normal = create();
- var tangent = create();
- var bitangent = create();
- var halfVector = create();
- var coord0 = [];
- var coord1 = [];
- function getCubicPointsOnGlobe(coords, coordSys) {
- vec2.copy(coord0, coords[0]);
- vec2.copy(coord1, coords[1]);
- var pts = [];
- var p0 = pts[0] = create();
- var p1 = pts[1] = create();
- var p2 = pts[2] = create();
- var p3 = pts[3] = create();
- coordSys.dataToPoint(coord0, p0);
- coordSys.dataToPoint(coord1, p3);
- // Get p1
- normalize(normal, p0);
- // TODO p0-p3 is parallel with normal
- sub(tangent, p3, p0);
- normalize(tangent, tangent);
- cross(bitangent, tangent, normal);
- normalize(bitangent, bitangent);
- cross(tangent, normal, bitangent);
- // p1 is half vector of p0 and tangent on p0
- add(p1, normal, tangent);
- normalize(p1, p1);
- // Get p2
- normalize(normal, p3);
- sub(tangent, p0, p3);
- normalize(tangent, tangent);
- cross(bitangent, tangent, normal);
- normalize(bitangent, bitangent);
- cross(tangent, normal, bitangent);
- // p2 is half vector of p3 and tangent on p3
- add(p2, normal, tangent);
- normalize(p2, p2);
- // Project distance of p0 on halfVector
- add(halfVector, p0, p3);
- normalize(halfVector, halfVector);
- var projDist = vec3.dot(p0, halfVector);
- // Angle of halfVector and p1
- var cosTheta = vec3.dot(halfVector, p1);
- var len = (Math.max(vec3.len(p0), vec3.len(p3)) - projDist) / cosTheta * 2;
- vec3.scaleAndAdd(p1, p0, p1, len);
- vec3.scaleAndAdd(p2, p3, p2, len);
- return pts;
- }
- function getCubicPointsOnPlane(coords, coordSys, up) {
- var pts = [];
- var p0 = pts[0] = vec3.create();
- var p1 = pts[1] = vec3.create();
- var p2 = pts[2] = vec3.create();
- var p3 = pts[3] = vec3.create();
- coordSys.dataToPoint(coords[0], p0);
- coordSys.dataToPoint(coords[1], p3);
- var len = vec3.dist(p0, p3);
- vec3.lerp(p1, p0, p3, 0.3);
- vec3.lerp(p2, p0, p3, 0.3);
- vec3.scaleAndAdd(p1, p1, up, Math.min(len * 0.1, 10));
- vec3.scaleAndAdd(p2, p2, up, Math.min(len * 0.1, 10));
- return pts;
- }
- function getPolylinePoints(coords, coordSys) {
- var pts = new Float32Array(coords.length * 3);
- var off = 0;
- var pt = [];
- for (var i = 0; i < coords.length; i++) {
- coordSys.dataToPoint(coords[i], pt);
- pts[off++] = pt[0];
- pts[off++] = pt[1];
- pts[off++] = pt[2];
- }
- return pts;
- }
- function prepareCoords(data) {
- var coordsList = [];
- data.each(function (idx) {
- var itemModel = data.getItemModel(idx);
- var coords = (itemModel.option instanceof Array) ?
- itemModel.option : itemModel.getShallow('coords', true);
- if (true) {
- if (!(coords instanceof Array && coords.length > 0 && coords[0] instanceof Array)) {
- throw new Error('Invalid coords ' + JSON.stringify(coords) + '. Lines must have 2d coords array in data item.');
- }
- }
- coordsList.push(coords);
- });
- return {
- coordsList: coordsList
- };
- }
- function layoutGlobe(seriesModel, coordSys) {
- var data = seriesModel.getData();
- var isPolyline = seriesModel.get('polyline');
- data.setLayout('lineType', isPolyline ? 'polyline' : 'cubicBezier');
- var res = prepareCoords(data);
- data.each(function (idx) {
- var coords = res.coordsList[idx];
- var getPointsMethod = isPolyline ? getPolylinePoints : getCubicPointsOnGlobe;
- data.setItemLayout(idx, getPointsMethod(coords, coordSys));
- });
- }
- function layoutOnPlane(seriesModel, coordSys, normal) {
- var data = seriesModel.getData();
- var isPolyline = seriesModel.get('polyline');
- var res = prepareCoords(data);
- data.setLayout('lineType', isPolyline ? 'polyline' : 'cubicBezier');
- data.each(function (idx) {
- var coords = res.coordsList[idx];
- var pts = isPolyline ? getPolylinePoints(coords, coordSys)
- : getCubicPointsOnPlane(coords, coordSys, normal);
- data.setItemLayout(idx, pts);
- });
- }
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout(function (ecModel, api) {
- ecModel.eachSeriesByType('lines3D', function (seriesModel) {
- var coordSys = seriesModel.coordinateSystem;
- if (coordSys.type === 'globe') {
- layoutGlobe(seriesModel, coordSys);
- }
- else if (coordSys.type === 'geo3D') {
- layoutOnPlane(seriesModel, coordSys, [0, 1, 0]);
- }
- else if (coordSys.type === 'mapbox3D' || coordSys.type === 'maptalks3D') {
- layoutOnPlane(seriesModel, coordSys, [0, 0, 1]);
- }
- });
- });
- /***/
- }),
- /* 245 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_geometry_Lines3D__ = __webpack_require__(25);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__TrailMesh2__ = __webpack_require__(246);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_shader_lines3D_glsl_js__ = __webpack_require__(46);
- // import TrailMesh from './TrailMesh';
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_4__util_shader_lines3D_glsl_js__["a" /* default */]);
- function getCoordSysSize(coordSys) {
- if (coordSys.radius != null) {
- return coordSys.radius;
- }
- if (coordSys.size != null) {
- return Math.max(coordSys.size[0], coordSys.size[1], coordSys.size[2]);
- }
- else {
- return 100;
- }
- }
- /* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({
- type: 'lines3D',
- __ecgl__: true,
- init: function (ecModel, api) {
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- this._meshLinesMaterial = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.meshLines3D'),
- transparent: true,
- depthMask: false
- });
- this._linesMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_2__util_geometry_Lines3D__["a" /* default */](),
- material: this._meshLinesMaterial,
- $ignorePicking: true
- });
- // this._trailMesh = new TrailMesh();
- this._trailMesh = new __WEBPACK_IMPORTED_MODULE_3__TrailMesh2__["a" /* default */]();
- },
- render: function (seriesModel, ecModel, api) {
- this.groupGL.add(this._linesMesh);
- var coordSys = seriesModel.coordinateSystem;
- var data = seriesModel.getData();
- if (coordSys && coordSys.viewGL) {
- var viewGL = coordSys.viewGL;
- viewGL.add(this.groupGL);
- this._updateLines(seriesModel, ecModel, api);
- var methodName = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine';
- this._linesMesh.material[methodName]('fragment', 'SRGB_DECODE');
- this._trailMesh.material[methodName]('fragment', 'SRGB_DECODE');
- }
- var trailMesh = this._trailMesh;
- trailMesh.stopAnimation();
- if (seriesModel.get('effect.show')) {
- this.groupGL.add(trailMesh);
- trailMesh.updateData(data, api, this._linesMesh.geometry);
- trailMesh.__time = trailMesh.__time || 0;
- var time = 3600 * 1000; // 1hour
- this._curveEffectsAnimator = trailMesh.animate('', { loop: true })
- .when(time, {
- __time: time
- })
- .during(function () {
- trailMesh.setAnimationTime(trailMesh.__time);
- })
- .start();
- }
- else {
- this.groupGL.remove(trailMesh);
- this._curveEffectsAnimator = null;
- }
- this._linesMesh.material.blend = this._trailMesh.material.blend
- = seriesModel.get('blendMode') === 'lighter'
- ? __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].additiveBlend : null;
- },
- pauseEffect: function () {
- if (this._curveEffectsAnimator) {
- this._curveEffectsAnimator.pause();
- }
- },
- resumeEffect: function () {
- if (this._curveEffectsAnimator) {
- this._curveEffectsAnimator.resume();
- }
- },
- toggleEffect: function () {
- var animator = this._curveEffectsAnimator;
- if (animator) {
- animator.isPaused() ? animator.resume() : animator.pause();
- }
- },
- _updateLines: function (seriesModel, ecModel, api) {
- var data = seriesModel.getData();
- var coordSys = seriesModel.coordinateSystem;
- var geometry = this._linesMesh.geometry;
- var isPolyline = seriesModel.get('polyline');
- geometry.expandLine = true;
- var size = getCoordSysSize(coordSys);
- geometry.segmentScale = size / 20;
- var lineWidthQueryPath = 'lineStyle.width'.split('.');
- var dpr = api.getDevicePixelRatio();
- var maxLineWidth = 0;
- data.each(function (idx) {
- var itemModel = data.getItemModel(idx);
- var lineWidth = itemModel.get(lineWidthQueryPath);
- if (lineWidth == null) {
- lineWidth = 1;
- }
- data.setItemVisual(idx, 'lineWidth', lineWidth);
- maxLineWidth = Math.max(lineWidth, maxLineWidth);
- });
- // Must set useNativeLine before calling any other methods
- geometry.useNativeLine = false;
- var nVertex = 0;
- var nTriangle = 0;
- data.each(function (idx) {
- var pts = data.getItemLayout(idx);
- if (isPolyline) {
- nVertex += geometry.getPolylineVertexCount(pts);
- nTriangle += geometry.getPolylineTriangleCount(pts);
- }
- else {
- nVertex += geometry.getCubicCurveVertexCount(pts[0], pts[1], pts[2], pts[3]);
- nTriangle += geometry.getCubicCurveTriangleCount(pts[0], pts[1], pts[2], pts[3]);
- }
- });
- geometry.setVertexCount(nVertex);
- geometry.setTriangleCount(nTriangle);
- geometry.resetOffset();
- var colorArr = [];
- data.each(function (idx) {
- var pts = data.getItemLayout(idx);
- var color = data.getItemVisual(idx, 'color');
- var opacity = data.getItemVisual(idx, 'opacity');
- var lineWidth = data.getItemVisual(idx, 'lineWidth') * dpr;
- if (opacity == null) {
- opacity = 1;
- }
- colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(color, colorArr);
- colorArr[3] *= opacity;
- if (isPolyline) {
- geometry.addPolyline(pts, colorArr, lineWidth);
- }
- else {
- geometry.addCubicCurve(pts[0], pts[1], pts[2], pts[3], colorArr, lineWidth);
- }
- });
- geometry.dirty();
- },
- remove: function () {
- this.groupGL.removeAll();
- },
- dispose: function () {
- this.groupGL.removeAll();
- }
- }));
- /***/
- }),
- /* 246 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__ = __webpack_require__(25);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__shader_trail2_glsl_js__ = __webpack_require__(247);
- var vec3 = __WEBPACK_IMPORTED_MODULE_2_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- function sign(a) {
- return a > 0 ? 1 : -1;
- }
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_4__shader_trail2_glsl_js__["a" /* default */]);
- /* harmony default export */ __webpack_exports__["a"] = (__WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.extend(function () {
- var material = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- shader: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader(
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('ecgl.trail2.vertex'),
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('ecgl.trail2.fragment')
- ),
- transparent: true,
- depthMask: false
- });
- var geometry = new __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines3D__["a" /* default */]({
- dynamic: true
- });
- geometry.createAttribute('dist', 'float', 1);
- geometry.createAttribute('distAll', 'float', 1);
- geometry.createAttribute('start', 'float', 1);
- return {
- geometry: geometry,
- material: material,
- culling: false,
- $ignorePicking: true
- };
- }, {
- updateData: function (data, api, lines3DGeometry) {
- var seriesModel = data.hostModel;
- var geometry = this.geometry;
- var effectModel = seriesModel.getModel('effect');
- var size = effectModel.get('trailWidth') * api.getDevicePixelRatio();
- var trailLength = effectModel.get('trailLength');
- var speed = seriesModel.get('effect.constantSpeed');
- var period = seriesModel.get('effect.period') * 1000;
- var useConstantSpeed = speed != null;
- if (true) {
- if (!this.getScene()) {
- console.error('TrailMesh must been add to scene before updateData');
- }
- }
- useConstantSpeed
- ? this.material.set('speed', speed / 1000)
- : this.material.set('period', period);
- this.material[useConstantSpeed ? 'define' : 'undefine']('vertex', 'CONSTANT_SPEED');
- var isPolyline = seriesModel.get('polyline');
- geometry.trailLength = trailLength;
- this.material.set('trailLength', trailLength);
- geometry.resetOffset();
- ['position', 'positionPrev', 'positionNext'].forEach(function (attrName) {
- geometry.attributes[attrName].value = lines3DGeometry.attributes[attrName].value;
- });
- var extraAttrs = ['dist', 'distAll', 'start', 'offset', 'color'];
- extraAttrs.forEach(function (attrName) {
- geometry.attributes[attrName].init(geometry.vertexCount);
- });
- geometry.indices = lines3DGeometry.indices;
- var colorArr = [];
- var effectColor = effectModel.get('trailColor');
- var effectOpacity = effectModel.get('trailOpacity');
- var hasEffectColor = effectColor != null;
- var hasEffectOpacity = effectOpacity != null;
- this.updateWorldTransform();
- var xScale = this.worldTransform.x.len();
- var yScale = this.worldTransform.y.len();
- var zScale = this.worldTransform.z.len();
- var vertexOffset = 0;
- var maxDistance = 0;
- data.each(function (idx) {
- var pts = data.getItemLayout(idx);
- var opacity = hasEffectOpacity ? effectOpacity : data.getItemVisual(idx, 'opacity');
- var color = data.getItemVisual(idx, 'color');
- if (opacity == null) {
- opacity = 1;
- }
- colorArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(hasEffectColor ? effectColor : color, colorArr);
- colorArr[3] *= opacity;
- var vertexCount = isPolyline
- ? lines3DGeometry.getPolylineVertexCount(pts)
- : lines3DGeometry.getCubicCurveVertexCount(pts[0], pts[1], pts[2], pts[3])
- var dist = 0;
- var pos = [];
- var posPrev = [];
- for (var i = vertexOffset; i < vertexOffset + vertexCount; i++) {
- geometry.attributes.position.get(i, pos);
- pos[0] *= xScale;
- pos[1] *= yScale;
- pos[2] *= zScale;
- if (i > vertexOffset) {
- dist += vec3.dist(pos, posPrev);
- }
- geometry.attributes.dist.set(i, dist);
- vec3.copy(posPrev, pos);
- }
- maxDistance = Math.max(maxDistance, dist);
- var randomStart = Math.random() * (useConstantSpeed ? dist : period);
- for (var i = vertexOffset; i < vertexOffset + vertexCount; i++) {
- geometry.attributes.distAll.set(i, dist);
- geometry.attributes.start.set(i, randomStart);
- geometry.attributes.offset.set(
- i, sign(lines3DGeometry.attributes.offset.get(i)) * size / 2
- );
- geometry.attributes.color.set(i, colorArr);
- }
- vertexOffset += vertexCount;
- });
- this.material.set('spotSize', maxDistance * 0.1 * trailLength);
- this.material.set('spotIntensity', effectModel.get('spotIntensity'));
- geometry.dirty();
- },
- setAnimationTime: function (time) {
- this.material.set('time', time);
- }
- }));
- /***/
- }),
- /* 247 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.trail2.vertex\nattribute vec3 position: POSITION;\nattribute vec3 positionPrev;\nattribute vec3 positionNext;\nattribute float offset;\nattribute float dist;\nattribute float distAll;\nattribute float start;\n\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\nuniform float near : NEAR;\n\nuniform float speed : 0;\nuniform float trailLength: 0.3;\nuniform float time;\nuniform float period: 1000;\n\nuniform float spotSize: 1;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.vertexHeader\n\n@import ecgl.lines3D.clipNear\n\nvoid main()\n{\n @import ecgl.lines3D.expandLine\n\n gl_Position = currProj;\n\n v_Color = a_Color;\n\n @import ecgl.common.wireframe.vertexMain\n\n#ifdef CONSTANT_SPEED\n float t = mod((speed * time + start) / distAll, 1. + trailLength) - trailLength;\n#else\n float t = mod((time + start) / period, 1. + trailLength) - trailLength;\n#endif\n\n float trailLen = distAll * trailLength;\n\n v_Percent = (dist - t * distAll) / trailLen;\n\n v_SpotPercent = spotSize / distAll;\n\n }\n@end\n\n\n@export ecgl.trail2.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float spotIntensity: 5;\n\nvarying vec4 v_Color;\nvarying float v_Percent;\nvarying float v_SpotPercent;\n\n@import ecgl.common.wireframe.fragmentHeader\n\n@import clay.util.srgb\n\nvoid main()\n{\n if (v_Percent > 1.0 || v_Percent < 0.0) {\n discard;\n }\n\n float fade = v_Percent;\n\n#ifdef SRGB_DECODE\n gl_FragColor = sRGBToLinear(color * v_Color);\n#else\n gl_FragColor = color * v_Color;\n#endif\n\n @import ecgl.common.wireframe.fragmentMain\n\n if (v_Percent > (1.0 - v_SpotPercent)) {\n gl_FragColor.rgb *= spotIntensity;\n }\n\n gl_FragColor.a *= fade;\n}\n\n@end");
- /***/
- }),
- /* 248 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({
- type: 'series.lines3D',
- dependencies: ['globe'],
- visualColorAccessPath: 'lineStyle.color',
- getInitialData: function (option, ecModel) {
- var lineData = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.List(['value'], this);
- lineData.hasItemOption = false;
- lineData.initData(option.data, [], function (dataItem, dimName, dataIndex, dimIndex) {
- // dataItem is simply coords
- if (dataItem instanceof Array) {
- return NaN;
- }
- else {
- lineData.hasItemOption = true;
- var value = dataItem.value;
- if (value != null) {
- return value instanceof Array ? value[dimIndex] : value;
- }
- }
- });
- return lineData;
- },
- defaultOption: {
- coordinateSystem: 'globe',
- globeIndex: 0,
- geo3DIndex: 0,
- zlevel: -10,
- polyline: false,
- effect: {
- show: false,
- period: 4,
- // Trail width
- trailWidth: 4,
- trailLength: 0.2,
- spotIntensity: 6
- },
- silent: true,
- // Support source-over, lighter
- blendMode: 'source-over',
- lineStyle: {
- width: 1,
- opacity: 0.5
- // color
- }
- }
- });
- /***/
- }),
- /* 249 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__polygons3D_Polygons3DSeries__ = __webpack_require__(250);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__polygons3D_Polygons3DView__ = __webpack_require__(251);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_opacityVisual__ = __webpack_require__(17);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_3__common_opacityVisual__["a" /* default */])('polygons3D'));
- /***/
- }),
- /* 250 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__ = __webpack_require__(31);
- function transformPolygon(coordSys, poly) {
- var ret = [];
- for (var i = 0; i < poly.length; i++) {
- ret.push(coordSys.dataToPoint(poly[i]));
- }
- return ret;
- }
- var Polygons3DSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({
- type: 'series.polygons3D',
- getRegionModel: function (idx) {
- return this.getData().getItemModel(idx);
- },
- getRegionPolygonCoords: function (idx) {
- var coordSys = this.coordinateSystem;
- var itemModel = this.getData().getItemModel(idx);
- var coords = itemModel.option instanceof Array
- ? itemModel.option : itemModel.getShallow('coords');
- if (!itemModel.get('multiPolygon')) {
- coords = [coords];
- }
- // TODO Validate
- var out = [];
- for (var i = 0; i < coords.length; i++) {
- // TODO Convert here ?
- var interiors = [];
- for (var k = 1; k < coords[i].length; k++) {
- interiors.push(transformPolygon(coordSys, coords[i][k]));
- }
- out.push({
- exterior: transformPolygon(coordSys, coords[i][0]),
- interiors: interiors
- });
- }
- return out;
- },
- getInitialData: function (option) {
- var polygonsData = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.List(['value'], this);
- polygonsData.hasItemOption = false;
- polygonsData.initData(option.data, [], function (dataItem, dimName, dataIndex, dimIndex) {
- // dataItem is simply coords
- if (dataItem instanceof Array) {
- return NaN;
- }
- else {
- polygonsData.hasItemOption = true;
- var value = dataItem.value;
- if (value != null) {
- return value instanceof Array ? value[dimIndex] : value;
- }
- }
- });
- return polygonsData;
- },
- defaultOption: {
- show: true,
- data: null,
- multiPolygon: false,
- progressiveThreshold: 1e3,
- progressive: 1e3,
- zlevel: -10,
- label: {
- show: false,
- // Distance in 3d space.
- distance: 2,
- textStyle: {
- fontSize: 20,
- color: '#000',
- backgroundColor: 'rgba(255,255,255,0.7)',
- padding: 3,
- borderRadius: 4
- }
- },
- itemStyle: {
- color: '#fff',
- borderWidth: 0,
- borderColor: '#333'
- },
- emphasis: {
- itemStyle: {
- color: '#639fc0'
- },
- label: {
- show: true
- }
- }
- }
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Polygons3DSeries.prototype, __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__["a" /* default */]);
- /* unused harmony default export */ var _unused_webpack_default_export = (Polygons3DSeries);
- /***/
- }),
- /* 251 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_Geo3DBuilder__ = __webpack_require__(64);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__ = __webpack_require__(1);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({
- type: 'polygons3D',
- __ecgl__: true,
- init: function (ecModel, api) {
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Node();
- this._geo3DBuilderList = [];
- this._currentStep = 0;
- },
- render: function (seriesModel, ecModel, api) {
- this.groupGL.removeAll();
- var coordSys = seriesModel.coordinateSystem;
- if (coordSys && coordSys.viewGL) {
- coordSys.viewGL.add(this.groupGL);
- }
- var geo3DBuilder = this._geo3DBuilderList[0];
- if (!geo3DBuilder) {
- geo3DBuilder = new __WEBPACK_IMPORTED_MODULE_1__component_common_Geo3DBuilder__["a" /* default */](api);
- geo3DBuilder.extrudeY = coordSys.type !== 'mapbox3D'
- && coordSys.type !== 'maptalks3D';
- this._geo3DBuilderList[0] = geo3DBuilder;
- }
- this._updateShaderDefines(coordSys, geo3DBuilder);
- geo3DBuilder.update(seriesModel, ecModel, api);
- this._geo3DBuilderList.length = 1;
- this.groupGL.add(geo3DBuilder.rootNode);
- },
- incrementalPrepareRender: function (seriesModel, ecModel, api) {
- this.groupGL.removeAll();
- var coordSys = seriesModel.coordinateSystem;
- if (coordSys && coordSys.viewGL) {
- coordSys.viewGL.add(this.groupGL);
- }
- this._currentStep = 0;
- },
- incrementalRender: function (params, seriesModel, ecModel, api) {
- var geo3DBuilder = this._geo3DBuilderList[this._currentStep];
- var coordSys = seriesModel.coordinateSystem;
- if (!geo3DBuilder) {
- geo3DBuilder = new __WEBPACK_IMPORTED_MODULE_1__component_common_Geo3DBuilder__["a" /* default */](api);
- geo3DBuilder.extrudeY = coordSys.type !== 'mapbox3D'
- && coordSys.type !== 'maptalks3D';
- this._geo3DBuilderList[this._currentStep] = geo3DBuilder;
- }
- geo3DBuilder.update(seriesModel, ecModel, api, params.start, params.end);
- this.groupGL.add(geo3DBuilder.rootNode);
- this._updateShaderDefines(coordSys, geo3DBuilder);
- this._currentStep++;
- },
- _updateShaderDefines: function (coordSys, geo3DBuilder) {
- var methodName = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine';
- geo3DBuilder.rootNode.traverse(function (mesh) {
- if (mesh.material) {
- mesh.material[methodName]('fragment', 'SRGB_DECODE');
- // FIXME
- if (coordSys.type === 'mapbox3D' || coordSys.type === 'maptalks3D') {
- mesh.material.define('fragment', 'NORMAL_UP_AXIS', 2);
- mesh.material.define('fragment', 'NORMAL_FRONT_AXIS', 1);
- }
- }
- });
- },
- remove: function () {
- this.groupGL.removeAll();
- },
- dispose: function () {
- this.groupGL.removeAll();
- }
- });
- /***/
- }),
- /* 252 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__surface_SurfaceSeries__ = __webpack_require__(253);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__surface_SurfaceView__ = __webpack_require__(254);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__surface_surfaceLayout__ = __webpack_require__(255);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__["a" /* default */])('surface'));
- /***/
- }),
- /* 253 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__ = __webpack_require__(31);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__common_formatTooltip__ = __webpack_require__(39);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_createList__ = __webpack_require__(50);
- var SurfaceSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({
- type: 'series.surface',
- dependencies: ['globe', 'grid3D', 'geo3D'],
- visualColorAccessPath: 'itemStyle.color',
- formatTooltip: function (dataIndex) {
- return Object(__WEBPACK_IMPORTED_MODULE_2__common_formatTooltip__["a" /* default */])(this, dataIndex);
- },
- getInitialData: function (option, ecModel) {
- var data = option.data;
- function validateDimension(dimOpts) {
- return !(isNaN(dimOpts.min) || isNaN(dimOpts.max) || isNaN(dimOpts.step));
- }
- function getPrecision(dimOpts) {
- var getPrecision = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.number.getPrecisionSafe;
- return Math.max(
- getPrecision(dimOpts.min), getPrecision(dimOpts.max), getPrecision(dimOpts.step)
- ) + 1;
- }
- if (!data) {
- if (!option.parametric) {
- // From surface equation
- var equation = option.equation || {};
- var xOpts = equation.x || {};
- var yOpts = equation.y || {};
- ['x', 'y'].forEach(function (dim) {
- if (!validateDimension(equation[dim])) {
- if (true) {
- console.error('Invalid equation.%s', dim);
- }
- return;
- }
- });
- if (typeof equation.z !== 'function') {
- if (true) {
- console.error('equation.z needs to be function');
- }
- return;
- }
- var xCount = Math.floor((xOpts.max + xOpts.step - xOpts.min) / xOpts.step);
- var yCount = Math.floor((yOpts.max + yOpts.step - yOpts.min) / yOpts.step);
- data = new Float32Array(xCount * yCount * 3);
- var xPrecision = getPrecision(xOpts);
- var yPrecision = getPrecision(yOpts);
- var off = 0;
- for (var j = 0; j < yCount; j++) {
- for (var i = 0; i < xCount; i++) {
- var x = i * xOpts.step + xOpts.min;
- var y = j * yOpts.step + yOpts.min;
- var x2 = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.number.round(Math.min(x, xOpts.max), xPrecision);
- var y2 = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.number.round(Math.min(y, yOpts.max), yPrecision);
- var z = equation.z(x2, y2);
- data[off++] = x2;
- data[off++] = y2;
- data[off++] = z;
- }
- }
- }
- else {
- var parametricEquation = option.parametricEquation || {};
- var uOpts = parametricEquation.u || {};
- var vOpts = parametricEquation.v || {};
- ['u', 'v'].forEach(function (dim) {
- if (!validateDimension(parametricEquation[dim])) {
- if (true) {
- console.error('Invalid parametricEquation.%s', dim);
- }
- return;
- }
- });
- ['x', 'y', 'z'].forEach(function (dim) {
- if (typeof parametricEquation[dim] !== 'function') {
- if (true) {
- console.error('parametricEquation.%s needs to be function', dim);
- }
- return;
- }
- });
- var uCount = Math.floor((uOpts.max + uOpts.step - uOpts.min) / uOpts.step);
- var vCount = Math.floor((vOpts.max + vOpts.step - vOpts.min) / vOpts.step);
- data = new Float32Array(uCount * vCount * 5);
- var uPrecision = getPrecision(uOpts);
- var vPrecision = getPrecision(vOpts);
- var off = 0;
- for (var j = 0; j < vCount; j++) {
- for (var i = 0; i < uCount; i++) {
- var u = i * uOpts.step + uOpts.min;
- var v = j * vOpts.step + vOpts.min;
- var u2 = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.number.round(Math.min(u, uOpts.max), uPrecision);
- var v2 = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.number.round(Math.min(v, vOpts.max), vPrecision);
- var x = parametricEquation.x(u2, v2);
- var y = parametricEquation.y(u2, v2);
- var z = parametricEquation.z(u2, v2);
- data[off++] = x;
- data[off++] = y;
- data[off++] = z;
- data[off++] = u2;
- data[off++] = v2;
- }
- }
- }
- }
- var dims = ['x', 'y', 'z'];
- if (option.parametric) {
- dims.push('u', 'v');
- }
- // PENDING getSource?
- var list = Object(__WEBPACK_IMPORTED_MODULE_3__common_createList__["a" /* default */])(this, dims, data);
- return list;
- },
- defaultOption: {
- coordinateSystem: 'cartesian3D',
- zlevel: -10,
- // Cartesian coordinate system
- grid3DIndex: 0,
- // Surface needs lambert shading to show the difference
- shading: 'lambert',
- // If parametric surface
- parametric: false,
- wireframe: {
- show: true,
- lineStyle: {
- color: 'rgba(0,0,0,0.5)',
- width: 1
- }
- },
- /**
- * Generate surface data from z = f(x, y) equation
- */
- equation: {
- // [min, max, step]
- x: {
- min: -1,
- max: 1,
- step: 0.1
- },
- y: {
- min: -1,
- max: 1,
- step: 0.1
- },
- z: null
- },
- parametricEquation: {
- // [min, max, step]
- u: {
- min: -1,
- max: 1,
- step: 0.1
- },
- v: {
- min: -1,
- max: 1,
- step: 0.1
- },
- // [x, y, z] = f(x, y)
- x: null,
- y: null,
- z: null
- },
- itemStyle: {
- // Color
- },
- animationDurationUpdate: 500
- }
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(SurfaceSeries.prototype, __WEBPACK_IMPORTED_MODULE_1__component_common_componentShadingMixin__["a" /* default */]);
- /* unused harmony default export */ var _unused_webpack_default_export = (SurfaceSeries);
- /***/
- }),
- /* 254 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_trianglesSortMixin__ = __webpack_require__(65);
- var vec3 = __WEBPACK_IMPORTED_MODULE_3_claygl_src_dep_glmatrix__["a" /* default */].vec3;
- function isPointsNaN(pt) {
- return isNaN(pt[0]) || isNaN(pt[1]) || isNaN(pt[2]);
- }
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({
- type: 'surface',
- __ecgl__: true,
- init: function (ecModel, api) {
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- },
- render: function (seriesModel, ecModel, api) {
- // Swap surfaceMesh
- var tmp = this._prevSurfaceMesh;
- this._prevSurfaceMesh = this._surfaceMesh;
- this._surfaceMesh = tmp;
- if (!this._surfaceMesh) {
- this._surfaceMesh = this._createSurfaceMesh();
- }
- this.groupGL.remove(this._prevSurfaceMesh);
- this.groupGL.add(this._surfaceMesh);
- var coordSys = seriesModel.coordinateSystem;
- var shading = seriesModel.get('shading');
- var data = seriesModel.getData();
- var shadingPrefix = 'ecgl.' + shading;
- if (!this._surfaceMesh.material || this._surfaceMesh.material.shader.name !== shadingPrefix) {
- this._surfaceMesh.material = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createMaterial(shadingPrefix, ['VERTEX_COLOR', 'DOUBLE_SIDED']);
- }
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].setMaterialFromModel(
- shading, this._surfaceMesh.material, seriesModel, api
- );
- if (coordSys && coordSys.viewGL) {
- coordSys.viewGL.add(this.groupGL);
- var methodName = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine';
- this._surfaceMesh.material[methodName]('fragment', 'SRGB_DECODE');
- }
- var isParametric = seriesModel.get('parametric');
- var dataShape = this._getDataShape(data, isParametric);
- var wireframeModel = seriesModel.getModel('wireframe');
- var wireframeLineWidth = wireframeModel.get('lineStyle.width');
- var showWireframe = wireframeModel.get('show') && wireframeLineWidth > 0;
- this._updateSurfaceMesh(this._surfaceMesh, seriesModel, dataShape, showWireframe);
- var material = this._surfaceMesh.material;
- if (showWireframe) {
- material.define('WIREFRAME_QUAD');
- material.set('wireframeLineWidth', wireframeLineWidth);
- material.set('wireframeLineColor', __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(wireframeModel.get('lineStyle.color')));
- }
- else {
- material.undefine('WIREFRAME_QUAD');
- }
- this._initHandler(seriesModel, api);
- this._updateAnimation(seriesModel);
- },
- _updateAnimation: function (seriesModel) {
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].updateVertexAnimation(
- [['prevPosition', 'position'],
- ['prevNormal', 'normal']],
- this._prevSurfaceMesh,
- this._surfaceMesh,
- seriesModel
- );
- },
- _createSurfaceMesh: function () {
- var mesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Geometry({
- dynamic: true,
- sortTriangles: true
- }),
- shadowDepthMaterial: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- shader: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader(__WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('ecgl.sm.depth.vertex'), __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('ecgl.sm.depth.fragment'))
- }),
- culling: false,
- // Render after axes
- renderOrder: 10,
- // Render normal in normal pass
- renderNormal: true
- });
- mesh.geometry.createAttribute('barycentric', 'float', 4);
- mesh.geometry.createAttribute('prevPosition', 'float', 3);
- mesh.geometry.createAttribute('prevNormal', 'float', 3);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend(mesh.geometry, __WEBPACK_IMPORTED_MODULE_4__util_geometry_trianglesSortMixin__["a" /* default */]);
- return mesh;
- },
- _initHandler: function (seriesModel, api) {
- var data = seriesModel.getData();
- var surfaceMesh = this._surfaceMesh;
- var coordSys = seriesModel.coordinateSystem;
- function getNearestPointIdx(triangle, point) {
- var nearestDist = Infinity;
- var nearestIdx = -1;
- var pos = [];
- for (var i = 0; i < triangle.length; i++) {
- surfaceMesh.geometry.attributes.position.get(triangle[i], pos);
- var dist = vec3.dist(point.array, pos);
- if (dist < nearestDist) {
- nearestDist = dist;
- nearestIdx = triangle[i];
- }
- }
- return nearestIdx;
- }
- surfaceMesh.seriesIndex = seriesModel.seriesIndex;
- var lastDataIndex = -1;
- surfaceMesh.off('mousemove');
- surfaceMesh.off('mouseout');
- surfaceMesh.on('mousemove', function (e) {
- var idx = getNearestPointIdx(e.triangle, e.point);
- if (idx >= 0) {
- var point = [];
- surfaceMesh.geometry.attributes.position.get(idx, point);
- var value = coordSys.pointToData(point);
- var minDist = Infinity;
- var dataIndex = -1;
- var item = [];
- for (var i = 0; i < data.count(); i++) {
- item[0] = data.get('x', i);
- item[1] = data.get('y', i);
- item[2] = data.get('z', i);
- var dist = vec3.squaredDistance(item, value);
- if (dist < minDist) {
- dataIndex = i;
- minDist = dist;
- }
- }
- if (dataIndex !== lastDataIndex) {
- api.dispatchAction({
- type: 'grid3DShowAxisPointer',
- value: value
- });
- }
- lastDataIndex = dataIndex;
- surfaceMesh.dataIndex = dataIndex;
- }
- else {
- surfaceMesh.dataIndex = -1;
- }
- }, this);
- surfaceMesh.on('mouseout', function (e) {
- lastDataIndex = -1;
- surfaceMesh.dataIndex = -1;
- api.dispatchAction({
- type: 'grid3DHideAxisPointer'
- });
- }, this);
- },
- _updateSurfaceMesh: function (surfaceMesh, seriesModel, dataShape, showWireframe) {
- var geometry = surfaceMesh.geometry;
- var data = seriesModel.getData();
- var pointsArr = data.getLayout('points');
- var invalidDataCount = 0;
- data.each(function (idx) {
- if (!data.hasValue(idx)) {
- invalidDataCount++;
- }
- });
- var needsSplitQuad = invalidDataCount || showWireframe;
- var positionAttr = geometry.attributes.position;
- var normalAttr = geometry.attributes.normal;
- var texcoordAttr = geometry.attributes.texcoord0;
- var barycentricAttr = geometry.attributes.barycentric;
- var colorAttr = geometry.attributes.color;
- var row = dataShape.row;
- var column = dataShape.column;
- var shading = seriesModel.get('shading');
- var needsNormal = shading !== 'color';
- if (needsSplitQuad) {
- // TODO, If needs remove the invalid points, or set color transparent.
- var vertexCount = (row - 1) * (column - 1) * 4;
- positionAttr.init(vertexCount);
- if (showWireframe) {
- barycentricAttr.init(vertexCount);
- }
- }
- else {
- positionAttr.value = new Float32Array(pointsArr);
- }
- colorAttr.init(geometry.vertexCount);
- texcoordAttr.init(geometry.vertexCount);
- var quadToTriangle = [0, 3, 1, 1, 3, 2];
- // 3----2
- // 0----1
- // Make sure pixels on 1---3 edge will not have channel 0.
- // And pixels on four edges have at least one channel 0.
- var quadBarycentric = [
- [1, 1, 0, 0],
- [0, 1, 0, 1],
- [1, 0, 0, 1],
- [1, 0, 1, 0]
- ];
- var indices = geometry.indices = new (geometry.vertexCount > 0xffff ? Uint32Array : Uint16Array)((row - 1) * (column - 1) * 6);
- var getQuadIndices = function (i, j, out) {
- out[1] = i * column + j;
- out[0] = i * column + j + 1;
- out[3] = (i + 1) * column + j + 1;
- out[2] = (i + 1) * column + j;
- };
- var isTransparent = false;
- if (needsSplitQuad) {
- var quadIndices = [];
- var pos = [];
- var faceOffset = 0;
- if (needsNormal) {
- normalAttr.init(geometry.vertexCount);
- }
- else {
- normalAttr.value = null;
- }
- var pts = [[], [], []];
- var v21 = [], v32 = [];
- var normal = vec3.create();
- var getFromArray = function (arr, idx, out) {
- var idx3 = idx * 3;
- out[0] = arr[idx3];
- out[1] = arr[idx3 + 1];
- out[2] = arr[idx3 + 2];
- return out;
- };
- var vertexNormals = new Float32Array(pointsArr.length);
- var vertexColors = new Float32Array(pointsArr.length / 3 * 4);
- for (var i = 0; i < data.count(); i++) {
- if (data.hasValue(i)) {
- var rgbaArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(data.getItemVisual(i, 'color'));
- var opacity = data.getItemVisual(i, 'opacity');
- rgbaArr[3] *= opacity;
- if (rgbaArr[3] < 0.99) {
- isTransparent = true;
- }
- for (var k = 0; k < 4; k++) {
- vertexColors[i * 4 + k] = rgbaArr[k];
- }
- }
- }
- var farPoints = [1e7, 1e7, 1e7];
- for (var i = 0; i < row - 1; i++) {
- for (var j = 0; j < column - 1; j++) {
- var dataIndex = i * (column - 1) + j;
- var vertexOffset = dataIndex * 4;
- getQuadIndices(i, j, quadIndices);
- var invisibleQuad = false;
- for (var k = 0; k < 4; k++) {
- getFromArray(pointsArr, quadIndices[k], pos);
- if (isPointsNaN(pos)) {
- // Quad is invisible if any point is NaN
- invisibleQuad = true;
- }
- }
- for (var k = 0; k < 4; k++) {
- if (invisibleQuad) {
- // Move point far away
- positionAttr.set(vertexOffset + k, farPoints);
- }
- else {
- getFromArray(pointsArr, quadIndices[k], pos);
- positionAttr.set(vertexOffset + k, pos);
- }
- if (showWireframe) {
- barycentricAttr.set(vertexOffset + k, quadBarycentric[k]);
- }
- }
- for (var k = 0; k < 6; k++) {
- indices[faceOffset++] = quadToTriangle[k] + vertexOffset;
- }
- // Vertex normals
- if (needsNormal && !invisibleQuad) {
- for (var k = 0; k < 2; k++) {
- var k3 = k * 3;
- for (var m = 0; m < 3; m++) {
- var idx = quadIndices[quadToTriangle[k3] + m];
- getFromArray(pointsArr, idx, pts[m]);
- }
- vec3.sub(v21, pts[0], pts[1]);
- vec3.sub(v32, pts[1], pts[2]);
- vec3.cross(normal, v21, v32);
- // Weighted by the triangle area
- for (var m = 0; m < 3; m++) {
- var idx3 = quadIndices[quadToTriangle[k3] + m] * 3;
- vertexNormals[idx3] = vertexNormals[idx3] + normal[0];
- vertexNormals[idx3 + 1] = vertexNormals[idx3 + 1] + normal[1];
- vertexNormals[idx3 + 2] = vertexNormals[idx3 + 2] + normal[2];
- }
- }
- }
- }
- }
- if (needsNormal) {
- for (var i = 0; i < vertexNormals.length / 3; i++) {
- getFromArray(vertexNormals, i, normal);
- vec3.normalize(normal, normal);
- vertexNormals[i * 3] = normal[0];
- vertexNormals[i * 3 + 1] = normal[1];
- vertexNormals[i * 3 + 2] = normal[2];
- }
- }
- // Split normal and colors, write to the attributes.
- var rgbaArr = [];
- var uvArr = [];
- for (var i = 0; i < row - 1; i++) {
- for (var j = 0; j < column - 1; j++) {
- var dataIndex = i * (column - 1) + j;
- var vertexOffset = dataIndex * 4;
- getQuadIndices(i, j, quadIndices);
- for (var k = 0; k < 4; k++) {
- for (var m = 0; m < 4; m++) {
- rgbaArr[m] = vertexColors[quadIndices[k] * 4 + m];
- }
- colorAttr.set(vertexOffset + k, rgbaArr);
- if (needsNormal) {
- getFromArray(vertexNormals, quadIndices[k], normal);
- normalAttr.set(vertexOffset + k, normal);
- }
- var idx = quadIndices[k];
- uvArr[0] = (idx % column) / (column - 1);
- uvArr[1] = Math.floor(idx / column) / (row - 1);
- texcoordAttr.set(vertexOffset + k, uvArr);
- }
- dataIndex++;
- }
- }
- }
- else {
- var uvArr = [];
- for (var i = 0; i < data.count(); i++) {
- uvArr[0] = (i % column) / (column - 1);
- uvArr[1] = Math.floor(i / column) / (row - 1);
- var rgbaArr = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(data.getItemVisual(i, 'color'));
- var opacity = data.getItemVisual(i, 'opacity');
- rgbaArr[3] *= opacity;
- if (rgbaArr[3] < 0.99) {
- isTransparent = true;
- }
- colorAttr.set(i, rgbaArr);
- texcoordAttr.set(i, uvArr);
- }
- var quadIndices = [];
- // Triangles
- var cursor = 0;
- for (var i = 0; i < row - 1; i++) {
- for (var j = 0; j < column - 1; j++) {
- getQuadIndices(i, j, quadIndices);
- for (var k = 0; k < 6; k++) {
- indices[cursor++] = quadIndices[quadToTriangle[k]];
- }
- }
- }
- if (needsNormal) {
- geometry.generateVertexNormals();
- }
- else {
- normalAttr.value = null;
- }
- }
- if (surfaceMesh.material.get('normalMap')) {
- geometry.generateTangents();
- }
- geometry.updateBoundingBox();
- geometry.dirty();
- surfaceMesh.material.transparent = isTransparent;
- surfaceMesh.material.depthMask = !isTransparent;
- },
- _getDataShape: function (data, isParametric) {
- var prevX = -Infinity;
- var rowCount = 0;
- var columnCount = 0;
- var prevColumnCount = 0;
- var rowDim = isParametric ? 'u' : 'x';
- // Check data format
- for (var i = 0; i < data.count(); i++) {
- var x = data.get(rowDim, i);
- if (x < prevX) {
- if (prevColumnCount && prevColumnCount !== columnCount) {
- if (true) {
- throw new Error('Invalid data. data should be a row major 2d array.')
- }
- }
- // A new row.
- prevColumnCount = columnCount;
- columnCount = 0;
- rowCount++;
- }
- prevX = x;
- columnCount++;
- }
- return {
- row: rowCount + 1,
- column: columnCount
- };
- },
- dispose: function () {
- this.groupGL.removeAll();
- },
- remove: function () {
- this.groupGL.removeAll();
- }
- });
- /***/
- }),
- /* 255 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout(function (ecModel, api) {
- ecModel.eachSeriesByType('surface', function (surfaceModel) {
- var cartesian = surfaceModel.coordinateSystem;
- if (!cartesian || cartesian.type !== 'cartesian3D') {
- if (true) {
- console.error('Surface chart only support cartesian3D coordinateSystem');
- }
- }
- var data = surfaceModel.getData();
- var points = new Float32Array(3 * data.count());
- var nanPoint = [NaN, NaN, NaN];
- if (cartesian && cartesian.type === 'cartesian3D') {
- var coordDims = cartesian.dimensions;
- var dims = coordDims.map(function (coordDim) {
- return surfaceModel.coordDimToDataDim(coordDim)[0];
- });
- data.each(dims, function (x, y, z, idx) {
- var pt;
- if (!data.hasValue(idx)) {
- pt = nanPoint;
- }
- else {
- pt = cartesian.dataToPoint([x, y, z]);
- }
- points[idx * 3] = pt[0];
- points[idx * 3 + 1] = pt[1];
- points[idx * 3 + 2] = pt[2];
- });
- }
- data.setLayout('points', points);
- });
- });
- /***/
- }),
- /* 256 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__coord_geo3D_Geo3D__ = __webpack_require__(99);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__map3D_Map3DSeries__ = __webpack_require__(257);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__map3D_Map3DView__ = __webpack_require__(258);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__["a" /* default */])('map3D'));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'map3DChangeCamera',
- event: 'map3dcamerachanged',
- update: 'series:updateCamera'
- }, function (payload, ecModel) {
- ecModel.eachComponent({
- mainType: 'series', subType: 'map3D', query: payload
- }, function (componentModel) {
- componentModel.setView(payload);
- });
- });
- /***/
- }),
- /* 257 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__component_common_componentViewControlMixin__ = __webpack_require__(44);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__component_common_componentPostEffectMixin__ = __webpack_require__(28);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__component_common_componentLightMixin__ = __webpack_require__(29);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__component_common_componentShadingMixin__ = __webpack_require__(31);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__coord_geo3D_geo3DModelMixin__ = __webpack_require__(96);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__util_format__ = __webpack_require__(32);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__common_formatTooltip__ = __webpack_require__(39);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__coord_geo3DCreator__ = __webpack_require__(98);
- function transformPolygon(mapbox3DCoordSys, poly) {
- var newPoly = [];
- for (var k = 0; k < poly.length; k++) {
- newPoly.push(mapbox3DCoordSys.dataToPoint(poly[k]));
- }
- return newPoly;
- }
- var Map3DSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({
- type: 'series.map3D',
- layoutMode: 'box',
- coordinateSystem: null,
- visualColorAccessPath: 'itemStyle.color',
- optionUpdated: function (newOpt) {
- newOpt = newOpt || {};
- var coordSysType = this.get('coordinateSystem');
- if (coordSysType == null || coordSysType === 'geo3D') {
- return;
- }
- if (true) {
- var propsNeedToCheck = [
- 'left', 'top', 'width', 'height',
- 'boxWidth', 'boxDepth', 'boxHeight',
- 'light', 'viewControl', 'postEffect', 'temporalSuperSampling',
- 'environment', 'groundPlane'
- ];
- var ignoredProperties = [];
- propsNeedToCheck.forEach(function (propName) {
- if (newOpt[propName] != null) {
- ignoredProperties.push(propName);
- }
- });
- if (ignoredProperties.length) {
- console.warn(
- 'Property %s in map3D series will be ignored if coordinate system is %s',
- ignoredProperties.join(', '), coordSysType
- );
- }
- }
- if (this.get('groundPlane.show')) {
- // Force disable groundPlane if map3D has other coordinate systems.
- this.option.groundPlane.show = false;
- }
- // Reset geo.
- this._geo = null;
- },
- getInitialData: function (option) {
- option.data = this.getFilledRegions(option.data, option.map);
- var dimensions = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.completeDimensions(['value'], option.data);
- var list = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.List(dimensions, this);
- list.initData(option.data);
- var regionModelMap = {};
- list.each(function (idx) {
- var name = list.getName(idx);
- var itemModel = list.getItemModel(idx);
- regionModelMap[name] = itemModel;
- });
- this._regionModelMap = regionModelMap;
- return list;
- },
- formatTooltip: function (dataIndex) {
- return Object(__WEBPACK_IMPORTED_MODULE_7__common_formatTooltip__["a" /* default */])(this, dataIndex);
- },
- getRegionModel: function (idx) {
- var name = this.getData().getName(idx);
- return this._regionModelMap[name] || new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.Model(null, this);
- },
- getRegionPolygonCoords: function (idx) {
- var coordSys = this.coordinateSystem;
- var name = this.getData().getName(idx);
- if (coordSys.transform) {
- var region = coordSys.getRegion(name);
- return region ? region.geometries : [];
- }
- else {
- if (!this._geo) {
- this._geo = __WEBPACK_IMPORTED_MODULE_8__coord_geo3DCreator__["a" /* default */].createGeo3D(this);
- }
- var region = this._geo.getRegion(name);
- var ret = [];
- for (var k = 0; k < region.geometries.length; k++) {
- var geo = region.geometries[k];
- var interiors = [];
- var exterior = transformPolygon(coordSys, geo.exterior);
- if (interiors && interiors.length) {
- for (var m = 0; m < geo.interiors.length; m++) {
- interiors.push(transformPolygon(coordSys, interiors[m]));
- }
- }
- ret.push({
- interiors: interiors,
- exterior: exterior
- });
- }
- return ret;
- }
- },
- /**
- * Format label
- * @param {string} name Region name
- * @param {string} [status='normal'] 'normal' or 'emphasis'
- * @return {string}
- */
- getFormattedLabel: function (dataIndex, status) {
- var text = __WEBPACK_IMPORTED_MODULE_6__util_format__["a" /* default */].getFormattedLabel(this, dataIndex, status);
- if (text == null) {
- text = this.getData().getName(dataIndex);
- }
- return text;
- },
- defaultOption: {
- // Support geo3D, mapbox, maptalks3D
- coordinateSystem: 'geo3D',
- // itemStyle: {},
- // height,
- // label: {}
- data: null
- }
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Map3DSeries.prototype, __WEBPACK_IMPORTED_MODULE_5__coord_geo3D_geo3DModelMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Map3DSeries.prototype, __WEBPACK_IMPORTED_MODULE_1__component_common_componentViewControlMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Map3DSeries.prototype, __WEBPACK_IMPORTED_MODULE_2__component_common_componentPostEffectMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Map3DSeries.prototype, __WEBPACK_IMPORTED_MODULE_3__component_common_componentLightMixin__["a" /* default */]);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.merge(Map3DSeries.prototype, __WEBPACK_IMPORTED_MODULE_4__component_common_componentShadingMixin__["a" /* default */]);
- /* unused harmony default export */ var _unused_webpack_default_export = (Map3DSeries);
- /***/
- }),
- /* 258 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__ = __webpack_require__(45);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__component_common_SceneHelper__ = __webpack_require__(30);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__component_common_Geo3DBuilder__ = __webpack_require__(64);
- /* unused harmony default export */ var _unused_webpack_default_export = (__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({
- type: 'map3D',
- __ecgl__: true,
- init: function (ecModel, api) {
- this._geo3DBuilder = new __WEBPACK_IMPORTED_MODULE_4__component_common_Geo3DBuilder__["a" /* default */](api);
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- },
- render: function (map3DModel, ecModel, api) {
- var coordSys = map3DModel.coordinateSystem;
- if (!coordSys || !coordSys.viewGL) {
- return;
- }
- this.groupGL.add(this._geo3DBuilder.rootNode);
- coordSys.viewGL.add(this.groupGL);
- var geo3D;
- if (coordSys.type === 'geo3D') {
- geo3D = coordSys;
- if (!this._sceneHelper) {
- this._sceneHelper = new __WEBPACK_IMPORTED_MODULE_3__component_common_SceneHelper__["a" /* default */]();
- this._sceneHelper.initLight(this.groupGL);
- }
- this._sceneHelper.setScene(coordSys.viewGL.scene);
- this._sceneHelper.updateLight(map3DModel);
- // Set post effect
- coordSys.viewGL.setPostEffect(map3DModel.getModel('postEffect'), api);
- coordSys.viewGL.setTemporalSuperSampling(map3DModel.getModel('temporalSuperSampling'));
- var control = this._control;
- if (!control) {
- control = this._control = new __WEBPACK_IMPORTED_MODULE_2__util_OrbitControl__["a" /* default */]({
- zr: api.getZr()
- });
- this._control.init();
- }
- var viewControlModel = map3DModel.getModel('viewControl');
- control.setViewGL(coordSys.viewGL);
- control.setFromViewControlModel(viewControlModel, 0);
- control.off('update');
- control.on('update', function () {
- api.dispatchAction({
- type: 'map3DChangeCamera',
- alpha: control.getAlpha(),
- beta: control.getBeta(),
- distance: control.getDistance(),
- from: this.uid,
- map3DId: map3DModel.id
- });
- });
- this._geo3DBuilder.extrudeY = true;
- }
- else {
- if (this._control) {
- this._control.dispose();
- this._control = null;
- }
- if (this._sceneHelper) {
- this._sceneHelper.dispose();
- this._sceneHelper = null;
- }
- geo3D = map3DModel.getData().getLayout('geo3D');
- this._geo3DBuilder.extrudeY = false;
- }
- this._geo3DBuilder.update(map3DModel, ecModel, api, 0, map3DModel.getData().count());
- // Must update after geo3D.viewGL.setPostEffect to determine linear space
- var srgbDefineMethod = coordSys.viewGL.isLinearSpace() ? 'define' : 'undefine';
- this._geo3DBuilder.rootNode.traverse(function (mesh) {
- if (mesh.material) {
- mesh.material[srgbDefineMethod]('fragment', 'SRGB_DECODE');
- }
- });
- },
- afterRender: function (map3DModel, ecModel, api, layerGL) {
- var renderer = layerGL.renderer;
- var coordSys = map3DModel.coordinateSystem;
- if (coordSys && coordSys.type === 'geo3D') {
- this._sceneHelper.updateAmbientCubemap(renderer, map3DModel, api);
- this._sceneHelper.updateSkybox(renderer, map3DModel, api);
- }
- },
- dispose: function () {
- this.groupGL.removeAll();
- this._control.dispose();
- }
- }));
- /***/
- }),
- /* 259 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__scatterGL_ScatterGLSeries__ = __webpack_require__(260);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__scatterGL_ScatterGLView__ = __webpack_require__(261);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(51);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default()('scatterGL', 'circle', null));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__["a" /* default */])('scatterGL'));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerLayout({
- seriesType: 'scatterGL',
- reset: function (seriesModel) {
- var coordSys = seriesModel.coordinateSystem;
- var progress;
- if (coordSys) {
- var dims = coordSys.dimensions;
- var pt = [];
- if (dims.length === 1) {
- progress = function (params, data) {
- var points = new Float32Array((params.end - params.start) * 2);
- for (var idx = params.start; idx < params.end; idx++) {
- var offset = (idx - params.start) * 2;
- var x = data.get(dims[0], idx);
- var pt = coordSys.dataToPoint(x);
- points[offset] = pt[0];
- points[offset + 1] = pt[1];
- }
- data.setLayout('points', points);
- };
- }
- else if (dims.length === 2) {
- progress = function (params, data) {
- var points = new Float32Array((params.end - params.start) * 2);
- for (var idx = params.start; idx < params.end; idx++) {
- var offset = (idx - params.start) * 2;
- var x = data.get(dims[0], idx);
- var y = data.get(dims[1], idx);
- pt[0] = x;
- pt[1] = y;
- pt = coordSys.dataToPoint(pt);
- points[offset] = pt[0];
- points[offset + 1] = pt[1];
- }
- data.setLayout('points', points);
- };
- }
- }
- return { progress: progress };
- }
- });
- /***/
- }),
- /* 260 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({
- type: 'series.scatterGL',
- dependencies: ['grid', 'polar', 'geo', 'singleAxis'],
- visualColorAccessPath: 'itemStyle.color',
- getInitialData: function () {
- return __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.createList(this);
- },
- defaultOption: {
- coordinateSystem: 'cartesian2d',
- zlevel: 10,
- progressive: 1e5,
- progressiveThreshold: 1e5,
- // Cartesian coordinate system
- // xAxisIndex: 0,
- // yAxisIndex: 0,
- // Polar coordinate system
- // polarIndex: 0,
- // Geo coordinate system
- // geoIndex: 0,
- large: false,
- symbol: 'circle',
- symbolSize: 10,
- // symbolSize scale when zooming.
- zoomScale: 0,
- // Support source-over, lighter
- blendMode: 'source-over',
- itemStyle: {
- opacity: 0.8
- },
- postEffect: {
- enable: false,
- colorCorrection: {
- exposure: 0,
- brightness: 0,
- contrast: 1,
- saturation: 1,
- enable: true
- }
- }
- }
- });
- /***/
- }),
- /* 261 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__ = __webpack_require__(22);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_PointsBuilder__ = __webpack_require__(67);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_GLViewHelper__ = __webpack_require__(103);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(2);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({
- type: 'scatterGL',
- __ecgl__: true,
- init: function (ecModel, api) {
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- this.viewGL = new __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__["a" /* default */]('orthographic');
- this.viewGL.add(this.groupGL);
- this._pointsBuilderList = [];
- this._currentStep = 0;
- this._sizeScale = 1;
- this._glViewHelper = new __WEBPACK_IMPORTED_MODULE_4__common_GLViewHelper__["a" /* default */](this.viewGL);
- },
- render: function (seriesModel, ecModel, api) {
- this.groupGL.removeAll();
- this._glViewHelper.reset(seriesModel, api);
- if (!seriesModel.getData().count()) {
- return;
- }
- var pointsBuilder = this._pointsBuilderList[0];
- if (!pointsBuilder) {
- pointsBuilder = this._pointsBuilderList[0] = new __WEBPACK_IMPORTED_MODULE_3__common_PointsBuilder__["a" /* default */](true, api);
- }
- this._pointsBuilderList.length = 1;
- this.groupGL.add(pointsBuilder.rootNode);
- this._removeTransformInPoints(seriesModel.getData().getLayout('points'));
- pointsBuilder.update(seriesModel, ecModel, api);
- this.viewGL.setPostEffect(seriesModel.getModel('postEffect'), api);
- },
- incrementalPrepareRender: function (seriesModel, ecModel, api) {
- this.groupGL.removeAll();
- this._glViewHelper.reset(seriesModel, api);
- this._currentStep = 0;
- this.viewGL.setPostEffect(seriesModel.getModel('postEffect'), api);
- },
- incrementalRender: function (params, seriesModel, ecModel, api) {
- if (params.end <= params.start) {
- return;
- }
- var pointsBuilder = this._pointsBuilderList[this._currentStep];
- if (!pointsBuilder) {
- pointsBuilder = new __WEBPACK_IMPORTED_MODULE_3__common_PointsBuilder__["a" /* default */](true, api);
- this._pointsBuilderList[this._currentStep] = pointsBuilder;
- }
- this.groupGL.add(pointsBuilder.rootNode);
- this._removeTransformInPoints(seriesModel.getData().getLayout('points'));
- pointsBuilder.setSizeScale(this._sizeScale);
- pointsBuilder.update(seriesModel, ecModel, api, params.start, params.end);
- api.getZr().refresh();
- this._currentStep++;
- },
- updateTransform: function (seriesModel, ecModel, api) {
- if (seriesModel.coordinateSystem.getRoamTransform) {
- this._glViewHelper.updateTransform(seriesModel, api);
- var zoom = this._glViewHelper.getZoom();
- var sizeScale = Math.max((seriesModel.get('zoomScale') || 0) * (zoom - 1) + 1, 0);
- this._sizeScale = sizeScale;
- this._pointsBuilderList.forEach(function (pointsBuilder) {
- pointsBuilder.setSizeScale(sizeScale);
- });
- }
- },
- _removeTransformInPoints: function (points) {
- if (!points) {
- return;
- }
- var pt = [];
- for (var i = 0; i < points.length; i += 2) {
- pt[0] = points[i];
- pt[1] = points[i + 1];
- this._glViewHelper.removeTransformInPoint(pt);
- points[i] = pt[0];
- points[i + 1] = pt[1];
- }
- },
- dispose: function () {
- this.groupGL.removeAll();
- },
- remove: function () {
- this.groupGL.removeAll();
- }
- });
- /***/
- }),
- /* 262 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__graphGL_GraphGLSeries__ = __webpack_require__(263);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__graphGL_GraphGLView__ = __webpack_require__(268);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__ = __webpack_require__(51);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__ = __webpack_require__(17);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(__WEBPACK_IMPORTED_MODULE_3_echarts_lib_visual_symbol___default()('graphGL', 'circle', null));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_4__common_opacityVisual__["a" /* default */])('graphGL'));
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(function (ecModel) {
- var paletteScope = {};
- ecModel.eachSeriesByType('graphGL', function (seriesModel) {
- var categoriesData = seriesModel.getCategoriesData();
- var data = seriesModel.getData();
- var categoryNameIdxMap = {};
- categoriesData.each(function (idx) {
- var name = categoriesData.getName(idx);
- categoryNameIdxMap[name] = idx;
- var itemModel = categoriesData.getItemModel(idx);
- var color = itemModel.get('itemStyle.color')
- || seriesModel.getColorFromPalette(name, paletteScope);
- categoriesData.setItemVisual(idx, 'color', color);
- });
- // Assign category color to visual
- if (categoriesData.count()) {
- data.each(function (idx) {
- var model = data.getItemModel(idx);
- var category = model.getShallow('category');
- if (category != null) {
- if (typeof category === 'string') {
- category = categoryNameIdxMap[category];
- }
- if (!data.getItemVisual(idx, 'color', true)) {
- data.setItemVisual(
- idx, 'color',
- categoriesData.getItemVisual(category, 'color')
- );
- }
- }
- });
- }
- });
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(function (ecModel) {
- ecModel.eachSeriesByType('graphGL', function (seriesModel) {
- var graph = seriesModel.getGraph();
- var edgeData = seriesModel.getEdgeData();
- var colorQuery = 'lineStyle.color'.split('.');
- var opacityQuery = 'lineStyle.opacity'.split('.');
- edgeData.setVisual('color', seriesModel.get(colorQuery));
- edgeData.setVisual('opacity', seriesModel.get(opacityQuery));
- edgeData.each(function (idx) {
- var itemModel = edgeData.getItemModel(idx);
- var edge = graph.getEdgeByIndex(idx);
- // Edge visual must after node visual
- var color = itemModel.get(colorQuery);
- var opacity = itemModel.get(opacityQuery);
- switch (color) {
- case 'source':
- color = edge.node1.getVisual('color');
- break;
- case 'target':
- color = edge.node2.getVisual('color');
- break;
- }
- edge.setVisual('color', color);
- edge.setVisual('opacity', opacity);
- });
- });
- });
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'graphGLRoam',
- event: 'graphglroam',
- update: 'series.graphGL:roam'
- }, function (payload, ecModel) {
- ecModel.eachComponent({
- mainType: 'series', query: payload
- }, function (componentModel) {
- componentModel.setView(payload);
- });
- });
- function noop() { }
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'graphGLStartLayout',
- event: 'graphgllayoutstarted',
- update: 'series.graphGL:startLayout'
- }, noop);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'graphGLStopLayout',
- event: 'graphgllayoutstopped',
- update: 'series.graphGL:stopLayout'
- }, noop);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'graphGLFocusNodeAdjacency',
- event: 'graphGLFocusNodeAdjacency',
- update: 'series.graphGL:focusNodeAdjacency'
- }, noop);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerAction({
- type: 'graphGLUnfocusNodeAdjacency',
- event: 'graphGLUnfocusNodeAdjacency',
- update: 'series.graphGL:unfocusNodeAdjacency'
- }, noop);
- /***/
- }),
- /* 263 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__createGraphFromNodeEdge__ = __webpack_require__(264);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_format__ = __webpack_require__(32);
- var GraphSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({
- type: 'series.graphGL',
- visualColorAccessPath: 'itemStyle.color',
- init: function (option) {
- GraphSeries.superApply(this, 'init', arguments);
- // Provide data for legend select
- this.legendDataProvider = function () {
- return this._categoriesData;
- };
- this._updateCategoriesData();
- },
- mergeOption: function (option) {
- GraphSeries.superApply(this, 'mergeOption', arguments);
- this._updateCategoriesData();
- },
- getFormattedLabel: function (dataIndex, status, dataType, dimIndex) {
- var text = __WEBPACK_IMPORTED_MODULE_2__util_format__["a" /* default */].getFormattedLabel(this, dataIndex, status, dataType, dimIndex);
- if (text == null) {
- var data = this.getData();
- var lastDim = data.dimensions[data.dimensions.length - 1];
- text = data.get(lastDim, dataIndex);
- }
- return text;
- },
- getInitialData: function (option, ecModel) {
- var edges = option.edges || option.links || [];
- var nodes = option.data || option.nodes || [];
- var self = this;
- if (nodes && edges) {
- return Object(__WEBPACK_IMPORTED_MODULE_1__createGraphFromNodeEdge__["a" /* default */])(nodes, edges, this, true, beforeLink).data;
- }
- function beforeLink(nodeData, edgeData) {
- // Overwrite nodeData.getItemModel to
- nodeData.wrapMethod('getItemModel', function (model) {
- var categoriesModels = self._categoriesModels;
- var categoryIdx = model.getShallow('category');
- var categoryModel = categoriesModels[categoryIdx];
- if (categoryModel) {
- categoryModel.parentModel = model.parentModel;
- model.parentModel = categoryModel;
- }
- return model;
- });
- var edgeLabelModel = self.getModel('edgeLabel');
- // For option `edgeLabel` can be found by label.xxx.xxx on item mode.
- var fakeSeriesModel = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.Model(
- { label: edgeLabelModel.option },
- edgeLabelModel.parentModel,
- ecModel
- );
- edgeData.wrapMethod('getItemModel', function (model) {
- model.customizeGetParent(edgeGetParent);
- return model;
- });
- function edgeGetParent(path) {
- path = this.parsePath(path);
- return (path && path[0] === 'label')
- ? fakeSeriesModel
- : this.parentModel;
- }
- }
- },
- /**
- * @return {module:echarts/data/Graph}
- */
- getGraph: function () {
- return this.getData().graph;
- },
- /**
- * @return {module:echarts/data/List}
- */
- getEdgeData: function () {
- return this.getGraph().edgeData;
- },
- /**
- * @return {module:echarts/data/List}
- */
- getCategoriesData: function () {
- return this._categoriesData;
- },
- /**
- * @override
- */
- formatTooltip: function (dataIndex, multipleSeries, dataType) {
- if (dataType === 'edge') {
- var nodeData = this.getData();
- var params = this.getDataParams(dataIndex, dataType);
- var edge = nodeData.graph.getEdgeByIndex(dataIndex);
- var sourceName = nodeData.getName(edge.node1.dataIndex);
- var targetName = nodeData.getName(edge.node2.dataIndex);
- var html = [];
- sourceName != null && html.push(sourceName);
- targetName != null && html.push(targetName);
- html = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.encodeHTML(html.join(' > '));
- if (params.value) {
- html += ' : ' + __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.format.encodeHTML(params.value);
- }
- return html;
- }
- else { // dataType === 'node' or empty
- return GraphSeries.superApply(this, 'formatTooltip', arguments);
- }
- },
- _updateCategoriesData: function () {
- var categories = (this.option.categories || []).map(function (category) {
- // Data must has value
- return category.value != null ? category : __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.util.extend({
- value: 0
- }, category);
- });
- var categoriesData = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.List(['value'], this);
- categoriesData.initData(categories);
- this._categoriesData = categoriesData;
- this._categoriesModels = categoriesData.mapArray(function (idx) {
- return categoriesData.getItemModel(idx, true);
- });
- },
- setView: function (payload) {
- if (payload.zoom != null) {
- this.option.zoom = payload.zoom;
- }
- if (payload.offset != null) {
- this.option.offset = payload.offset;
- }
- },
- setNodePosition: function (points) {
- for (var i = 0; i < points.length / 2; i++) {
- var x = points[i * 2];
- var y = points[i * 2 + 1];
- var opt = this.getData().getRawDataItem(i);
- opt.x = x;
- opt.y = y;
- }
- },
- isAnimationEnabled: function () {
- return GraphSeries.superCall(this, 'isAnimationEnabled')
- // Not enable animation when do force layout
- && !(this.get('layout') === 'force' && this.get('force.layoutAnimation'));
- },
- defaultOption: {
- zlevel: 10,
- z: 2,
- legendHoverLink: true,
- // Only support forceAtlas2
- layout: 'forceAtlas2',
- // Configuration of force directed layout
- forceAtlas2: {
- initLayout: null,
- GPU: true,
- steps: 1,
- // barnesHutOptimize
- // Maxp layout steps.
- maxSteps: 1000,
- repulsionByDegree: true,
- linLogMode: false,
- strongGravityMode: false,
- gravity: 1.0,
- // scaling: 1.0,
- edgeWeightInfluence: 1.0,
- // Edge weight range.
- edgeWeight: [1, 4],
- // Node weight range.
- nodeWeight: [1, 4],
- // jitterTolerence: 0.1,
- preventOverlap: false,
- gravityCenter: null
- },
- focusNodeAdjacency: true,
- focusNodeAdjacencyOn: 'mouseover',
- left: 'center',
- top: 'center',
- // right: null,
- // bottom: null,
- // width: '80%',
- // height: '80%',
- symbol: 'circle',
- symbolSize: 5,
- roam: false,
- // Default on center of graph
- center: null,
- zoom: 1,
- // categories: [],
- // data: []
- // Or
- // nodes: []
- //
- // links: []
- // Or
- // edges: []
- label: {
- show: false,
- formatter: '{b}',
- position: 'right',
- distance: 5,
- textStyle: {
- fontSize: 14
- }
- },
- itemStyle: {},
- lineStyle: {
- color: '#aaa',
- width: 1,
- opacity: 0.5
- },
- emphasis: {
- label: {
- show: true
- }
- },
- animation: false
- }
- });
- /* unused harmony default export */ var _unused_webpack_default_export = (GraphSeries);
- /***/
- }),
- /* 264 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_data_Graph__ = __webpack_require__(265);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_data_Graph___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_data_Graph__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_helper_linkList__ = __webpack_require__(267);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_helper_linkList___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_helper_linkList__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_retrieve__ = __webpack_require__(2);
- /* harmony default export */ __webpack_exports__["a"] = (function (nodes, edges, hostModel, directed, beforeLink) {
- var graph = new __WEBPACK_IMPORTED_MODULE_1_echarts_lib_data_Graph___default.a(directed);
- for (var i = 0; i < nodes.length; i++) {
- graph.addNode(__WEBPACK_IMPORTED_MODULE_3__util_retrieve__["a" /* default */].firstNotNull(
- // Id, name, dataIndex
- nodes[i].id, nodes[i].name, i
- ), i);
- }
- var linkNameList = [];
- var validEdges = [];
- var linkCount = 0;
- for (var i = 0; i < edges.length; i++) {
- var link = edges[i];
- var source = link.source;
- var target = link.target;
- // addEdge may fail when source or target not exists
- if (graph.addEdge(source, target, linkCount)) {
- validEdges.push(link);
- linkNameList.push(__WEBPACK_IMPORTED_MODULE_3__util_retrieve__["a" /* default */].firstNotNull(link.id, source + ' > ' + target));
- linkCount++;
- }
- }
- var nodeData;
- // FIXME, support more coordinate systems.
- var dimensionNames = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.completeDimensions(
- ['value'], nodes
- );
- nodeData = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.List(dimensionNames, hostModel);
- nodeData.initData(nodes);
- var edgeData = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.List(['value'], hostModel);
- edgeData.initData(validEdges, linkNameList);
- beforeLink && beforeLink(nodeData, edgeData);
- __WEBPACK_IMPORTED_MODULE_2_echarts_lib_data_helper_linkList___default()({
- mainData: nodeData,
- struct: graph,
- structAttr: 'graph',
- datas: { node: nodeData, edge: edgeData },
- datasAttr: { node: 'data', edge: 'edgeData' }
- });
- // Update dataIndex of nodes and edges because invalid edge may be removed
- graph.update();
- return graph;
- });;
- /***/
- }),
- /* 265 */
- /***/ (function (module, exports, __webpack_require__) {
- var _config = __webpack_require__(104);
- var __DEV__ = _config.__DEV__;
- var zrUtil = __webpack_require__(13);
- var _clazz = __webpack_require__(266);
- var enableClassCheck = _clazz.enableClassCheck;
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- /**
- * Graph data structure
- *
- * @module echarts/data/Graph
- * @author Yi Shen(https://www.github.com/pissang)
- */
- // id may be function name of Object, add a prefix to avoid this problem.
- function generateNodeKey(id) {
- return '_EC_' + id;
- }
- /**
- * @alias module:echarts/data/Graph
- * @constructor
- * @param {boolean} directed
- */
- var Graph = function (directed) {
- /**
- * æ˜¯å¦æ˜¯æœ‰å‘图
- * @type {boolean}
- * @private
- */
- this._directed = directed || false;
- /**
- * @type {Array.<module:echarts/data/Graph.Node>}
- * @readOnly
- */
- this.nodes = [];
- /**
- * @type {Array.<module:echarts/data/Graph.Edge>}
- * @readOnly
- */
- this.edges = [];
- /**
- * @type {Object.<string, module:echarts/data/Graph.Node>}
- * @private
- */
- this._nodesMap = {};
- /**
- * @type {Object.<string, module:echarts/data/Graph.Edge>}
- * @private
- */
- this._edgesMap = {};
- /**
- * @type {module:echarts/data/List}
- * @readOnly
- */
- this.data;
- /**
- * @type {module:echarts/data/List}
- * @readOnly
- */
- this.edgeData;
- };
- var graphProto = Graph.prototype;
- /**
- * @type {string}
- */
- graphProto.type = 'graph';
- /**
- * If is directed graph
- * @return {boolean}
- */
- graphProto.isDirected = function () {
- return this._directed;
- };
- /**
- * Add a new node
- * @param {string} id
- * @param {number} [dataIndex]
- */
- graphProto.addNode = function (id, dataIndex) {
- id = id || '' + dataIndex;
- var nodesMap = this._nodesMap;
- if (nodesMap[generateNodeKey(id)]) {
- return;
- }
- var node = new Node(id, dataIndex);
- node.hostGraph = this;
- this.nodes.push(node);
- nodesMap[generateNodeKey(id)] = node;
- return node;
- };
- /**
- * Get node by data index
- * @param {number} dataIndex
- * @return {module:echarts/data/Graph~Node}
- */
- graphProto.getNodeByIndex = function (dataIndex) {
- var rawIdx = this.data.getRawIndex(dataIndex);
- return this.nodes[rawIdx];
- };
- /**
- * Get node by id
- * @param {string} id
- * @return {module:echarts/data/Graph.Node}
- */
- graphProto.getNodeById = function (id) {
- return this._nodesMap[generateNodeKey(id)];
- };
- /**
- * Add a new edge
- * @param {number|string|module:echarts/data/Graph.Node} n1
- * @param {number|string|module:echarts/data/Graph.Node} n2
- * @param {number} [dataIndex=-1]
- * @return {module:echarts/data/Graph.Edge}
- */
- graphProto.addEdge = function (n1, n2, dataIndex) {
- var nodesMap = this._nodesMap;
- var edgesMap = this._edgesMap; // PNEDING
- if (typeof n1 === 'number') {
- n1 = this.nodes[n1];
- }
- if (typeof n2 === 'number') {
- n2 = this.nodes[n2];
- }
- if (!Node.isInstance(n1)) {
- n1 = nodesMap[generateNodeKey(n1)];
- }
- if (!Node.isInstance(n2)) {
- n2 = nodesMap[generateNodeKey(n2)];
- }
- if (!n1 || !n2) {
- return;
- }
- var key = n1.id + '-' + n2.id; // PENDING
- if (edgesMap[key]) {
- return;
- }
- var edge = new Edge(n1, n2, dataIndex);
- edge.hostGraph = this;
- if (this._directed) {
- n1.outEdges.push(edge);
- n2.inEdges.push(edge);
- }
- n1.edges.push(edge);
- if (n1 !== n2) {
- n2.edges.push(edge);
- }
- this.edges.push(edge);
- edgesMap[key] = edge;
- return edge;
- };
- /**
- * Get edge by data index
- * @param {number} dataIndex
- * @return {module:echarts/data/Graph~Node}
- */
- graphProto.getEdgeByIndex = function (dataIndex) {
- var rawIdx = this.edgeData.getRawIndex(dataIndex);
- return this.edges[rawIdx];
- };
- /**
- * Get edge by two linked nodes
- * @param {module:echarts/data/Graph.Node|string} n1
- * @param {module:echarts/data/Graph.Node|string} n2
- * @return {module:echarts/data/Graph.Edge}
- */
- graphProto.getEdge = function (n1, n2) {
- if (Node.isInstance(n1)) {
- n1 = n1.id;
- }
- if (Node.isInstance(n2)) {
- n2 = n2.id;
- }
- var edgesMap = this._edgesMap;
- if (this._directed) {
- return edgesMap[n1 + '-' + n2];
- } else {
- return edgesMap[n1 + '-' + n2] || edgesMap[n2 + '-' + n1];
- }
- };
- /**
- * Iterate all nodes
- * @param {Function} cb
- * @param {*} [context]
- */
- graphProto.eachNode = function (cb, context) {
- var nodes = this.nodes;
- var len = nodes.length;
- for (var i = 0; i < len; i++) {
- if (nodes[i].dataIndex >= 0) {
- cb.call(context, nodes[i], i);
- }
- }
- };
- /**
- * Iterate all edges
- * @param {Function} cb
- * @param {*} [context]
- */
- graphProto.eachEdge = function (cb, context) {
- var edges = this.edges;
- var len = edges.length;
- for (var i = 0; i < len; i++) {
- if (edges[i].dataIndex >= 0 && edges[i].node1.dataIndex >= 0 && edges[i].node2.dataIndex >= 0) {
- cb.call(context, edges[i], i);
- }
- }
- };
- /**
- * Breadth first traverse
- * @param {Function} cb
- * @param {module:echarts/data/Graph.Node} startNode
- * @param {string} [direction='none'] 'none'|'in'|'out'
- * @param {*} [context]
- */
- graphProto.breadthFirstTraverse = function (cb, startNode, direction, context) {
- if (!Node.isInstance(startNode)) {
- startNode = this._nodesMap[generateNodeKey(startNode)];
- }
- if (!startNode) {
- return;
- }
- var edgeType = direction === 'out' ? 'outEdges' : direction === 'in' ? 'inEdges' : 'edges';
- for (var i = 0; i < this.nodes.length; i++) {
- this.nodes[i].__visited = false;
- }
- if (cb.call(context, startNode, null)) {
- return;
- }
- var queue = [startNode];
- while (queue.length) {
- var currentNode = queue.shift();
- var edges = currentNode[edgeType];
- for (var i = 0; i < edges.length; i++) {
- var e = edges[i];
- var otherNode = e.node1 === currentNode ? e.node2 : e.node1;
- if (!otherNode.__visited) {
- if (cb.call(context, otherNode, currentNode)) {
- // Stop traversing
- return;
- }
- queue.push(otherNode);
- otherNode.__visited = true;
- }
- }
- }
- }; // TODO
- // graphProto.depthFirstTraverse = function (
- // cb, startNode, direction, context
- // ) {
- // };
- // Filter update
- graphProto.update = function () {
- var data = this.data;
- var edgeData = this.edgeData;
- var nodes = this.nodes;
- var edges = this.edges;
- for (var i = 0, len = nodes.length; i < len; i++) {
- nodes[i].dataIndex = -1;
- }
- for (var i = 0, len = data.count(); i < len; i++) {
- nodes[data.getRawIndex(i)].dataIndex = i;
- }
- edgeData.filterSelf(function (idx) {
- var edge = edges[edgeData.getRawIndex(idx)];
- return edge.node1.dataIndex >= 0 && edge.node2.dataIndex >= 0;
- }); // Update edge
- for (var i = 0, len = edges.length; i < len; i++) {
- edges[i].dataIndex = -1;
- }
- for (var i = 0, len = edgeData.count(); i < len; i++) {
- edges[edgeData.getRawIndex(i)].dataIndex = i;
- }
- };
- /**
- * @return {module:echarts/data/Graph}
- */
- graphProto.clone = function () {
- var graph = new Graph(this._directed);
- var nodes = this.nodes;
- var edges = this.edges;
- for (var i = 0; i < nodes.length; i++) {
- graph.addNode(nodes[i].id, nodes[i].dataIndex);
- }
- for (var i = 0; i < edges.length; i++) {
- var e = edges[i];
- graph.addEdge(e.node1.id, e.node2.id, e.dataIndex);
- }
- return graph;
- };
- /**
- * @alias module:echarts/data/Graph.Node
- */
- function Node(id, dataIndex) {
- /**
- * @type {string}
- */
- this.id = id == null ? '' : id;
- /**
- * @type {Array.<module:echarts/data/Graph.Edge>}
- */
- this.inEdges = [];
- /**
- * @type {Array.<module:echarts/data/Graph.Edge>}
- */
- this.outEdges = [];
- /**
- * @type {Array.<module:echarts/data/Graph.Edge>}
- */
- this.edges = [];
- /**
- * @type {module:echarts/data/Graph}
- */
- this.hostGraph;
- /**
- * @type {number}
- */
- this.dataIndex = dataIndex == null ? -1 : dataIndex;
- }
- Node.prototype = {
- constructor: Node,
- /**
- * @return {number}
- */
- degree: function () {
- return this.edges.length;
- },
- /**
- * @return {number}
- */
- inDegree: function () {
- return this.inEdges.length;
- },
- /**
- * @return {number}
- */
- outDegree: function () {
- return this.outEdges.length;
- },
- /**
- * @param {string} [path]
- * @return {module:echarts/model/Model}
- */
- getModel: function (path) {
- if (this.dataIndex < 0) {
- return;
- }
- var graph = this.hostGraph;
- var itemModel = graph.data.getItemModel(this.dataIndex);
- return itemModel.getModel(path);
- }
- };
- /**
- * 图边
- * @alias module:echarts/data/Graph.Edge
- * @param {module:echarts/data/Graph.Node} n1
- * @param {module:echarts/data/Graph.Node} n2
- * @param {number} [dataIndex=-1]
- */
- function Edge(n1, n2, dataIndex) {
- /**
- * 节点1,如果是有å‘图则为æºèŠ‚ç‚¹
- * @type {module:echarts/data/Graph.Node}
- */
- this.node1 = n1;
- /**
- * 节点2,如果是有å‘å›¾åˆ™ä¸ºç›®æ ‡èŠ‚ç‚¹
- * @type {module:echarts/data/Graph.Node}
- */
- this.node2 = n2;
- this.dataIndex = dataIndex == null ? -1 : dataIndex;
- }
- /**
- * @param {string} [path]
- * @return {module:echarts/model/Model}
- */
- Edge.prototype.getModel = function (path) {
- if (this.dataIndex < 0) {
- return;
- }
- var graph = this.hostGraph;
- var itemModel = graph.edgeData.getItemModel(this.dataIndex);
- return itemModel.getModel(path);
- };
- var createGraphDataProxyMixin = function (hostName, dataName) {
- return {
- /**
- * @param {string=} [dimension='value'] Default 'value'. can be 'a', 'b', 'c', 'd', 'e'.
- * @return {number}
- */
- getValue: function (dimension) {
- var data = this[hostName][dataName];
- return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
- },
- /**
- * @param {Object|string} key
- * @param {*} [value]
- */
- setVisual: function (key, value) {
- this.dataIndex >= 0 && this[hostName][dataName].setItemVisual(this.dataIndex, key, value);
- },
- /**
- * @param {string} key
- * @return {boolean}
- */
- getVisual: function (key, ignoreParent) {
- return this[hostName][dataName].getItemVisual(this.dataIndex, key, ignoreParent);
- },
- /**
- * @param {Object} layout
- * @return {boolean} [merge=false]
- */
- setLayout: function (layout, merge) {
- this.dataIndex >= 0 && this[hostName][dataName].setItemLayout(this.dataIndex, layout, merge);
- },
- /**
- * @return {Object}
- */
- getLayout: function () {
- return this[hostName][dataName].getItemLayout(this.dataIndex);
- },
- /**
- * @return {module:zrender/Element}
- */
- getGraphicEl: function () {
- return this[hostName][dataName].getItemGraphicEl(this.dataIndex);
- },
- /**
- * @return {number}
- */
- getRawIndex: function () {
- return this[hostName][dataName].getRawIndex(this.dataIndex);
- }
- };
- };
- zrUtil.mixin(Node, createGraphDataProxyMixin('hostGraph', 'data'));
- zrUtil.mixin(Edge, createGraphDataProxyMixin('hostGraph', 'edgeData'));
- Graph.Node = Node;
- Graph.Edge = Edge;
- enableClassCheck(Node);
- enableClassCheck(Edge);
- var _default = Graph;
- module.exports = _default;
- /***/
- }),
- /* 266 */
- /***/ (function (module, exports, __webpack_require__) {
- var _config = __webpack_require__(104);
- var __DEV__ = _config.__DEV__;
- var zrUtil = __webpack_require__(13);
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- var TYPE_DELIMITER = '.';
- var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___';
- /**
- * Notice, parseClassType('') should returns {main: '', sub: ''}
- * @public
- */
- function parseClassType(componentType) {
- var ret = {
- main: '',
- sub: ''
- };
- if (componentType) {
- componentType = componentType.split(TYPE_DELIMITER);
- ret.main = componentType[0] || '';
- ret.sub = componentType[1] || '';
- }
- return ret;
- }
- /**
- * @public
- */
- function checkClassType(componentType) {
- zrUtil.assert(/^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(componentType), 'componentType "' + componentType + '" illegal');
- }
- /**
- * @public
- */
- function enableClassExtend(RootClass, mandatoryMethods) {
- RootClass.$constructor = RootClass;
- RootClass.extend = function (proto) {
- var superClass = this;
- var ExtendedClass = function () {
- if (!proto.$constructor) {
- superClass.apply(this, arguments);
- } else {
- proto.$constructor.apply(this, arguments);
- }
- };
- zrUtil.extend(ExtendedClass.prototype, proto);
- ExtendedClass.extend = this.extend;
- ExtendedClass.superCall = superCall;
- ExtendedClass.superApply = superApply;
- zrUtil.inherits(ExtendedClass, this);
- ExtendedClass.superClass = superClass;
- return ExtendedClass;
- };
- }
- var classBase = 0;
- /**
- * Can not use instanceof, consider different scope by
- * cross domain or es module import in ec extensions.
- * Mount a method "isInstance()" to Clz.
- */
- function enableClassCheck(Clz) {
- var classAttr = ['__\0is_clz', classBase++, Math.random().toFixed(3)].join('_');
- Clz.prototype[classAttr] = true;
- Clz.isInstance = function (obj) {
- return !!(obj && obj[classAttr]);
- };
- } // superCall should have class info, which can not be fetch from 'this'.
- // Consider this case:
- // class A has method f,
- // class B inherits class A, overrides method f, f call superApply('f'),
- // class C inherits class B, do not overrides method f,
- // then when method of class C is called, dead loop occured.
- function superCall(context, methodName) {
- var args = zrUtil.slice(arguments, 2);
- return this.superClass.prototype[methodName].apply(context, args);
- }
- function superApply(context, methodName, args) {
- return this.superClass.prototype[methodName].apply(context, args);
- }
- /**
- * @param {Object} entity
- * @param {Object} options
- * @param {boolean} [options.registerWhenExtend]
- * @public
- */
- function enableClassManagement(entity, options) {
- options = options || {};
- /**
- * Component model classes
- * key: componentType,
- * value:
- * componentClass, when componentType is 'xxx'
- * or Object.<subKey, componentClass>, when componentType is 'xxx.yy'
- * @type {Object}
- */
- var storage = {};
- entity.registerClass = function (Clazz, componentType) {
- if (componentType) {
- checkClassType(componentType);
- componentType = parseClassType(componentType);
- if (!componentType.sub) {
- storage[componentType.main] = Clazz;
- } else if (componentType.sub !== IS_CONTAINER) {
- var container = makeContainer(componentType);
- container[componentType.sub] = Clazz;
- }
- }
- return Clazz;
- };
- entity.getClass = function (componentMainType, subType, throwWhenNotFound) {
- var Clazz = storage[componentMainType];
- if (Clazz && Clazz[IS_CONTAINER]) {
- Clazz = subType ? Clazz[subType] : null;
- }
- if (throwWhenNotFound && !Clazz) {
- throw new Error(!subType ? componentMainType + '.' + 'type should be specified.' : 'Component ' + componentMainType + '.' + (subType || '') + ' not exists. Load it first.');
- }
- return Clazz;
- };
- entity.getClassesByMainType = function (componentType) {
- componentType = parseClassType(componentType);
- var result = [];
- var obj = storage[componentType.main];
- if (obj && obj[IS_CONTAINER]) {
- zrUtil.each(obj, function (o, type) {
- type !== IS_CONTAINER && result.push(o);
- });
- } else {
- result.push(obj);
- }
- return result;
- };
- entity.hasClass = function (componentType) {
- // Just consider componentType.main.
- componentType = parseClassType(componentType);
- return !!storage[componentType.main];
- };
- /**
- * @return {Array.<string>} Like ['aa', 'bb'], but can not be ['aa.xx']
- */
- entity.getAllClassMainTypes = function () {
- var types = [];
- zrUtil.each(storage, function (obj, type) {
- types.push(type);
- });
- return types;
- };
- /**
- * If a main type is container and has sub types
- * @param {string} mainType
- * @return {boolean}
- */
- entity.hasSubTypes = function (componentType) {
- componentType = parseClassType(componentType);
- var obj = storage[componentType.main];
- return obj && obj[IS_CONTAINER];
- };
- entity.parseClassType = parseClassType;
- function makeContainer(componentType) {
- var container = storage[componentType.main];
- if (!container || !container[IS_CONTAINER]) {
- container = storage[componentType.main] = {};
- container[IS_CONTAINER] = true;
- }
- return container;
- }
- if (options.registerWhenExtend) {
- var originalExtend = entity.extend;
- if (originalExtend) {
- entity.extend = function (proto) {
- var ExtendedClass = originalExtend.call(this, proto);
- return entity.registerClass(ExtendedClass, proto.type);
- };
- }
- }
- return entity;
- }
- /**
- * @param {string|Array.<string>} properties
- */
- function setReadOnly(obj, properties) {// FIXME It seems broken in IE8 simulation of IE11
- // if (!zrUtil.isArray(properties)) {
- // properties = properties != null ? [properties] : [];
- // }
- // zrUtil.each(properties, function (prop) {
- // var value = obj[prop];
- // Object.defineProperty
- // && Object.defineProperty(obj, prop, {
- // value: value, writable: false
- // });
- // zrUtil.isArray(obj[prop])
- // && Object.freeze
- // && Object.freeze(obj[prop]);
- // });
- }
- exports.parseClassType = parseClassType;
- exports.enableClassExtend = enableClassExtend;
- exports.enableClassCheck = enableClassCheck;
- exports.enableClassManagement = enableClassManagement;
- exports.setReadOnly = setReadOnly;
- /***/
- }),
- /* 267 */
- /***/ (function (module, exports, __webpack_require__) {
- var zrUtil = __webpack_require__(13);
- /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
- /**
- * Link lists and struct (graph or tree)
- */
- var each = zrUtil.each;
- var DATAS = '\0__link_datas';
- var MAIN_DATA = '\0__link_mainData'; // Caution:
- // In most case, either list or its shallow clones (see list.cloneShallow)
- // is active in echarts process. So considering heap memory consumption,
- // we do not clone tree or graph, but share them among list and its shallow clones.
- // But in some rare case, we have to keep old list (like do animation in chart). So
- // please take care that both the old list and the new list share the same tree/graph.
- /**
- * @param {Object} opt
- * @param {module:echarts/data/List} opt.mainData
- * @param {Object} [opt.struct] For example, instance of Graph or Tree.
- * @param {string} [opt.structAttr] designation: list[structAttr] = struct;
- * @param {Object} [opt.datas] {dataType: data},
- * like: {node: nodeList, edge: edgeList}.
- * Should contain mainData.
- * @param {Object} [opt.datasAttr] {dataType: attr},
- * designation: struct[datasAttr[dataType]] = list;
- */
- function linkList(opt) {
- var mainData = opt.mainData;
- var datas = opt.datas;
- if (!datas) {
- datas = {
- main: mainData
- };
- opt.datasAttr = {
- main: 'data'
- };
- }
- opt.datas = opt.mainData = null;
- linkAll(mainData, datas, opt); // Porxy data original methods.
- each(datas, function (data) {
- each(mainData.TRANSFERABLE_METHODS, function (methodName) {
- data.wrapMethod(methodName, zrUtil.curry(transferInjection, opt));
- });
- }); // Beyond transfer, additional features should be added to `cloneShallow`.
- mainData.wrapMethod('cloneShallow', zrUtil.curry(cloneShallowInjection, opt)); // Only mainData trigger change, because struct.update may trigger
- // another changable methods, which may bring about dead lock.
- each(mainData.CHANGABLE_METHODS, function (methodName) {
- mainData.wrapMethod(methodName, zrUtil.curry(changeInjection, opt));
- }); // Make sure datas contains mainData.
- zrUtil.assert(datas[mainData.dataType] === mainData);
- }
- function transferInjection(opt, res) {
- if (isMainData(this)) {
- // Transfer datas to new main data.
- var datas = zrUtil.extend({}, this[DATAS]);
- datas[this.dataType] = res;
- linkAll(res, datas, opt);
- } else {
- // Modify the reference in main data to point newData.
- linkSingle(res, this.dataType, this[MAIN_DATA], opt);
- }
- return res;
- }
- function changeInjection(opt, res) {
- opt.struct && opt.struct.update(this);
- return res;
- }
- function cloneShallowInjection(opt, res) {
- // cloneShallow, which brings about some fragilities, may be inappropriate
- // to be exposed as an API. So for implementation simplicity we can make
- // the restriction that cloneShallow of not-mainData should not be invoked
- // outside, but only be invoked here.
- each(res[DATAS], function (data, dataType) {
- data !== res && linkSingle(data.cloneShallow(), dataType, res, opt);
- });
- return res;
- }
- /**
- * Supplement method to List.
- *
- * @public
- * @param {string} [dataType] If not specified, return mainData.
- * @return {module:echarts/data/List}
- */
- function getLinkedData(dataType) {
- var mainData = this[MAIN_DATA];
- return dataType == null || mainData == null ? mainData : mainData[DATAS][dataType];
- }
- function isMainData(data) {
- return data[MAIN_DATA] === data;
- }
- function linkAll(mainData, datas, opt) {
- mainData[DATAS] = {};
- each(datas, function (data, dataType) {
- linkSingle(data, dataType, mainData, opt);
- });
- }
- function linkSingle(data, dataType, mainData, opt) {
- mainData[DATAS][dataType] = data;
- data[MAIN_DATA] = mainData;
- data.dataType = dataType;
- if (opt.struct) {
- data[opt.structAttr] = opt.struct;
- opt.struct[opt.datasAttr[dataType]] = data;
- } // Supplement method.
- data.getLinkedData = getLinkedData;
- }
- var _default = linkList;
- module.exports = _default;
- /***/
- }),
- /* 268 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_util_layout__ = __webpack_require__(47);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_util_layout___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_util_layout__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(22);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__util_geometry_Lines2D__ = __webpack_require__(105);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__ForceAtlas2GPU__ = __webpack_require__(269);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__ForceAtlas2__ = __webpack_require__(271);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_zrender_lib_animation_requestAnimationFrame__ = __webpack_require__(80);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_zrender_lib_animation_requestAnimationFrame___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8_zrender_lib_animation_requestAnimationFrame__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_claygl_src_dep_glmatrix__ = __webpack_require__(6);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__util_Roam2DControl__ = __webpack_require__(273);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__common_PointsBuilder__ = __webpack_require__(67);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__util_shader_lines2D_glsl_js__ = __webpack_require__(274);
- var vec2 = __WEBPACK_IMPORTED_MODULE_9_claygl_src_dep_glmatrix__["a" /* default */].vec2;
- __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_12__util_shader_lines2D_glsl_js__["a" /* default */]);
- var globalLayoutId = 1;
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({
- type: 'graphGL',
- __ecgl__: true,
- init: function (ecModel, api) {
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Node();
- this.viewGL = new __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__["a" /* default */]('orthographic');
- this.viewGL.camera.left = this.viewGL.camera.right = 0;
- this.viewGL.add(this.groupGL);
- this._pointsBuilder = new __WEBPACK_IMPORTED_MODULE_11__common_PointsBuilder__["a" /* default */](true, api);
- // Mesh used during force directed layout.
- this._forceEdgesMesh = new __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Mesh({
- material: new __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Material({
- shader: __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].createShader('ecgl.forceAtlas2.edges'),
- transparent: true,
- depthMask: false,
- depthTest: false
- }),
- $ignorePicking: true,
- geometry: new __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Geometry({
- attributes: {
- node: new __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Geometry.Attribute('node', 'float', 2),
- color: new __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Geometry.Attribute('color', 'float', 4, 'COLOR')
- },
- dynamic: true,
- mainAttribute: 'node'
- }),
- renderOrder: -1,
- mode: __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Mesh.LINES
- });
- // Mesh used after force directed layout.
- this._edgesMesh = new __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Mesh({
- material: new __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].Material({
- shader: __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].createShader('ecgl.meshLines2D'),
- transparent: true,
- depthMask: false,
- depthTest: false
- }),
- $ignorePicking: true,
- geometry: new __WEBPACK_IMPORTED_MODULE_4__util_geometry_Lines2D__["a" /* default */]({
- useNativeLine: false,
- dynamic: true
- }),
- renderOrder: -1,
- culling: false
- });
- this._layoutId = 0;
- this._control = new __WEBPACK_IMPORTED_MODULE_10__util_Roam2DControl__["a" /* default */]({
- zr: api.getZr(),
- viewGL: this.viewGL
- });
- this._control.setTarget(this.groupGL);
- this._control.init();
- this._clickHandler = this._clickHandler.bind(this);
- },
- render: function (seriesModel, ecModel, api) {
- this.groupGL.add(this._pointsBuilder.rootNode);
- this._model = seriesModel;
- this._api = api;
- this._initLayout(seriesModel, ecModel, api);
- this._pointsBuilder.update(seriesModel, ecModel, api);
- if (!(this._forceLayoutInstance instanceof __WEBPACK_IMPORTED_MODULE_6__ForceAtlas2GPU__["a" /* default */])) {
- this.groupGL.remove(this._forceEdgesMesh);
- }
- this._updateCamera(seriesModel, api);
- this._control.off('update');
- this._control.on('update', function () {
- api.dispatchAction({
- type: 'graphGLRoam',
- seriesId: seriesModel.id,
- zoom: this._control.getZoom(),
- offset: this._control.getOffset()
- });
- this._pointsBuilder.updateView(this.viewGL.camera);
- }, this);
- this._control.setZoom(__WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(seriesModel.get('zoom'), 1));
- this._control.setOffset(seriesModel.get('offset') || [0, 0]);
- var mesh = this._pointsBuilder.getPointsMesh();
- mesh.off('mousemove', this._mousemoveHandler);
- mesh.off('mouseout', this._mouseOutHandler, this);
- api.getZr().off('click', this._clickHandler);
- this._pointsBuilder.highlightOnMouseover = true;
- if (seriesModel.get('focusNodeAdjacency')) {
- var focusNodeAdjacencyOn = seriesModel.get('focusNodeAdjacencyOn');
- if (focusNodeAdjacencyOn === 'click') {
- // Remove default emphasis effect
- api.getZr().on('click', this._clickHandler);
- }
- else if (focusNodeAdjacencyOn === 'mouseover') {
- mesh.on('mousemove', this._mousemoveHandler, this);
- mesh.on('mouseout', this._mouseOutHandler, this);
- this._pointsBuilder.highlightOnMouseover = false;
- }
- else {
- if (true) {
- console.warn('Unkown focusNodeAdjacencyOn value \s' + focusNodeAdjacencyOn);
- }
- }
- }
- // Reset
- this._lastMouseOverDataIndex = -1;
- },
- _clickHandler: function (e) {
- if (this._layouting) {
- return;
- }
- var dataIndex = this._pointsBuilder.getPointsMesh().dataIndex;
- if (dataIndex >= 0) {
- this._api.dispatchAction({
- type: 'graphGLFocusNodeAdjacency',
- seriesId: this._model.id,
- dataIndex: dataIndex
- });
- }
- else {
- this._api.dispatchAction({
- type: 'graphGLUnfocusNodeAdjacency',
- seriesId: this._model.id
- });
- }
- },
- _mousemoveHandler: function (e) {
- if (this._layouting) {
- return;
- }
- var dataIndex = this._pointsBuilder.getPointsMesh().dataIndex;
- if (dataIndex >= 0) {
- if (dataIndex !== this._lastMouseOverDataIndex) {
- this._api.dispatchAction({
- type: 'graphGLFocusNodeAdjacency',
- seriesId: this._model.id,
- dataIndex: dataIndex
- });
- }
- }
- else {
- this._mouseOutHandler(e);
- }
- this._lastMouseOverDataIndex = dataIndex;
- },
- _mouseOutHandler: function (e) {
- if (this._layouting) {
- return;
- }
- this._api.dispatchAction({
- type: 'graphGLUnfocusNodeAdjacency',
- seriesId: this._model.id
- });
- this._lastMouseOverDataIndex = -1;
- },
- _updateForceEdgesGeometry: function (edges, seriesModel) {
- var geometry = this._forceEdgesMesh.geometry;
- var edgeData = seriesModel.getEdgeData();
- var offset = 0;
- var layoutInstance = this._forceLayoutInstance;
- var vertexCount = edgeData.count() * 2;
- geometry.attributes.node.init(vertexCount);
- geometry.attributes.color.init(vertexCount);
- edgeData.each(function (idx) {
- var edge = edges[idx];
- geometry.attributes.node.set(offset, layoutInstance.getNodeUV(edge.node1));
- geometry.attributes.node.set(offset + 1, layoutInstance.getNodeUV(edge.node2));
- var color = edgeData.getItemVisual(edge.dataIndex, 'color');
- var colorArr = __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].parseColor(color);
- colorArr[3] *= __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(
- edgeData.getItemVisual(edge.dataIndex, 'opacity'), 1
- );
- geometry.attributes.color.set(offset, colorArr);
- geometry.attributes.color.set(offset + 1, colorArr);
- offset += 2;
- });
- geometry.dirty();
- },
- _updateMeshLinesGeometry: function () {
- var edgeData = this._model.getEdgeData();
- var geometry = this._edgesMesh.geometry;
- var edgeData = this._model.getEdgeData();
- var points = this._model.getData().getLayout('points');
- geometry.resetOffset();
- geometry.setVertexCount(edgeData.count() * geometry.getLineVertexCount());
- geometry.setTriangleCount(edgeData.count() * geometry.getLineTriangleCount());
- var p0 = [];
- var p1 = [];
- var lineWidthQuery = ['lineStyle', 'width'];
- this._originalEdgeColors = new Float32Array(edgeData.count() * 4);
- this._edgeIndicesMap = new Float32Array(edgeData.count());
- edgeData.each(function (idx) {
- var edge = edgeData.graph.getEdgeByIndex(idx);
- var idx1 = edge.node1.dataIndex * 2;
- var idx2 = edge.node2.dataIndex * 2;
- p0[0] = points[idx1];
- p0[1] = points[idx1 + 1];
- p1[0] = points[idx2];
- p1[1] = points[idx2 + 1];
- var color = edgeData.getItemVisual(edge.dataIndex, 'color');
- var colorArr = __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].parseColor(color);
- colorArr[3] *= __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(edgeData.getItemVisual(edge.dataIndex, 'opacity'), 1);
- var itemModel = edgeData.getItemModel(edge.dataIndex);
- var lineWidth = __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(itemModel.get(lineWidthQuery), 1) * this._api.getDevicePixelRatio();
- geometry.addLine(p0, p1, colorArr, lineWidth);
- for (var k = 0; k < 4; k++) {
- this._originalEdgeColors[edge.dataIndex * 4 + k] = colorArr[k];
- }
- this._edgeIndicesMap[edge.dataIndex] = idx;
- }, this);
- geometry.dirty();
- },
- _updateForceNodesGeometry: function (nodeData) {
- var pointsMesh = this._pointsBuilder.getPointsMesh();
- var pos = [];
- for (var i = 0; i < nodeData.count(); i++) {
- this._forceLayoutInstance.getNodeUV(i, pos);
- pointsMesh.geometry.attributes.position.set(i, pos);
- }
- pointsMesh.geometry.dirty('position');
- },
- _initLayout: function (seriesModel, ecModel, api) {
- var layout = seriesModel.get('layout');
- var graph = seriesModel.getGraph();
- var boxLayoutOption = seriesModel.getBoxLayoutParams();
- var viewport = __WEBPACK_IMPORTED_MODULE_1_echarts_lib_util_layout___default.a.getLayoutRect(boxLayoutOption, {
- width: api.getWidth(),
- height: api.getHeight()
- });
- if (layout === 'force') {
- if (true) {
- console.warn('Currently only forceAtlas2 layout supported.');
- }
- layout = 'forceAtlas2';
- }
- // Stop previous layout
- this.stopLayout(seriesModel, ecModel, api, {
- beforeLayout: true
- });
- var nodeData = seriesModel.getData();
- var edgeData = seriesModel.getData();
- if (layout === 'forceAtlas2') {
- var layoutModel = seriesModel.getModel('forceAtlas2');
- var layoutInstance = this._forceLayoutInstance;
- var nodes = [];
- var edges = [];
- var nodeDataExtent = nodeData.getDataExtent('value');
- var edgeDataExtent = edgeData.getDataExtent('value');
- var edgeWeightRange = __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(layoutModel.get('edgeWeight'), 1.0);
- var nodeWeightRange = __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(layoutModel.get('nodeWeight'), 1.0);
- if (typeof edgeWeightRange === 'number') {
- edgeWeightRange = [edgeWeightRange, edgeWeightRange];
- }
- if (typeof nodeWeightRange === 'number') {
- nodeWeightRange = [nodeWeightRange, nodeWeightRange];
- }
- var offset = 0;
- var nodesIndicesMap = {};
- var layoutPoints = new Float32Array(nodeData.count() * 2);
- graph.eachNode(function (node) {
- var dataIndex = node.dataIndex;
- var value = nodeData.get('value', dataIndex);
- var x;
- var y;
- if (nodeData.hasItemOption) {
- var itemModel = nodeData.getItemModel(dataIndex);
- x = itemModel.get('x');
- y = itemModel.get('y');
- }
- if (x == null) {
- // Random in rectangle
- x = viewport.x + Math.random() * viewport.width;
- y = viewport.y + Math.random() * viewport.height;
- }
- layoutPoints[offset * 2] = x;
- layoutPoints[offset * 2 + 1] = y;
- nodesIndicesMap[node.id] = offset++;
- var mass = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.number.linearMap(value, nodeDataExtent, nodeWeightRange);
- if (isNaN(mass)) {
- if (!isNaN(nodeWeightRange[0])) {
- mass = nodeWeightRange[0];
- }
- else {
- mass = 1;
- }
- }
- nodes.push({
- x: x, y: y, mass: mass, size: nodeData.getItemVisual(dataIndex, 'symbolSize')
- });
- });
- nodeData.setLayout('points', layoutPoints);
- graph.eachEdge(function (edge) {
- var dataIndex = edge.dataIndex;
- var value = nodeData.get('value', dataIndex);
- var weight = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.number.linearMap(value, edgeDataExtent, edgeWeightRange);
- if (isNaN(weight)) {
- if (!isNaN(edgeWeightRange[0])) {
- weight = edgeWeightRange[0];
- }
- else {
- weight = 1;
- }
- }
- edges.push({
- node1: nodesIndicesMap[edge.node1.id],
- node2: nodesIndicesMap[edge.node2.id],
- weight: weight,
- dataIndex: dataIndex
- });
- });
- if (!layoutInstance) {
- var isGPU = layoutModel.get('GPU');
- if (this._forceLayoutInstance) {
- if ((isGPU && !(this._forceLayoutInstance instanceof __WEBPACK_IMPORTED_MODULE_6__ForceAtlas2GPU__["a" /* default */]))
- || (!isGPU && !(this._forceLayoutInstance instanceof __WEBPACK_IMPORTED_MODULE_7__ForceAtlas2__["a" /* default */]))
- ) {
- // Mark to dispose
- this._forceLayoutInstanceToDispose = this._forceLayoutInstance;
- }
- }
- layoutInstance = this._forceLayoutInstance = isGPU
- ? new __WEBPACK_IMPORTED_MODULE_6__ForceAtlas2GPU__["a" /* default */]()
- : new __WEBPACK_IMPORTED_MODULE_7__ForceAtlas2__["a" /* default */]();
- }
- layoutInstance.initData(nodes, edges);
- layoutInstance.updateOption(layoutModel.option);
- // Update lines geometry after first layout;
- this._updateForceEdgesGeometry(layoutInstance.getEdges(), seriesModel);
- this._updatePositionTexture();
- api.dispatchAction({
- type: 'graphGLStartLayout',
- from: this.uid
- });
- }
- else {
- var layoutPoints = new Float32Array(nodeData.count() * 2);
- var offset = 0;
- graph.eachNode(function (node) {
- var dataIndex = node.dataIndex;
- var x;
- var y;
- if (nodeData.hasItemOption) {
- var itemModel = nodeData.getItemModel(dataIndex);
- x = itemModel.get('x');
- y = itemModel.get('y');
- }
- layoutPoints[offset++] = x;
- layoutPoints[offset++] = y;
- });
- nodeData.setLayout('points', layoutPoints);
- this._updateAfterLayout(seriesModel, ecModel, api);
- }
- },
- _updatePositionTexture: function () {
- var positionTex = this._forceLayoutInstance.getNodePositionTexture();
- this._pointsBuilder.setPositionTexture(positionTex);
- this._forceEdgesMesh.material.set('positionTex', positionTex);
- },
- startLayout: function (seriesModel, ecModel, api, payload) {
- if (payload && payload.from != null && payload.from !== this.uid) {
- return;
- }
- var viewGL = this.viewGL;
- var api = this._api;
- var layoutInstance = this._forceLayoutInstance;
- var data = this._model.getData();
- var layoutModel = this._model.getModel('forceAtlas2');
- if (!layoutInstance) {
- if (true) {
- console.error('None layout don\'t have startLayout action');
- }
- return;
- }
- this.groupGL.remove(this._edgesMesh);
- this.groupGL.add(this._forceEdgesMesh);
- if (!this._forceLayoutInstance) {
- return;
- }
- this._updateForceNodesGeometry(seriesModel.getData());
- this._pointsBuilder.hideLabels();
- var self = this;
- var layoutId = this._layoutId = globalLayoutId++;
- var maxSteps = layoutModel.getShallow('maxSteps');
- var steps = layoutModel.getShallow('steps');
- var stepsCount = 0;
- var syncStepCount = Math.max(steps * 2, 20);
- var doLayout = function (layoutId) {
- if (layoutId !== self._layoutId) {
- return;
- }
- if (layoutInstance.isFinished(maxSteps)) {
- api.dispatchAction({
- type: 'graphGLStopLayout',
- from: self.uid
- });
- api.dispatchAction({
- type: 'graphGLFinishLayout',
- points: data.getLayout('points'),
- from: self.uid
- });
- return;
- }
- layoutInstance.update(viewGL.layer.renderer, steps, function () {
- self._updatePositionTexture();
- // PENDING Performance.
- stepsCount += steps;
- // Sync posiiton every 20 steps.
- if (stepsCount >= syncStepCount) {
- self._syncNodePosition(seriesModel);
- stepsCount = 0;
- }
- // Position texture will been swapped. set every time.
- api.getZr().refresh();
- __WEBPACK_IMPORTED_MODULE_8_zrender_lib_animation_requestAnimationFrame___default()(function () {
- doLayout(layoutId);
- });
- });
- };
- __WEBPACK_IMPORTED_MODULE_8_zrender_lib_animation_requestAnimationFrame___default()(function () {
- if (self._forceLayoutInstanceToDispose) {
- self._forceLayoutInstanceToDispose.dispose(viewGL.layer.renderer);
- self._forceLayoutInstanceToDispose = null;
- }
- doLayout(layoutId);
- });
- this._layouting = true;
- },
- stopLayout: function (seriesModel, ecModel, api, payload) {
- if (payload && payload.from != null && payload.from !== this.uid) {
- return;
- }
- this._layoutId = 0;
- this.groupGL.remove(this._forceEdgesMesh);
- this.groupGL.add(this._edgesMesh);
- if (!this._forceLayoutInstance) {
- return;
- }
- if (!this.viewGL.layer) {
- return;
- }
- if (!(payload && payload.beforeLayout)) {
- this._syncNodePosition(seriesModel);
- this._updateAfterLayout(seriesModel, ecModel, api);
- }
- this._api.getZr().refresh();
- this._layouting = false;
- },
- _syncNodePosition: function (seriesModel) {
- var points = this._forceLayoutInstance.getNodePosition(this.viewGL.layer.renderer);
- seriesModel.getData().setLayout('points', points);
- seriesModel.setNodePosition(points);
- },
- _updateAfterLayout: function (seriesModel, ecModel, api) {
- this._updateMeshLinesGeometry();
- this._pointsBuilder.removePositionTexture();
- this._pointsBuilder.updateLayout(seriesModel, ecModel, api);
- this._pointsBuilder.updateView(this.viewGL.camera);
- this._pointsBuilder.updateLabels();
- this._pointsBuilder.showLabels();
- },
- focusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
- var data = this._model.getData();
- this._downplayAll();
- var dataIndex = payload.dataIndex;
- var graph = data.graph;
- var focusNodes = [];
- var node = graph.getNodeByIndex(dataIndex);
- focusNodes.push(node);
- node.edges.forEach(function (edge) {
- if (edge.dataIndex < 0) {
- return;
- }
- edge.node1 !== node && focusNodes.push(edge.node1);
- edge.node2 !== node && focusNodes.push(edge.node2);
- }, this);
- this._pointsBuilder.fadeOutAll(0.05);
- this._fadeOutEdgesAll(0.05);
- focusNodes.forEach(function (node) {
- this._pointsBuilder.highlight(data, node.dataIndex);
- }, this);
- this._pointsBuilder.updateLabels(focusNodes.map(function (node) {
- return node.dataIndex;
- }));
- var focusEdges = [];
- node.edges.forEach(function (edge) {
- if (edge.dataIndex >= 0) {
- this._highlightEdge(edge.dataIndex);
- focusEdges.push(edge);
- }
- }, this);
- this._focusNodes = focusNodes;
- this._focusEdges = focusEdges;
- },
- unfocusNodeAdjacency: function (seriesModel, ecModel, api, payload) {
- this._downplayAll();
- this._pointsBuilder.fadeInAll();
- this._fadeInEdgesAll();
- this._pointsBuilder.updateLabels();
- },
- _highlightEdge: function (dataIndex) {
- var itemModel = this._model.getEdgeData().getItemModel(dataIndex);
- var emphasisColor = __WEBPACK_IMPORTED_MODULE_2__util_graphicGL__["a" /* default */].parseColor(itemModel.get('emphasis.lineStyle.color') || itemModel.get('lineStyle.color'));
- var emphasisOpacity = __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(itemModel.get('emphasis.lineStyle.opacity'), itemModel.get('lineStyle.opacity'), 1);
- emphasisColor[3] *= emphasisOpacity;
- this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[dataIndex], emphasisColor);
- },
- _downplayAll: function () {
- if (this._focusNodes) {
- this._focusNodes.forEach(function (node) {
- this._pointsBuilder.downplay(this._model.getData(), node.dataIndex);
- }, this);
- }
- if (this._focusEdges) {
- this._focusEdges.forEach(function (edge) {
- this._downplayEdge(edge.dataIndex);
- }, this);
- }
- },
- _downplayEdge: function (dataIndex) {
- var color = this._getColor(dataIndex, []);
- this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[dataIndex], color);
- },
- _setEdgeFade: (function () {
- var color = [];
- return function (dataIndex, percent) {
- this._getColor(dataIndex, color);
- color[3] *= percent;
- this._edgesMesh.geometry.setItemColor(this._edgeIndicesMap[dataIndex], color);
- };
- })(),
- _getColor: function (dataIndex, out) {
- for (var i = 0; i < 4; i++) {
- out[i] = this._originalEdgeColors[dataIndex * 4 + i];
- }
- return out;
- },
- _fadeOutEdgesAll: function (percent) {
- var graph = this._model.getData().graph;
- graph.eachEdge(function (edge) {
- this._setEdgeFade(edge.dataIndex, percent);
- }, this);
- },
- _fadeInEdgesAll: function () {
- this._fadeOutEdgesAll(1);
- },
- _updateCamera: function (seriesModel, api) {
- this.viewGL.setViewport(0, 0, api.getWidth(), api.getHeight(), api.getDevicePixelRatio());
- var camera = this.viewGL.camera;
- var nodeData = seriesModel.getData();
- var points = nodeData.getLayout('points');
- var min = vec2.create(Infinity, Infinity);
- var max = vec2.create(-Infinity, -Infinity);
- var pt = [];
- for (var i = 0; i < points.length;) {
- pt[0] = points[i++];
- pt[1] = points[i++];
- vec2.min(min, min, pt);
- vec2.max(max, max, pt);
- }
- var cy = (max[1] + min[1]) / 2;
- var cx = (max[0] + min[0]) / 2;
- // Only fit the camera when graph is not in the center.
- // PENDING
- if (cx > camera.left && cx < camera.right
- && cy < camera.bottom && cy > camera.top
- ) {
- return;
- }
- // Scale a bit
- var width = Math.max(max[0] - min[0], 10);
- // Keep aspect
- var height = width / api.getWidth() * api.getHeight();
- width *= 1.4;
- height *= 1.4;
- min[0] -= width * 0.2;
- camera.left = min[0];
- camera.top = cy - height / 2;
- camera.bottom = cy + height / 2;
- camera.right = width + min[0];
- camera.near = 0;
- camera.far = 100;
- },
- dispose: function () {
- var renderer = this.viewGL.layer.renderer;
- if (this._forceLayoutInstance) {
- this._forceLayoutInstance.dispose(renderer);
- }
- this.groupGL.removeAll();
- // Stop layout.
- this._layoutId = -1;
- },
- remove: function () {
- this.groupGL.removeAll();
- this._control.dispose();
- }
- });
- /***/
- }),
- /* 269 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_compositor_Pass__ = __webpack_require__(16);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_FrameBuffer__ = __webpack_require__(10);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__forceAtlas2_glsl_js__ = __webpack_require__(270);
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.import(__WEBPACK_IMPORTED_MODULE_4__forceAtlas2_glsl_js__["a" /* default */]);
- var defaultConfigs = {
- repulsionByDegree: true,
- linLogMode: false,
- strongGravityMode: false,
- gravity: 1.0,
- scaling: 1.0,
- edgeWeightInfluence: 1.0,
- jitterTolerence: 0.1,
- preventOverlap: false,
- dissuadeHubs: false,
- gravityCenter: null
- };
- function ForceAtlas2GPU(options) {
- var textureOpt = {
- type: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture.FLOAT,
- minFilter: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture.NEAREST,
- magFilter: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture.NEAREST
- };
- this._positionSourceTex = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture2D(textureOpt);
- this._positionSourceTex.flipY = false;
- this._positionTex = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture2D(textureOpt);
- this._positionPrevTex = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture2D(textureOpt);
- this._forceTex = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture2D(textureOpt);
- this._forcePrevTex = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture2D(textureOpt);
- this._weightedSumTex = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture2D(textureOpt);
- this._weightedSumTex.width = this._weightedSumTex.height = 1;
- this._globalSpeedTex = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture2D(textureOpt);
- this._globalSpeedPrevTex = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture2D(textureOpt);
- this._globalSpeedTex.width = this._globalSpeedTex.height = 1;
- this._globalSpeedPrevTex.width = this._globalSpeedPrevTex.height = 1;
- this._nodeRepulsionPass = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('ecgl.forceAtlas2.updateNodeRepulsion')
- });
- this._positionPass = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('ecgl.forceAtlas2.updatePosition')
- });
- this._globalSpeedPass = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('ecgl.forceAtlas2.calcGlobalSpeed')
- });
- this._copyPass = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('clay.compositor.output')
- });
- var additiveBlend = function (gl) {
- gl.blendEquation(gl.FUNC_ADD);
- gl.blendFunc(gl.ONE, gl.ONE);
- };
- this._edgeForceMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Geometry({
- attributes: {
- node1: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Geometry.Attribute('node1', 'float', 2),
- node2: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Geometry.Attribute('node2', 'float', 2),
- weight: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Geometry.Attribute('weight', 'float', 1)
- },
- dynamic: true,
- mainAttribute: 'node1'
- }),
- material: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- transparent: true,
- shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.forceAtlas2.updateEdgeAttraction'),
- blend: additiveBlend,
- depthMask: false,
- depthText: false
- }),
- mode: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.POINTS
- });
- this._weightedSumMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Geometry({
- attributes: {
- node: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Geometry.Attribute('node', 'float', 2)
- },
- dynamic: true,
- mainAttribute: 'node'
- }),
- material: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- transparent: true,
- shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.forceAtlas2.calcWeightedSum'),
- blend: additiveBlend,
- depthMask: false,
- depthText: false
- }),
- mode: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.POINTS
- });
- this._framebuffer = new __WEBPACK_IMPORTED_MODULE_3_claygl_src_FrameBuffer__["a" /* default */]({
- depthBuffer: false
- });
- this._dummyCamera = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].OrthographicCamera({
- left: -1, right: 1,
- top: 1, bottom: -1,
- near: 0, far: 100
- });
- this._globalSpeed = 0;
- }
- ForceAtlas2GPU.prototype.updateOption = function (options) {
- // Default config
- for (var name in defaultConfigs) {
- this[name] = defaultConfigs[name];
- }
- // Config according to data scale
- var nNodes = this._nodes.length;
- if (nNodes > 50000) {
- this.jitterTolerence = 10;
- }
- else if (nNodes > 5000) {
- this.jitterTolerence = 1;
- }
- else {
- this.jitterTolerence = 0.1;
- }
- if (nNodes > 100) {
- this.scaling = 2.0;
- }
- else {
- this.scaling = 10.0;
- }
- // this.edgeWeightInfluence = 1;
- // this.gravity = 1;
- // this.strongGravityMode = false;
- if (options) {
- for (var name in defaultConfigs) {
- if (options[name] != null) {
- this[name] = options[name];
- }
- }
- }
- if (this.repulsionByDegree) {
- var positionBuffer = this._positionSourceTex.pixels;
- for (var i = 0; i < this._nodes.length; i++) {
- positionBuffer[i * 4 + 2] = (this._nodes[i].degree || 0) + 1;
- }
- }
- };
- ForceAtlas2GPU.prototype._updateGravityCenter = function (options) {
- var nodes = this._nodes;
- var edges = this._edges;
- if (!this.gravityCenter) {
- var min = [Infinity, Infinity];
- var max = [-Infinity, -Infinity];
- for (var i = 0; i < nodes.length; i++) {
- min[0] = Math.min(nodes[i].x, min[0]);
- min[1] = Math.min(nodes[i].y, min[1]);
- max[0] = Math.max(nodes[i].x, max[0]);
- max[1] = Math.max(nodes[i].y, max[1]);
- }
- this._gravityCenter = [(min[0] + max[0]) * 0.5, (min[1] + max[1]) * 0.5];
- }
- else {
- this._gravityCenter = this.gravityCenter;
- }
- // Update inDegree, outDegree
- for (var i = 0; i < edges.length; i++) {
- var node1 = edges[i].node1;
- var node2 = edges[i].node2;
- nodes[node1].degree = (nodes[node1].degree || 0) + 1;
- nodes[node2].degree = (nodes[node2].degree || 0) + 1;
- }
- };
- /**
- * @param {Array.<Object>} [{ x, y, mass }] nodes
- * @param {Array.<Object>} [{ node1, node2, weight }] edges
- */
- ForceAtlas2GPU.prototype.initData = function (nodes, edges) {
- this._nodes = nodes;
- this._edges = edges;
- this._updateGravityCenter();
- var textureWidth = Math.ceil(Math.sqrt(nodes.length));
- var textureHeight = textureWidth;
- var positionBuffer = new Float32Array(textureWidth * textureHeight * 4);
- this._resize(textureWidth, textureHeight);
- var offset = 0;
- for (var i = 0; i < nodes.length; i++) {
- var node = nodes[i];
- positionBuffer[offset++] = node.x || 0;
- positionBuffer[offset++] = node.y || 0;
- positionBuffer[offset++] = node.mass || 1;
- positionBuffer[offset++] = node.size || 1;
- }
- this._positionSourceTex.pixels = positionBuffer;
- var edgeGeometry = this._edgeForceMesh.geometry;
- var edgeLen = edges.length;
- edgeGeometry.attributes.node1.init(edgeLen * 2);
- edgeGeometry.attributes.node2.init(edgeLen * 2);
- edgeGeometry.attributes.weight.init(edgeLen * 2);
- var uv = [];
- for (var i = 0; i < edges.length; i++) {
- var attributes = edgeGeometry.attributes;
- var weight = edges[i].weight;
- if (weight == null) {
- weight = 1;
- }
- // Two way.
- attributes.node1.set(i, this.getNodeUV(edges[i].node1, uv));
- attributes.node2.set(i, this.getNodeUV(edges[i].node2, uv));
- attributes.weight.set(i, weight);
- attributes.node1.set(i + edgeLen, this.getNodeUV(edges[i].node2, uv));
- attributes.node2.set(i + edgeLen, this.getNodeUV(edges[i].node1, uv));
- attributes.weight.set(i + edgeLen, weight);
- }
- var weigtedSumGeo = this._weightedSumMesh.geometry;
- weigtedSumGeo.attributes.node.init(nodes.length);
- for (var i = 0; i < nodes.length; i++) {
- weigtedSumGeo.attributes.node.set(i, this.getNodeUV(i, uv));
- }
- edgeGeometry.dirty();
- weigtedSumGeo.dirty();
- this._nodeRepulsionPass.material.define('fragment', 'NODE_COUNT', nodes.length);
- this._nodeRepulsionPass.material.setUniform('textureSize', [textureWidth, textureHeight]);
- this._inited = false;
- this._frame = 0;
- };
- ForceAtlas2GPU.prototype.getNodes = function () {
- return this._nodes;
- };
- ForceAtlas2GPU.prototype.getEdges = function () {
- return this._edges;
- };
- ForceAtlas2GPU.prototype.step = function (renderer) {
- if (!this._inited) {
- this._initFromSource(renderer);
- this._inited = true;
- }
- this._frame++;
- this._framebuffer.attach(this._forceTex);
- this._framebuffer.bind(renderer);
- var nodeRepulsionPass = this._nodeRepulsionPass;
- // Calc node repulsion, gravity
- nodeRepulsionPass.setUniform('strongGravityMode', this.strongGravityMode);
- nodeRepulsionPass.setUniform('gravity', this.gravity);
- nodeRepulsionPass.setUniform('gravityCenter', this._gravityCenter);
- nodeRepulsionPass.setUniform('scaling', this.scaling);
- nodeRepulsionPass.setUniform('preventOverlap', this.preventOverlap);
- nodeRepulsionPass.setUniform('positionTex', this._positionPrevTex);
- nodeRepulsionPass.render(renderer);
- // Calc edge attraction force
- var edgeForceMesh = this._edgeForceMesh;
- edgeForceMesh.material.set('linLogMode', this.linLogMode);
- edgeForceMesh.material.set('edgeWeightInfluence', this.edgeWeightInfluence);
- edgeForceMesh.material.set('preventOverlap', this.preventOverlap);
- edgeForceMesh.material.set('positionTex', this._positionPrevTex);
- renderer.gl.enable(renderer.gl.BLEND);
- renderer.renderPass([edgeForceMesh], this._dummyCamera);
- // Calc weighted sum.
- this._framebuffer.attach(this._weightedSumTex);
- renderer.gl.clearColor(0, 0, 0, 0);
- renderer.gl.clear(renderer.gl.COLOR_BUFFER_BIT);
- renderer.gl.enable(renderer.gl.BLEND);
- var weightedSumMesh = this._weightedSumMesh;
- weightedSumMesh.material.set('positionTex', this._positionPrevTex);
- weightedSumMesh.material.set('forceTex', this._forceTex);
- weightedSumMesh.material.set('forcePrevTex', this._forcePrevTex);
- renderer.renderPass([weightedSumMesh], this._dummyCamera);
- // Calc global speed.
- this._framebuffer.attach(this._globalSpeedTex);
- var globalSpeedPass = this._globalSpeedPass;
- globalSpeedPass.setUniform('globalSpeedPrevTex', this._globalSpeedPrevTex);
- globalSpeedPass.setUniform('weightedSumTex', this._weightedSumTex);
- globalSpeedPass.setUniform('jitterTolerence', this.jitterTolerence);
- renderer.gl.disable(renderer.gl.BLEND);
- globalSpeedPass.render(renderer);
- // Update position.
- var positionPass = this._positionPass;
- this._framebuffer.attach(this._positionTex);
- positionPass.setUniform('globalSpeedTex', this._globalSpeedTex);
- positionPass.setUniform('positionTex', this._positionPrevTex);
- positionPass.setUniform('forceTex', this._forceTex);
- positionPass.setUniform('forcePrevTex', this._forcePrevTex);
- positionPass.render(renderer);
- this._framebuffer.unbind(renderer);
- this._swapTexture();
- };
- ForceAtlas2GPU.prototype.update = function (renderer, steps, cb) {
- if (steps == null) {
- steps = 1;
- }
- steps = Math.max(steps, 1);
- for (var i = 0; i < steps; i++) {
- this.step(renderer);
- }
- cb && cb();
- };
- ForceAtlas2GPU.prototype.getNodePositionTexture = function () {
- return this._inited
- // Texture already been swapped.
- ? this._positionPrevTex
- : this._positionSourceTex;
- };
- ForceAtlas2GPU.prototype.getNodeUV = function (nodeIndex, uv) {
- uv = uv || [];
- var textureWidth = this._positionTex.width;
- var textureHeight = this._positionTex.height;
- uv[0] = (nodeIndex % textureWidth) / (textureWidth - 1);
- uv[1] = Math.floor(nodeIndex / textureWidth) / (textureHeight - 1) || 0;
- return uv;
- };
- ForceAtlas2GPU.prototype.getNodePosition = function (renderer, out) {
- var positionArr = this._positionArr;
- var width = this._positionTex.width;
- var height = this._positionTex.height;
- var size = width * height;
- if (!positionArr || positionArr.length !== size * 4) {
- positionArr = this._positionArr = new Float32Array(size * 4);
- }
- this._framebuffer.bind(renderer);
- this._framebuffer.attach(this._positionPrevTex);
- renderer.gl.readPixels(
- 0, 0, width, height,
- renderer.gl.RGBA, renderer.gl.FLOAT,
- positionArr
- );
- this._framebuffer.unbind(renderer);
- if (!out) {
- out = new Float32Array(this._nodes.length * 2);
- }
- for (var i = 0; i < this._nodes.length; i++) {
- out[i * 2] = positionArr[i * 4];
- out[i * 2 + 1] = positionArr[i * 4 + 1];
- }
- return out;
- };
- ForceAtlas2GPU.prototype.getTextureData = function (renderer, textureName) {
- var tex = this['_' + textureName + 'Tex'];
- var width = tex.width;
- var height = tex.height;
- this._framebuffer.bind(renderer);
- this._framebuffer.attach(tex);
- var arr = new Float32Array(width * height * 4);
- renderer.gl.readPixels(0, 0, width, height, renderer.gl.RGBA, renderer.gl.FLOAT, arr);
- this._framebuffer.unbind(renderer);
- return arr;
- };
- ForceAtlas2GPU.prototype.getTextureSize = function () {
- return {
- width: this._positionTex.width,
- height: this._positionTex.height
- };
- };
- ForceAtlas2GPU.prototype.isFinished = function (maxSteps) {
- return this._frame > maxSteps;
- };
- ForceAtlas2GPU.prototype._swapTexture = function () {
- var tmp = this._positionPrevTex;
- this._positionPrevTex = this._positionTex;
- this._positionTex = tmp;
- var tmp = this._forcePrevTex;
- this._forcePrevTex = this._forceTex;
- this._forceTex = tmp;
- var tmp = this._globalSpeedPrevTex;
- this._globalSpeedPrevTex = this._globalSpeedTex;
- this._globalSpeedTex = tmp;
- };
- ForceAtlas2GPU.prototype._initFromSource = function (renderer) {
- this._framebuffer.attach(this._positionPrevTex);
- this._framebuffer.bind(renderer);
- this._copyPass.setUniform('texture', this._positionSourceTex);
- this._copyPass.render(renderer);
- renderer.gl.clearColor(0, 0, 0, 0);
- this._framebuffer.attach(this._forcePrevTex);
- renderer.gl.clear(renderer.gl.COLOR_BUFFER_BIT);
- this._framebuffer.attach(this._globalSpeedPrevTex);
- renderer.gl.clear(renderer.gl.COLOR_BUFFER_BIT);
- this._framebuffer.unbind(renderer);
- };
- ForceAtlas2GPU.prototype._resize = function (width, height) {
- ['_positionSourceTex', '_positionTex', '_positionPrevTex', '_forceTex', '_forcePrevTex'].forEach(function (texName) {
- this[texName].width = width;
- this[texName].height = height;
- this[texName].dirty();
- }, this);
- };
- ForceAtlas2GPU.prototype.dispose = function (renderer) {
- this._framebuffer.dispose(renderer);
- this._copyPass.dispose(renderer);
- this._nodeRepulsionPass.dispose(renderer);
- this._positionPass.dispose(renderer);
- this._globalSpeedPass.dispose(renderer);
- this._edgeForceMesh.geometry.dispose(renderer);
- this._weightedSumMesh.geometry.dispose(renderer);
- this._positionSourceTex.dispose(renderer);
- this._positionTex.dispose(renderer);
- this._positionPrevTex.dispose(renderer);
- this._forceTex.dispose(renderer);
- this._forcePrevTex.dispose(renderer);
- this._weightedSumTex.dispose(renderer);
- this._globalSpeedTex.dispose(renderer);
- this._globalSpeedPrevTex.dispose(renderer);
- };
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.ForceAtlas2GPU = ForceAtlas2GPU;
- /* harmony default export */ __webpack_exports__["a"] = (ForceAtlas2GPU);
- /***/
- }),
- /* 270 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.forceAtlas2.updateNodeRepulsion\n\n#define NODE_COUNT 0\n\nuniform sampler2D positionTex;\n\nuniform vec2 textureSize;\nuniform float gravity;\nuniform float scaling;\nuniform vec2 gravityCenter;\n\nuniform bool strongGravityMode;\nuniform bool preventOverlap;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, v_Texcoord);\n\n vec2 force = vec2(0.0);\n for (int i = 0; i < NODE_COUNT; i++) {\n vec2 uv = vec2(\n mod(float(i), textureSize.x) / (textureSize.x - 1.0),\n floor(float(i) / textureSize.x) / (textureSize.y - 1.0)\n );\n vec4 n1 = texture2D(positionTex, uv);\n\n vec2 dir = n0.xy - n1.xy;\n float d2 = dot(dir, dir);\n\n if (d2 > 0.0) {\n float factor = 0.0;\n if (preventOverlap) {\n float d = sqrt(d2);\n d = d - n0.w - n1.w;\n if (d > 0.0) {\n factor = scaling * n0.z * n1.z / (d * d);\n }\n else if (d < 0.0) {\n factor = scaling * 100.0 * n0.z * n1.z;\n }\n }\n else {\n factor = scaling * n0.z * n1.z / d2;\n }\n force += dir * factor;\n }\n }\n\n vec2 dir = gravityCenter - n0.xy;\n float d = 1.0;\n if (!strongGravityMode) {\n d = length(dir);\n }\n\n force += dir * n0.z * gravity / (d + 1.0);\n\n gl_FragColor = vec4(force, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.vertex\n\nattribute vec2 node1;\nattribute vec2 node2;\nattribute float weight;\n\nuniform sampler2D positionTex;\nuniform float edgeWeightInfluence;\nuniform bool preventOverlap;\nuniform bool linLogMode;\n\nuniform vec2 windowSize: WINDOW_SIZE;\n\nvarying vec2 v_Force;\n\nvoid main() {\n\n vec4 n0 = texture2D(positionTex, node1);\n vec4 n1 = texture2D(positionTex, node2);\n\n vec2 dir = n1.xy - n0.xy;\n float d = length(dir);\n float w;\n if (edgeWeightInfluence == 0.0) {\n w = 1.0;\n }\n else if (edgeWeightInfluence == 1.0) {\n w = weight;\n }\n else {\n w = pow(weight, edgeWeightInfluence);\n }\n vec2 offset = vec2(1.0 / windowSize.x, 1.0 / windowSize.y);\n vec2 scale = vec2((windowSize.x - 1.0) / windowSize.x, (windowSize.y - 1.0) / windowSize.y);\n vec2 pos = node1 * scale * 2.0 - 1.0;\n gl_Position = vec4(pos + offset, 0.0, 1.0);\n gl_PointSize = 1.0;\n\n float factor;\n if (preventOverlap) {\n d = d - n1.w - n0.w;\n }\n if (d <= 0.0) {\n v_Force = vec2(0.0);\n return;\n }\n\n if (linLogMode) {\n factor = w * log(d) / d;\n }\n else {\n factor = w;\n }\n v_Force = dir * factor;\n}\n@end\n\n@export ecgl.forceAtlas2.updateEdgeAttraction.fragment\n\nvarying vec2 v_Force;\n\nvoid main() {\n gl_FragColor = vec4(v_Force, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.vertex\n\nattribute vec2 node;\n\nvarying vec2 v_NodeUv;\n\nvoid main() {\n\n v_NodeUv = node;\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n gl_PointSize = 1.0;\n}\n@end\n\n@export ecgl.forceAtlas2.calcWeightedSum.fragment\n\nvarying vec2 v_NodeUv;\n\nuniform sampler2D positionTex;\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_NodeUv).rg;\n vec2 forcePrev = texture2D(forcePrevTex, v_NodeUv).rg;\n\n float mass = texture2D(positionTex, v_NodeUv).z;\n float swing = length(force - forcePrev) * mass;\n float traction = length(force + forcePrev) * 0.5 * mass;\n\n gl_FragColor = vec4(swing, traction, 0.0, 0.0);\n}\n@end\n\n@export ecgl.forceAtlas2.calcGlobalSpeed\n\nuniform sampler2D globalSpeedPrevTex;\nuniform sampler2D weightedSumTex;\nuniform float jitterTolerence;\n\nvoid main() {\n vec2 weightedSum = texture2D(weightedSumTex, vec2(0.5)).xy;\n float prevGlobalSpeed = texture2D(globalSpeedPrevTex, vec2(0.5)).x;\n float globalSpeed = jitterTolerence * jitterTolerence\n * weightedSum.y / weightedSum.x;\n if (prevGlobalSpeed > 0.0) {\n globalSpeed = min(globalSpeed / prevGlobalSpeed, 1.5) * prevGlobalSpeed;\n }\n gl_FragColor = vec4(globalSpeed, 0.0, 0.0, 1.0);\n}\n@end\n\n@export ecgl.forceAtlas2.updatePosition\n\nuniform sampler2D forceTex;\nuniform sampler2D forcePrevTex;\nuniform sampler2D positionTex;\nuniform sampler2D globalSpeedTex;\n\nvarying vec2 v_Texcoord;\n\nvoid main() {\n vec2 force = texture2D(forceTex, v_Texcoord).xy;\n vec2 forcePrev = texture2D(forcePrevTex, v_Texcoord).xy;\n vec4 node = texture2D(positionTex, v_Texcoord);\n\n float globalSpeed = texture2D(globalSpeedTex, vec2(0.5)).r;\n float swing = length(force - forcePrev);\n float speed = 0.1 * globalSpeed / (0.1 + globalSpeed * sqrt(swing));\n\n float df = length(force);\n if (df > 0.0) {\n speed = min(df * speed, 10.0) / df;\n\n gl_FragColor = vec4(node.xy + speed * force, node.zw);\n }\n else {\n gl_FragColor = node;\n }\n}\n@end\n\n@export ecgl.forceAtlas2.edges.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 node;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\nuniform sampler2D positionTex;\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(\n texture2D(positionTex, node).xy, -10.0, 1.0\n );\n v_Color = a_Color;\n}\n@end\n\n@export ecgl.forceAtlas2.edges.fragment\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nvarying vec4 v_Color;\nvoid main() {\n gl_FragColor = color * v_Color;\n}\n@end");
- /***/
- }),
- /* 271 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__forceAtlas2Worker_js__ = __webpack_require__(272);
- var workerUrl = __WEBPACK_IMPORTED_MODULE_2__forceAtlas2Worker_js__["a" /* default */].toString();
- workerUrl = workerUrl.slice(workerUrl.indexOf('{') + 1, workerUrl.lastIndexOf('}'));
- var defaultConfigs = {
- barnesHutOptimize: true,
- barnesHutTheta: 1.5,
- repulsionByDegree: true,
- linLogMode: false,
- strongGravityMode: false,
- gravity: 1.0,
- scaling: 1.0,
- edgeWeightInfluence: 1.0,
- jitterTolerence: 0.1,
- preventOverlap: false,
- dissuadeHubs: false,
- gravityCenter: null
- };
- var ForceAtlas2 = function (options) {
- for (var name in defaultConfigs) {
- this[name] = defaultConfigs[name];
- }
- if (options) {
- for (var name in options) {
- this[name] = options[name];
- }
- }
- this._nodes = [];
- this._edges = [];
- this._disposed = false;
- this._positionTex = new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Texture2D__["a" /* default */]({
- type: __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__["a" /* default */].FLOAT,
- flipY: false,
- minFilter: __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__["a" /* default */].NEAREST,
- magFilter: __WEBPACK_IMPORTED_MODULE_1_claygl_src_Texture__["a" /* default */].NEAREST
- });
- };
- ForceAtlas2.prototype.initData = function (nodes, edges) {
- var bb = new Blob([workerUrl]);
- var blobURL = window.URL.createObjectURL(bb);
- this._worker = new Worker(blobURL);
- this._worker.onmessage = this._$onupdate.bind(this);
- this._nodes = nodes;
- this._edges = edges;
- this._frame = 0;
- var nNodes = nodes.length;
- var nEdges = edges.length;
- var positionArr = new Float32Array(nNodes * 2);
- var massArr = new Float32Array(nNodes);
- var sizeArr = new Float32Array(nNodes);
- var edgeArr = new Float32Array(nEdges * 2);
- var edgeWeightArr = new Float32Array(nEdges);
- for (var i = 0; i < nodes.length; i++) {
- var node = nodes[i];
- positionArr[i * 2] = node.x;
- positionArr[i * 2 + 1] = node.y;
- massArr[i] = node.mass == null ? 1 : node.mass;
- sizeArr[i] = node.size == null ? 1 : node.size;
- }
- for (var i = 0; i < edges.length; i++) {
- var edge = edges[i];
- var source = edge.node1;
- var target = edge.node2;
- edgeArr[i * 2] = source;
- edgeArr[i * 2 + 1] = target;
- edgeWeightArr[i] = edge.weight == null ? 1 : edge.weight;
- }
- var textureWidth = Math.ceil(Math.sqrt(nodes.length));
- var textureHeight = textureWidth;
- var pixels = new Float32Array(textureWidth * textureHeight * 4);
- var positionTex = this._positionTex;
- positionTex.width = textureWidth;
- positionTex.height = textureHeight;
- positionTex.pixels = pixels;
- this._worker.postMessage({
- cmd: 'init',
- nodesPosition: positionArr,
- nodesMass: massArr,
- nodesSize: sizeArr,
- edges: edgeArr,
- edgesWeight: edgeWeightArr
- });
- this._globalSpeed = Infinity;
- };
- ForceAtlas2.prototype.updateOption = function (options) {
- var config = {};
- // Default config
- for (var name in defaultConfigs) {
- config[name] = defaultConfigs[name];
- }
- var nodes = this._nodes;
- var edges = this._edges;
- // Config according to data scale
- var nNodes = nodes.length;
- if (nNodes > 50000) {
- config.jitterTolerence = 10;
- }
- else if (nNodes > 5000) {
- config.jitterTolerence = 1;
- }
- else {
- config.jitterTolerence = 0.1;
- }
- if (nNodes > 100) {
- config.scaling = 2.0;
- }
- else {
- config.scaling = 10.0;
- }
- if (nNodes > 1000) {
- config.barnesHutOptimize = true;
- }
- else {
- config.barnesHutOptimize = false;
- }
- if (options) {
- for (var name in defaultConfigs) {
- if (options[name] != null) {
- config[name] = options[name];
- }
- }
- }
- if (!config.gravityCenter) {
- var min = [Infinity, Infinity];
- var max = [-Infinity, -Infinity];
- for (var i = 0; i < nodes.length; i++) {
- min[0] = Math.min(nodes[i].x, min[0]);
- min[1] = Math.min(nodes[i].y, min[1]);
- max[0] = Math.max(nodes[i].x, max[0]);
- max[1] = Math.max(nodes[i].y, max[1]);
- }
- config.gravityCenter = [(min[0] + max[0]) * 0.5, (min[1] + max[1]) * 0.5];
- }
- // Update inDegree, outDegree
- for (var i = 0; i < edges.length; i++) {
- var node1 = edges[i].node1;
- var node2 = edges[i].node2;
- nodes[node1].degree = (nodes[node1].degree || 0) + 1;
- nodes[node2].degree = (nodes[node2].degree || 0) + 1;
- }
- if (this._worker) {
- this._worker.postMessage({
- cmd: 'updateConfig',
- config: config
- });
- }
- };
- // Steps per call, to keep sync with rendering
- ForceAtlas2.prototype.update = function (renderer, steps, cb) {
- if (steps == null) {
- steps = 1;
- }
- steps = Math.max(steps, 1);
- this._frame += steps;
- this._onupdate = cb;
- if (this._worker) {
- this._worker.postMessage({
- cmd: 'update',
- steps: Math.round(steps)
- });
- }
- };
- ForceAtlas2.prototype._$onupdate = function (e) {
- // Incase the worker keep postMessage of last frame after it is disposed
- if (this._disposed) {
- return;
- }
- var positionArr = new Float32Array(e.data.buffer);
- this._globalSpeed = e.data.globalSpeed;
- this._positionArr = positionArr;
- this._updateTexture(positionArr);
- this._onupdate && this._onupdate();
- };
- ForceAtlas2.prototype.getNodePositionTexture = function () {
- return this._positionTex;
- };
- ForceAtlas2.prototype.getNodeUV = function (nodeIndex, uv) {
- uv = uv || [];
- var textureWidth = this._positionTex.width;
- var textureHeight = this._positionTex.height;
- uv[0] = (nodeIndex % textureWidth) / (textureWidth - 1);
- uv[1] = Math.floor(nodeIndex / textureWidth) / (textureHeight - 1);
- return uv;
- };
- ForceAtlas2.prototype.getNodes = function () {
- return this._nodes;
- };
- ForceAtlas2.prototype.getEdges = function () {
- return this._edges;
- };
- ForceAtlas2.prototype.isFinished = function (maxSteps) {
- return this._frame > maxSteps;
- };
- ForceAtlas2.prototype.getNodePosition = function (renderer, out) {
- if (!out) {
- out = new Float32Array(this._nodes.length * 2);
- }
- if (this._positionArr) {
- for (var i = 0; i < this._positionArr.length; i++) {
- out[i] = this._positionArr[i];
- }
- }
- return out;
- };
- ForceAtlas2.prototype._updateTexture = function (positionArr) {
- var pixels = this._positionTex.pixels;
- var offset = 0;
- for (var i = 0; i < positionArr.length;) {
- pixels[offset++] = positionArr[i++];
- pixels[offset++] = positionArr[i++];
- pixels[offset++] = 1;
- pixels[offset++] = 1;
- }
- this._positionTex.dirty();
- };
- ForceAtlas2.prototype.dispose = function (renderer) {
- this._disposed = true;
- this._worker = null;
- };
- /* harmony default export */ __webpack_exports__["a"] = (ForceAtlas2);
- /***/
- }),
- /* 272 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /****************************
- * Vector2 math functions
- ***************************/
- function forceAtlas2Worker() {
- var vec2 = {
- create: function () {
- return new Float32Array(2);
- },
- dist: function (a, b) {
- var x = b[0] - a[0];
- var y = b[1] - a[1];
- return Math.sqrt(x * x + y * y);
- },
- len: function (a) {
- var x = a[0];
- var y = a[1];
- return Math.sqrt(x * x + y * y);
- },
- scaleAndAdd: function (out, a, b, scale) {
- out[0] = a[0] + b[0] * scale;
- out[1] = a[1] + b[1] * scale;
- return out;
- },
- scale: function (out, a, b) {
- out[0] = a[0] * b;
- out[1] = a[1] * b;
- return out;
- },
- add: function (out, a, b) {
- out[0] = a[0] + b[0];
- out[1] = a[1] + b[1];
- return out;
- },
- sub: function (out, a, b) {
- out[0] = a[0] - b[0];
- out[1] = a[1] - b[1];
- return out;
- },
- normalize: function (out, a) {
- var x = a[0];
- var y = a[1];
- var len = x * x + y * y;
- if (len > 0) {
- //TODO: evaluate use of glm_invsqrt here?
- len = 1 / Math.sqrt(len);
- out[0] = a[0] * len;
- out[1] = a[1] * len;
- }
- return out;
- },
- negate: function (out, a) {
- out[0] = -a[0];
- out[1] = -a[1];
- return out;
- },
- copy: function (out, a) {
- out[0] = a[0];
- out[1] = a[1];
- return out;
- },
- set: function (out, x, y) {
- out[0] = x;
- out[1] = y;
- return out;
- }
- }
- /****************************
- * Class: Region
- ***************************/
- function Region() {
- this.subRegions = [];
- this.nSubRegions = 0;
- this.node = null;
- this.mass = 0;
- this.centerOfMass = null;
- this.bbox = new Float32Array(4);
- this.size = 0;
- }
- var regionProto = Region.prototype;
- // Reset before update
- regionProto.beforeUpdate = function () {
- for (var i = 0; i < this.nSubRegions; i++) {
- this.subRegions[i].beforeUpdate();
- }
- this.mass = 0;
- if (this.centerOfMass) {
- this.centerOfMass[0] = 0;
- this.centerOfMass[1] = 0;
- }
- this.nSubRegions = 0;
- this.node = null;
- };
- // Clear after update
- regionProto.afterUpdate = function () {
- this.subRegions.length = this.nSubRegions;
- for (var i = 0; i < this.nSubRegions; i++) {
- this.subRegions[i].afterUpdate();
- }
- };
- regionProto.addNode = function (node) {
- if (this.nSubRegions === 0) {
- if (this.node == null) {
- this.node = node;
- return;
- }
- // Already have node, subdivide self.
- else {
- this._addNodeToSubRegion(this.node);
- this.node = null;
- }
- }
- this._addNodeToSubRegion(node);
- this._updateCenterOfMass(node);
- };
- regionProto.findSubRegion = function (x, y) {
- for (var i = 0; i < this.nSubRegions; i++) {
- var region = this.subRegions[i];
- if (region.contain(x, y)) {
- return region;
- }
- }
- };
- regionProto.contain = function (x, y) {
- return this.bbox[0] <= x
- && this.bbox[2] >= x
- && this.bbox[1] <= y
- && this.bbox[3] >= y;
- };
- regionProto.setBBox = function (minX, minY, maxX, maxY) {
- // Min
- this.bbox[0] = minX;
- this.bbox[1] = minY;
- // Max
- this.bbox[2] = maxX;
- this.bbox[3] = maxY;
- this.size = (maxX - minX + maxY - minY) / 2;
- };
- regionProto._newSubRegion = function () {
- var subRegion = this.subRegions[this.nSubRegions];
- if (!subRegion) {
- subRegion = new Region();
- this.subRegions[this.nSubRegions] = subRegion;
- }
- this.nSubRegions++;
- return subRegion;
- };
- regionProto._addNodeToSubRegion = function (node) {
- var subRegion = this.findSubRegion(node.position[0], node.position[1]);
- var bbox = this.bbox;
- if (!subRegion) {
- var cx = (bbox[0] + bbox[2]) / 2;
- var cy = (bbox[1] + bbox[3]) / 2;
- var w = (bbox[2] - bbox[0]) / 2;
- var h = (bbox[3] - bbox[1]) / 2;
- var xi = node.position[0] >= cx ? 1 : 0;
- var yi = node.position[1] >= cy ? 1 : 0;
- var subRegion = this._newSubRegion();
- // Min
- subRegion.setBBox(
- // Min
- xi * w + bbox[0],
- yi * h + bbox[1],
- // Max
- (xi + 1) * w + bbox[0],
- (yi + 1) * h + bbox[1]
- );
- }
- subRegion.addNode(node);
- };
- regionProto._updateCenterOfMass = function (node) {
- // Incrementally update
- if (this.centerOfMass == null) {
- this.centerOfMass = new Float32Array(2);
- }
- var x = this.centerOfMass[0] * this.mass;
- var y = this.centerOfMass[1] * this.mass;
- x += node.position[0] * node.mass;
- y += node.position[1] * node.mass;
- this.mass += node.mass;
- this.centerOfMass[0] = x / this.mass;
- this.centerOfMass[1] = y / this.mass;
- };
- /****************************
- * Class: Graph Node
- ***************************/
- function GraphNode() {
- this.position = new Float32Array(2);
- this.force = vec2.create();
- this.forcePrev = vec2.create();
- // If repulsionByDegree is true
- // mass = inDegree + outDegree + 1
- // Else
- // mass is manually set
- this.mass = 1;
- this.inDegree = 0;
- this.outDegree = 0;
- // Optional
- // this.size = 1;
- }
- /****************************
- * Class: Graph Edge
- ***************************/
- function GraphEdge(source, target) {
- this.source = source;
- this.target = target;
- this.weight = 1;
- }
- /****************************
- * Class: ForceStlas2
- ***************************/
- function ForceAtlas2() {
- //-------------
- // Configs
- // If auto settings is true
- // barnesHutOptimize,
- // barnesHutTheta,
- // scaling,
- // jitterTolerence
- // Will be set by the system automatically
- // preventOverlap will be set false
- // if node size is not given
- this.autoSettings = true;
- // Barnes Hut
- // http://arborjs.org/docs/barnes-hut
- this.barnesHutOptimize = true;
- this.barnesHutTheta = 1.5;
- // Force Atlas2 Configs
- this.repulsionByDegree = true;
- this.linLogMode = false;
- this.strongGravityMode = false;
- this.gravity = 1.0;
- this.scaling = 1.0;
- this.edgeWeightInfluence = 1.0;
- this.jitterTolerence = 0.1;
- // TODO
- this.preventOverlap = false;
- this.dissuadeHubs = false;
- //
- this.rootRegion = new Region();
- this.rootRegion.centerOfMass = vec2.create();
- this.nodes = [];
- this.edges = [];
- this.bbox = new Float32Array(4);
- this.gravityCenter = null;
- this._massArr = null;
- this._swingingArr = null;
- this._sizeArr = null;
- this._globalSpeed = 0;
- }
- var forceAtlas2Proto = ForceAtlas2.prototype;
- forceAtlas2Proto.initNodes = function (positionArr, massArr, sizeArr) {
- var nNodes = massArr.length;
- this.nodes.length = 0;
- var haveSize = typeof (sizeArr) != 'undefined';
- for (var i = 0; i < nNodes; i++) {
- var node = new GraphNode();
- node.position[0] = positionArr[i * 2];
- node.position[1] = positionArr[i * 2 + 1];
- node.mass = massArr[i];
- if (haveSize) {
- node.size = sizeArr[i];
- }
- this.nodes.push(node);
- }
- this._massArr = massArr;
- this._swingingArr = new Float32Array(nNodes);
- if (haveSize) {
- this._sizeArr = sizeArr;
- }
- };
- forceAtlas2Proto.initEdges = function (edgeArr, edgeWeightArr) {
- var nEdges = edgeArr.length / 2;
- this.edges.length = 0;
- for (var i = 0; i < nEdges; i++) {
- var sIdx = edgeArr[i * 2];
- var tIdx = edgeArr[i * 2 + 1];
- var sNode = this.nodes[sIdx];
- var tNode = this.nodes[tIdx];
- if (!sNode || !tNode) {
- console.error('Node not exists, try initNodes before initEdges');
- return;
- }
- sNode.outDegree++;
- tNode.inDegree++;
- var edge = new GraphEdge(sNode, tNode);
- if (edgeWeightArr) {
- edge.weight = edgeWeightArr[i];
- }
- this.edges.push(edge);
- }
- }
- forceAtlas2Proto.updateSettings = function () {
- if (this.repulsionByDegree) {
- for (var i = 0; i < this.nodes.length; i++) {
- var node = this.nodes[i];
- node.mass = node.inDegree + node.outDegree + 1;
- }
- }
- else {
- for (var i = 0; i < this.nodes.length; i++) {
- var node = this.nodes[i];
- node.mass = this._massArr[i];
- }
- }
- };
- forceAtlas2Proto.update = function () {
- var nNodes = this.nodes.length;
- this.updateSettings();
- this.updateBBox();
- // Update region
- if (this.barnesHutOptimize) {
- this.rootRegion.setBBox(
- this.bbox[0], this.bbox[1],
- this.bbox[2], this.bbox[3]
- );
- this.rootRegion.beforeUpdate();
- for (var i = 0; i < nNodes; i++) {
- this.rootRegion.addNode(this.nodes[i]);
- }
- this.rootRegion.afterUpdate();
- }
- // Reset forces
- for (var i = 0; i < nNodes; i++) {
- var node = this.nodes[i];
- vec2.copy(node.forcePrev, node.force);
- vec2.set(node.force, 0, 0);
- }
- // Compute forces
- // Repulsion
- for (var i = 0; i < nNodes; i++) {
- var na = this.nodes[i];
- if (this.barnesHutOptimize) {
- this.applyRegionToNodeRepulsion(this.rootRegion, na);
- }
- else {
- for (var j = i + 1; j < nNodes; j++) {
- var nb = this.nodes[j];
- this.applyNodeToNodeRepulsion(na, nb, false);
- }
- }
- // Gravity
- if (this.gravity > 0) {
- if (this.strongGravityMode) {
- this.applyNodeStrongGravity(na);
- }
- else {
- this.applyNodeGravity(na);
- }
- }
- }
- // Attraction
- for (var i = 0; i < this.edges.length; i++) {
- this.applyEdgeAttraction(this.edges[i]);
- }
- // Handle swinging
- var swingWeightedSum = 0;
- var tractionWeightedSum = 0;
- var tmp = vec2.create();
- for (var i = 0; i < nNodes; i++) {
- var node = this.nodes[i];
- var swing = vec2.dist(node.force, node.forcePrev);
- swingWeightedSum += swing * node.mass;
- vec2.add(tmp, node.force, node.forcePrev);
- var traction = vec2.len(tmp) * 0.5;
- tractionWeightedSum += traction * node.mass;
- // Save the value for using later
- this._swingingArr[i] = swing;
- }
- var globalSpeed = this.jitterTolerence * this.jitterTolerence
- * tractionWeightedSum / swingWeightedSum;
- // NB: During our tests we observed that an excessive rise of the global speed could have a negative impact.
- // That’s why we limited the increase of global speed s(t)(G) to 50% of the previous step s(t−1)(G).
- if (this._globalSpeed > 0) {
- globalSpeed = Math.min(globalSpeed / this._globalSpeed, 1.5) * this._globalSpeed;
- }
- this._globalSpeed = globalSpeed;
- // Apply forces
- for (var i = 0; i < nNodes; i++) {
- var node = this.nodes[i];
- var swing = this._swingingArr[i];
- var speed = 0.1 * globalSpeed / (1 + globalSpeed * Math.sqrt(swing));
- // Additional constraint to prevent local speed gets too high
- var df = vec2.len(node.force);
- if (df > 0) {
- speed = Math.min(df * speed, 10) / df;
- vec2.scaleAndAdd(node.position, node.position, node.force, speed);
- }
- }
- };
- forceAtlas2Proto.applyRegionToNodeRepulsion = (function () {
- var v = vec2.create();
- return function applyRegionToNodeRepulsion(region, node) {
- if (region.node) { // Region is a leaf
- this.applyNodeToNodeRepulsion(region.node, node, true);
- }
- else {
- vec2.sub(v, node.position, region.centerOfMass);
- var d2 = v[0] * v[0] + v[1] * v[1];
- if (d2 > this.barnesHutTheta * region.size * region.size) {
- var factor = this.scaling * node.mass * region.mass / d2;
- vec2.scaleAndAdd(node.force, node.force, v, factor);
- }
- else {
- for (var i = 0; i < region.nSubRegions; i++) {
- this.applyRegionToNodeRepulsion(region.subRegions[i], node);
- }
- }
- }
- }
- })();
- forceAtlas2Proto.applyNodeToNodeRepulsion = (function () {
- var v = vec2.create();
- return function applyNodeToNodeRepulsion(na, nb, oneWay) {
- if (na == nb) {
- return;
- }
- vec2.sub(v, na.position, nb.position);
- var d2 = v[0] * v[0] + v[1] * v[1];
- // PENDING
- if (d2 === 0) {
- return;
- }
- var factor;
- if (this.preventOverlap) {
- var d = Math.sqrt(d2);
- d = d - na.size - nb.size;
- if (d > 0) {
- factor = this.scaling * na.mass * nb.mass / (d * d);
- }
- else if (d < 0) {
- // A stronger repulsion if overlap
- factor = this.scaling * 100 * na.mass * nb.mass;
- }
- else {
- // No repulsion
- return;
- }
- }
- else {
- // Divide factor by an extra `d` to normalize the `v`
- factor = this.scaling * na.mass * nb.mass / d2;
- }
- vec2.scaleAndAdd(na.force, na.force, v, factor);
- vec2.scaleAndAdd(nb.force, nb.force, v, -factor);
- }
- })();
- forceAtlas2Proto.applyEdgeAttraction = (function () {
- var v = vec2.create();
- return function applyEdgeAttraction(edge) {
- var na = edge.source;
- var nb = edge.target;
- vec2.sub(v, na.position, nb.position);
- var d = vec2.len(v);
- var w;
- if (this.edgeWeightInfluence === 0) {
- w = 1;
- }
- else if (this.edgeWeightInfluence === 1) {
- w = edge.weight;
- }
- else {
- w = Math.pow(edge.weight, this.edgeWeightInfluence);
- }
- var factor;
- if (this.preventOverlap) {
- d = d - na.size - nb.size;
- if (d <= 0) {
- // No attraction
- return;
- }
- }
- if (this.linLogMode) {
- // Divide factor by an extra `d` to normalize the `v`
- factor = - w * Math.log(d + 1) / (d + 1);
- }
- else {
- factor = - w;
- }
- vec2.scaleAndAdd(na.force, na.force, v, factor);
- vec2.scaleAndAdd(nb.force, nb.force, v, -factor);
- }
- })();
- forceAtlas2Proto.applyNodeGravity = (function () {
- var v = vec2.create();
- return function (node) {
- vec2.sub(v, this.gravityCenter, node.position);
- var d = vec2.len(v);
- vec2.scaleAndAdd(node.force, node.force, v, this.gravity * node.mass / (d + 1));
- }
- })();
- forceAtlas2Proto.applyNodeStrongGravity = (function () {
- var v = vec2.create();
- return function (node) {
- vec2.sub(v, this.gravityCenter, node.position);
- vec2.scaleAndAdd(node.force, node.force, v, this.gravity * node.mass);
- }
- })();
- forceAtlas2Proto.updateBBox = function () {
- var minX = Infinity;
- var minY = Infinity;
- var maxX = -Infinity;
- var maxY = -Infinity;
- for (var i = 0; i < this.nodes.length; i++) {
- var pos = this.nodes[i].position;
- minX = Math.min(minX, pos[0]);
- minY = Math.min(minY, pos[1]);
- maxX = Math.max(maxX, pos[0]);
- maxY = Math.max(maxY, pos[1]);
- }
- this.bbox[0] = minX;
- this.bbox[1] = minY;
- this.bbox[2] = maxX;
- this.bbox[3] = maxY;
- };
- forceAtlas2Proto.getGlobalSpeed = function () {
- return this._globalSpeed;
- }
- /****************************
- * Main process
- ***************************/
- var forceAtlas2 = null;
- self.onmessage = function (e) {
- switch (e.data.cmd) {
- case 'init':
- forceAtlas2 = new ForceAtlas2();
- forceAtlas2.initNodes(e.data.nodesPosition, e.data.nodesMass, e.data.nodesSize);
- forceAtlas2.initEdges(e.data.edges, e.data.edgesWeight);
- break;
- case 'updateConfig':
- if (forceAtlas2) {
- for (var name in e.data.config) {
- forceAtlas2[name] = e.data.config[name];
- }
- }
- break;
- case 'update':
- var steps = e.data.steps;
- if (forceAtlas2) {
- for (var i = 0; i < steps; i++) {
- forceAtlas2.update();
- }
- var nNodes = forceAtlas2.nodes.length;
- var positionArr = new Float32Array(nNodes * 2);
- // Callback
- for (var i = 0; i < nNodes; i++) {
- var node = forceAtlas2.nodes[i];
- positionArr[i * 2] = node.position[0];
- positionArr[i * 2 + 1] = node.position[1];
- }
- self.postMessage({
- buffer: positionArr.buffer,
- globalSpeed: forceAtlas2.getGlobalSpeed()
- }, [positionArr.buffer]);
- }
- else {
- // Not initialzied yet
- var emptyArr = new Float32Array();
- // Post transfer object
- self.postMessage({
- buffer: emptyArr.buffer,
- globalSpeed: forceAtlas2.getGlobalSpeed()
- }, [emptyArr.buffer]);
- }
- break;
- }
- }
- }
- /* harmony default export */ __webpack_exports__["a"] = (forceAtlas2Worker);
- /***/
- }),
- /* 273 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_core_Base__ = __webpack_require__(7);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__retrieve__ = __webpack_require__(2);
- /**
- * @alias module:echarts-gl/util/Roam2DControl
- */
- var Roam2DControl = __WEBPACK_IMPORTED_MODULE_0_claygl_src_core_Base__["a" /* default */].extend(function () {
- return {
- /**
- * @type {module:zrender~ZRender}
- */
- zr: null,
- /**
- * @type {module:echarts-gl/core/ViewGL}
- */
- viewGL: null,
- minZoom: 0.2,
- maxZoom: 5,
- _needsUpdate: false,
- _dx: 0,
- _dy: 0,
- _zoom: 1
- };
- }, function () {
- // Each Roam2DControl has it's own handler
- this._mouseDownHandler = this._mouseDownHandler.bind(this);
- this._mouseWheelHandler = this._mouseWheelHandler.bind(this);
- this._mouseMoveHandler = this._mouseMoveHandler.bind(this);
- this._mouseUpHandler = this._mouseUpHandler.bind(this);
- this._update = this._update.bind(this);
- }, {
- init: function () {
- var zr = this.zr;
- zr.on('mousedown', this._mouseDownHandler);
- zr.on('mousewheel', this._mouseWheelHandler);
- zr.on('globalout', this._mouseUpHandler);
- zr.animation.on('frame', this._update);
- },
- setTarget: function (target) {
- this._target = target;
- },
- setZoom: function (zoom) {
- this._zoom = Math.max(Math.min(
- zoom, this.maxZoom
- ), this.minZoom);
- this._needsUpdate = true;
- },
- setOffset: function (offset) {
- this._dx = offset[0];
- this._dy = offset[1];
- this._needsUpdate = true;
- },
- getZoom: function () {
- return this._zoom;
- },
- getOffset: function () {
- return [this._dx, this._dy];
- },
- _update: function () {
- if (!this._target) {
- return;
- }
- if (!this._needsUpdate) {
- return;
- }
- var target = this._target;
- var scale = this._zoom;
- target.position.x = this._dx;
- target.position.y = this._dy;
- target.scale.set(scale, scale, scale);
- this.zr.refresh();
- this._needsUpdate = false;
- this.trigger('update');
- },
- _mouseDownHandler: function (e) {
- if (e.target) {
- return;
- }
- var x = e.offsetX;
- var y = e.offsetY;
- if (this.viewGL && !this.viewGL.containPoint(x, y)) {
- return;
- }
- this.zr.on('mousemove', this._mouseMoveHandler);
- this.zr.on('mouseup', this._mouseUpHandler);
- var pos = this._convertPos(x, y);
- this._x = pos.x;
- this._y = pos.y;
- },
- // Convert pos from screen space to viewspace.
- _convertPos: function (x, y) {
- var camera = this.viewGL.camera;
- var viewport = this.viewGL.viewport;
- // PENDING
- return {
- x: (x - viewport.x) / viewport.width * (camera.right - camera.left) + camera.left,
- y: (y - viewport.y) / viewport.height * (camera.bottom - camera.top) + camera.top
- };
- },
- _mouseMoveHandler: function (e) {
- var pos = this._convertPos(e.offsetX, e.offsetY);
- this._dx += pos.x - this._x;
- this._dy += pos.y - this._y;
- this._x = pos.x;
- this._y = pos.y;
- this._needsUpdate = true;
- },
- _mouseUpHandler: function (e) {
- this.zr.off('mousemove', this._mouseMoveHandler);
- this.zr.off('mouseup', this._mouseUpHandler);
- },
- _mouseWheelHandler: function (e) {
- e = e.event;
- var delta = e.wheelDelta // Webkit
- || -e.detail; // Firefox
- if (delta === 0) {
- return;
- }
- var x = e.offsetX;
- var y = e.offsetY;
- if (this.viewGL && !this.viewGL.containPoint(x, y)) {
- return;
- }
- var zoomScale = delta > 0 ? 1.1 : 0.9;
- var newZoom = Math.max(Math.min(
- this._zoom * zoomScale, this.maxZoom
- ), this.minZoom);
- zoomScale = newZoom / this._zoom;
- var pos = this._convertPos(x, y);
- var fixX = (pos.x - this._dx) * (zoomScale - 1);
- var fixY = (pos.y - this._dy) * (zoomScale - 1);
- this._dx -= fixX;
- this._dy -= fixY;
- this._zoom = newZoom;
- this._needsUpdate = true;
- },
- dispose: function () {
- var zr = this.zr;
- zr.off('mousedown', this._mouseDownHandler);
- zr.off('mousemove', this._mouseMoveHandler);
- zr.off('mouseup', this._mouseUpHandler);
- zr.off('mousewheel', this._mouseWheelHandler);
- zr.off('globalout', this._mouseUpHandler);
- zr.animation.off('frame', this._update);
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (Roam2DControl);
- /***/
- }),
- /* 274 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.lines2D.vertex\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nattribute vec2 position: POSITION;\nattribute vec4 a_Color : COLOR;\nvarying vec4 v_Color;\n\n#ifdef POSITIONTEXTURE_ENABLED\nuniform sampler2D positionTexture;\n#endif\n\nvoid main()\n{\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n v_Color = a_Color;\n}\n\n@end\n\n@export ecgl.lines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.vertex\n\nattribute vec2 position: POSITION;\nattribute vec2 normal;\nattribute float offset;\nattribute vec4 a_Color : COLOR;\n\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec4 viewport : VIEWPORT;\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n vec4 p2 = worldViewProjection * vec4(position + normal, -10.0, 1.0);\n gl_Position = worldViewProjection * vec4(position, -10.0, 1.0);\n\n p2.xy /= p2.w;\n gl_Position.xy /= gl_Position.w;\n\n vec2 N = normalize(p2.xy - gl_Position.xy);\n gl_Position.xy += N * offset / viewport.zw * 2.0;\n\n gl_Position.xy *= gl_Position.w;\n\n v_Color = a_Color;\n}\n@end\n\n\n@export ecgl.meshLines2D.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\n\nvarying vec4 v_Color;\nvarying float v_Miter;\n\nvoid main()\n{\n gl_FragColor = color * v_Color;\n}\n\n@end");
- /***/
- }),
- /* 275 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__flowGL_FlowGLView__ = __webpack_require__(276);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__flowGL_FlowGLSeries__ = __webpack_require__(280);
- /***/
- }),
- /* 276 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__util_retrieve__ = __webpack_require__(2);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__ = __webpack_require__(22);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__VectorFieldParticleSurface__ = __webpack_require__(277);
- // TODO ç™¾åº¦åœ°å›¾ä¸æ˜¯ linear çš„
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({
- type: 'flowGL',
- __ecgl__: true,
- init: function (ecModel, api) {
- this.viewGL = new __WEBPACK_IMPORTED_MODULE_3__core_ViewGL__["a" /* default */]('orthographic');
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- this.viewGL.add(this.groupGL);
- this._particleSurface = new __WEBPACK_IMPORTED_MODULE_4__VectorFieldParticleSurface__["a" /* default */]();
- var planeMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- geometry: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].PlaneGeometry(),
- material: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- shader: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader({
- vertex: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('ecgl.color.vertex'),
- fragment: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Shader.source('ecgl.color.fragment')
- }),
- // Must enable blending and multiply alpha.
- // Or premultipliedAlpha will let the alpha useless.
- transparent: true
- })
- });
- planeMesh.material.enableTexture('diffuseMap');
- this.groupGL.add(planeMesh);
- this._planeMesh = planeMesh;
- },
- render: function (seriesModel, ecModel, api) {
- var particleSurface = this._particleSurface;
- // Set particleType before set others.
- particleSurface.setParticleType(seriesModel.get('particleType'));
- particleSurface.setSupersampling(seriesModel.get('supersampling'));
- this._updateData(seriesModel, api);
- this._updateCamera(api.getWidth(), api.getHeight(), api.getDevicePixelRatio());
- var particleDensity = __WEBPACK_IMPORTED_MODULE_2__util_retrieve__["a" /* default */].firstNotNull(seriesModel.get('particleDensity'), 128);
- particleSurface.setParticleDensity(particleDensity, particleDensity);
- var planeMesh = this._planeMesh;
- var time = +(new Date());
- var self = this;
- var firstFrame = true;
- planeMesh.__percent = 0;
- planeMesh.stopAnimation();
- planeMesh.animate('', { loop: true })
- .when(100000, {
- __percent: 1
- })
- .during(function () {
- var timeNow = + (new Date());
- var dTime = Math.min(timeNow - time, 20);
- time = time + dTime;
- if (self._renderer) {
- particleSurface.update(self._renderer, api, dTime / 1000, firstFrame);
- planeMesh.material.set('diffuseMap', particleSurface.getSurfaceTexture());
- // planeMesh.material.set('diffuseMap', self._particleSurface.vectorFieldTexture);
- }
- firstFrame = false;
- })
- .start();
- var itemStyleModel = seriesModel.getModel('itemStyle');
- var color = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(itemStyleModel.get('color'));
- color[3] *= __WEBPACK_IMPORTED_MODULE_2__util_retrieve__["a" /* default */].firstNotNull(itemStyleModel.get('opacity'), 1);
- planeMesh.material.set('color', color);
- particleSurface.setColorTextureImage(seriesModel.get('colorTexture'), api);
- particleSurface.setParticleSize(seriesModel.get('particleSize'));
- particleSurface.particleSpeedScaling = seriesModel.get('particleSpeed');
- particleSurface.motionBlurFactor = 1.0 - Math.pow(0.1, seriesModel.get('particleTrail'));
- },
- updateTransform: function (seriesModel, ecModel, api) {
- this._updateData(seriesModel, api);
- },
- afterRender: function (globeModel, ecModel, api, layerGL) {
- var renderer = layerGL.renderer;
- this._renderer = renderer;
- },
- _updateData: function (seriesModel, api) {
- var coordSys = seriesModel.coordinateSystem;
- var dims = coordSys.dimensions.map(function (coordDim) {
- return seriesModel.coordDimToDataDim(coordDim)[0];
- });
- var data = seriesModel.getData();
- var xExtent = data.getDataExtent(dims[0]);
- var yExtent = data.getDataExtent(dims[1]);
- var gridWidth = seriesModel.get('gridWidth');
- var gridHeight = seriesModel.get('gridHeight');
- if (gridWidth == null || gridWidth === 'auto') {
- // TODO not accurate.
- var aspect = (xExtent[1] - xExtent[0]) / (yExtent[1] - yExtent[0]);
- gridWidth = Math.round(Math.sqrt(aspect * data.count()));
- }
- if (gridHeight == null || gridHeight === 'auto') {
- gridHeight = Math.ceil(data.count() / gridWidth);
- }
- var vectorFieldTexture = this._particleSurface.vectorFieldTexture;
- // Half Float needs Uint16Array
- var pixels = vectorFieldTexture.pixels;
- if (!pixels || pixels.length !== gridHeight * gridWidth * 4) {
- pixels = vectorFieldTexture.pixels = new Float32Array(gridWidth * gridHeight * 4);
- }
- else {
- for (var i = 0; i < pixels.length; i++) {
- pixels[i] = 0;
- }
- }
- var maxMag = 0;
- var minMag = Infinity;
- var points = new Float32Array(data.count() * 2);
- var offset = 0;
- var bbox = [[Infinity, Infinity], [-Infinity, -Infinity]];
- data.each([dims[0], dims[1], 'vx', 'vy'], function (x, y, vx, vy) {
- var pt = coordSys.dataToPoint([x, y]);
- points[offset++] = pt[0];
- points[offset++] = pt[1];
- bbox[0][0] = Math.min(pt[0], bbox[0][0]);
- bbox[0][1] = Math.min(pt[1], bbox[0][1]);
- bbox[1][0] = Math.max(pt[0], bbox[1][0]);
- bbox[1][1] = Math.max(pt[1], bbox[1][1]);
- var mag = Math.sqrt(vx * vx + vy * vy);
- maxMag = Math.max(maxMag, mag);
- minMag = Math.min(minMag, mag);
- });
- data.each(['vx', 'vy'], function (vx, vy, i) {
- var xPix = Math.round((points[i * 2] - bbox[0][0]) / (bbox[1][0] - bbox[0][0]) * (gridWidth - 1));
- var yPix = gridHeight - 1 - Math.round((points[i * 2 + 1] - bbox[0][1]) / (bbox[1][1] - bbox[0][1]) * (gridHeight - 1));
- var idx = (yPix * gridWidth + xPix) * 4;
- pixels[idx] = (vx / maxMag * 0.5 + 0.5);
- pixels[idx + 1] = (vy / maxMag * 0.5 + 0.5);
- pixels[idx + 3] = 1;
- });
- vectorFieldTexture.width = gridWidth;
- vectorFieldTexture.height = gridHeight;
- if (seriesModel.get('coordinateSystem') === 'bmap') {
- this._fillEmptyPixels(vectorFieldTexture);
- }
- vectorFieldTexture.dirty();
- this._updatePlanePosition(bbox[0], bbox[1], seriesModel, api);
- this._updateGradientTexture(data.getVisual('visualMeta'), [minMag, maxMag]);
- },
- // PENDING Use grid mesh ? or delaunay triangulation?
- _fillEmptyPixels: function (texture) {
- var pixels = texture.pixels;
- var width = texture.width;
- var height = texture.height;
- function fetchPixel(x, y, rg) {
- x = Math.max(Math.min(x, width - 1), 0);
- y = Math.max(Math.min(y, height - 1), 0);
- var idx = (y * (width - 1) + x) * 4;
- if (pixels[idx + 3] === 0) {
- return false;
- }
- rg[0] = pixels[idx];
- rg[1] = pixels[idx + 1];
- return true;
- }
- function addPixel(a, b, out) {
- out[0] = a[0] + b[0];
- out[1] = a[1] + b[1];
- }
- var center = [], left = [], right = [], top = [], bottom = [];
- var weight = 0;
- for (var y = 0; y < height; y++) {
- for (var x = 0; x < width; x++) {
- var idx = (y * (width - 1) + x) * 4;
- if (pixels[idx + 3] === 0) {
- weight = center[0] = center[1] = 0;
- if (fetchPixel(x - 1, y, left)) {
- weight++; addPixel(left, center, center);
- }
- if (fetchPixel(x + 1, y, right)) {
- weight++; addPixel(right, center, center);
- }
- if (fetchPixel(x, y - 1, top)) {
- weight++; addPixel(top, center, center);
- }
- if (fetchPixel(x, y + 1, bottom)) {
- weight++; addPixel(bottom, center, center);
- }
- center[0] /= weight;
- center[1] /= weight;
- // PENDING If overwrite. bilinear interpolation.
- pixels[idx] = center[0];
- pixels[idx + 1] = center[1];
- }
- pixels[idx + 3] = 1;
- }
- }
- },
- _updateGradientTexture: function (visualMeta, magExtent) {
- if (!visualMeta || !visualMeta.length) {
- this._particleSurface.setGradientTexture(null);
- return;
- }
- // TODO Different dimensions
- this._gradientTexture = this._gradientTexture || new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Texture2D({
- image: document.createElement('canvas')
- });
- var gradientTexture = this._gradientTexture;
- var canvas = gradientTexture.image;
- canvas.width = 200;
- canvas.height = 1;
- var ctx = canvas.getContext('2d');
- var gradient = ctx.createLinearGradient(0, 0.5, canvas.width, 0.5);
- visualMeta[0].stops.forEach(function (stop) {
- var offset;
- if (magExtent[1] === magExtent[0]) {
- offset = 0;
- }
- else {
- offset = stop.value / magExtent[1];
- offset = Math.min(Math.max(offset, 0), 1);
- }
- gradient.addColorStop(offset, stop.color);
- });
- ctx.fillStyle = gradient;
- ctx.fillRect(0, 0, canvas.width, canvas.height);
- gradientTexture.dirty();
- this._particleSurface.setGradientTexture(this._gradientTexture);
- },
- _updatePlanePosition: function (leftTop, rightBottom, seriesModel, api) {
- var limitedResult = this._limitInViewportAndFullFill(leftTop, rightBottom, seriesModel, api);
- leftTop = limitedResult.leftTop;
- rightBottom = limitedResult.rightBottom;
- this._particleSurface.setRegion(limitedResult.region);
- this._planeMesh.position.set(
- (leftTop[0] + rightBottom[0]) / 2,
- api.getHeight() - (leftTop[1] + rightBottom[1]) / 2,
- 0
- );
- var width = rightBottom[0] - leftTop[0];
- var height = rightBottom[1] - leftTop[1];
- this._planeMesh.scale.set(width / 2, height / 2, 1);
- this._particleSurface.resize(
- Math.max(Math.min(width, 2048), 1),
- Math.max(Math.min(height, 2048), 1)
- );
- if (this._renderer) {
- this._particleSurface.clearFrame(this._renderer);
- }
- },
- _limitInViewportAndFullFill: function (leftTop, rightBottom, seriesModel, api) {
- var newLeftTop = [
- Math.max(leftTop[0], 0),
- Math.max(leftTop[1], 0)
- ];
- var newRightBottom = [
- Math.min(rightBottom[0], api.getWidth()),
- Math.min(rightBottom[1], api.getHeight())
- ];
- // Tiliing in lng orientation.
- if (seriesModel.get('coordinateSystem') === 'bmap') {
- var lngRange = seriesModel.getData().getDataExtent(seriesModel.coordDimToDataDim('lng')[0]);
- // PENDING, consider grid density
- var isContinuous = Math.floor(lngRange[1] - lngRange[0]) >= 359;
- if (isContinuous) {
- if (newLeftTop[0] > 0) {
- newLeftTop[0] = 0;
- }
- if (newRightBottom[0] < api.getWidth()) {
- newRightBottom[0] = api.getWidth();
- }
- }
- }
- var width = rightBottom[0] - leftTop[0];
- var height = rightBottom[1] - leftTop[1];
- var newWidth = newRightBottom[0] - newLeftTop[0];
- var newHeight = newRightBottom[1] - newLeftTop[1];
- var region = [
- (newLeftTop[0] - leftTop[0]) / width,
- 1.0 - newHeight / height - (newLeftTop[1] - leftTop[1]) / height,
- newWidth / width,
- newHeight / height
- ];
- return {
- leftTop: newLeftTop,
- rightBottom: newRightBottom,
- region: region
- };
- },
- _updateCamera: function (width, height, dpr) {
- this.viewGL.setViewport(0, 0, width, height, dpr);
- var camera = this.viewGL.camera;
- // FIXME bottom can't be larger than top
- camera.left = camera.bottom = 0;
- camera.top = height;
- camera.right = width;
- camera.near = 0;
- camera.far = 100;
- camera.position.z = 10;
- },
- remove: function () {
- this._planeMesh.stopAnimation();
- this.groupGL.removeAll();
- },
- dispose: function () {
- if (this._renderer) {
- this._particleSurface.dispose(this._renderer);
- }
- this.groupGL.removeAll();
- }
- });
- /***/
- }),
- /* 277 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_compositor_Pass__ = __webpack_require__(16);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__ = __webpack_require__(15);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_claygl_src_Mesh__ = __webpack_require__(40);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3_claygl_src_Material__ = __webpack_require__(19);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__ = __webpack_require__(8);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5_claygl_src_Texture2D__ = __webpack_require__(5);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6_claygl_src_Texture__ = __webpack_require__(4);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7_claygl_src_camera_Orthographic__ = __webpack_require__(37);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8_claygl_src_geometry_Plane__ = __webpack_require__(43);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9_claygl_src_FrameBuffer__ = __webpack_require__(10);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Line2D__ = __webpack_require__(278);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__vectorFieldParticle_glsl_js__ = __webpack_require__(279);
- // import TemporalSS from '../../effect/TemporalSuperSampling';
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */]['import'](__WEBPACK_IMPORTED_MODULE_11__vectorFieldParticle_glsl_js__["a" /* default */]);
- function createSpriteCanvas(size) {
- var canvas = document.createElement('canvas');
- canvas.width = canvas.height = size;
- var ctx = canvas.getContext('2d');
- ctx.fillStyle = '#fff';
- ctx.arc(size / 2, size / 2, size / 2, 0, Math.PI * 2);
- ctx.fill();
- return canvas;
- }
- // import spriteUtil from '../../util/sprite';
- var VectorFieldParticleSurface = function () {
- /**
- * @type {number}
- */
- this.motionBlurFactor = 0.99;
- /**
- * Vector field lookup image
- * @type {clay.Texture2D}
- */
- this.vectorFieldTexture = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_Texture2D__["a" /* default */]({
- type: __WEBPACK_IMPORTED_MODULE_6_claygl_src_Texture__["a" /* default */].FLOAT,
- // minFilter: Texture.NEAREST,
- // magFilter: Texture.NEAREST,
- flipY: false
- });
- /**
- * Particle life range
- * @type {Array.<number>}
- */
- this.particleLife = [5, 20];
- this._particleType = 'point';
- /**
- * @type {number}
- */
- this._particleSize = 1;
- /**
- * @type {Array.<number>}
- */
- this.particleColor = [1, 1, 1, 1];
- /**
- * @type {number}
- */
- this.particleSpeedScaling = 1.0;
- /**
- * @type {clay.Texture2D}
- */
- this._thisFrameTexture = null;
- this._particlePass = null;
- this._spawnTexture = null;
- this._particleTexture0 = null;
- this._particleTexture1 = null;
- this._particlePointsMesh = null;
- this._surfaceFrameBuffer = null;
- this._elapsedTime = 0.0;
- this._scene = null;
- this._camera = null;
- this._lastFrameTexture = null;
- // this._temporalSS = new TemporalSS(50);
- // this._antialising = false;
- this._supersampling = 1;
- this._downsampleTextures = [];
- this._width = 512;
- this._height = 512;
- this.init();
- };
- VectorFieldParticleSurface.prototype = {
- constructor: VectorFieldParticleSurface,
- init: function () {
- var parameters = {
- type: __WEBPACK_IMPORTED_MODULE_6_claygl_src_Texture__["a" /* default */].FLOAT,
- minFilter: __WEBPACK_IMPORTED_MODULE_6_claygl_src_Texture__["a" /* default */].NEAREST,
- magFilter: __WEBPACK_IMPORTED_MODULE_6_claygl_src_Texture__["a" /* default */].NEAREST,
- useMipmap: false
- };
- this._spawnTexture = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_Texture2D__["a" /* default */](parameters);
- this._particleTexture0 = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_Texture2D__["a" /* default */](parameters);
- this._particleTexture1 = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_Texture2D__["a" /* default */](parameters);
- this._frameBuffer = new __WEBPACK_IMPORTED_MODULE_9_claygl_src_FrameBuffer__["a" /* default */]({
- depthBuffer: false
- });
- this._particlePass = new __WEBPACK_IMPORTED_MODULE_0_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source('ecgl.vfParticle.particle.fragment')
- });
- this._particlePass.setUniform('velocityTexture', this.vectorFieldTexture);
- this._particlePass.setUniform('spawnTexture', this._spawnTexture);
- this._downsamplePass = new __WEBPACK_IMPORTED_MODULE_0_claygl_src_compositor_Pass__["a" /* default */]({
- fragment: __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source('clay.compositor.downsample')
- });
- var particlePointsMesh = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Mesh__["a" /* default */]({
- // Render after last frame full quad
- renderOrder: 10,
- material: new __WEBPACK_IMPORTED_MODULE_3_claygl_src_Material__["a" /* default */]({
- shader: new __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */](
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source('ecgl.vfParticle.renderPoints.vertex'),
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source('ecgl.vfParticle.renderPoints.fragment')
- )
- }),
- mode: __WEBPACK_IMPORTED_MODULE_2_claygl_src_Mesh__["a" /* default */].POINTS,
- geometry: new __WEBPACK_IMPORTED_MODULE_1_claygl_src_Geometry__["a" /* default */]({
- dynamic: true,
- mainAttribute: 'texcoord0'
- })
- });
- var particleLinesMesh = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Mesh__["a" /* default */]({
- // Render after last frame full quad
- renderOrder: 10,
- material: new __WEBPACK_IMPORTED_MODULE_3_claygl_src_Material__["a" /* default */]({
- shader: new __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */](
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source('ecgl.vfParticle.renderLines.vertex'),
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source('ecgl.vfParticle.renderLines.fragment')
- )
- }),
- geometry: new __WEBPACK_IMPORTED_MODULE_10__Line2D__["a" /* default */](),
- culling: false
- });
- var lastFrameFullQuad = new __WEBPACK_IMPORTED_MODULE_2_claygl_src_Mesh__["a" /* default */]({
- material: new __WEBPACK_IMPORTED_MODULE_3_claygl_src_Material__["a" /* default */]({
- shader: new __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */](
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source('ecgl.color.vertex'),
- __WEBPACK_IMPORTED_MODULE_4_claygl_src_Shader__["a" /* default */].source('ecgl.color.fragment')
- )
- // DO NOT BLEND Blend will multiply alpha
- // transparent: true
- }),
- geometry: new __WEBPACK_IMPORTED_MODULE_8_claygl_src_geometry_Plane__["a" /* default */]()
- });
- lastFrameFullQuad.material.enableTexture('diffuseMap');
- this._particlePointsMesh = particlePointsMesh;
- this._particleLinesMesh = particleLinesMesh;
- this._lastFrameFullQuadMesh = lastFrameFullQuad;
- this._camera = new __WEBPACK_IMPORTED_MODULE_7_claygl_src_camera_Orthographic__["a" /* default */]();
- this._thisFrameTexture = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_Texture2D__["a" /* default */]();
- this._lastFrameTexture = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_Texture2D__["a" /* default */]();
- },
- setParticleDensity: function (width, height) {
- var nVertex = width * height;
- var spawnTextureData = new Float32Array(nVertex * 4);
- var off = 0;
- var lifeRange = this.particleLife;
- for (var i = 0; i < width; i++) {
- for (var j = 0; j < height; j++ , off++) {
- // x position, range [0 - 1]
- spawnTextureData[off * 4] = Math.random();
- // y position, range [0 - 1]
- spawnTextureData[off * 4 + 1] = Math.random();
- // Some property
- spawnTextureData[off * 4 + 2] = Math.random();
- var life = (lifeRange[1] - lifeRange[0]) * Math.random() + lifeRange[0];
- // Particle life
- spawnTextureData[off * 4 + 3] = life;
- }
- }
- if (this._particleType === 'line') {
- this._setLineGeometry(width, height);
- }
- else {
- this._setPointsGeometry(width, height);
- }
- this._spawnTexture.width = width;
- this._spawnTexture.height = height;
- this._spawnTexture.pixels = spawnTextureData;
- this._particleTexture0.width = this._particleTexture1.width = width;
- this._particleTexture0.height = this._particleTexture1.height = height;
- this._particlePass.setUniform('textureSize', [width, height]);
- },
- _setPointsGeometry: function (width, height) {
- var nVertex = width * height;
- var geometry = this._particlePointsMesh.geometry;
- var attributes = geometry.attributes;
- attributes.texcoord0.init(nVertex);
- var off = 0;
- for (var i = 0; i < width; i++) {
- for (var j = 0; j < height; j++ , off++) {
- attributes.texcoord0.value[off * 2] = i / width;
- attributes.texcoord0.value[off * 2 + 1] = j / height;
- }
- }
- geometry.dirty();
- },
- _setLineGeometry: function (width, height) {
- var nLine = width * height;
- var geometry = this._getParticleMesh().geometry;
- geometry.setLineCount(nLine);
- geometry.resetOffset();
- for (var i = 0; i < width; i++) {
- for (var j = 0; j < height; j++) {
- geometry.addLine([i / width, j / height]);
- }
- }
- geometry.dirty();
- },
- _getParticleMesh: function () {
- return this._particleType === 'line' ? this._particleLinesMesh : this._particlePointsMesh;
- },
- update: function (renderer, api, deltaTime, firstFrame) {
- var particleMesh = this._getParticleMesh();
- var frameBuffer = this._frameBuffer;
- var particlePass = this._particlePass;
- if (firstFrame) {
- this._updateDownsampleTextures(renderer, api);
- }
- particleMesh.material.set('size', this._particleSize * this._supersampling);
- particleMesh.material.set('color', this.particleColor);
- particlePass.setUniform('speedScaling', this.particleSpeedScaling);
- frameBuffer.attach(this._particleTexture1);
- particlePass.setUniform('firstFrameTime', firstFrame ? (this.particleLife[1] + this.particleLife[0]) / 2 : 0);
- particlePass.setUniform('particleTexture', this._particleTexture0);
- particlePass.setUniform('deltaTime', deltaTime);
- particlePass.setUniform('elapsedTime', this._elapsedTime);
- particlePass.render(renderer, frameBuffer);
- particleMesh.material.set('particleTexture', this._particleTexture1);
- particleMesh.material.set('prevParticleTexture', this._particleTexture0);
- frameBuffer.attach(this._thisFrameTexture);
- frameBuffer.bind(renderer);
- renderer.gl.clear(renderer.gl.DEPTH_BUFFER_BIT | renderer.gl.COLOR_BUFFER_BIT);
- var lastFrameFullQuad = this._lastFrameFullQuadMesh;
- lastFrameFullQuad.material.set('diffuseMap', this._lastFrameTexture);
- lastFrameFullQuad.material.set('color', [1, 1, 1, this.motionBlurFactor]);
- this._camera.update(true);
- renderer.renderPass([lastFrameFullQuad, particleMesh], this._camera);
- frameBuffer.unbind(renderer);
- this._downsample(renderer);
- this._swapTexture();
- this._elapsedTime += deltaTime;
- },
- _downsample: function (renderer) {
- var downsampleTextures = this._downsampleTextures;
- if (downsampleTextures.length === 0) {
- return;
- }
- var current = 0;
- var sourceTexture = this._thisFrameTexture;
- var targetTexture = downsampleTextures[current];
- while (targetTexture) {
- this._frameBuffer.attach(targetTexture);
- this._downsamplePass.setUniform('texture', sourceTexture);
- this._downsamplePass.setUniform('textureSize', [sourceTexture.width, sourceTexture.height]);
- this._downsamplePass.render(renderer, this._frameBuffer);
- sourceTexture = targetTexture;
- targetTexture = downsampleTextures[++current];
- }
- },
- getSurfaceTexture: function () {
- var downsampleTextures = this._downsampleTextures;
- return downsampleTextures.length > 0
- ? downsampleTextures[downsampleTextures.length - 1]
- : this._lastFrameTexture;
- },
- setRegion: function (region) {
- this._particlePass.setUniform('region', region);
- },
- resize: function (width, height) {
- this._lastFrameTexture.width = width * this._supersampling;
- this._lastFrameTexture.height = height * this._supersampling;
- this._thisFrameTexture.width = width * this._supersampling;
- this._thisFrameTexture.height = height * this._supersampling;
- this._width = width;
- this._height = height;
- },
- setParticleSize: function (size) {
- var particleMesh = this._getParticleMesh();
- if (size <= 2) {
- particleMesh.material.disableTexture('spriteTexture');
- particleMesh.material.transparent = false;
- return;
- }
- if (!this._spriteTexture) {
- this._spriteTexture = new __WEBPACK_IMPORTED_MODULE_5_claygl_src_Texture2D__["a" /* default */]();
- }
- if (!this._spriteTexture.image || this._spriteTexture.image.width !== size) {
- this._spriteTexture.image = createSpriteCanvas(size);
- this._spriteTexture.dirty();
- }
- particleMesh.material.transparent = true;
- particleMesh.material.enableTexture('spriteTexture');
- particleMesh.material.set('spriteTexture', this._spriteTexture);
- this._particleSize = size;
- },
- setGradientTexture: function (gradientTexture) {
- var material = this._getParticleMesh().material;
- material[gradientTexture ? 'enableTexture' : 'disableTexture']('gradientTexture');
- material.setUniform('gradientTexture', gradientTexture);
- },
- setColorTextureImage: function (colorTextureImg, api) {
- var material = this._getParticleMesh().material;
- material.setTextureImage('colorTexture', colorTextureImg, api, {
- flipY: true
- });
- },
- setParticleType: function (type) {
- this._particleType = type;
- },
- clearFrame: function (renderer) {
- var frameBuffer = this._frameBuffer;
- frameBuffer.attach(this._lastFrameTexture);
- frameBuffer.bind(renderer);
- renderer.gl.clear(renderer.gl.DEPTH_BUFFER_BIT | renderer.gl.COLOR_BUFFER_BIT);
- frameBuffer.unbind(renderer);
- },
- setSupersampling: function (supersampling) {
- this._supersampling = supersampling;
- this.resize(this._width, this._height);
- },
- _updateDownsampleTextures: function (renderer, api) {
- var downsampleTextures = this._downsampleTextures;
- var upScale = Math.max(Math.floor(Math.log(this._supersampling / api.getDevicePixelRatio()) / Math.log(2)), 0);
- var scale = 2;
- var width = this._width * this._supersampling;
- var height = this._height * this._supersampling;
- for (var i = 0; i < upScale; i++) {
- downsampleTextures[i] = downsampleTextures[i] || new __WEBPACK_IMPORTED_MODULE_5_claygl_src_Texture2D__["a" /* default */]();
- downsampleTextures[i].width = width / scale;
- downsampleTextures[i].height = height / scale;
- scale *= 2;
- }
- for (; i < downsampleTextures.length; i++) {
- downsampleTextures[i].dispose(renderer);
- }
- downsampleTextures.length = upScale;
- },
- _swapTexture: function () {
- var tmp = this._particleTexture0;
- this._particleTexture0 = this._particleTexture1;
- this._particleTexture1 = tmp;
- var tmp = this._thisFrameTexture;
- this._thisFrameTexture = this._lastFrameTexture;
- this._lastFrameTexture = tmp;
- },
- dispose: function (renderer) {
- renderer.disposeFrameBuffer(this._frameBuffer);
- // Dispose textures
- renderer.disposeTexture(this.vectorFieldTexture);
- renderer.disposeTexture(this._spawnTexture);
- renderer.disposeTexture(this._particleTexture0);
- renderer.disposeTexture(this._particleTexture1);
- renderer.disposeTexture(this._thisFrameTexture);
- renderer.disposeTexture(this._lastFrameTexture);
- renderer.disposeGeometry(this._particleLinesMesh.geometry);
- renderer.disposeGeometry(this._particlePointsMesh.geometry);
- renderer.disposeGeometry(this._lastFrameFullQuadMesh.geometry);
- if (this._spriteTexture) {
- renderer.disposeTexture(this._spriteTexture);
- }
- this._particlePass.dispose(renderer);
- this._downsamplePass.dispose(renderer);
- this._downsampleTextures.forEach(function (texture) {
- texture.dispose(renderer);
- });
- }
- };
- /* harmony default export */ __webpack_exports__["a"] = (VectorFieldParticleSurface);
- /***/
- }),
- /* 278 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__ = __webpack_require__(15);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_echarts_lib_echarts__);
- /**
- * Lines geometry
- * Use screen space projected lines lineWidth > MAX_LINE_WIDTH
- * https://mattdesl.svbtle.com/drawing-lines-is-hard
- * @module echarts-gl/util/geometry/LinesGeometry
- * @author Yi Shen(http://github.com/pissang)
- */
- /**
- * @constructor
- * @alias module:echarts-gl/chart/flowGL/Line2D
- * @extends clay.Geometry
- */
- var LinesGeometry = __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].extend(function () {
- return {
- dynamic: true,
- attributes: {
- position: new __WEBPACK_IMPORTED_MODULE_0_claygl_src_Geometry__["a" /* default */].Attribute('position', 'float', 3, 'POSITION')
- }
- };
- },
- /** @lends module: echarts-gl/util/geometry/LinesGeometry.prototype */
- {
- /**
- * Reset offset
- */
- resetOffset: function () {
- this._vertexOffset = 0;
- this._faceOffset = 0;
- },
- /**
- * @param {number} nVertex
- */
- setLineCount: function (nLine) {
- var attributes = this.attributes;
- var nVertex = 4 * nLine;
- var nTriangle = 2 * nLine;
- if (this.vertexCount !== nVertex) {
- attributes.position.init(nVertex);
- }
- if (this.triangleCount !== nTriangle) {
- if (nTriangle === 0) {
- this.indices = null;
- }
- else {
- this.indices = this.vertexCount > 0xffff ? new Uint32Array(nTriangle * 3) : new Uint16Array(nTriangle * 3);
- }
- }
- },
- addLine: function (p) {
- var vertexOffset = this._vertexOffset;
- this.attributes.position.set(vertexOffset, [p[0], p[1], 1]);
- this.attributes.position.set(vertexOffset + 1, [p[0], p[1], -1]);
- this.attributes.position.set(vertexOffset + 2, [p[0], p[1], 2]);
- this.attributes.position.set(vertexOffset + 3, [p[0], p[1], -2]);
- this.setTriangleIndices(
- this._faceOffset++, [
- vertexOffset, vertexOffset + 1, vertexOffset + 2
- ]
- );
- this.setTriangleIndices(
- this._faceOffset++, [
- vertexOffset + 1, vertexOffset + 2, vertexOffset + 3
- ]
- );
- this._vertexOffset += 4;
- }
- });
- /* harmony default export */ __webpack_exports__["a"] = (LinesGeometry);
- /***/
- }),
- /* 279 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony default export */ __webpack_exports__["a"] = ("@export ecgl.vfParticle.particle.fragment\n\nuniform sampler2D particleTexture;\nuniform sampler2D spawnTexture;\nuniform sampler2D velocityTexture;\n\nuniform float deltaTime;\nuniform float elapsedTime;\n\nuniform float speedScaling : 1.0;\n\nuniform vec2 textureSize;\nuniform vec4 region : [0, 0, 1, 1];\nuniform float firstFrameTime;\n\nvarying vec2 v_Texcoord;\n\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, v_Texcoord);\n bool spawn = false;\n if (p.w <= 0.0) {\n p = texture2D(spawnTexture, fract(v_Texcoord + elapsedTime / 10.0));\n p.w -= firstFrameTime;\n spawn = true;\n }\n vec2 v = texture2D(velocityTexture, fract(p.xy * region.zw + region.xy)).xy;\n v = (v - 0.5) * 2.0;\n p.z = length(v);\n p.xy += v * deltaTime / 10.0 * speedScaling;\n p.w -= deltaTime;\n\n if (spawn || p.xy != fract(p.xy)) {\n p.z = 0.0;\n }\n p.xy = fract(p.xy);\n\n gl_FragColor = p;\n}\n@end\n\n@export ecgl.vfParticle.renderPoints.vertex\n\n#define PI 3.1415926\n\nattribute vec2 texcoord : TEXCOORD_0;\n\nuniform sampler2D particleTexture;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nuniform float size : 1.0;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, texcoord);\n\n if (p.w > 0.0 && p.z > 1e-5) {\n gl_Position = worldViewProjection * vec4(p.xy * 2.0 - 1.0, 0.0, 1.0);\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n\n v_Mag = p.z;\n v_Uv = p.xy;\n\n gl_PointSize = size;\n}\n\n@end\n\n@export ecgl.vfParticle.renderPoints.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\nuniform sampler2D spriteTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n#ifdef SPRITETEXTURE_ENABLED\n gl_FragColor *= texture2D(spriteTexture, gl_PointCoord);\n if (color.a == 0.0) {\n discard;\n }\n#endif\n#ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.vertex\n\n#define PI 3.1415926\n\nattribute vec3 position : POSITION;\n\nuniform sampler2D particleTexture;\nuniform sampler2D prevParticleTexture;\n\nuniform float size : 1.0;\nuniform vec4 vp: VIEWPORT;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\n@import clay.util.rand\n\nvoid main()\n{\n vec4 p = texture2D(particleTexture, position.xy);\n vec4 p2 = texture2D(prevParticleTexture, position.xy);\n\n p.xy = p.xy * 2.0 - 1.0;\n p2.xy = p2.xy * 2.0 - 1.0;\n\n if (p.w > 0.0 && p.z > 1e-5) {\n vec2 dir = normalize(p.xy - p2.xy);\n vec2 norm = vec2(dir.y / vp.z, -dir.x / vp.w) * sign(position.z) * size;\n if (abs(position.z) == 2.0) {\n gl_Position = vec4(p.xy + norm, 0.0, 1.0);\n v_Uv = p.xy;\n v_Mag = p.z;\n }\n else {\n gl_Position = vec4(p2.xy + norm, 0.0, 1.0);\n v_Mag = p2.z;\n v_Uv = p2.xy;\n }\n gl_Position = worldViewProjection * gl_Position;\n }\n else {\n gl_Position = vec4(100000.0, 100000.0, 100000.0, 1.0);\n }\n}\n\n@end\n\n@export ecgl.vfParticle.renderLines.fragment\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform sampler2D gradientTexture;\nuniform sampler2D colorTexture;\n\nvarying float v_Mag;\nvarying vec2 v_Uv;\n\nvoid main()\n{\n gl_FragColor = color;\n #ifdef GRADIENTTEXTURE_ENABLED\n gl_FragColor *= texture2D(gradientTexture, vec2(v_Mag, 0.5));\n#endif\n#ifdef COLORTEXTURE_ENABLED\n gl_FragColor *= texture2D(colorTexture, v_Uv);\n#endif\n}\n\n@end\n");
- /***/
- }),
- /* 280 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({
- type: 'series.flowGL',
- dependencies: ['geo', 'grid', 'bmap'],
- visualColorAccessPath: 'itemStyle.color',
- getInitialData: function (option, ecModel) {
- var coordSysDimensions = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.getCoordinateSystemDimensions(this.get('coordinateSystem')) || ['x', 'y'];
- if (true) {
- if (coordSysDimensions.length > 2) {
- throw new Error('flowGL can only be used on 2d coordinate systems.')
- }
- }
- coordSysDimensions.push('vx', 'vy');
- var dimensions = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.helper.completeDimensions(coordSysDimensions, this.getSource(), {
- encodeDef: this.get('encode'),
- dimsDef: this.get('dimensions')
- });
- var data = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.List(dimensions, this);
- data.initData(this.getSource());
- return data;
- },
- defaultOption: {
- coordinateSystem: 'cartesian2d',
- zlevel: 10,
- supersampling: 1,
- // 128x128 particles
- particleType: 'point',
- particleDensity: 128,
- particleSize: 1,
- particleSpeed: 1,
- particleTrail: 2,
- colorTexture: null,
- gridWidth: 'auto',
- gridHeight: 'auto',
- itemStyle: {
- color: '#fff',
- opacity: 0.8
- }
- }
- });
- /***/
- }),
- /* 281 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__linesGL_LinesGLSeries__ = __webpack_require__(282);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__linesGL_LinesGLView__ = __webpack_require__(283);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__common_opacityVisual__ = __webpack_require__(17);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.registerVisual(Object(__WEBPACK_IMPORTED_MODULE_3__common_opacityVisual__["a" /* default */])('linesGL'));
- /***/
- }),
- /* 282 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_util__ = __webpack_require__(13);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_util___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_util__);
- var LinesSeries = __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendSeriesModel({
- type: 'series.linesGL',
- dependencies: ['grid', 'geo'],
- visualColorAccessPath: 'lineStyle.color',
- streamEnabled: true,
- init: function (option) {
- var result = this._processFlatCoordsArray(option.data);
- this._flatCoords = result.flatCoords;
- this._flatCoordsOffset = result.flatCoordsOffset;
- if (result.flatCoords) {
- option.data = new Float32Array(result.count);
- }
- LinesSeries.superApply(this, 'init', arguments);
- },
- mergeOption: function (option) {
- var result = this._processFlatCoordsArray(option.data);
- this._flatCoords = result.flatCoords;
- this._flatCoordsOffset = result.flatCoordsOffset;
- if (result.flatCoords) {
- option.data = new Float32Array(result.count);
- }
- LinesSeries.superApply(this, 'mergeOption', arguments);
- },
- appendData: function (params) {
- var result = this._processFlatCoordsArray(params.data);
- if (result.flatCoords) {
- if (!this._flatCoords) {
- this._flatCoords = result.flatCoords;
- this._flatCoordsOffset = result.flatCoordsOffset;
- }
- else {
- this._flatCoords = Object(__WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_util__["concatArray"])(this._flatCoords, result.flatCoords);
- this._flatCoordsOffset = Object(__WEBPACK_IMPORTED_MODULE_1_zrender_lib_core_util__["concatArray"])(this._flatCoordsOffset, result.flatCoordsOffset);
- }
- params.data = new Float32Array(result.count);
- }
- this.getRawData().appendData(params.data);
- },
- _getCoordsFromItemModel: function (idx) {
- var itemModel = this.getData().getItemModel(idx);
- var coords = (itemModel.option instanceof Array)
- ? itemModel.option : itemModel.getShallow('coords');
- if (true) {
- if (!(coords instanceof Array && coords.length > 0 && coords[0] instanceof Array)) {
- throw new Error('Invalid coords ' + JSON.stringify(coords) + '. Lines must have 2d coords array in data item.');
- }
- }
- return coords;
- },
- getLineCoordsCount: function (idx) {
- if (this._flatCoordsOffset) {
- return this._flatCoordsOffset[idx * 2 + 1];
- }
- else {
- return this._getCoordsFromItemModel(idx).length;
- }
- },
- getLineCoords: function (idx, out) {
- if (this._flatCoordsOffset) {
- var offset = this._flatCoordsOffset[idx * 2];
- var len = this._flatCoordsOffset[idx * 2 + 1];
- for (var i = 0; i < len; i++) {
- out[i] = out[i] || [];
- out[i][0] = this._flatCoords[offset + i * 2];
- out[i][1] = this._flatCoords[offset + i * 2 + 1];
- }
- return len;
- }
- else {
- var coords = this._getCoordsFromItemModel(idx);
- for (var i = 0; i < coords.length; i++) {
- out[i] = out[i] || [];
- out[i][0] = coords[i][0];
- out[i][1] = coords[i][1];
- }
- return coords.length;
- }
- },
- _processFlatCoordsArray: function (data) {
- var startOffset = 0;
- if (this._flatCoords) {
- startOffset = this._flatCoords.length;
- }
- // Stored as a typed array. In format
- // Points Count(2) | x | y | x | y | Points Count(3) | x | y | x | y | x | y |
- if (typeof data[0] === 'number') {
- var len = data.length;
- // Store offset and len of each segment
- var coordsOffsetAndLenStorage = new Uint32Array(len);
- var coordsStorage = new Float64Array(len);
- var coordsCursor = 0;
- var offsetCursor = 0;
- var dataCount = 0;
- for (var i = 0; i < len;) {
- dataCount++;
- var count = data[i++];
- // Offset
- coordsOffsetAndLenStorage[offsetCursor++] = coordsCursor + startOffset;
- // Len
- coordsOffsetAndLenStorage[offsetCursor++] = count;
- for (var k = 0; k < count; k++) {
- var x = data[i++];
- var y = data[i++];
- coordsStorage[coordsCursor++] = x;
- coordsStorage[coordsCursor++] = y;
- if (i > len) {
- if (true) {
- throw new Error('Invalid data format.');
- }
- }
- }
- }
- return {
- flatCoordsOffset: new Uint32Array(coordsOffsetAndLenStorage.buffer, 0, offsetCursor),
- flatCoords: coordsStorage,
- count: dataCount
- };
- }
- return {
- flatCoordsOffset: null,
- flatCoords: null,
- count: data.length
- };
- },
- getInitialData: function (option, ecModel) {
- var lineData = new __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.List(['value'], this);
- lineData.hasItemOption = false;
- lineData.initData(option.data, [], function (dataItem, dimName, dataIndex, dimIndex) {
- // dataItem is simply coords
- if (dataItem instanceof Array) {
- return NaN;
- }
- else {
- lineData.hasItemOption = true;
- var value = dataItem.value;
- if (value != null) {
- return value instanceof Array ? value[dimIndex] : value;
- }
- }
- });
- return lineData;
- },
- defaultOption: {
- coordinateSystem: 'geo',
- zlevel: 10,
- progressive: 1e4,
- progressiveThreshold: 5e4,
- // Cartesian coordinate system
- // xAxisIndex: 0,
- // yAxisIndex: 0,
- // Geo coordinate system
- // geoIndex: 0,
- // Support source-over, lighter
- blendMode: 'source-over',
- lineStyle: {
- opacity: 0.8
- },
- postEffect: {
- enable: false,
- colorCorrection: {
- exposure: 0,
- brightness: 0,
- contrast: 1,
- saturation: 1,
- enable: true
- }
- }
- }
- });
- /***/
- }),
- /* 283 */
- /***/ (function (module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__ = __webpack_require__(0);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts__);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__ = __webpack_require__(22);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines2D__ = __webpack_require__(105);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__common_GLViewHelper__ = __webpack_require__(103);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__util_retrieve__ = __webpack_require__(2);
- __WEBPACK_IMPORTED_MODULE_0_echarts_lib_echarts___default.a.extendChartView({
- type: 'linesGL',
- __ecgl__: true,
- init: function (ecModel, api) {
- this.groupGL = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Node();
- this.viewGL = new __WEBPACK_IMPORTED_MODULE_2__core_ViewGL__["a" /* default */]('orthographic');
- this.viewGL.add(this.groupGL);
- this._glViewHelper = new __WEBPACK_IMPORTED_MODULE_4__common_GLViewHelper__["a" /* default */](this.viewGL);
- this._nativeLinesShader = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.lines3D');
- this._meshLinesShader = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.meshLines3D');
- this._linesMeshes = [];
- this._currentStep = 0;
- },
- render: function (seriesModel, ecModel, api) {
- this.groupGL.removeAll();
- this._glViewHelper.reset(seriesModel, api);
- var linesMesh = this._linesMeshes[0];
- if (!linesMesh) {
- linesMesh = this._linesMeshes[0] = this._createLinesMesh(seriesModel);
- }
- this._linesMeshes.length = 1;
- this.groupGL.add(linesMesh);
- this._updateLinesMesh(seriesModel, linesMesh, 0, seriesModel.getData().count());
- this.viewGL.setPostEffect(seriesModel.getModel('postEffect'), api);
- },
- incrementalPrepareRender: function (seriesModel, ecModel, api) {
- this.groupGL.removeAll();
- this._glViewHelper.reset(seriesModel, api);
- this._currentStep = 0;
- this.viewGL.setPostEffect(seriesModel.getModel('postEffect'), api);
- },
- incrementalRender: function (params, seriesModel, ecModel, api) {
- var linesMesh = this._linesMeshes[this._currentStep];
- if (!linesMesh) {
- linesMesh = this._createLinesMesh(seriesModel);
- this._linesMeshes[this._currentStep] = linesMesh;
- }
- this._updateLinesMesh(seriesModel, linesMesh, params.start, params.end);
- this.groupGL.add(linesMesh);
- api.getZr().refresh();
- this._currentStep++;
- },
- updateTransform: function (seriesModel, ecModel, api) {
- if (seriesModel.coordinateSystem.getRoamTransform) {
- this._glViewHelper.updateTransform(seriesModel, api);
- }
- },
- _createLinesMesh: function (seriesModel) {
- var linesMesh = new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh({
- $ignorePicking: true,
- material: new __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Material({
- shader: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].createShader('ecgl.lines3D'),
- transparent: true,
- depthMask: false,
- depthTest: false
- }),
- geometry: new __WEBPACK_IMPORTED_MODULE_3__util_geometry_Lines2D__["a" /* default */]({
- segmentScale: 10,
- useNativeLine: true,
- dynamic: false
- }),
- mode: __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.LINES,
- culling: false
- });
- return linesMesh;
- },
- _updateLinesMesh: function (seriesModel, linesMesh, start, end) {
- var data = seriesModel.getData();
- linesMesh.material.blend = seriesModel.get('blendMode') === 'lighter'
- ? __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].additiveBlend : null;
- var curveness = seriesModel.get('lineStyle.curveness') || 0;
- var isPolyline = seriesModel.get('polyline');
- var geometry = linesMesh.geometry;
- var coordSys = seriesModel.coordinateSystem;
- var lineWidth = __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(seriesModel.get('lineStyle.width'), 1);
- if (lineWidth > 1) {
- if (linesMesh.material.shader !== this._meshLinesShader) {
- linesMesh.material.attachShader(this._meshLinesShader);
- }
- linesMesh.mode = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.TRIANGLES;
- }
- else {
- if (linesMesh.material.shader !== this._nativeLinesShader) {
- linesMesh.material.attachShader(this._nativeLinesShader);
- }
- linesMesh.mode = __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].Mesh.LINES;
- }
- start = start || 0;
- end = end || data.count();
- geometry.resetOffset();
- var vertexCount = 0;
- var triangleCount = 0;
- var p0 = [];
- var p1 = [];
- var p2 = [];
- var p3 = [];
- var lineCoords = [];
- var t = 0.3;
- var t2 = 0.7;
- function updateBezierControlPoints() {
- p1[0] = (p0[0] * t2 + p3[0] * t) - (p0[1] - p3[1]) * curveness;
- p1[1] = (p0[1] * t2 + p3[1] * t) - (p3[0] - p0[0]) * curveness;
- p2[0] = (p0[0] * t + p3[0] * t2) - (p0[1] - p3[1]) * curveness;
- p2[1] = (p0[1] * t + p3[1] * t2) - (p3[0] - p0[0]) * curveness;
- }
- if (isPolyline || curveness !== 0) {
- for (var idx = start; idx < end; idx++) {
- if (isPolyline) {
- var count = seriesModel.getLineCoordsCount(idx);
- vertexCount += geometry.getPolylineVertexCount(count);
- triangleCount += geometry.getPolylineTriangleCount(count);
- }
- else {
- seriesModel.getLineCoords(idx, lineCoords);
- this._glViewHelper.dataToPoint(coordSys, lineCoords[0], p0);
- this._glViewHelper.dataToPoint(coordSys, lineCoords[1], p3);
- updateBezierControlPoints();
- vertexCount += geometry.getCubicCurveVertexCount(p0, p1, p2, p3);
- triangleCount += geometry.getCubicCurveTriangleCount(p0, p1, p2, p3);
- }
- }
- }
- else {
- var lineCount = end - start;
- vertexCount += lineCount * geometry.getLineVertexCount();
- triangleCount += lineCount * geometry.getLineVertexCount();
- }
- geometry.setVertexCount(vertexCount);
- geometry.setTriangleCount(triangleCount);
- var dataIndex = start;
- var colorArr = [];
- for (var idx = start; idx < end; idx++) {
- __WEBPACK_IMPORTED_MODULE_1__util_graphicGL__["a" /* default */].parseColor(data.getItemVisual(dataIndex, 'color'), colorArr);
- var opacity = __WEBPACK_IMPORTED_MODULE_5__util_retrieve__["a" /* default */].firstNotNull(data.getItemVisual(dataIndex, 'opacity'), 1);
- colorArr[3] *= opacity;
- var count = seriesModel.getLineCoords(idx, lineCoords);
- for (var k = 0; k < count; k++) {
- this._glViewHelper.dataToPoint(coordSys, lineCoords[k], lineCoords[k]);
- }
- if (isPolyline) {
- geometry.addPolyline(lineCoords, colorArr, lineWidth, 0, count);
- }
- else if (curveness !== 0) {
- p0 = lineCoords[0];
- p3 = lineCoords[1];
- updateBezierControlPoints();
- geometry.addCubicCurve(p0, p1, p2, p3, colorArr, lineWidth);
- }
- else {
- geometry.addPolyline(lineCoords, colorArr, lineWidth, 0, 2);
- }
- dataIndex++;
- }
- },
- dispose: function () {
- this.groupGL.removeAll();
- },
- remove: function () {
- this.groupGL.removeAll();
- }
- });
- /***/
- })
- /******/]);
- });
|