babylonjs.materials.js 321 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-materials", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-materials"] = factory(require("babylonjs"));
  8. else
  9. root["MATLIB"] = factory(root["BABYLON"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE_babylonjs__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/webpack/buildin/global.js":
  99. /*!*************************************************!*\
  100. !*** ../node_modules/webpack/buildin/global.js ***!
  101. \*************************************************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports) {
  104. var g;
  105. // This works in non-strict mode
  106. g = (function() {
  107. return this;
  108. })();
  109. try {
  110. // This works if eval is allowed (see CSP)
  111. g = g || Function("return this")() || (1, eval)("this");
  112. } catch (e) {
  113. // This works if the window reference is available
  114. if (typeof window === "object") g = window;
  115. }
  116. // g can still be undefined, but nothing to do about it...
  117. // We return undefined, instead of nothing here, so it's
  118. // easier to handle this case. if(!global) { ...}
  119. module.exports = g;
  120. /***/ }),
  121. /***/ "./legacy/legacy.ts":
  122. /*!**************************!*\
  123. !*** ./legacy/legacy.ts ***!
  124. \**************************/
  125. /*! no static exports found */
  126. /***/ (function(module, exports, __webpack_require__) {
  127. "use strict";
  128. /* WEBPACK VAR INJECTION */(function(global) {
  129. function __export(m) {
  130. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  131. }
  132. Object.defineProperty(exports, "__esModule", { value: true });
  133. var MatLib = __webpack_require__(/*! ../src/index */ "./src/index.ts");
  134. /**
  135. * Legacy support, defining window.BABYLON.GridMaterial... (global variable).
  136. *
  137. * This is the entry point for the UMD module.
  138. * The entry point for a future ESM package should be index.ts
  139. */
  140. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  141. if (typeof globalObject !== "undefined") {
  142. globalObject.BABYLON = globalObject.BABYLON || {};
  143. for (var mat in MatLib) {
  144. if (MatLib.hasOwnProperty(mat)) {
  145. globalObject.BABYLON[mat] = MatLib[mat];
  146. }
  147. }
  148. }
  149. __export(__webpack_require__(/*! ../src/index */ "./src/index.ts"));
  150. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  151. /***/ }),
  152. /***/ "./src/cell/cell.fragment.ts":
  153. /*!***********************************!*\
  154. !*** ./src/cell/cell.fragment.ts ***!
  155. \***********************************/
  156. /*! no static exports found */
  157. /***/ (function(module, exports, __webpack_require__) {
  158. "use strict";
  159. Object.defineProperty(exports, "__esModule", { value: true });
  160. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  161. var name = 'cellPixelShader';
  162. exports.name = name;
  163. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n\nvec3 computeCustomDiffuseLighting(lightingInfo info,vec3 diffuseBase,float shadow)\n{\ndiffuseBase=info.diffuse*shadow;\n#ifdef CELLBASIC\nfloat level=1.0;\nif (info.ndl<0.5)\nlevel=0.5;\ndiffuseBase.rgb*vec3(level,level,level);\n#else\nfloat ToonThresholds[4];\nToonThresholds[0]=0.95;\nToonThresholds[1]=0.5;\nToonThresholds[2]=0.2;\nToonThresholds[3]=0.03;\nfloat ToonBrightnessLevels[5];\nToonBrightnessLevels[0]=1.0;\nToonBrightnessLevels[1]=0.8;\nToonBrightnessLevels[2]=0.6;\nToonBrightnessLevels[3]=0.35;\nToonBrightnessLevels[4]=0.2;\nif (info.ndl>ToonThresholds[0])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[0];\n}\nelse if (info.ndl>ToonThresholds[1])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[1];\n}\nelse if (info.ndl>ToonThresholds[2])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[2];\n}\nelse if (info.ndl>ToonThresholds[3])\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[3];\n}\nelse\n{\ndiffuseBase.rgb*=ToonBrightnessLevels[4];\n}\n#endif\nreturn max(diffuseBase,vec3(0.2));\n}\nvoid main(void)\n{\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nlightingInfo info;\nvec3 diffuseBase=vec3(0.,0.,0.);\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";
  164. exports.shader = shader;
  165. babylonjs_1.Effect.ShadersStore[name] = shader;
  166. /***/ }),
  167. /***/ "./src/cell/cell.vertex.ts":
  168. /*!*********************************!*\
  169. !*** ./src/cell/cell.vertex.ts ***!
  170. \*********************************/
  171. /*! no static exports found */
  172. /***/ (function(module, exports, __webpack_require__) {
  173. "use strict";
  174. Object.defineProperty(exports, "__esModule", { value: true });
  175. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  176. var name = 'cellVertexShader';
  177. exports.name = name;
  178. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  179. exports.shader = shader;
  180. babylonjs_1.Effect.ShadersStore[name] = shader;
  181. /***/ }),
  182. /***/ "./src/cell/cellMaterial.ts":
  183. /*!**********************************!*\
  184. !*** ./src/cell/cellMaterial.ts ***!
  185. \**********************************/
  186. /*! no static exports found */
  187. /***/ (function(module, exports, __webpack_require__) {
  188. "use strict";
  189. var __extends = (this && this.__extends) || (function () {
  190. var extendStatics = function (d, b) {
  191. extendStatics = Object.setPrototypeOf ||
  192. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  193. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  194. return extendStatics(d, b);
  195. }
  196. return function (d, b) {
  197. extendStatics(d, b);
  198. function __() { this.constructor = d; }
  199. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  200. };
  201. })();
  202. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  203. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  204. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  205. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  206. return c > 3 && r && Object.defineProperty(target, key, r), r;
  207. };
  208. Object.defineProperty(exports, "__esModule", { value: true });
  209. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  210. __webpack_require__(/*! ./cell.fragment */ "./src/cell/cell.fragment.ts");
  211. __webpack_require__(/*! ./cell.vertex */ "./src/cell/cell.vertex.ts");
  212. var CellMaterialDefines = /** @class */ (function (_super) {
  213. __extends(CellMaterialDefines, _super);
  214. function CellMaterialDefines() {
  215. var _this = _super.call(this) || this;
  216. _this.DIFFUSE = false;
  217. _this.CLIPPLANE = false;
  218. _this.CLIPPLANE2 = false;
  219. _this.CLIPPLANE3 = false;
  220. _this.CLIPPLANE4 = false;
  221. _this.ALPHATEST = false;
  222. _this.POINTSIZE = false;
  223. _this.FOG = false;
  224. _this.NORMAL = false;
  225. _this.UV1 = false;
  226. _this.UV2 = false;
  227. _this.VERTEXCOLOR = false;
  228. _this.VERTEXALPHA = false;
  229. _this.NUM_BONE_INFLUENCERS = 0;
  230. _this.BonesPerMesh = 0;
  231. _this.INSTANCES = false;
  232. _this.NDOTL = true;
  233. _this.CUSTOMUSERLIGHTING = true;
  234. _this.CELLBASIC = true;
  235. _this.DEPTHPREPASS = false;
  236. _this.rebuild();
  237. return _this;
  238. }
  239. return CellMaterialDefines;
  240. }(babylonjs_1.MaterialDefines));
  241. var CellMaterial = /** @class */ (function (_super) {
  242. __extends(CellMaterial, _super);
  243. function CellMaterial(name, scene) {
  244. var _this = _super.call(this, name, scene) || this;
  245. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  246. _this._computeHighLevel = false;
  247. _this._disableLighting = false;
  248. _this._maxSimultaneousLights = 4;
  249. return _this;
  250. }
  251. CellMaterial.prototype.needAlphaBlending = function () {
  252. return (this.alpha < 1.0);
  253. };
  254. CellMaterial.prototype.needAlphaTesting = function () {
  255. return false;
  256. };
  257. CellMaterial.prototype.getAlphaTestTexture = function () {
  258. return null;
  259. };
  260. // Methods
  261. CellMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  262. if (this.isFrozen) {
  263. if (this._wasPreviouslyReady && subMesh.effect) {
  264. return true;
  265. }
  266. }
  267. if (!subMesh._materialDefines) {
  268. subMesh._materialDefines = new CellMaterialDefines();
  269. }
  270. var defines = subMesh._materialDefines;
  271. var scene = this.getScene();
  272. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  273. if (this._renderId === scene.getRenderId()) {
  274. return true;
  275. }
  276. }
  277. var engine = scene.getEngine();
  278. // Textures
  279. if (defines._areTexturesDirty) {
  280. defines._needUVs = false;
  281. if (scene.texturesEnabled) {
  282. if (this._diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  283. if (!this._diffuseTexture.isReady()) {
  284. return false;
  285. }
  286. else {
  287. defines._needUVs = true;
  288. defines.DIFFUSE = true;
  289. }
  290. }
  291. }
  292. }
  293. // High level
  294. defines.CELLBASIC = !this.computeHighLevel;
  295. // Misc.
  296. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  297. // Lights
  298. defines._needNormals = babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  299. // Values that need to be evaluated on every frame
  300. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  301. // Attribs
  302. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  303. // Get correct effect
  304. if (defines.isDirty) {
  305. defines.markAsProcessed();
  306. scene.resetCachedMaterial();
  307. // Fallbacks
  308. var fallbacks = new babylonjs_1.EffectFallbacks();
  309. if (defines.FOG) {
  310. fallbacks.addFallback(1, "FOG");
  311. }
  312. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
  313. if (defines.NUM_BONE_INFLUENCERS > 0) {
  314. fallbacks.addCPUSkinningFallback(0, mesh);
  315. }
  316. //Attributes
  317. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  318. if (defines.NORMAL) {
  319. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  320. }
  321. if (defines.UV1) {
  322. attribs.push(babylonjs_1.VertexBuffer.UVKind);
  323. }
  324. if (defines.UV2) {
  325. attribs.push(babylonjs_1.VertexBuffer.UV2Kind);
  326. }
  327. if (defines.VERTEXCOLOR) {
  328. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  329. }
  330. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  331. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  332. var shaderName = "cell";
  333. var join = defines.toString();
  334. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
  335. "vFogInfos", "vFogColor", "pointSize",
  336. "vDiffuseInfos",
  337. "mBones",
  338. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix"
  339. ];
  340. var samplers = ["diffuseSampler"];
  341. var uniformBuffers = new Array();
  342. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  343. uniformsNames: uniforms,
  344. uniformBuffersNames: uniformBuffers,
  345. samplers: samplers,
  346. defines: defines,
  347. maxSimultaneousLights: this.maxSimultaneousLights
  348. });
  349. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  350. attributes: attribs,
  351. uniformsNames: uniforms,
  352. uniformBuffersNames: uniformBuffers,
  353. samplers: samplers,
  354. defines: join,
  355. fallbacks: fallbacks,
  356. onCompiled: this.onCompiled,
  357. onError: this.onError,
  358. indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights - 1 }
  359. }, engine), defines);
  360. }
  361. if (!subMesh.effect || !subMesh.effect.isReady()) {
  362. return false;
  363. }
  364. this._renderId = scene.getRenderId();
  365. this._wasPreviouslyReady = true;
  366. return true;
  367. };
  368. CellMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  369. var scene = this.getScene();
  370. var defines = subMesh._materialDefines;
  371. if (!defines) {
  372. return;
  373. }
  374. var effect = subMesh.effect;
  375. if (!effect) {
  376. return;
  377. }
  378. this._activeEffect = effect;
  379. // Matrices
  380. this.bindOnlyWorldMatrix(world);
  381. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  382. // Bones
  383. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  384. if (this._mustRebind(scene, effect)) {
  385. // Textures
  386. if (this._diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  387. this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
  388. this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  389. this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
  390. }
  391. // Clip plane
  392. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  393. // Point size
  394. if (this.pointsCloud) {
  395. this._activeEffect.setFloat("pointSize", this.pointSize);
  396. }
  397. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  398. }
  399. this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  400. // Lights
  401. if (scene.lightsEnabled && !this.disableLighting) {
  402. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights);
  403. }
  404. // View
  405. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  406. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  407. }
  408. // Fog
  409. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  410. this._afterBind(mesh, this._activeEffect);
  411. };
  412. CellMaterial.prototype.getAnimatables = function () {
  413. var results = [];
  414. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  415. results.push(this._diffuseTexture);
  416. }
  417. return results;
  418. };
  419. CellMaterial.prototype.getActiveTextures = function () {
  420. var activeTextures = _super.prototype.getActiveTextures.call(this);
  421. if (this._diffuseTexture) {
  422. activeTextures.push(this._diffuseTexture);
  423. }
  424. return activeTextures;
  425. };
  426. CellMaterial.prototype.hasTexture = function (texture) {
  427. if (_super.prototype.hasTexture.call(this, texture)) {
  428. return true;
  429. }
  430. return this._diffuseTexture === texture;
  431. };
  432. CellMaterial.prototype.dispose = function (forceDisposeEffect) {
  433. if (this._diffuseTexture) {
  434. this._diffuseTexture.dispose();
  435. }
  436. _super.prototype.dispose.call(this, forceDisposeEffect);
  437. };
  438. CellMaterial.prototype.getClassName = function () {
  439. return "CellMaterial";
  440. };
  441. CellMaterial.prototype.clone = function (name) {
  442. var _this = this;
  443. return babylonjs_1.SerializationHelper.Clone(function () { return new CellMaterial(name, _this.getScene()); }, this);
  444. };
  445. CellMaterial.prototype.serialize = function () {
  446. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  447. serializationObject.customType = "BABYLON.CellMaterial";
  448. return serializationObject;
  449. };
  450. // Statics
  451. CellMaterial.Parse = function (source, scene, rootUrl) {
  452. return babylonjs_1.SerializationHelper.Parse(function () { return new CellMaterial(source.name, scene); }, source, scene, rootUrl);
  453. };
  454. __decorate([
  455. babylonjs_1.serializeAsTexture("diffuseTexture")
  456. ], CellMaterial.prototype, "_diffuseTexture", void 0);
  457. __decorate([
  458. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  459. ], CellMaterial.prototype, "diffuseTexture", void 0);
  460. __decorate([
  461. babylonjs_1.serializeAsColor3("diffuse")
  462. ], CellMaterial.prototype, "diffuseColor", void 0);
  463. __decorate([
  464. babylonjs_1.serialize("computeHighLevel")
  465. ], CellMaterial.prototype, "_computeHighLevel", void 0);
  466. __decorate([
  467. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  468. ], CellMaterial.prototype, "computeHighLevel", void 0);
  469. __decorate([
  470. babylonjs_1.serialize("disableLighting")
  471. ], CellMaterial.prototype, "_disableLighting", void 0);
  472. __decorate([
  473. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  474. ], CellMaterial.prototype, "disableLighting", void 0);
  475. __decorate([
  476. babylonjs_1.serialize("maxSimultaneousLights")
  477. ], CellMaterial.prototype, "_maxSimultaneousLights", void 0);
  478. __decorate([
  479. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  480. ], CellMaterial.prototype, "maxSimultaneousLights", void 0);
  481. return CellMaterial;
  482. }(babylonjs_1.PushMaterial));
  483. exports.CellMaterial = CellMaterial;
  484. /***/ }),
  485. /***/ "./src/cell/index.ts":
  486. /*!***************************!*\
  487. !*** ./src/cell/index.ts ***!
  488. \***************************/
  489. /*! no static exports found */
  490. /***/ (function(module, exports, __webpack_require__) {
  491. "use strict";
  492. function __export(m) {
  493. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  494. }
  495. Object.defineProperty(exports, "__esModule", { value: true });
  496. __export(__webpack_require__(/*! ./cellMaterial */ "./src/cell/cellMaterial.ts"));
  497. /***/ }),
  498. /***/ "./src/custom/customMaterial.ts":
  499. /*!**************************************!*\
  500. !*** ./src/custom/customMaterial.ts ***!
  501. \**************************************/
  502. /*! no static exports found */
  503. /***/ (function(module, exports, __webpack_require__) {
  504. "use strict";
  505. var __extends = (this && this.__extends) || (function () {
  506. var extendStatics = function (d, b) {
  507. extendStatics = Object.setPrototypeOf ||
  508. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  509. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  510. return extendStatics(d, b);
  511. }
  512. return function (d, b) {
  513. extendStatics(d, b);
  514. function __() { this.constructor = d; }
  515. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  516. };
  517. })();
  518. Object.defineProperty(exports, "__esModule", { value: true });
  519. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  520. var CustomShaderStructure = /** @class */ (function () {
  521. function CustomShaderStructure() {
  522. }
  523. return CustomShaderStructure;
  524. }());
  525. exports.CustomShaderStructure = CustomShaderStructure;
  526. var ShaderSpecialParts = /** @class */ (function () {
  527. function ShaderSpecialParts() {
  528. }
  529. return ShaderSpecialParts;
  530. }());
  531. exports.ShaderSpecialParts = ShaderSpecialParts;
  532. var CustomMaterial = /** @class */ (function (_super) {
  533. __extends(CustomMaterial, _super);
  534. function CustomMaterial(name, scene) {
  535. var _this = _super.call(this, name, scene) || this;
  536. _this.CustomParts = new ShaderSpecialParts();
  537. _this.customShaderNameResolve = _this.Builder;
  538. _this.FragmentShader = BABYLON.Effect.ShadersStore["defaultPixelShader"];
  539. _this.VertexShader = BABYLON.Effect.ShadersStore["defaultVertexShader"];
  540. return _this;
  541. }
  542. CustomMaterial.prototype.AttachAfterBind = function (mesh, effect) {
  543. for (var el in this._newUniformInstances) {
  544. var ea = el.toString().split('-');
  545. if (ea[0] == 'vec2') {
  546. effect.setVector2(ea[1], this._newUniformInstances[el]);
  547. }
  548. else if (ea[0] == 'vec3') {
  549. effect.setVector3(ea[1], this._newUniformInstances[el]);
  550. }
  551. else if (ea[0] == 'vec4') {
  552. effect.setVector4(ea[1], this._newUniformInstances[el]);
  553. }
  554. else if (ea[0] == 'mat4') {
  555. effect.setMatrix(ea[1], this._newUniformInstances[el]);
  556. }
  557. else if (ea[0] == 'float') {
  558. effect.setFloat(ea[1], this._newUniformInstances[el]);
  559. }
  560. }
  561. for (var el in this._newSamplerInstances) {
  562. var ea = el.toString().split('-');
  563. if (ea[0] == 'sampler2D' && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady()) {
  564. effect.setTexture(ea[1], this._newSamplerInstances[el]);
  565. }
  566. }
  567. };
  568. CustomMaterial.prototype.ReviewUniform = function (name, arr) {
  569. if (name == "uniform") {
  570. for (var ind in this._newUniforms) {
  571. if (this._customUniform[ind].indexOf('sampler') == -1) {
  572. arr.push(this._newUniforms[ind]);
  573. }
  574. }
  575. }
  576. if (name == "sampler") {
  577. for (var ind in this._newUniforms) {
  578. if (this._customUniform[ind].indexOf('sampler') != -1) {
  579. arr.push(this._newUniforms[ind]);
  580. }
  581. }
  582. }
  583. return arr;
  584. };
  585. CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines) {
  586. var _this = this;
  587. if (this._isCreatedShader) {
  588. return this._createdShaderName;
  589. }
  590. this._isCreatedShader = false;
  591. CustomMaterial.ShaderIndexer++;
  592. var name = "custom_" + CustomMaterial.ShaderIndexer;
  593. this.ReviewUniform("uniform", uniforms);
  594. this.ReviewUniform("sampler", samplers);
  595. var fn_afterBind = this._afterBind.bind(this);
  596. this._afterBind = function (m, e) {
  597. if (!e) {
  598. return;
  599. }
  600. _this.AttachAfterBind(m, e);
  601. try {
  602. fn_afterBind(m, e);
  603. }
  604. catch (e) { }
  605. };
  606. BABYLON.Effect.ShadersStore[name + "VertexShader"] = this.VertexShader
  607. .replace('#define CUSTOM_VERTEX_BEGIN', (this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : ""))
  608. .replace('#define CUSTOM_VERTEX_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
  609. .replace('#define CUSTOM_VERTEX_MAIN_BEGIN', (this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : ""))
  610. .replace('#define CUSTOM_VERTEX_UPDATE_POSITION', (this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : ""))
  611. .replace('#define CUSTOM_VERTEX_UPDATE_NORMAL', (this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : ""));
  612. // #define CUSTOM_VERTEX_MAIN_END
  613. BABYLON.Effect.ShadersStore[name + "PixelShader"] = this.FragmentShader
  614. .replace('#define CUSTOM_FRAGMENT_BEGIN', (this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : ""))
  615. .replace('#define CUSTOM_FRAGMENT_MAIN_BEGIN', (this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : ""))
  616. .replace('#define CUSTOM_FRAGMENT_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : ""))
  617. .replace('#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE', (this.CustomParts.Fragment_Custom_Diffuse ? this.CustomParts.Fragment_Custom_Diffuse : ""))
  618. .replace('#define CUSTOM_FRAGMENT_UPDATE_ALPHA', (this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : ""))
  619. .replace('#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR', (this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : ""));
  620. // #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
  621. // #define CUSTOM_FRAGMENT_BEFORE_FOG
  622. this._isCreatedShader = true;
  623. this._createdShaderName = name;
  624. return name;
  625. };
  626. CustomMaterial.prototype.AddUniform = function (name, kind, param) {
  627. if (!this._customUniform) {
  628. this._customUniform = new Array();
  629. this._newUniforms = new Array();
  630. this._newSamplerInstances = new Array();
  631. this._newUniformInstances = new Array();
  632. }
  633. if (param) {
  634. if (kind.indexOf("sampler") == -1) {
  635. this._newUniformInstances[kind + "-" + name] = param;
  636. }
  637. else {
  638. this._newUniformInstances[kind + "-" + name] = param;
  639. }
  640. }
  641. this._customUniform.push("uniform " + kind + " " + name + ";");
  642. this._newUniforms.push(name);
  643. return this;
  644. };
  645. CustomMaterial.prototype.Fragment_Begin = function (shaderPart) {
  646. this.CustomParts.Fragment_Begin = shaderPart;
  647. return this;
  648. };
  649. CustomMaterial.prototype.Fragment_Definitions = function (shaderPart) {
  650. this.CustomParts.Fragment_Definitions = shaderPart;
  651. return this;
  652. };
  653. CustomMaterial.prototype.Fragment_MainBegin = function (shaderPart) {
  654. this.CustomParts.Fragment_MainBegin = shaderPart;
  655. return this;
  656. };
  657. CustomMaterial.prototype.Fragment_Custom_Diffuse = function (shaderPart) {
  658. this.CustomParts.Fragment_Custom_Diffuse = shaderPart.replace("result", "diffuseColor");
  659. return this;
  660. };
  661. CustomMaterial.prototype.Fragment_Custom_Alpha = function (shaderPart) {
  662. this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace("result", "alpha");
  663. return this;
  664. };
  665. CustomMaterial.prototype.Fragment_Before_FragColor = function (shaderPart) {
  666. this.CustomParts.Fragment_Before_FragColor = shaderPart.replace("result", "color");
  667. return this;
  668. };
  669. CustomMaterial.prototype.Vertex_Begin = function (shaderPart) {
  670. this.CustomParts.Vertex_Begin = shaderPart;
  671. return this;
  672. };
  673. CustomMaterial.prototype.Vertex_Definitions = function (shaderPart) {
  674. this.CustomParts.Vertex_Definitions = shaderPart;
  675. return this;
  676. };
  677. CustomMaterial.prototype.Vertex_MainBegin = function (shaderPart) {
  678. this.CustomParts.Vertex_MainBegin = shaderPart;
  679. return this;
  680. };
  681. CustomMaterial.prototype.Vertex_Before_PositionUpdated = function (shaderPart) {
  682. this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace("result", "positionUpdated");
  683. return this;
  684. };
  685. CustomMaterial.prototype.Vertex_Before_NormalUpdated = function (shaderPart) {
  686. this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace("result", "normalUpdated");
  687. return this;
  688. };
  689. CustomMaterial.ShaderIndexer = 1;
  690. return CustomMaterial;
  691. }(babylonjs_1.StandardMaterial));
  692. exports.CustomMaterial = CustomMaterial;
  693. /***/ }),
  694. /***/ "./src/custom/index.ts":
  695. /*!*****************************!*\
  696. !*** ./src/custom/index.ts ***!
  697. \*****************************/
  698. /*! no static exports found */
  699. /***/ (function(module, exports, __webpack_require__) {
  700. "use strict";
  701. function __export(m) {
  702. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  703. }
  704. Object.defineProperty(exports, "__esModule", { value: true });
  705. __export(__webpack_require__(/*! ./customMaterial */ "./src/custom/customMaterial.ts"));
  706. /***/ }),
  707. /***/ "./src/fire/fire.fragment.ts":
  708. /*!***********************************!*\
  709. !*** ./src/fire/fire.fragment.ts ***!
  710. \***********************************/
  711. /*! no static exports found */
  712. /***/ (function(module, exports, __webpack_require__) {
  713. "use strict";
  714. Object.defineProperty(exports, "__esModule", { value: true });
  715. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  716. var name = 'firePixelShader';
  717. exports.name = name;
  718. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n\nuniform sampler2D distortionSampler;\nuniform sampler2D opacitySampler;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;\nvarying vec2 vDistortionCoords2;\nvarying vec2 vDistortionCoords3;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvec4 bx2(vec4 x)\n{\nreturn vec4(2.0)*x-vec4(1.0);\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\n\nfloat alpha=1.0;\n#ifdef DIFFUSE\n\nconst float distortionAmount0=0.092;\nconst float distortionAmount1=0.092;\nconst float distortionAmount2=0.092;\nvec2 heightAttenuation=vec2(0.3,0.39);\nvec4 noise0=texture2D(distortionSampler,vDistortionCoords1);\nvec4 noise1=texture2D(distortionSampler,vDistortionCoords2);\nvec4 noise2=texture2D(distortionSampler,vDistortionCoords3);\nvec4 noiseSum=bx2(noise0)*distortionAmount0+bx2(noise1)*distortionAmount1+bx2(noise2)*distortionAmount2;\nvec4 perturbedBaseCoords=vec4(vDiffuseUV,0.0,1.0)+noiseSum*(vDiffuseUV.y*heightAttenuation.x+heightAttenuation.y);\nvec4 opacityColor=texture2D(opacitySampler,perturbedBaseCoords.xy);\n#ifdef ALPHATEST\nif (opacityColor.r<0.1)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor=texture2D(diffuseSampler,perturbedBaseCoords.xy)*2.0;\nbaseColor*=opacityColor;\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(1.0,1.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n\nvec4 color=vec4(baseColor.rgb,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";
  719. exports.shader = shader;
  720. babylonjs_1.Effect.ShadersStore[name] = shader;
  721. /***/ }),
  722. /***/ "./src/fire/fire.vertex.ts":
  723. /*!*********************************!*\
  724. !*** ./src/fire/fire.vertex.ts ***!
  725. \*********************************/
  726. /*! no static exports found */
  727. /***/ (function(module, exports, __webpack_require__) {
  728. "use strict";
  729. Object.defineProperty(exports, "__esModule", { value: true });
  730. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  731. var name = 'fireVertexShader';
  732. exports.name = name;
  733. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n\nuniform float time;\nuniform float speed;\n#ifdef DIFFUSE\nvarying vec2 vDistortionCoords1;\nvarying vec2 vDistortionCoords2;\nvarying vec2 vDistortionCoords3;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n\n#ifdef DIFFUSE\nvDiffuseUV=uv;\nvDiffuseUV.y-=0.2;\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n#ifdef DIFFUSE\n\nvec3 layerSpeed=vec3(-0.2,-0.52,-0.1)*speed;\nvDistortionCoords1.x=uv.x;\nvDistortionCoords1.y=uv.y+layerSpeed.x*time/1000.0;\nvDistortionCoords2.x=uv.x;\nvDistortionCoords2.y=uv.y+layerSpeed.y*time/1000.0;\nvDistortionCoords3.x=uv.x;\nvDistortionCoords3.y=uv.y+layerSpeed.z*time/1000.0;\n#endif\n}\n";
  734. exports.shader = shader;
  735. babylonjs_1.Effect.ShadersStore[name] = shader;
  736. /***/ }),
  737. /***/ "./src/fire/fireMaterial.ts":
  738. /*!**********************************!*\
  739. !*** ./src/fire/fireMaterial.ts ***!
  740. \**********************************/
  741. /*! no static exports found */
  742. /***/ (function(module, exports, __webpack_require__) {
  743. "use strict";
  744. var __extends = (this && this.__extends) || (function () {
  745. var extendStatics = function (d, b) {
  746. extendStatics = Object.setPrototypeOf ||
  747. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  748. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  749. return extendStatics(d, b);
  750. }
  751. return function (d, b) {
  752. extendStatics(d, b);
  753. function __() { this.constructor = d; }
  754. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  755. };
  756. })();
  757. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  758. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  759. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  760. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  761. return c > 3 && r && Object.defineProperty(target, key, r), r;
  762. };
  763. Object.defineProperty(exports, "__esModule", { value: true });
  764. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  765. __webpack_require__(/*! ./fire.fragment */ "./src/fire/fire.fragment.ts");
  766. __webpack_require__(/*! ./fire.vertex */ "./src/fire/fire.vertex.ts");
  767. var FireMaterialDefines = /** @class */ (function (_super) {
  768. __extends(FireMaterialDefines, _super);
  769. function FireMaterialDefines() {
  770. var _this = _super.call(this) || this;
  771. _this.DIFFUSE = false;
  772. _this.CLIPPLANE = false;
  773. _this.CLIPPLANE2 = false;
  774. _this.CLIPPLANE3 = false;
  775. _this.CLIPPLANE4 = false;
  776. _this.ALPHATEST = false;
  777. _this.DEPTHPREPASS = false;
  778. _this.POINTSIZE = false;
  779. _this.FOG = false;
  780. _this.UV1 = false;
  781. _this.VERTEXCOLOR = false;
  782. _this.VERTEXALPHA = false;
  783. _this.BonesPerMesh = 0;
  784. _this.NUM_BONE_INFLUENCERS = 0;
  785. _this.INSTANCES = false;
  786. _this.rebuild();
  787. return _this;
  788. }
  789. return FireMaterialDefines;
  790. }(babylonjs_1.MaterialDefines));
  791. var FireMaterial = /** @class */ (function (_super) {
  792. __extends(FireMaterial, _super);
  793. function FireMaterial(name, scene) {
  794. var _this = _super.call(this, name, scene) || this;
  795. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  796. _this.speed = 1.0;
  797. _this._scaledDiffuse = new babylonjs_1.Color3();
  798. _this._lastTime = 0;
  799. return _this;
  800. }
  801. FireMaterial.prototype.needAlphaBlending = function () {
  802. return false;
  803. };
  804. FireMaterial.prototype.needAlphaTesting = function () {
  805. return true;
  806. };
  807. FireMaterial.prototype.getAlphaTestTexture = function () {
  808. return null;
  809. };
  810. // Methods
  811. FireMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  812. if (this.isFrozen) {
  813. if (this._wasPreviouslyReady && subMesh.effect) {
  814. return true;
  815. }
  816. }
  817. if (!subMesh._materialDefines) {
  818. subMesh._materialDefines = new FireMaterialDefines();
  819. }
  820. var defines = subMesh._materialDefines;
  821. var scene = this.getScene();
  822. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  823. if (this._renderId === scene.getRenderId()) {
  824. return true;
  825. }
  826. }
  827. var engine = scene.getEngine();
  828. // Textures
  829. if (defines._areTexturesDirty) {
  830. defines._needUVs = false;
  831. if (this._diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  832. if (!this._diffuseTexture.isReady()) {
  833. return false;
  834. }
  835. else {
  836. defines._needUVs = true;
  837. defines.DIFFUSE = true;
  838. }
  839. }
  840. }
  841. defines.ALPHATEST = this._opacityTexture ? true : false;
  842. // Misc.
  843. if (defines._areMiscDirty) {
  844. defines.POINTSIZE = (this.pointsCloud || scene.forcePointsCloud);
  845. defines.FOG = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE && this.fogEnabled);
  846. }
  847. // Values that need to be evaluated on every frame
  848. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  849. // Attribs
  850. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
  851. // Get correct effect
  852. if (defines.isDirty) {
  853. defines.markAsProcessed();
  854. scene.resetCachedMaterial();
  855. // Fallbacks
  856. var fallbacks = new babylonjs_1.EffectFallbacks();
  857. if (defines.FOG) {
  858. fallbacks.addFallback(1, "FOG");
  859. }
  860. if (defines.NUM_BONE_INFLUENCERS > 0) {
  861. fallbacks.addCPUSkinningFallback(0, mesh);
  862. }
  863. //Attributes
  864. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  865. if (defines.UV1) {
  866. attribs.push(babylonjs_1.VertexBuffer.UVKind);
  867. }
  868. if (defines.VERTEXCOLOR) {
  869. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  870. }
  871. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  872. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  873. // Legacy browser patch
  874. var shaderName = "fire";
  875. var join = defines.toString();
  876. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  877. attributes: attribs,
  878. uniformsNames: ["world", "view", "viewProjection", "vEyePosition",
  879. "vFogInfos", "vFogColor", "pointSize",
  880. "vDiffuseInfos",
  881. "mBones",
  882. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix",
  883. // Fire
  884. "time", "speed"
  885. ],
  886. uniformBuffersNames: [],
  887. samplers: ["diffuseSampler",
  888. // Fire
  889. "distortionSampler", "opacitySampler"
  890. ],
  891. defines: join,
  892. fallbacks: fallbacks,
  893. onCompiled: this.onCompiled,
  894. onError: this.onError,
  895. indexParameters: null,
  896. maxSimultaneousLights: 4,
  897. transformFeedbackVaryings: null
  898. }, engine), defines);
  899. }
  900. if (!subMesh.effect || !subMesh.effect.isReady()) {
  901. return false;
  902. }
  903. this._renderId = scene.getRenderId();
  904. this._wasPreviouslyReady = true;
  905. return true;
  906. };
  907. FireMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  908. var scene = this.getScene();
  909. var defines = subMesh._materialDefines;
  910. if (!defines) {
  911. return;
  912. }
  913. var effect = subMesh.effect;
  914. if (!effect) {
  915. return;
  916. }
  917. this._activeEffect = effect;
  918. // Matrices
  919. this.bindOnlyWorldMatrix(world);
  920. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  921. // Bones
  922. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  923. if (this._mustRebind(scene, effect)) {
  924. // Textures
  925. if (this._diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  926. this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
  927. this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  928. this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
  929. this._activeEffect.setTexture("distortionSampler", this._distortionTexture);
  930. this._activeEffect.setTexture("opacitySampler", this._opacityTexture);
  931. }
  932. // Clip plane
  933. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  934. // Point size
  935. if (this.pointsCloud) {
  936. this._activeEffect.setFloat("pointSize", this.pointSize);
  937. }
  938. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  939. }
  940. this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
  941. // View
  942. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  943. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  944. }
  945. // Fog
  946. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  947. // Time
  948. this._lastTime += scene.getEngine().getDeltaTime();
  949. this._activeEffect.setFloat("time", this._lastTime);
  950. // Speed
  951. this._activeEffect.setFloat("speed", this.speed);
  952. this._afterBind(mesh, this._activeEffect);
  953. };
  954. FireMaterial.prototype.getAnimatables = function () {
  955. var results = [];
  956. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  957. results.push(this._diffuseTexture);
  958. }
  959. if (this._distortionTexture && this._distortionTexture.animations && this._distortionTexture.animations.length > 0) {
  960. results.push(this._distortionTexture);
  961. }
  962. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  963. results.push(this._opacityTexture);
  964. }
  965. return results;
  966. };
  967. FireMaterial.prototype.getActiveTextures = function () {
  968. var activeTextures = _super.prototype.getActiveTextures.call(this);
  969. if (this._diffuseTexture) {
  970. activeTextures.push(this._diffuseTexture);
  971. }
  972. if (this._distortionTexture) {
  973. activeTextures.push(this._distortionTexture);
  974. }
  975. if (this._opacityTexture) {
  976. activeTextures.push(this._opacityTexture);
  977. }
  978. return activeTextures;
  979. };
  980. FireMaterial.prototype.hasTexture = function (texture) {
  981. if (_super.prototype.hasTexture.call(this, texture)) {
  982. return true;
  983. }
  984. if (this._diffuseTexture === texture) {
  985. return true;
  986. }
  987. if (this._distortionTexture === texture) {
  988. return true;
  989. }
  990. if (this._opacityTexture === texture) {
  991. return true;
  992. }
  993. return false;
  994. };
  995. FireMaterial.prototype.getClassName = function () {
  996. return "FireMaterial";
  997. };
  998. FireMaterial.prototype.dispose = function (forceDisposeEffect) {
  999. if (this._diffuseTexture) {
  1000. this._diffuseTexture.dispose();
  1001. }
  1002. if (this._distortionTexture) {
  1003. this._distortionTexture.dispose();
  1004. }
  1005. _super.prototype.dispose.call(this, forceDisposeEffect);
  1006. };
  1007. FireMaterial.prototype.clone = function (name) {
  1008. var _this = this;
  1009. return babylonjs_1.SerializationHelper.Clone(function () { return new FireMaterial(name, _this.getScene()); }, this);
  1010. };
  1011. FireMaterial.prototype.serialize = function () {
  1012. var serializationObject = _super.prototype.serialize.call(this);
  1013. serializationObject.customType = "BABYLON.FireMaterial";
  1014. serializationObject.diffuseColor = this.diffuseColor.asArray();
  1015. serializationObject.speed = this.speed;
  1016. if (this._diffuseTexture) {
  1017. serializationObject._diffuseTexture = this._diffuseTexture.serialize();
  1018. }
  1019. if (this._distortionTexture) {
  1020. serializationObject._distortionTexture = this._distortionTexture.serialize();
  1021. }
  1022. if (this._opacityTexture) {
  1023. serializationObject._opacityTexture = this._opacityTexture.serialize();
  1024. }
  1025. return serializationObject;
  1026. };
  1027. FireMaterial.Parse = function (source, scene, rootUrl) {
  1028. var material = new FireMaterial(source.name, scene);
  1029. material.diffuseColor = babylonjs_1.Color3.FromArray(source.diffuseColor);
  1030. material.speed = source.speed;
  1031. material.alpha = source.alpha;
  1032. material.id = source.id;
  1033. babylonjs_1.Tags.AddTagsTo(material, source.tags);
  1034. material.backFaceCulling = source.backFaceCulling;
  1035. material.wireframe = source.wireframe;
  1036. if (source._diffuseTexture) {
  1037. material._diffuseTexture = babylonjs_1.Texture.Parse(source._diffuseTexture, scene, rootUrl);
  1038. }
  1039. if (source._distortionTexture) {
  1040. material._distortionTexture = babylonjs_1.Texture.Parse(source._distortionTexture, scene, rootUrl);
  1041. }
  1042. if (source._opacityTexture) {
  1043. material._opacityTexture = babylonjs_1.Texture.Parse(source._opacityTexture, scene, rootUrl);
  1044. }
  1045. if (source.checkReadyOnlyOnce) {
  1046. material.checkReadyOnlyOnce = source.checkReadyOnlyOnce;
  1047. }
  1048. return material;
  1049. };
  1050. __decorate([
  1051. babylonjs_1.serializeAsTexture("diffuseTexture")
  1052. ], FireMaterial.prototype, "_diffuseTexture", void 0);
  1053. __decorate([
  1054. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  1055. ], FireMaterial.prototype, "diffuseTexture", void 0);
  1056. __decorate([
  1057. babylonjs_1.serializeAsTexture("distortionTexture")
  1058. ], FireMaterial.prototype, "_distortionTexture", void 0);
  1059. __decorate([
  1060. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  1061. ], FireMaterial.prototype, "distortionTexture", void 0);
  1062. __decorate([
  1063. babylonjs_1.serializeAsTexture("opacityTexture")
  1064. ], FireMaterial.prototype, "_opacityTexture", void 0);
  1065. __decorate([
  1066. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  1067. ], FireMaterial.prototype, "opacityTexture", void 0);
  1068. __decorate([
  1069. babylonjs_1.serializeAsColor3("diffuse")
  1070. ], FireMaterial.prototype, "diffuseColor", void 0);
  1071. __decorate([
  1072. babylonjs_1.serialize()
  1073. ], FireMaterial.prototype, "speed", void 0);
  1074. return FireMaterial;
  1075. }(babylonjs_1.PushMaterial));
  1076. exports.FireMaterial = FireMaterial;
  1077. /***/ }),
  1078. /***/ "./src/fire/index.ts":
  1079. /*!***************************!*\
  1080. !*** ./src/fire/index.ts ***!
  1081. \***************************/
  1082. /*! no static exports found */
  1083. /***/ (function(module, exports, __webpack_require__) {
  1084. "use strict";
  1085. function __export(m) {
  1086. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1087. }
  1088. Object.defineProperty(exports, "__esModule", { value: true });
  1089. __export(__webpack_require__(/*! ./fireMaterial */ "./src/fire/fireMaterial.ts"));
  1090. /***/ }),
  1091. /***/ "./src/fur/fur.fragment.ts":
  1092. /*!*********************************!*\
  1093. !*** ./src/fur/fur.fragment.ts ***!
  1094. \*********************************/
  1095. /*! no static exports found */
  1096. /***/ (function(module, exports, __webpack_require__) {
  1097. "use strict";
  1098. Object.defineProperty(exports, "__esModule", { value: true });
  1099. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1100. var name = 'furPixelShader';
  1101. exports.name = name;
  1102. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nuniform vec4 furColor;\nuniform float furLength;\nvarying vec3 vPositionW;\nvarying float vfur_length;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n\n#ifdef HIGHLEVEL\nuniform float furOffset;\nuniform float furOcclusion;\nuniform sampler2D furTexture;\nvarying vec2 vFurUV;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<fogFragmentDeclaration>\n#include<clipPlaneFragmentDeclaration>\nfloat Rand(vec3 rv) {\nfloat x=dot(rv,vec3(12.9898,78.233,24.65487));\nreturn fract(sin(x)*43758.5453);\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=furColor;\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor*=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef HIGHLEVEL\n\nvec4 furTextureColor=texture2D(furTexture,vec2(vFurUV.x,vFurUV.y));\nif (furTextureColor.a<=0.0 || furTextureColor.g<furOffset) {\ndiscard;\n}\nfloat occlusion=mix(0.0,furTextureColor.b*1.2,furOffset);\nbaseColor=vec4(baseColor.xyz*max(occlusion,furOcclusion),1.1-furOffset);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase.rgb*baseColor.rgb,0.0,1.0);\n\n#ifdef HIGHLEVEL\nvec4 color=vec4(finalDiffuse,alpha);\n#else\nfloat r=vfur_length/furLength*0.5;\nvec4 color=vec4(finalDiffuse*(0.5+r),alpha);\n#endif\n#include<fogFragment>\ngl_FragColor=color;\n}";
  1103. exports.shader = shader;
  1104. babylonjs_1.Effect.ShadersStore[name] = shader;
  1105. /***/ }),
  1106. /***/ "./src/fur/fur.vertex.ts":
  1107. /*!*******************************!*\
  1108. !*** ./src/fur/fur.vertex.ts ***!
  1109. \*******************************/
  1110. /*! no static exports found */
  1111. /***/ (function(module, exports, __webpack_require__) {
  1112. "use strict";
  1113. Object.defineProperty(exports, "__esModule", { value: true });
  1114. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1115. var name = 'furVertexShader';
  1116. exports.name = name;
  1117. var shader = "precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\nuniform float furLength;\nuniform float furAngle;\n#ifdef HIGHLEVEL\nuniform float furOffset;\nuniform vec3 furGravity;\nuniform float furTime;\nuniform float furSpacing;\nuniform float furDensity;\n#endif\n#ifdef HEIGHTMAP\nuniform sampler2D heightTexture;\n#endif\n#ifdef HIGHLEVEL\nvarying vec2 vFurUV;\n#endif\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\nvarying float vfur_length;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nfloat Rand(vec3 rv) {\nfloat x=dot(rv,vec3(12.9898,78.233,24.65487));\nreturn fract(sin(x)*43758.5453);\n}\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\n\nfloat r=Rand(position);\n#ifdef HEIGHTMAP\n#if __VERSION__>100\nvfur_length=furLength*texture(heightTexture,uv).x;\n#else\nvfur_length=furLength*texture2D(heightTexture,uv).r;\n#endif\n#else\nvfur_length=(furLength*r);\n#endif\nvec3 tangent1=vec3(normal.y,-normal.x,0);\nvec3 tangent2=vec3(-normal.z,0,normal.x);\nr=Rand(tangent1*r);\nfloat J=(2.0+4.0*r);\nr=Rand(tangent2*r);\nfloat K=(2.0+2.0*r);\ntangent1=tangent1*J+tangent2*K;\ntangent1=normalize(tangent1);\nvec3 newPosition=position+normal*vfur_length*cos(furAngle)+tangent1*vfur_length*sin(furAngle);\n#ifdef HIGHLEVEL\n\nvec3 forceDirection=vec3(0.0,0.0,0.0);\nforceDirection.x=sin(furTime+position.x*0.05)*0.2;\nforceDirection.y=cos(furTime*0.7+position.y*0.04)*0.2;\nforceDirection.z=sin(furTime*0.7+position.z*0.04)*0.2;\nvec3 displacement=vec3(0.0,0.0,0.0);\ndisplacement=furGravity+forceDirection;\nfloat displacementFactor=pow(furOffset,3.0);\nvec3 aNormal=normal;\naNormal.xyz+=displacement*displacementFactor;\nnewPosition=vec3(newPosition.x,newPosition.y,newPosition.z)+(normalize(aNormal)*furOffset*furSpacing);\n#endif\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\ngl_Position=viewProjection*finalWorld*vec4(newPosition,1.0);\nvec4 worldPos=finalWorld*vec4(newPosition,1.0);\nvPositionW=vec3(worldPos);\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#ifdef HIGHLEVEL\nvFurUV=vDiffuseUV*furDensity;\n#endif\n#else\n#ifdef HIGHLEVEL\nvFurUV=uv*furDensity;\n#endif\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  1118. exports.shader = shader;
  1119. babylonjs_1.Effect.ShadersStore[name] = shader;
  1120. /***/ }),
  1121. /***/ "./src/fur/furMaterial.ts":
  1122. /*!********************************!*\
  1123. !*** ./src/fur/furMaterial.ts ***!
  1124. \********************************/
  1125. /*! no static exports found */
  1126. /***/ (function(module, exports, __webpack_require__) {
  1127. "use strict";
  1128. var __extends = (this && this.__extends) || (function () {
  1129. var extendStatics = function (d, b) {
  1130. extendStatics = Object.setPrototypeOf ||
  1131. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1132. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1133. return extendStatics(d, b);
  1134. }
  1135. return function (d, b) {
  1136. extendStatics(d, b);
  1137. function __() { this.constructor = d; }
  1138. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1139. };
  1140. })();
  1141. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1142. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1143. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1144. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  1145. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1146. };
  1147. Object.defineProperty(exports, "__esModule", { value: true });
  1148. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1149. __webpack_require__(/*! ./fur.fragment */ "./src/fur/fur.fragment.ts");
  1150. __webpack_require__(/*! ./fur.vertex */ "./src/fur/fur.vertex.ts");
  1151. var FurMaterialDefines = /** @class */ (function (_super) {
  1152. __extends(FurMaterialDefines, _super);
  1153. function FurMaterialDefines() {
  1154. var _this = _super.call(this) || this;
  1155. _this.DIFFUSE = false;
  1156. _this.HEIGHTMAP = false;
  1157. _this.CLIPPLANE = false;
  1158. _this.CLIPPLANE2 = false;
  1159. _this.CLIPPLANE3 = false;
  1160. _this.CLIPPLANE4 = false;
  1161. _this.ALPHATEST = false;
  1162. _this.DEPTHPREPASS = false;
  1163. _this.POINTSIZE = false;
  1164. _this.FOG = false;
  1165. _this.NORMAL = false;
  1166. _this.UV1 = false;
  1167. _this.UV2 = false;
  1168. _this.VERTEXCOLOR = false;
  1169. _this.VERTEXALPHA = false;
  1170. _this.NUM_BONE_INFLUENCERS = 0;
  1171. _this.BonesPerMesh = 0;
  1172. _this.INSTANCES = false;
  1173. _this.HIGHLEVEL = false;
  1174. _this.rebuild();
  1175. return _this;
  1176. }
  1177. return FurMaterialDefines;
  1178. }(babylonjs_1.MaterialDefines));
  1179. var FurMaterial = /** @class */ (function (_super) {
  1180. __extends(FurMaterial, _super);
  1181. function FurMaterial(name, scene) {
  1182. var _this = _super.call(this, name, scene) || this;
  1183. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  1184. _this.furLength = 1;
  1185. _this.furAngle = 0;
  1186. _this.furColor = new babylonjs_1.Color3(0.44, 0.21, 0.02);
  1187. _this.furOffset = 0.0;
  1188. _this.furSpacing = 12;
  1189. _this.furGravity = new babylonjs_1.Vector3(0, 0, 0);
  1190. _this.furSpeed = 100;
  1191. _this.furDensity = 20;
  1192. _this.furOcclusion = 0.0;
  1193. _this._disableLighting = false;
  1194. _this._maxSimultaneousLights = 4;
  1195. _this.highLevelFur = true;
  1196. _this._furTime = 0;
  1197. return _this;
  1198. }
  1199. Object.defineProperty(FurMaterial.prototype, "furTime", {
  1200. get: function () {
  1201. return this._furTime;
  1202. },
  1203. set: function (furTime) {
  1204. this._furTime = furTime;
  1205. },
  1206. enumerable: true,
  1207. configurable: true
  1208. });
  1209. FurMaterial.prototype.needAlphaBlending = function () {
  1210. return (this.alpha < 1.0);
  1211. };
  1212. FurMaterial.prototype.needAlphaTesting = function () {
  1213. return false;
  1214. };
  1215. FurMaterial.prototype.getAlphaTestTexture = function () {
  1216. return null;
  1217. };
  1218. FurMaterial.prototype.updateFur = function () {
  1219. for (var i = 1; i < this._meshes.length; i++) {
  1220. var offsetFur = this._meshes[i].material;
  1221. offsetFur.furLength = this.furLength;
  1222. offsetFur.furAngle = this.furAngle;
  1223. offsetFur.furGravity = this.furGravity;
  1224. offsetFur.furSpacing = this.furSpacing;
  1225. offsetFur.furSpeed = this.furSpeed;
  1226. offsetFur.furColor = this.furColor;
  1227. offsetFur.diffuseTexture = this.diffuseTexture;
  1228. offsetFur.furTexture = this.furTexture;
  1229. offsetFur.highLevelFur = this.highLevelFur;
  1230. offsetFur.furTime = this.furTime;
  1231. offsetFur.furDensity = this.furDensity;
  1232. }
  1233. };
  1234. // Methods
  1235. FurMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  1236. if (this.isFrozen) {
  1237. if (this._wasPreviouslyReady && subMesh.effect) {
  1238. return true;
  1239. }
  1240. }
  1241. if (!subMesh._materialDefines) {
  1242. subMesh._materialDefines = new FurMaterialDefines();
  1243. }
  1244. var defines = subMesh._materialDefines;
  1245. var scene = this.getScene();
  1246. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  1247. if (this._renderId === scene.getRenderId()) {
  1248. return true;
  1249. }
  1250. }
  1251. var engine = scene.getEngine();
  1252. // Textures
  1253. if (defines._areTexturesDirty) {
  1254. if (scene.texturesEnabled) {
  1255. if (this.diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  1256. if (!this.diffuseTexture.isReady()) {
  1257. return false;
  1258. }
  1259. else {
  1260. defines._needUVs = true;
  1261. defines.DIFFUSE = true;
  1262. }
  1263. }
  1264. if (this.heightTexture && engine.getCaps().maxVertexTextureImageUnits) {
  1265. if (!this.heightTexture.isReady()) {
  1266. return false;
  1267. }
  1268. else {
  1269. defines._needUVs = true;
  1270. defines.HEIGHTMAP = true;
  1271. }
  1272. }
  1273. }
  1274. }
  1275. // High level
  1276. if (this.highLevelFur !== defines.HIGHLEVEL) {
  1277. defines.HIGHLEVEL = true;
  1278. defines.markAsUnprocessed();
  1279. }
  1280. // Misc.
  1281. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  1282. // Lights
  1283. defines._needNormals = babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  1284. // Values that need to be evaluated on every frame
  1285. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  1286. // Attribs
  1287. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  1288. // Get correct effect
  1289. if (defines.isDirty) {
  1290. defines.markAsProcessed();
  1291. scene.resetCachedMaterial();
  1292. // Fallbacks
  1293. var fallbacks = new babylonjs_1.EffectFallbacks();
  1294. if (defines.FOG) {
  1295. fallbacks.addFallback(1, "FOG");
  1296. }
  1297. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
  1298. if (defines.NUM_BONE_INFLUENCERS > 0) {
  1299. fallbacks.addCPUSkinningFallback(0, mesh);
  1300. }
  1301. //Attributes
  1302. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  1303. if (defines.NORMAL) {
  1304. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  1305. }
  1306. if (defines.UV1) {
  1307. attribs.push(babylonjs_1.VertexBuffer.UVKind);
  1308. }
  1309. if (defines.UV2) {
  1310. attribs.push(babylonjs_1.VertexBuffer.UV2Kind);
  1311. }
  1312. if (defines.VERTEXCOLOR) {
  1313. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  1314. }
  1315. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  1316. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  1317. // Legacy browser patch
  1318. var shaderName = "fur";
  1319. var join = defines.toString();
  1320. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
  1321. "vFogInfos", "vFogColor", "pointSize",
  1322. "vDiffuseInfos",
  1323. "mBones",
  1324. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix",
  1325. "furLength", "furAngle", "furColor", "furOffset", "furGravity", "furTime", "furSpacing", "furDensity", "furOcclusion"
  1326. ];
  1327. var samplers = ["diffuseSampler",
  1328. "heightTexture", "furTexture"
  1329. ];
  1330. var uniformBuffers = new Array();
  1331. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  1332. uniformsNames: uniforms,
  1333. uniformBuffersNames: uniformBuffers,
  1334. samplers: samplers,
  1335. defines: defines,
  1336. maxSimultaneousLights: this.maxSimultaneousLights
  1337. });
  1338. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  1339. attributes: attribs,
  1340. uniformsNames: uniforms,
  1341. uniformBuffersNames: uniformBuffers,
  1342. samplers: samplers,
  1343. defines: join,
  1344. fallbacks: fallbacks,
  1345. onCompiled: this.onCompiled,
  1346. onError: this.onError,
  1347. indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
  1348. }, engine), defines);
  1349. }
  1350. if (!subMesh.effect || !subMesh.effect.isReady()) {
  1351. return false;
  1352. }
  1353. this._renderId = scene.getRenderId();
  1354. this._wasPreviouslyReady = true;
  1355. return true;
  1356. };
  1357. FurMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  1358. var scene = this.getScene();
  1359. var defines = subMesh._materialDefines;
  1360. if (!defines) {
  1361. return;
  1362. }
  1363. var effect = subMesh.effect;
  1364. if (!effect) {
  1365. return;
  1366. }
  1367. this._activeEffect = effect;
  1368. // Matrices
  1369. this.bindOnlyWorldMatrix(world);
  1370. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  1371. // Bones
  1372. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  1373. if (scene.getCachedMaterial() !== this) {
  1374. // Textures
  1375. if (this._diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  1376. this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
  1377. this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  1378. this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
  1379. }
  1380. if (this._heightTexture) {
  1381. this._activeEffect.setTexture("heightTexture", this._heightTexture);
  1382. }
  1383. // Clip plane
  1384. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  1385. // Point size
  1386. if (this.pointsCloud) {
  1387. this._activeEffect.setFloat("pointSize", this.pointSize);
  1388. }
  1389. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  1390. }
  1391. this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  1392. if (scene.lightsEnabled && !this.disableLighting) {
  1393. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
  1394. }
  1395. // View
  1396. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  1397. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  1398. }
  1399. // Fog
  1400. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  1401. this._activeEffect.setFloat("furLength", this.furLength);
  1402. this._activeEffect.setFloat("furAngle", this.furAngle);
  1403. this._activeEffect.setColor4("furColor", this.furColor, 1.0);
  1404. if (this.highLevelFur) {
  1405. this._activeEffect.setVector3("furGravity", this.furGravity);
  1406. this._activeEffect.setFloat("furOffset", this.furOffset);
  1407. this._activeEffect.setFloat("furSpacing", this.furSpacing);
  1408. this._activeEffect.setFloat("furDensity", this.furDensity);
  1409. this._activeEffect.setFloat("furOcclusion", this.furOcclusion);
  1410. this._furTime += this.getScene().getEngine().getDeltaTime() / this.furSpeed;
  1411. this._activeEffect.setFloat("furTime", this._furTime);
  1412. this._activeEffect.setTexture("furTexture", this.furTexture);
  1413. }
  1414. this._afterBind(mesh, this._activeEffect);
  1415. };
  1416. FurMaterial.prototype.getAnimatables = function () {
  1417. var results = [];
  1418. if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
  1419. results.push(this.diffuseTexture);
  1420. }
  1421. if (this.heightTexture && this.heightTexture.animations && this.heightTexture.animations.length > 0) {
  1422. results.push(this.heightTexture);
  1423. }
  1424. return results;
  1425. };
  1426. FurMaterial.prototype.getActiveTextures = function () {
  1427. var activeTextures = _super.prototype.getActiveTextures.call(this);
  1428. if (this._diffuseTexture) {
  1429. activeTextures.push(this._diffuseTexture);
  1430. }
  1431. if (this._heightTexture) {
  1432. activeTextures.push(this._heightTexture);
  1433. }
  1434. return activeTextures;
  1435. };
  1436. FurMaterial.prototype.hasTexture = function (texture) {
  1437. if (_super.prototype.hasTexture.call(this, texture)) {
  1438. return true;
  1439. }
  1440. if (this.diffuseTexture === texture) {
  1441. return true;
  1442. }
  1443. if (this._heightTexture === texture) {
  1444. return true;
  1445. }
  1446. return false;
  1447. };
  1448. FurMaterial.prototype.dispose = function (forceDisposeEffect) {
  1449. if (this.diffuseTexture) {
  1450. this.diffuseTexture.dispose();
  1451. }
  1452. if (this._meshes) {
  1453. for (var i = 1; i < this._meshes.length; i++) {
  1454. var mat = this._meshes[i].material;
  1455. if (mat) {
  1456. mat.dispose(forceDisposeEffect);
  1457. }
  1458. this._meshes[i].dispose();
  1459. }
  1460. }
  1461. _super.prototype.dispose.call(this, forceDisposeEffect);
  1462. };
  1463. FurMaterial.prototype.clone = function (name) {
  1464. var _this = this;
  1465. return babylonjs_1.SerializationHelper.Clone(function () { return new FurMaterial(name, _this.getScene()); }, this);
  1466. };
  1467. FurMaterial.prototype.serialize = function () {
  1468. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  1469. serializationObject.customType = "BABYLON.FurMaterial";
  1470. if (this._meshes) {
  1471. serializationObject.sourceMeshName = this._meshes[0].name;
  1472. serializationObject.quality = this._meshes.length;
  1473. }
  1474. return serializationObject;
  1475. };
  1476. FurMaterial.prototype.getClassName = function () {
  1477. return "FurMaterial";
  1478. };
  1479. // Statics
  1480. FurMaterial.Parse = function (source, scene, rootUrl) {
  1481. var material = babylonjs_1.SerializationHelper.Parse(function () { return new FurMaterial(source.name, scene); }, source, scene, rootUrl);
  1482. if (source.sourceMeshName && material.highLevelFur) {
  1483. scene.executeWhenReady(function () {
  1484. var sourceMesh = scene.getMeshByName(source.sourceMeshName);
  1485. if (sourceMesh) {
  1486. var furTexture = FurMaterial.GenerateTexture("Fur Texture", scene);
  1487. material.furTexture = furTexture;
  1488. FurMaterial.FurifyMesh(sourceMesh, source.quality);
  1489. }
  1490. });
  1491. }
  1492. return material;
  1493. };
  1494. FurMaterial.GenerateTexture = function (name, scene) {
  1495. // Generate fur textures
  1496. var texture = new babylonjs_1.DynamicTexture("FurTexture " + name, 256, scene, true);
  1497. var context = texture.getContext();
  1498. for (var i = 0; i < 20000; ++i) {
  1499. context.fillStyle = "rgba(255, " + Math.floor(Math.random() * 255) + ", " + Math.floor(Math.random() * 255) + ", 1)";
  1500. context.fillRect((Math.random() * texture.getSize().width), (Math.random() * texture.getSize().height), 2, 2);
  1501. }
  1502. texture.update(false);
  1503. texture.wrapU = babylonjs_1.Texture.WRAP_ADDRESSMODE;
  1504. texture.wrapV = babylonjs_1.Texture.WRAP_ADDRESSMODE;
  1505. return texture;
  1506. };
  1507. // Creates and returns an array of meshes used as shells for the Fur Material
  1508. // that can be disposed later in your code
  1509. // The quality is in interval [0, 100]
  1510. FurMaterial.FurifyMesh = function (sourceMesh, quality) {
  1511. var meshes = [sourceMesh];
  1512. var mat = sourceMesh.material;
  1513. var i;
  1514. if (!(mat instanceof FurMaterial)) {
  1515. throw "The material of the source mesh must be a Fur Material";
  1516. }
  1517. for (i = 1; i < quality; i++) {
  1518. var offsetFur = new FurMaterial(mat.name + i, sourceMesh.getScene());
  1519. sourceMesh.getScene().materials.pop();
  1520. babylonjs_1.Tags.EnableFor(offsetFur);
  1521. babylonjs_1.Tags.AddTagsTo(offsetFur, "furShellMaterial");
  1522. offsetFur.furLength = mat.furLength;
  1523. offsetFur.furAngle = mat.furAngle;
  1524. offsetFur.furGravity = mat.furGravity;
  1525. offsetFur.furSpacing = mat.furSpacing;
  1526. offsetFur.furSpeed = mat.furSpeed;
  1527. offsetFur.furColor = mat.furColor;
  1528. offsetFur.diffuseTexture = mat.diffuseTexture;
  1529. offsetFur.furOffset = i / quality;
  1530. offsetFur.furTexture = mat.furTexture;
  1531. offsetFur.highLevelFur = mat.highLevelFur;
  1532. offsetFur.furTime = mat.furTime;
  1533. offsetFur.furDensity = mat.furDensity;
  1534. var offsetMesh = sourceMesh.clone(sourceMesh.name + i);
  1535. offsetMesh.material = offsetFur;
  1536. offsetMesh.skeleton = sourceMesh.skeleton;
  1537. offsetMesh.position = babylonjs_1.Vector3.Zero();
  1538. meshes.push(offsetMesh);
  1539. }
  1540. for (i = 1; i < meshes.length; i++) {
  1541. meshes[i].parent = sourceMesh;
  1542. }
  1543. sourceMesh.material._meshes = meshes;
  1544. return meshes;
  1545. };
  1546. __decorate([
  1547. babylonjs_1.serializeAsTexture("diffuseTexture")
  1548. ], FurMaterial.prototype, "_diffuseTexture", void 0);
  1549. __decorate([
  1550. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  1551. ], FurMaterial.prototype, "diffuseTexture", void 0);
  1552. __decorate([
  1553. babylonjs_1.serializeAsTexture("heightTexture")
  1554. ], FurMaterial.prototype, "_heightTexture", void 0);
  1555. __decorate([
  1556. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  1557. ], FurMaterial.prototype, "heightTexture", void 0);
  1558. __decorate([
  1559. babylonjs_1.serializeAsColor3()
  1560. ], FurMaterial.prototype, "diffuseColor", void 0);
  1561. __decorate([
  1562. babylonjs_1.serialize()
  1563. ], FurMaterial.prototype, "furLength", void 0);
  1564. __decorate([
  1565. babylonjs_1.serialize()
  1566. ], FurMaterial.prototype, "furAngle", void 0);
  1567. __decorate([
  1568. babylonjs_1.serializeAsColor3()
  1569. ], FurMaterial.prototype, "furColor", void 0);
  1570. __decorate([
  1571. babylonjs_1.serialize()
  1572. ], FurMaterial.prototype, "furOffset", void 0);
  1573. __decorate([
  1574. babylonjs_1.serialize()
  1575. ], FurMaterial.prototype, "furSpacing", void 0);
  1576. __decorate([
  1577. babylonjs_1.serializeAsVector3()
  1578. ], FurMaterial.prototype, "furGravity", void 0);
  1579. __decorate([
  1580. babylonjs_1.serialize()
  1581. ], FurMaterial.prototype, "furSpeed", void 0);
  1582. __decorate([
  1583. babylonjs_1.serialize()
  1584. ], FurMaterial.prototype, "furDensity", void 0);
  1585. __decorate([
  1586. babylonjs_1.serialize()
  1587. ], FurMaterial.prototype, "furOcclusion", void 0);
  1588. __decorate([
  1589. babylonjs_1.serialize("disableLighting")
  1590. ], FurMaterial.prototype, "_disableLighting", void 0);
  1591. __decorate([
  1592. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  1593. ], FurMaterial.prototype, "disableLighting", void 0);
  1594. __decorate([
  1595. babylonjs_1.serialize("maxSimultaneousLights")
  1596. ], FurMaterial.prototype, "_maxSimultaneousLights", void 0);
  1597. __decorate([
  1598. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  1599. ], FurMaterial.prototype, "maxSimultaneousLights", void 0);
  1600. __decorate([
  1601. babylonjs_1.serialize()
  1602. ], FurMaterial.prototype, "highLevelFur", void 0);
  1603. __decorate([
  1604. babylonjs_1.serialize()
  1605. ], FurMaterial.prototype, "furTime", null);
  1606. return FurMaterial;
  1607. }(babylonjs_1.PushMaterial));
  1608. exports.FurMaterial = FurMaterial;
  1609. /***/ }),
  1610. /***/ "./src/fur/index.ts":
  1611. /*!**************************!*\
  1612. !*** ./src/fur/index.ts ***!
  1613. \**************************/
  1614. /*! no static exports found */
  1615. /***/ (function(module, exports, __webpack_require__) {
  1616. "use strict";
  1617. function __export(m) {
  1618. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1619. }
  1620. Object.defineProperty(exports, "__esModule", { value: true });
  1621. __export(__webpack_require__(/*! ./furMaterial */ "./src/fur/furMaterial.ts"));
  1622. /***/ }),
  1623. /***/ "./src/gradient/gradient.fragment.ts":
  1624. /*!*******************************************!*\
  1625. !*** ./src/gradient/gradient.fragment.ts ***!
  1626. \*******************************************/
  1627. /*! no static exports found */
  1628. /***/ (function(module, exports, __webpack_require__) {
  1629. "use strict";
  1630. Object.defineProperty(exports, "__esModule", { value: true });
  1631. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1632. var name = 'gradientPixelShader';
  1633. exports.name = name;
  1634. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nuniform vec4 topColor;\nuniform vec4 bottomColor;\nuniform float offset;\nuniform float scale;\nuniform float smoothness;\n\nvarying vec3 vPositionW;\nvarying vec3 vPosition;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\nfloat h=vPosition.y*scale+offset;\nfloat mysmoothness=clamp(smoothness,0.01,max(smoothness,10.));\nvec4 baseColor=mix(bottomColor,topColor,max(pow(max(h,0.0),mysmoothness),0.0));\n\nvec3 diffuseColor=baseColor.rgb;\n\nfloat alpha=baseColor.a;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n";
  1635. exports.shader = shader;
  1636. babylonjs_1.Effect.ShadersStore[name] = shader;
  1637. /***/ }),
  1638. /***/ "./src/gradient/gradient.vertex.ts":
  1639. /*!*****************************************!*\
  1640. !*** ./src/gradient/gradient.vertex.ts ***!
  1641. \*****************************************/
  1642. /*! no static exports found */
  1643. /***/ (function(module, exports, __webpack_require__) {
  1644. "use strict";
  1645. Object.defineProperty(exports, "__esModule", { value: true });
  1646. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1647. var name = 'gradientVertexShader';
  1648. exports.name = name;
  1649. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\nvarying vec3 vPosition;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\nvPosition=position;\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  1650. exports.shader = shader;
  1651. babylonjs_1.Effect.ShadersStore[name] = shader;
  1652. /***/ }),
  1653. /***/ "./src/gradient/gradientMaterial.ts":
  1654. /*!******************************************!*\
  1655. !*** ./src/gradient/gradientMaterial.ts ***!
  1656. \******************************************/
  1657. /*! no static exports found */
  1658. /***/ (function(module, exports, __webpack_require__) {
  1659. "use strict";
  1660. var __extends = (this && this.__extends) || (function () {
  1661. var extendStatics = function (d, b) {
  1662. extendStatics = Object.setPrototypeOf ||
  1663. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1664. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1665. return extendStatics(d, b);
  1666. }
  1667. return function (d, b) {
  1668. extendStatics(d, b);
  1669. function __() { this.constructor = d; }
  1670. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1671. };
  1672. })();
  1673. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  1674. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  1675. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  1676. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  1677. return c > 3 && r && Object.defineProperty(target, key, r), r;
  1678. };
  1679. Object.defineProperty(exports, "__esModule", { value: true });
  1680. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1681. __webpack_require__(/*! ./gradient.fragment */ "./src/gradient/gradient.fragment.ts");
  1682. __webpack_require__(/*! ./gradient.vertex */ "./src/gradient/gradient.vertex.ts");
  1683. var GradientMaterialDefines = /** @class */ (function (_super) {
  1684. __extends(GradientMaterialDefines, _super);
  1685. function GradientMaterialDefines() {
  1686. var _this = _super.call(this) || this;
  1687. _this.DIFFUSE = false;
  1688. _this.CLIPPLANE = false;
  1689. _this.CLIPPLANE2 = false;
  1690. _this.CLIPPLANE3 = false;
  1691. _this.CLIPPLANE4 = false;
  1692. _this.ALPHATEST = false;
  1693. _this.DEPTHPREPASS = false;
  1694. _this.POINTSIZE = false;
  1695. _this.FOG = false;
  1696. _this.LIGHT0 = false;
  1697. _this.LIGHT1 = false;
  1698. _this.LIGHT2 = false;
  1699. _this.LIGHT3 = false;
  1700. _this.SPOTLIGHT0 = false;
  1701. _this.SPOTLIGHT1 = false;
  1702. _this.SPOTLIGHT2 = false;
  1703. _this.SPOTLIGHT3 = false;
  1704. _this.HEMILIGHT0 = false;
  1705. _this.HEMILIGHT1 = false;
  1706. _this.HEMILIGHT2 = false;
  1707. _this.HEMILIGHT3 = false;
  1708. _this.DIRLIGHT0 = false;
  1709. _this.DIRLIGHT1 = false;
  1710. _this.DIRLIGHT2 = false;
  1711. _this.DIRLIGHT3 = false;
  1712. _this.POINTLIGHT0 = false;
  1713. _this.POINTLIGHT1 = false;
  1714. _this.POINTLIGHT2 = false;
  1715. _this.POINTLIGHT3 = false;
  1716. _this.SHADOW0 = false;
  1717. _this.SHADOW1 = false;
  1718. _this.SHADOW2 = false;
  1719. _this.SHADOW3 = false;
  1720. _this.SHADOWS = false;
  1721. _this.SHADOWESM0 = false;
  1722. _this.SHADOWESM1 = false;
  1723. _this.SHADOWESM2 = false;
  1724. _this.SHADOWESM3 = false;
  1725. _this.SHADOWPOISSON0 = false;
  1726. _this.SHADOWPOISSON1 = false;
  1727. _this.SHADOWPOISSON2 = false;
  1728. _this.SHADOWPOISSON3 = false;
  1729. _this.SHADOWPCF0 = false;
  1730. _this.SHADOWPCF1 = false;
  1731. _this.SHADOWPCF2 = false;
  1732. _this.SHADOWPCF3 = false;
  1733. _this.SHADOWPCSS0 = false;
  1734. _this.SHADOWPCSS1 = false;
  1735. _this.SHADOWPCSS2 = false;
  1736. _this.SHADOWPCSS3 = false;
  1737. _this.NORMAL = false;
  1738. _this.UV1 = false;
  1739. _this.UV2 = false;
  1740. _this.VERTEXCOLOR = false;
  1741. _this.VERTEXALPHA = false;
  1742. _this.NUM_BONE_INFLUENCERS = 0;
  1743. _this.BonesPerMesh = 0;
  1744. _this.INSTANCES = false;
  1745. _this.rebuild();
  1746. return _this;
  1747. }
  1748. return GradientMaterialDefines;
  1749. }(babylonjs_1.MaterialDefines));
  1750. var GradientMaterial = /** @class */ (function (_super) {
  1751. __extends(GradientMaterial, _super);
  1752. function GradientMaterial(name, scene) {
  1753. var _this = _super.call(this, name, scene) || this;
  1754. _this._maxSimultaneousLights = 4;
  1755. // The gradient top color, red by default
  1756. _this.topColor = new babylonjs_1.Color3(1, 0, 0);
  1757. _this.topColorAlpha = 1.0;
  1758. // The gradient top color, blue by default
  1759. _this.bottomColor = new babylonjs_1.Color3(0, 0, 1);
  1760. _this.bottomColorAlpha = 1.0;
  1761. // Gradient offset
  1762. _this.offset = 0;
  1763. _this.scale = 1.0;
  1764. _this.smoothness = 1.0;
  1765. _this.disableLighting = false;
  1766. _this._scaledDiffuse = new babylonjs_1.Color3();
  1767. return _this;
  1768. }
  1769. GradientMaterial.prototype.needAlphaBlending = function () {
  1770. return (this.alpha < 1.0 || this.topColorAlpha < 1.0 || this.bottomColorAlpha < 1.0);
  1771. };
  1772. GradientMaterial.prototype.needAlphaTesting = function () {
  1773. return true;
  1774. };
  1775. GradientMaterial.prototype.getAlphaTestTexture = function () {
  1776. return null;
  1777. };
  1778. // Methods
  1779. GradientMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  1780. if (this.isFrozen) {
  1781. if (this._wasPreviouslyReady && subMesh.effect) {
  1782. return true;
  1783. }
  1784. }
  1785. if (!subMesh._materialDefines) {
  1786. subMesh._materialDefines = new GradientMaterialDefines();
  1787. }
  1788. var defines = subMesh._materialDefines;
  1789. var scene = this.getScene();
  1790. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  1791. if (this._renderId === scene.getRenderId()) {
  1792. return true;
  1793. }
  1794. }
  1795. var engine = scene.getEngine();
  1796. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  1797. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  1798. defines._needNormals = babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  1799. // Attribs
  1800. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
  1801. // Get correct effect
  1802. if (defines.isDirty) {
  1803. defines.markAsProcessed();
  1804. scene.resetCachedMaterial();
  1805. // Fallbacks
  1806. var fallbacks = new babylonjs_1.EffectFallbacks();
  1807. if (defines.FOG) {
  1808. fallbacks.addFallback(1, "FOG");
  1809. }
  1810. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks);
  1811. if (defines.NUM_BONE_INFLUENCERS > 0) {
  1812. fallbacks.addCPUSkinningFallback(0, mesh);
  1813. }
  1814. //Attributes
  1815. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  1816. if (defines.NORMAL) {
  1817. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  1818. }
  1819. if (defines.UV1) {
  1820. attribs.push(babylonjs_1.VertexBuffer.UVKind);
  1821. }
  1822. if (defines.UV2) {
  1823. attribs.push(babylonjs_1.VertexBuffer.UV2Kind);
  1824. }
  1825. if (defines.VERTEXCOLOR) {
  1826. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  1827. }
  1828. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  1829. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  1830. // Legacy browser patch
  1831. var shaderName = "gradient";
  1832. var join = defines.toString();
  1833. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
  1834. "vFogInfos", "vFogColor", "pointSize",
  1835. "vDiffuseInfos",
  1836. "mBones",
  1837. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix",
  1838. "topColor", "bottomColor", "offset", "smoothness", "scale"
  1839. ];
  1840. var samplers = ["diffuseSampler"];
  1841. var uniformBuffers = new Array();
  1842. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  1843. uniformsNames: uniforms,
  1844. uniformBuffersNames: uniformBuffers,
  1845. samplers: samplers,
  1846. defines: defines,
  1847. maxSimultaneousLights: 4
  1848. });
  1849. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  1850. attributes: attribs,
  1851. uniformsNames: uniforms,
  1852. uniformBuffersNames: uniformBuffers,
  1853. samplers: samplers,
  1854. defines: join,
  1855. fallbacks: fallbacks,
  1856. onCompiled: this.onCompiled,
  1857. onError: this.onError,
  1858. indexParameters: { maxSimultaneousLights: 4 }
  1859. }, engine), defines);
  1860. }
  1861. if (!subMesh.effect || !subMesh.effect.isReady()) {
  1862. return false;
  1863. }
  1864. this._renderId = scene.getRenderId();
  1865. this._wasPreviouslyReady = true;
  1866. return true;
  1867. };
  1868. GradientMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  1869. var scene = this.getScene();
  1870. var defines = subMesh._materialDefines;
  1871. if (!defines) {
  1872. return;
  1873. }
  1874. var effect = subMesh.effect;
  1875. if (!effect) {
  1876. return;
  1877. }
  1878. this._activeEffect = effect;
  1879. // Matrices
  1880. this.bindOnlyWorldMatrix(world);
  1881. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  1882. // Bones
  1883. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, effect);
  1884. if (this._mustRebind(scene, effect)) {
  1885. // Clip plane
  1886. babylonjs_1.MaterialHelper.BindClipPlane(effect, scene);
  1887. // Point size
  1888. if (this.pointsCloud) {
  1889. this._activeEffect.setFloat("pointSize", this.pointSize);
  1890. }
  1891. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  1892. }
  1893. this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
  1894. if (scene.lightsEnabled && !this.disableLighting) {
  1895. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines);
  1896. }
  1897. // View
  1898. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  1899. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  1900. }
  1901. // Fog
  1902. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  1903. this._activeEffect.setColor4("topColor", this.topColor, this.topColorAlpha);
  1904. this._activeEffect.setColor4("bottomColor", this.bottomColor, this.bottomColorAlpha);
  1905. this._activeEffect.setFloat("offset", this.offset);
  1906. this._activeEffect.setFloat("scale", this.scale);
  1907. this._activeEffect.setFloat("smoothness", this.smoothness);
  1908. this._afterBind(mesh, this._activeEffect);
  1909. };
  1910. GradientMaterial.prototype.getAnimatables = function () {
  1911. return [];
  1912. };
  1913. GradientMaterial.prototype.dispose = function (forceDisposeEffect) {
  1914. _super.prototype.dispose.call(this, forceDisposeEffect);
  1915. };
  1916. GradientMaterial.prototype.clone = function (name) {
  1917. var _this = this;
  1918. return babylonjs_1.SerializationHelper.Clone(function () { return new GradientMaterial(name, _this.getScene()); }, this);
  1919. };
  1920. GradientMaterial.prototype.serialize = function () {
  1921. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  1922. serializationObject.customType = "BABYLON.GradientMaterial";
  1923. return serializationObject;
  1924. };
  1925. GradientMaterial.prototype.getClassName = function () {
  1926. return "GradientMaterial";
  1927. };
  1928. // Statics
  1929. GradientMaterial.Parse = function (source, scene, rootUrl) {
  1930. return babylonjs_1.SerializationHelper.Parse(function () { return new GradientMaterial(source.name, scene); }, source, scene, rootUrl);
  1931. };
  1932. __decorate([
  1933. babylonjs_1.serialize("maxSimultaneousLights")
  1934. ], GradientMaterial.prototype, "_maxSimultaneousLights", void 0);
  1935. __decorate([
  1936. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  1937. ], GradientMaterial.prototype, "maxSimultaneousLights", void 0);
  1938. __decorate([
  1939. babylonjs_1.serializeAsColor3()
  1940. ], GradientMaterial.prototype, "topColor", void 0);
  1941. __decorate([
  1942. babylonjs_1.serialize()
  1943. ], GradientMaterial.prototype, "topColorAlpha", void 0);
  1944. __decorate([
  1945. babylonjs_1.serializeAsColor3()
  1946. ], GradientMaterial.prototype, "bottomColor", void 0);
  1947. __decorate([
  1948. babylonjs_1.serialize()
  1949. ], GradientMaterial.prototype, "bottomColorAlpha", void 0);
  1950. __decorate([
  1951. babylonjs_1.serialize()
  1952. ], GradientMaterial.prototype, "offset", void 0);
  1953. __decorate([
  1954. babylonjs_1.serialize()
  1955. ], GradientMaterial.prototype, "scale", void 0);
  1956. __decorate([
  1957. babylonjs_1.serialize()
  1958. ], GradientMaterial.prototype, "smoothness", void 0);
  1959. __decorate([
  1960. babylonjs_1.serialize()
  1961. ], GradientMaterial.prototype, "disableLighting", void 0);
  1962. return GradientMaterial;
  1963. }(babylonjs_1.PushMaterial));
  1964. exports.GradientMaterial = GradientMaterial;
  1965. /***/ }),
  1966. /***/ "./src/gradient/index.ts":
  1967. /*!*******************************!*\
  1968. !*** ./src/gradient/index.ts ***!
  1969. \*******************************/
  1970. /*! no static exports found */
  1971. /***/ (function(module, exports, __webpack_require__) {
  1972. "use strict";
  1973. function __export(m) {
  1974. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1975. }
  1976. Object.defineProperty(exports, "__esModule", { value: true });
  1977. __export(__webpack_require__(/*! ./gradientMaterial */ "./src/gradient/gradientMaterial.ts"));
  1978. /***/ }),
  1979. /***/ "./src/grid/grid.fragment.ts":
  1980. /*!***********************************!*\
  1981. !*** ./src/grid/grid.fragment.ts ***!
  1982. \***********************************/
  1983. /*! no static exports found */
  1984. /***/ (function(module, exports, __webpack_require__) {
  1985. "use strict";
  1986. Object.defineProperty(exports, "__esModule", { value: true });
  1987. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  1988. var name = 'gridPixelShader';
  1989. exports.name = name;
  1990. var shader = "#extension GL_OES_standard_derivatives : enable\n#define SQRT2 1.41421356\n#define PI 3.14159\nprecision highp float;\nuniform vec3 mainColor;\nuniform vec3 lineColor;\nuniform vec4 gridControl;\nuniform vec3 gridOffset;\n\n#ifdef TRANSPARENT\nvarying vec4 vCameraSpacePosition;\n#endif\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogFragmentDeclaration>\nfloat getVisibility(float position) {\n\nfloat majorGridFrequency=gridControl.y;\nif (floor(position+0.5) == floor(position/majorGridFrequency+0.5)*majorGridFrequency)\n{\nreturn 1.0;\n}\nreturn gridControl.z;\n}\nfloat getAnisotropicAttenuation(float differentialLength) {\nconst float maxNumberOfLines=10.0;\nreturn clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);\n}\nfloat isPointOnLine(float position,float differentialLength) {\nfloat fractionPartOfPosition=position-floor(position+0.5);\nfractionPartOfPosition/=differentialLength;\nfractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);\nfloat result=0.5+0.5*cos(fractionPartOfPosition*PI);\nreturn result;\n}\nfloat contributionOnAxis(float position) {\nfloat differentialLength=length(vec2(dFdx(position),dFdy(position)));\ndifferentialLength*=SQRT2;\n\nfloat result=isPointOnLine(position,differentialLength);\n\nfloat visibility=getVisibility(position);\nresult*=visibility;\n\nfloat anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);\nresult*=anisotropicAttenuation;\nreturn result;\n}\nfloat normalImpactOnAxis(float x) {\nfloat normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);\nreturn normalImpact;\n}\nvoid main(void) {\n\nfloat gridRatio=gridControl.x;\nvec3 gridPos=(vPosition+gridOffset)/gridRatio;\n\nfloat x=contributionOnAxis(gridPos.x);\nfloat y=contributionOnAxis(gridPos.y);\nfloat z=contributionOnAxis(gridPos.z);\n\nvec3 normal=normalize(vNormal);\nx*=normalImpactOnAxis(normal.x);\ny*=normalImpactOnAxis(normal.y);\nz*=normalImpactOnAxis(normal.z);\n\nfloat grid=clamp(x+y+z,0.,1.);\n\nvec3 color=mix(mainColor,lineColor,grid);\n#ifdef FOG\n#include<fogFragment>\n#endif\n#ifdef TRANSPARENT\nfloat distanceToFragment=length(vCameraSpacePosition.xyz);\nfloat cameraPassThrough=clamp(distanceToFragment-0.25,0.0,1.0);\nfloat opacity=clamp(grid,0.08,cameraPassThrough*gridControl.w*grid);\ngl_FragColor=vec4(color.rgb,opacity);\n#ifdef PREMULTIPLYALPHA\ngl_FragColor.rgb*=opacity;\n#endif\n#else\n\ngl_FragColor=vec4(color.rgb,1.0);\n#endif\n}";
  1991. exports.shader = shader;
  1992. babylonjs_1.Effect.ShadersStore[name] = shader;
  1993. /***/ }),
  1994. /***/ "./src/grid/grid.vertex.ts":
  1995. /*!*********************************!*\
  1996. !*** ./src/grid/grid.vertex.ts ***!
  1997. \*********************************/
  1998. /*! no static exports found */
  1999. /***/ (function(module, exports, __webpack_require__) {
  2000. "use strict";
  2001. Object.defineProperty(exports, "__esModule", { value: true });
  2002. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  2003. var name = 'gridVertexShader';
  2004. exports.name = name;
  2005. var shader = "precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 projection;\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 worldView;\n\n#ifdef TRANSPARENT\nvarying vec4 vCameraSpacePosition;\n#endif\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogVertexDeclaration>\nvoid main(void) {\n#ifdef FOG\nvec4 worldPos=world*vec4(position,1.0);\n#endif\n#include<fogVertex>\nvec4 cameraSpacePosition=worldView*vec4(position,1.0);\ngl_Position=projection*cameraSpacePosition;\n#ifdef TRANSPARENT\nvCameraSpacePosition=cameraSpacePosition;\n#endif\nvPosition=position;\nvNormal=normal;\n}";
  2006. exports.shader = shader;
  2007. babylonjs_1.Effect.ShadersStore[name] = shader;
  2008. /***/ }),
  2009. /***/ "./src/grid/gridMaterial.ts":
  2010. /*!**********************************!*\
  2011. !*** ./src/grid/gridMaterial.ts ***!
  2012. \**********************************/
  2013. /*! no static exports found */
  2014. /***/ (function(module, exports, __webpack_require__) {
  2015. "use strict";
  2016. var __extends = (this && this.__extends) || (function () {
  2017. var extendStatics = function (d, b) {
  2018. extendStatics = Object.setPrototypeOf ||
  2019. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2020. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2021. return extendStatics(d, b);
  2022. }
  2023. return function (d, b) {
  2024. extendStatics(d, b);
  2025. function __() { this.constructor = d; }
  2026. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2027. };
  2028. })();
  2029. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2030. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  2031. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  2032. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  2033. return c > 3 && r && Object.defineProperty(target, key, r), r;
  2034. };
  2035. Object.defineProperty(exports, "__esModule", { value: true });
  2036. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  2037. __webpack_require__(/*! ./grid.fragment */ "./src/grid/grid.fragment.ts");
  2038. __webpack_require__(/*! ./grid.vertex */ "./src/grid/grid.vertex.ts");
  2039. var GridMaterialDefines = /** @class */ (function (_super) {
  2040. __extends(GridMaterialDefines, _super);
  2041. function GridMaterialDefines() {
  2042. var _this = _super.call(this) || this;
  2043. _this.TRANSPARENT = false;
  2044. _this.FOG = false;
  2045. _this.PREMULTIPLYALPHA = false;
  2046. _this.rebuild();
  2047. return _this;
  2048. }
  2049. return GridMaterialDefines;
  2050. }(babylonjs_1.MaterialDefines));
  2051. /**
  2052. * The grid materials allows you to wrap any shape with a grid.
  2053. * Colors are customizable.
  2054. */
  2055. var GridMaterial = /** @class */ (function (_super) {
  2056. __extends(GridMaterial, _super);
  2057. /**
  2058. * constructor
  2059. * @param name The name given to the material in order to identify it afterwards.
  2060. * @param scene The scene the material is used in.
  2061. */
  2062. function GridMaterial(name, scene) {
  2063. var _this = _super.call(this, name, scene) || this;
  2064. /**
  2065. * Main color of the grid (e.g. between lines)
  2066. */
  2067. _this.mainColor = babylonjs_1.Color3.Black();
  2068. /**
  2069. * Color of the grid lines.
  2070. */
  2071. _this.lineColor = babylonjs_1.Color3.Teal();
  2072. /**
  2073. * The scale of the grid compared to unit.
  2074. */
  2075. _this.gridRatio = 1.0;
  2076. /**
  2077. * Allows setting an offset for the grid lines.
  2078. */
  2079. _this.gridOffset = babylonjs_1.Vector3.Zero();
  2080. /**
  2081. * The frequency of thicker lines.
  2082. */
  2083. _this.majorUnitFrequency = 10;
  2084. /**
  2085. * The visibility of minor units in the grid.
  2086. */
  2087. _this.minorUnitVisibility = 0.33;
  2088. /**
  2089. * The grid opacity outside of the lines.
  2090. */
  2091. _this.opacity = 1.0;
  2092. /**
  2093. * Determine RBG output is premultiplied by alpha value.
  2094. */
  2095. _this.preMultiplyAlpha = false;
  2096. _this._gridControl = new babylonjs_1.Vector4(_this.gridRatio, _this.majorUnitFrequency, _this.minorUnitVisibility, _this.opacity);
  2097. return _this;
  2098. }
  2099. /**
  2100. * Returns wehter or not the grid requires alpha blending.
  2101. */
  2102. GridMaterial.prototype.needAlphaBlending = function () {
  2103. return this.opacity < 1.0;
  2104. };
  2105. GridMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  2106. return this.needAlphaBlending();
  2107. };
  2108. GridMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  2109. if (this.isFrozen) {
  2110. if (this._wasPreviouslyReady && subMesh.effect) {
  2111. return true;
  2112. }
  2113. }
  2114. if (!subMesh._materialDefines) {
  2115. subMesh._materialDefines = new GridMaterialDefines();
  2116. }
  2117. var defines = subMesh._materialDefines;
  2118. var scene = this.getScene();
  2119. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  2120. if (this._renderId === scene.getRenderId()) {
  2121. return true;
  2122. }
  2123. }
  2124. if (defines.TRANSPARENT !== (this.opacity < 1.0)) {
  2125. defines.TRANSPARENT = !defines.TRANSPARENT;
  2126. defines.markAsUnprocessed();
  2127. }
  2128. if (defines.PREMULTIPLYALPHA != this.preMultiplyAlpha) {
  2129. defines.PREMULTIPLYALPHA = !defines.PREMULTIPLYALPHA;
  2130. defines.markAsUnprocessed();
  2131. }
  2132. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, false, this.fogEnabled, false, defines);
  2133. // Get correct effect
  2134. if (defines.isDirty) {
  2135. defines.markAsProcessed();
  2136. scene.resetCachedMaterial();
  2137. // Attributes
  2138. var attribs = [babylonjs_1.VertexBuffer.PositionKind, babylonjs_1.VertexBuffer.NormalKind];
  2139. // Defines
  2140. var join = defines.toString();
  2141. subMesh.setEffect(scene.getEngine().createEffect("grid", attribs, ["projection", "worldView", "mainColor", "lineColor", "gridControl", "gridOffset", "vFogInfos", "vFogColor", "world", "view"], [], join, undefined, this.onCompiled, this.onError), defines);
  2142. }
  2143. if (!subMesh.effect || !subMesh.effect.isReady()) {
  2144. return false;
  2145. }
  2146. this._renderId = scene.getRenderId();
  2147. this._wasPreviouslyReady = true;
  2148. return true;
  2149. };
  2150. GridMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  2151. var scene = this.getScene();
  2152. var defines = subMesh._materialDefines;
  2153. if (!defines) {
  2154. return;
  2155. }
  2156. var effect = subMesh.effect;
  2157. if (!effect) {
  2158. return;
  2159. }
  2160. this._activeEffect = effect;
  2161. // Matrices
  2162. this.bindOnlyWorldMatrix(world);
  2163. this._activeEffect.setMatrix("worldView", world.multiply(scene.getViewMatrix()));
  2164. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  2165. this._activeEffect.setMatrix("projection", scene.getProjectionMatrix());
  2166. // Uniforms
  2167. if (this._mustRebind(scene, effect)) {
  2168. this._activeEffect.setColor3("mainColor", this.mainColor);
  2169. this._activeEffect.setColor3("lineColor", this.lineColor);
  2170. this._activeEffect.setVector3("gridOffset", this.gridOffset);
  2171. this._gridControl.x = this.gridRatio;
  2172. this._gridControl.y = Math.round(this.majorUnitFrequency);
  2173. this._gridControl.z = this.minorUnitVisibility;
  2174. this._gridControl.w = this.opacity;
  2175. this._activeEffect.setVector4("gridControl", this._gridControl);
  2176. }
  2177. // Fog
  2178. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  2179. this._afterBind(mesh, this._activeEffect);
  2180. };
  2181. /**
  2182. * Dispose the material and its associated resources.
  2183. * @param forceDisposeEffect will also dispose the used effect when true
  2184. */
  2185. GridMaterial.prototype.dispose = function (forceDisposeEffect) {
  2186. _super.prototype.dispose.call(this, forceDisposeEffect);
  2187. };
  2188. GridMaterial.prototype.clone = function (name) {
  2189. var _this = this;
  2190. return babylonjs_1.SerializationHelper.Clone(function () { return new GridMaterial(name, _this.getScene()); }, this);
  2191. };
  2192. GridMaterial.prototype.serialize = function () {
  2193. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  2194. serializationObject.customType = "BABYLON.GridMaterial";
  2195. return serializationObject;
  2196. };
  2197. GridMaterial.prototype.getClassName = function () {
  2198. return "GridMaterial";
  2199. };
  2200. GridMaterial.Parse = function (source, scene, rootUrl) {
  2201. return babylonjs_1.SerializationHelper.Parse(function () { return new GridMaterial(source.name, scene); }, source, scene, rootUrl);
  2202. };
  2203. __decorate([
  2204. babylonjs_1.serializeAsColor3()
  2205. ], GridMaterial.prototype, "mainColor", void 0);
  2206. __decorate([
  2207. babylonjs_1.serializeAsColor3()
  2208. ], GridMaterial.prototype, "lineColor", void 0);
  2209. __decorate([
  2210. babylonjs_1.serialize()
  2211. ], GridMaterial.prototype, "gridRatio", void 0);
  2212. __decorate([
  2213. babylonjs_1.serializeAsColor3()
  2214. ], GridMaterial.prototype, "gridOffset", void 0);
  2215. __decorate([
  2216. babylonjs_1.serialize()
  2217. ], GridMaterial.prototype, "majorUnitFrequency", void 0);
  2218. __decorate([
  2219. babylonjs_1.serialize()
  2220. ], GridMaterial.prototype, "minorUnitVisibility", void 0);
  2221. __decorate([
  2222. babylonjs_1.serialize()
  2223. ], GridMaterial.prototype, "opacity", void 0);
  2224. __decorate([
  2225. babylonjs_1.serialize()
  2226. ], GridMaterial.prototype, "preMultiplyAlpha", void 0);
  2227. return GridMaterial;
  2228. }(BABYLON.PushMaterial));
  2229. exports.GridMaterial = GridMaterial;
  2230. /***/ }),
  2231. /***/ "./src/grid/index.ts":
  2232. /*!***************************!*\
  2233. !*** ./src/grid/index.ts ***!
  2234. \***************************/
  2235. /*! no static exports found */
  2236. /***/ (function(module, exports, __webpack_require__) {
  2237. "use strict";
  2238. function __export(m) {
  2239. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  2240. }
  2241. Object.defineProperty(exports, "__esModule", { value: true });
  2242. __export(__webpack_require__(/*! ./gridMaterial */ "./src/grid/gridMaterial.ts"));
  2243. /***/ }),
  2244. /***/ "./src/index.ts":
  2245. /*!**********************!*\
  2246. !*** ./src/index.ts ***!
  2247. \**********************/
  2248. /*! no static exports found */
  2249. /***/ (function(module, exports, __webpack_require__) {
  2250. "use strict";
  2251. function __export(m) {
  2252. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  2253. }
  2254. Object.defineProperty(exports, "__esModule", { value: true });
  2255. __export(__webpack_require__(/*! ./cell */ "./src/cell/index.ts"));
  2256. __export(__webpack_require__(/*! ./custom */ "./src/custom/index.ts"));
  2257. __export(__webpack_require__(/*! ./fire */ "./src/fire/index.ts"));
  2258. __export(__webpack_require__(/*! ./fur */ "./src/fur/index.ts"));
  2259. __export(__webpack_require__(/*! ./gradient */ "./src/gradient/index.ts"));
  2260. __export(__webpack_require__(/*! ./grid */ "./src/grid/index.ts"));
  2261. __export(__webpack_require__(/*! ./lava */ "./src/lava/index.ts"));
  2262. __export(__webpack_require__(/*! ./mix */ "./src/mix/index.ts"));
  2263. __export(__webpack_require__(/*! ./normal */ "./src/normal/index.ts"));
  2264. __export(__webpack_require__(/*! ./shadowOnly */ "./src/shadowOnly/index.ts"));
  2265. __export(__webpack_require__(/*! ./simple */ "./src/simple/index.ts"));
  2266. __export(__webpack_require__(/*! ./sky */ "./src/sky/index.ts"));
  2267. __export(__webpack_require__(/*! ./terrain */ "./src/terrain/index.ts"));
  2268. __export(__webpack_require__(/*! ./triPlanar */ "./src/triPlanar/index.ts"));
  2269. __export(__webpack_require__(/*! ./water */ "./src/water/index.ts"));
  2270. /***/ }),
  2271. /***/ "./src/lava/index.ts":
  2272. /*!***************************!*\
  2273. !*** ./src/lava/index.ts ***!
  2274. \***************************/
  2275. /*! no static exports found */
  2276. /***/ (function(module, exports, __webpack_require__) {
  2277. "use strict";
  2278. function __export(m) {
  2279. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  2280. }
  2281. Object.defineProperty(exports, "__esModule", { value: true });
  2282. __export(__webpack_require__(/*! ./lavaMaterial */ "./src/lava/lavaMaterial.ts"));
  2283. /***/ }),
  2284. /***/ "./src/lava/lava.fragment.ts":
  2285. /*!***********************************!*\
  2286. !*** ./src/lava/lava.fragment.ts ***!
  2287. \***********************************/
  2288. /*! no static exports found */
  2289. /***/ (function(module, exports, __webpack_require__) {
  2290. "use strict";
  2291. Object.defineProperty(exports, "__esModule", { value: true });
  2292. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  2293. var name = 'lavaPixelShader';
  2294. exports.name = name;
  2295. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n\nuniform float time;\nuniform float speed;\nuniform float movingSpeed;\nuniform vec3 fogColor;\nuniform sampler2D noiseTexture;\nuniform float fogDensity;\n\nvarying float noise;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nfloat random( vec3 scale,float seed ){\nreturn fract( sin( dot( gl_FragCoord.xyz+seed,scale ) )*43758.5453+seed ) ;\n}\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\n\nvec4 noiseTex=texture2D( noiseTexture,vDiffuseUV );\nvec2 T1=vDiffuseUV+vec2( 1.5,-1.5 )*time*0.02;\nvec2 T2=vDiffuseUV+vec2( -0.5,2.0 )*time*0.01*speed;\nT1.x+=noiseTex.x*2.0;\nT1.y+=noiseTex.y*2.0;\nT2.x-=noiseTex.y*0.2+time*0.001*movingSpeed;\nT2.y+=noiseTex.z*0.2+time*0.002*movingSpeed;\nfloat p=texture2D( noiseTexture,T1*3.0 ).a;\nvec4 lavaColor=texture2D( diffuseSampler,T2*4.0);\nvec4 temp=lavaColor*( vec4( p,p,p,p )*2. )+( lavaColor*lavaColor-0.1 );\nbaseColor=temp;\nfloat depth=gl_FragCoord.z*4.0;\nconst float LOG2=1.442695;\nfloat fogFactor=exp2(-fogDensity*fogDensity*depth*depth*LOG2 );\nfogFactor=1.0-clamp( fogFactor,0.0,1.0 );\nbaseColor=mix( baseColor,vec4( fogColor,baseColor.w ),fogFactor );\ndiffuseColor=baseColor.rgb;\n\n\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";
  2296. exports.shader = shader;
  2297. babylonjs_1.Effect.ShadersStore[name] = shader;
  2298. /***/ }),
  2299. /***/ "./src/lava/lava.vertex.ts":
  2300. /*!*********************************!*\
  2301. !*** ./src/lava/lava.vertex.ts ***!
  2302. \*********************************/
  2303. /*! no static exports found */
  2304. /***/ (function(module, exports, __webpack_require__) {
  2305. "use strict";
  2306. Object.defineProperty(exports, "__esModule", { value: true });
  2307. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  2308. var name = 'lavaVertexShader';
  2309. exports.name = name;
  2310. var shader = "precision highp float;\n\nuniform float time;\nuniform float lowFrequencySpeed;\n\nvarying float noise;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n\n\nvec3 mod289(vec3 x)\n{\nreturn x-floor(x*(1.0/289.0))*289.0;\n}\nvec4 mod289(vec4 x)\n{\nreturn x-floor(x*(1.0/289.0))*289.0;\n}\nvec4 permute(vec4 x)\n{\nreturn mod289(((x*34.0)+1.0)*x);\n}\nvec4 taylorInvSqrt(vec4 r)\n{\nreturn 1.79284291400159-0.85373472095314*r;\n}\nvec3 fade(vec3 t) {\nreturn t*t*t*(t*(t*6.0-15.0)+10.0);\n}\n\nfloat pnoise(vec3 P,vec3 rep)\n{\nvec3 Pi0=mod(floor(P),rep);\nvec3 Pi1=mod(Pi0+vec3(1.0),rep);\nPi0=mod289(Pi0);\nPi1=mod289(Pi1);\nvec3 Pf0=fract(P);\nvec3 Pf1=Pf0-vec3(1.0);\nvec4 ix=vec4(Pi0.x,Pi1.x,Pi0.x,Pi1.x);\nvec4 iy=vec4(Pi0.yy,Pi1.yy);\nvec4 iz0=Pi0.zzzz;\nvec4 iz1=Pi1.zzzz;\nvec4 ixy=permute(permute(ix)+iy);\nvec4 ixy0=permute(ixy+iz0);\nvec4 ixy1=permute(ixy+iz1);\nvec4 gx0=ixy0*(1.0/7.0);\nvec4 gy0=fract(floor(gx0)*(1.0/7.0))-0.5;\ngx0=fract(gx0);\nvec4 gz0=vec4(0.5)-abs(gx0)-abs(gy0);\nvec4 sz0=step(gz0,vec4(0.0));\ngx0-=sz0*(step(0.0,gx0)-0.5);\ngy0-=sz0*(step(0.0,gy0)-0.5);\nvec4 gx1=ixy1*(1.0/7.0);\nvec4 gy1=fract(floor(gx1)*(1.0/7.0))-0.5;\ngx1=fract(gx1);\nvec4 gz1=vec4(0.5)-abs(gx1)-abs(gy1);\nvec4 sz1=step(gz1,vec4(0.0));\ngx1-=sz1*(step(0.0,gx1)-0.5);\ngy1-=sz1*(step(0.0,gy1)-0.5);\nvec3 g000=vec3(gx0.x,gy0.x,gz0.x);\nvec3 g100=vec3(gx0.y,gy0.y,gz0.y);\nvec3 g010=vec3(gx0.z,gy0.z,gz0.z);\nvec3 g110=vec3(gx0.w,gy0.w,gz0.w);\nvec3 g001=vec3(gx1.x,gy1.x,gz1.x);\nvec3 g101=vec3(gx1.y,gy1.y,gz1.y);\nvec3 g011=vec3(gx1.z,gy1.z,gz1.z);\nvec3 g111=vec3(gx1.w,gy1.w,gz1.w);\nvec4 norm0=taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));\ng000*=norm0.x;\ng010*=norm0.y;\ng100*=norm0.z;\ng110*=norm0.w;\nvec4 norm1=taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));\ng001*=norm1.x;\ng011*=norm1.y;\ng101*=norm1.z;\ng111*=norm1.w;\nfloat n000=dot(g000,Pf0);\nfloat n100=dot(g100,vec3(Pf1.x,Pf0.yz));\nfloat n010=dot(g010,vec3(Pf0.x,Pf1.y,Pf0.z));\nfloat n110=dot(g110,vec3(Pf1.xy,Pf0.z));\nfloat n001=dot(g001,vec3(Pf0.xy,Pf1.z));\nfloat n101=dot(g101,vec3(Pf1.x,Pf0.y,Pf1.z));\nfloat n011=dot(g011,vec3(Pf0.x,Pf1.yz));\nfloat n111=dot(g111,Pf1);\nvec3 fade_xyz=fade(Pf0);\nvec4 n_z=mix(vec4(n000,n100,n010,n110),vec4(n001,n101,n011,n111),fade_xyz.z);\nvec2 n_yz=mix(n_z.xy,n_z.zw,fade_xyz.y);\nfloat n_xyz=mix(n_yz.x,n_yz.y,fade_xyz.x);\nreturn 2.2*n_xyz;\n}\n\nfloat turbulence( vec3 p ) {\nfloat w=100.0;\nfloat t=-.5;\nfor (float f=1.0 ; f<=10.0 ; f++ ){\nfloat power=pow( 2.0,f );\nt+=abs( pnoise( vec3( power*p ),vec3( 10.0,10.0,10.0 ) )/power );\n}\nreturn t;\n}\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef NORMAL\n\nnoise=10.0*-.10*turbulence( .5*normal+time*1.15 );\n\nfloat b=lowFrequencySpeed*5.0*pnoise( 0.05*position +vec3(time*1.025),vec3( 100.0 ) );\n\nfloat displacement =-1.5*noise+b;\n\nvec3 newPosition=position+normal*displacement;\ngl_Position=viewProjection*finalWorld*vec4( newPosition,1.0 );\nvec4 worldPos=finalWorld*vec4(newPosition,1.0);\nvPositionW=vec3(worldPos);\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}";
  2311. exports.shader = shader;
  2312. babylonjs_1.Effect.ShadersStore[name] = shader;
  2313. /***/ }),
  2314. /***/ "./src/lava/lavaMaterial.ts":
  2315. /*!**********************************!*\
  2316. !*** ./src/lava/lavaMaterial.ts ***!
  2317. \**********************************/
  2318. /*! no static exports found */
  2319. /***/ (function(module, exports, __webpack_require__) {
  2320. "use strict";
  2321. var __extends = (this && this.__extends) || (function () {
  2322. var extendStatics = function (d, b) {
  2323. extendStatics = Object.setPrototypeOf ||
  2324. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2325. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2326. return extendStatics(d, b);
  2327. }
  2328. return function (d, b) {
  2329. extendStatics(d, b);
  2330. function __() { this.constructor = d; }
  2331. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2332. };
  2333. })();
  2334. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2335. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  2336. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  2337. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  2338. return c > 3 && r && Object.defineProperty(target, key, r), r;
  2339. };
  2340. Object.defineProperty(exports, "__esModule", { value: true });
  2341. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  2342. __webpack_require__(/*! ./lava.fragment */ "./src/lava/lava.fragment.ts");
  2343. __webpack_require__(/*! ./lava.vertex */ "./src/lava/lava.vertex.ts");
  2344. var LavaMaterialDefines = /** @class */ (function (_super) {
  2345. __extends(LavaMaterialDefines, _super);
  2346. function LavaMaterialDefines() {
  2347. var _this = _super.call(this) || this;
  2348. _this.DIFFUSE = false;
  2349. _this.CLIPPLANE = false;
  2350. _this.CLIPPLANE2 = false;
  2351. _this.CLIPPLANE3 = false;
  2352. _this.CLIPPLANE4 = false;
  2353. _this.ALPHATEST = false;
  2354. _this.DEPTHPREPASS = false;
  2355. _this.POINTSIZE = false;
  2356. _this.FOG = false;
  2357. _this.LIGHT0 = false;
  2358. _this.LIGHT1 = false;
  2359. _this.LIGHT2 = false;
  2360. _this.LIGHT3 = false;
  2361. _this.SPOTLIGHT0 = false;
  2362. _this.SPOTLIGHT1 = false;
  2363. _this.SPOTLIGHT2 = false;
  2364. _this.SPOTLIGHT3 = false;
  2365. _this.HEMILIGHT0 = false;
  2366. _this.HEMILIGHT1 = false;
  2367. _this.HEMILIGHT2 = false;
  2368. _this.HEMILIGHT3 = false;
  2369. _this.DIRLIGHT0 = false;
  2370. _this.DIRLIGHT1 = false;
  2371. _this.DIRLIGHT2 = false;
  2372. _this.DIRLIGHT3 = false;
  2373. _this.POINTLIGHT0 = false;
  2374. _this.POINTLIGHT1 = false;
  2375. _this.POINTLIGHT2 = false;
  2376. _this.POINTLIGHT3 = false;
  2377. _this.SHADOW0 = false;
  2378. _this.SHADOW1 = false;
  2379. _this.SHADOW2 = false;
  2380. _this.SHADOW3 = false;
  2381. _this.SHADOWS = false;
  2382. _this.SHADOWESM0 = false;
  2383. _this.SHADOWESM1 = false;
  2384. _this.SHADOWESM2 = false;
  2385. _this.SHADOWESM3 = false;
  2386. _this.SHADOWPOISSON0 = false;
  2387. _this.SHADOWPOISSON1 = false;
  2388. _this.SHADOWPOISSON2 = false;
  2389. _this.SHADOWPOISSON3 = false;
  2390. _this.SHADOWPCF0 = false;
  2391. _this.SHADOWPCF1 = false;
  2392. _this.SHADOWPCF2 = false;
  2393. _this.SHADOWPCF3 = false;
  2394. _this.SHADOWPCSS0 = false;
  2395. _this.SHADOWPCSS1 = false;
  2396. _this.SHADOWPCSS2 = false;
  2397. _this.SHADOWPCSS3 = false;
  2398. _this.NORMAL = false;
  2399. _this.UV1 = false;
  2400. _this.UV2 = false;
  2401. _this.VERTEXCOLOR = false;
  2402. _this.VERTEXALPHA = false;
  2403. _this.NUM_BONE_INFLUENCERS = 0;
  2404. _this.BonesPerMesh = 0;
  2405. _this.INSTANCES = false;
  2406. _this.UNLIT = false;
  2407. _this.rebuild();
  2408. return _this;
  2409. }
  2410. return LavaMaterialDefines;
  2411. }(babylonjs_1.MaterialDefines));
  2412. var LavaMaterial = /** @class */ (function (_super) {
  2413. __extends(LavaMaterial, _super);
  2414. function LavaMaterial(name, scene) {
  2415. var _this = _super.call(this, name, scene) || this;
  2416. _this.speed = 1;
  2417. _this.movingSpeed = 1;
  2418. _this.lowFrequencySpeed = 1;
  2419. _this.fogDensity = 0.15;
  2420. _this._lastTime = 0;
  2421. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  2422. _this._disableLighting = false;
  2423. _this._unlit = false;
  2424. _this._maxSimultaneousLights = 4;
  2425. _this._scaledDiffuse = new babylonjs_1.Color3();
  2426. return _this;
  2427. }
  2428. LavaMaterial.prototype.needAlphaBlending = function () {
  2429. return (this.alpha < 1.0);
  2430. };
  2431. LavaMaterial.prototype.needAlphaTesting = function () {
  2432. return false;
  2433. };
  2434. LavaMaterial.prototype.getAlphaTestTexture = function () {
  2435. return null;
  2436. };
  2437. // Methods
  2438. LavaMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  2439. if (this.isFrozen) {
  2440. if (this._wasPreviouslyReady && subMesh.effect) {
  2441. return true;
  2442. }
  2443. }
  2444. if (!subMesh._materialDefines) {
  2445. subMesh._materialDefines = new LavaMaterialDefines();
  2446. }
  2447. var defines = subMesh._materialDefines;
  2448. var scene = this.getScene();
  2449. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  2450. if (this._renderId === scene.getRenderId()) {
  2451. return true;
  2452. }
  2453. }
  2454. var engine = scene.getEngine();
  2455. // Textures
  2456. if (defines._areTexturesDirty) {
  2457. defines._needUVs = false;
  2458. if (scene.texturesEnabled) {
  2459. if (this._diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  2460. if (!this._diffuseTexture.isReady()) {
  2461. return false;
  2462. }
  2463. else {
  2464. defines._needUVs = true;
  2465. defines.DIFFUSE = true;
  2466. }
  2467. }
  2468. }
  2469. }
  2470. // Misc.
  2471. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  2472. // Lights
  2473. defines._needNormals = true;
  2474. babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  2475. // Values that need to be evaluated on every frame
  2476. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  2477. // Attribs
  2478. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  2479. // Get correct effect
  2480. if (defines.isDirty) {
  2481. defines.markAsProcessed();
  2482. scene.resetCachedMaterial();
  2483. // Fallbacks
  2484. var fallbacks = new babylonjs_1.EffectFallbacks();
  2485. if (defines.FOG) {
  2486. fallbacks.addFallback(1, "FOG");
  2487. }
  2488. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks);
  2489. if (defines.NUM_BONE_INFLUENCERS > 0) {
  2490. fallbacks.addCPUSkinningFallback(0, mesh);
  2491. }
  2492. //Attributes
  2493. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  2494. if (defines.NORMAL) {
  2495. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  2496. }
  2497. if (defines.UV1) {
  2498. attribs.push(babylonjs_1.VertexBuffer.UVKind);
  2499. }
  2500. if (defines.UV2) {
  2501. attribs.push(babylonjs_1.VertexBuffer.UV2Kind);
  2502. }
  2503. if (defines.VERTEXCOLOR) {
  2504. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  2505. }
  2506. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  2507. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  2508. // Legacy browser patch
  2509. var shaderName = "lava";
  2510. var join = defines.toString();
  2511. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
  2512. "vFogInfos", "vFogColor", "pointSize",
  2513. "vDiffuseInfos",
  2514. "mBones",
  2515. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix",
  2516. "time", "speed", "movingSpeed",
  2517. "fogColor", "fogDensity", "lowFrequencySpeed"
  2518. ];
  2519. var samplers = ["diffuseSampler",
  2520. "noiseTexture"
  2521. ];
  2522. var uniformBuffers = new Array();
  2523. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  2524. uniformsNames: uniforms,
  2525. uniformBuffersNames: uniformBuffers,
  2526. samplers: samplers,
  2527. defines: defines,
  2528. maxSimultaneousLights: this.maxSimultaneousLights
  2529. });
  2530. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  2531. attributes: attribs,
  2532. uniformsNames: uniforms,
  2533. uniformBuffersNames: uniformBuffers,
  2534. samplers: samplers,
  2535. defines: join,
  2536. fallbacks: fallbacks,
  2537. onCompiled: this.onCompiled,
  2538. onError: this.onError,
  2539. indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
  2540. }, engine), defines);
  2541. }
  2542. if (!subMesh.effect || !subMesh.effect.isReady()) {
  2543. return false;
  2544. }
  2545. this._renderId = scene.getRenderId();
  2546. this._wasPreviouslyReady = true;
  2547. return true;
  2548. };
  2549. LavaMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  2550. var scene = this.getScene();
  2551. var defines = subMesh._materialDefines;
  2552. if (!defines) {
  2553. return;
  2554. }
  2555. var effect = subMesh.effect;
  2556. if (!effect) {
  2557. return;
  2558. }
  2559. this._activeEffect = effect;
  2560. defines.UNLIT = this._unlit;
  2561. // Matrices
  2562. this.bindOnlyWorldMatrix(world);
  2563. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  2564. // Bones
  2565. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  2566. if (this._mustRebind(scene, effect)) {
  2567. // Textures
  2568. if (this.diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  2569. this._activeEffect.setTexture("diffuseSampler", this.diffuseTexture);
  2570. this._activeEffect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
  2571. this._activeEffect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
  2572. }
  2573. if (this.noiseTexture) {
  2574. this._activeEffect.setTexture("noiseTexture", this.noiseTexture);
  2575. }
  2576. // Clip plane
  2577. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  2578. // Point size
  2579. if (this.pointsCloud) {
  2580. this._activeEffect.setFloat("pointSize", this.pointSize);
  2581. }
  2582. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  2583. }
  2584. this._activeEffect.setColor4("vDiffuseColor", this._scaledDiffuse, this.alpha * mesh.visibility);
  2585. if (scene.lightsEnabled && !this.disableLighting) {
  2586. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines);
  2587. }
  2588. // View
  2589. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  2590. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  2591. }
  2592. // Fog
  2593. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  2594. this._lastTime += scene.getEngine().getDeltaTime();
  2595. this._activeEffect.setFloat("time", this._lastTime * this.speed / 1000);
  2596. if (!this.fogColor) {
  2597. this.fogColor = babylonjs_1.Color3.Black();
  2598. }
  2599. this._activeEffect.setColor3("fogColor", this.fogColor);
  2600. this._activeEffect.setFloat("fogDensity", this.fogDensity);
  2601. this._activeEffect.setFloat("lowFrequencySpeed", this.lowFrequencySpeed);
  2602. this._activeEffect.setFloat("movingSpeed", this.movingSpeed);
  2603. this._afterBind(mesh, this._activeEffect);
  2604. };
  2605. LavaMaterial.prototype.getAnimatables = function () {
  2606. var results = [];
  2607. if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
  2608. results.push(this.diffuseTexture);
  2609. }
  2610. if (this.noiseTexture && this.noiseTexture.animations && this.noiseTexture.animations.length > 0) {
  2611. results.push(this.noiseTexture);
  2612. }
  2613. return results;
  2614. };
  2615. LavaMaterial.prototype.getActiveTextures = function () {
  2616. var activeTextures = _super.prototype.getActiveTextures.call(this);
  2617. if (this._diffuseTexture) {
  2618. activeTextures.push(this._diffuseTexture);
  2619. }
  2620. return activeTextures;
  2621. };
  2622. LavaMaterial.prototype.hasTexture = function (texture) {
  2623. if (_super.prototype.hasTexture.call(this, texture)) {
  2624. return true;
  2625. }
  2626. if (this.diffuseTexture === texture) {
  2627. return true;
  2628. }
  2629. return false;
  2630. };
  2631. LavaMaterial.prototype.dispose = function (forceDisposeEffect) {
  2632. if (this.diffuseTexture) {
  2633. this.diffuseTexture.dispose();
  2634. }
  2635. if (this.noiseTexture) {
  2636. this.noiseTexture.dispose();
  2637. }
  2638. _super.prototype.dispose.call(this, forceDisposeEffect);
  2639. };
  2640. LavaMaterial.prototype.clone = function (name) {
  2641. var _this = this;
  2642. return babylonjs_1.SerializationHelper.Clone(function () { return new LavaMaterial(name, _this.getScene()); }, this);
  2643. };
  2644. LavaMaterial.prototype.serialize = function () {
  2645. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  2646. serializationObject.customType = "BABYLON.LavaMaterial";
  2647. return serializationObject;
  2648. };
  2649. LavaMaterial.prototype.getClassName = function () {
  2650. return "LavaMaterial";
  2651. };
  2652. // Statics
  2653. LavaMaterial.Parse = function (source, scene, rootUrl) {
  2654. return babylonjs_1.SerializationHelper.Parse(function () { return new LavaMaterial(source.name, scene); }, source, scene, rootUrl);
  2655. };
  2656. __decorate([
  2657. babylonjs_1.serializeAsTexture("diffuseTexture")
  2658. ], LavaMaterial.prototype, "_diffuseTexture", void 0);
  2659. __decorate([
  2660. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  2661. ], LavaMaterial.prototype, "diffuseTexture", void 0);
  2662. __decorate([
  2663. babylonjs_1.serializeAsTexture()
  2664. ], LavaMaterial.prototype, "noiseTexture", void 0);
  2665. __decorate([
  2666. babylonjs_1.serializeAsColor3()
  2667. ], LavaMaterial.prototype, "fogColor", void 0);
  2668. __decorate([
  2669. babylonjs_1.serialize()
  2670. ], LavaMaterial.prototype, "speed", void 0);
  2671. __decorate([
  2672. babylonjs_1.serialize()
  2673. ], LavaMaterial.prototype, "movingSpeed", void 0);
  2674. __decorate([
  2675. babylonjs_1.serialize()
  2676. ], LavaMaterial.prototype, "lowFrequencySpeed", void 0);
  2677. __decorate([
  2678. babylonjs_1.serialize()
  2679. ], LavaMaterial.prototype, "fogDensity", void 0);
  2680. __decorate([
  2681. babylonjs_1.serializeAsColor3()
  2682. ], LavaMaterial.prototype, "diffuseColor", void 0);
  2683. __decorate([
  2684. babylonjs_1.serialize("disableLighting")
  2685. ], LavaMaterial.prototype, "_disableLighting", void 0);
  2686. __decorate([
  2687. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  2688. ], LavaMaterial.prototype, "disableLighting", void 0);
  2689. __decorate([
  2690. babylonjs_1.serialize("unlit")
  2691. ], LavaMaterial.prototype, "_unlit", void 0);
  2692. __decorate([
  2693. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  2694. ], LavaMaterial.prototype, "unlit", void 0);
  2695. __decorate([
  2696. babylonjs_1.serialize("maxSimultaneousLights")
  2697. ], LavaMaterial.prototype, "_maxSimultaneousLights", void 0);
  2698. __decorate([
  2699. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  2700. ], LavaMaterial.prototype, "maxSimultaneousLights", void 0);
  2701. return LavaMaterial;
  2702. }(babylonjs_1.PushMaterial));
  2703. exports.LavaMaterial = LavaMaterial;
  2704. /***/ }),
  2705. /***/ "./src/mix/index.ts":
  2706. /*!**************************!*\
  2707. !*** ./src/mix/index.ts ***!
  2708. \**************************/
  2709. /*! no static exports found */
  2710. /***/ (function(module, exports, __webpack_require__) {
  2711. "use strict";
  2712. function __export(m) {
  2713. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  2714. }
  2715. Object.defineProperty(exports, "__esModule", { value: true });
  2716. __export(__webpack_require__(/*! ./mixMaterial */ "./src/mix/mixMaterial.ts"));
  2717. /***/ }),
  2718. /***/ "./src/mix/mix.fragment.ts":
  2719. /*!*********************************!*\
  2720. !*** ./src/mix/mix.fragment.ts ***!
  2721. \*********************************/
  2722. /*! no static exports found */
  2723. /***/ (function(module, exports, __webpack_require__) {
  2724. "use strict";
  2725. Object.defineProperty(exports, "__esModule", { value: true });
  2726. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  2727. var name = 'mixPixelShader';
  2728. exports.name = name;
  2729. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform sampler2D mixMap1Sampler;\nuniform vec2 vTextureInfos;\n#ifdef MIXMAP2\nuniform sampler2D mixMap2Sampler;\n#endif\nuniform sampler2D diffuse1Sampler;\nuniform sampler2D diffuse2Sampler;\nuniform sampler2D diffuse3Sampler;\nuniform sampler2D diffuse4Sampler;\nuniform vec2 diffuse1Infos;\nuniform vec2 diffuse2Infos;\nuniform vec2 diffuse3Infos;\nuniform vec2 diffuse4Infos;\n#ifdef MIXMAP2\nuniform sampler2D diffuse5Sampler;\nuniform sampler2D diffuse6Sampler;\nuniform sampler2D diffuse7Sampler;\nuniform sampler2D diffuse8Sampler;\nuniform vec2 diffuse5Infos;\nuniform vec2 diffuse6Infos;\nuniform vec2 diffuse7Infos;\nuniform vec2 diffuse8Infos;\n#endif\n#endif\n\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 finalMixColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef MIXMAP2\nvec4 mixColor2=vec4(1.,1.,1.,1.);\n#endif\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nvec4 mixColor=texture2D(mixMap1Sampler,vTextureUV);\n#include<depthPrePass>\nmixColor.rgb*=vTextureInfos.y;\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\nvec4 diffuse4Color=texture2D(diffuse4Sampler,vTextureUV*diffuse4Infos);\ndiffuse1Color.rgb*=mixColor.r;\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,mixColor.g);\ndiffuse3Color.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,mixColor.b);\nfinalMixColor.rgb=mix(diffuse3Color.rgb,diffuse4Color.rgb,1.0-mixColor.a);\n#ifdef MIXMAP2\nmixColor=texture2D(mixMap2Sampler,vTextureUV);\nmixColor.rgb*=vTextureInfos.y;\nvec4 diffuse5Color=texture2D(diffuse5Sampler,vTextureUV*diffuse5Infos);\nvec4 diffuse6Color=texture2D(diffuse6Sampler,vTextureUV*diffuse6Infos);\nvec4 diffuse7Color=texture2D(diffuse7Sampler,vTextureUV*diffuse7Infos);\nvec4 diffuse8Color=texture2D(diffuse8Sampler,vTextureUV*diffuse8Infos);\ndiffuse5Color.rgb=mix(finalMixColor.rgb,diffuse5Color.rgb,mixColor.r);\ndiffuse6Color.rgb=mix(diffuse5Color.rgb,diffuse6Color.rgb,mixColor.g);\ndiffuse7Color.rgb=mix(diffuse6Color.rgb,diffuse7Color.rgb,mixColor.b);\nfinalMixColor.rgb=mix(diffuse7Color.rgb,diffuse8Color.rgb,1.0-mixColor.a);\n#endif\n#endif\n#ifdef VERTEXCOLOR\nfinalMixColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*finalMixColor.rgb,0.0,1.0);\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n";
  2730. exports.shader = shader;
  2731. babylonjs_1.Effect.ShadersStore[name] = shader;
  2732. /***/ }),
  2733. /***/ "./src/mix/mix.vertex.ts":
  2734. /*!*******************************!*\
  2735. !*** ./src/mix/mix.vertex.ts ***!
  2736. \*******************************/
  2737. /*! no static exports found */
  2738. /***/ (function(module, exports, __webpack_require__) {
  2739. "use strict";
  2740. Object.defineProperty(exports, "__esModule", { value: true });
  2741. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  2742. var name = 'mixVertexShader';
  2743. exports.name = name;
  2744. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform mat4 textureMatrix;\nuniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vTextureInfos.x == 0.)\n{\nvTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  2745. exports.shader = shader;
  2746. babylonjs_1.Effect.ShadersStore[name] = shader;
  2747. /***/ }),
  2748. /***/ "./src/mix/mixMaterial.ts":
  2749. /*!********************************!*\
  2750. !*** ./src/mix/mixMaterial.ts ***!
  2751. \********************************/
  2752. /*! no static exports found */
  2753. /***/ (function(module, exports, __webpack_require__) {
  2754. "use strict";
  2755. var __extends = (this && this.__extends) || (function () {
  2756. var extendStatics = function (d, b) {
  2757. extendStatics = Object.setPrototypeOf ||
  2758. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2759. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2760. return extendStatics(d, b);
  2761. }
  2762. return function (d, b) {
  2763. extendStatics(d, b);
  2764. function __() { this.constructor = d; }
  2765. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2766. };
  2767. })();
  2768. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2769. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  2770. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  2771. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  2772. return c > 3 && r && Object.defineProperty(target, key, r), r;
  2773. };
  2774. Object.defineProperty(exports, "__esModule", { value: true });
  2775. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  2776. __webpack_require__(/*! ./mix.fragment */ "./src/mix/mix.fragment.ts");
  2777. __webpack_require__(/*! ./mix.vertex */ "./src/mix/mix.vertex.ts");
  2778. var MixMaterialDefines = /** @class */ (function (_super) {
  2779. __extends(MixMaterialDefines, _super);
  2780. function MixMaterialDefines() {
  2781. var _this = _super.call(this) || this;
  2782. _this.DIFFUSE = false;
  2783. _this.CLIPPLANE = false;
  2784. _this.CLIPPLANE2 = false;
  2785. _this.CLIPPLANE3 = false;
  2786. _this.CLIPPLANE4 = false;
  2787. _this.ALPHATEST = false;
  2788. _this.DEPTHPREPASS = false;
  2789. _this.POINTSIZE = false;
  2790. _this.FOG = false;
  2791. _this.SPECULARTERM = false;
  2792. _this.NORMAL = false;
  2793. _this.UV1 = false;
  2794. _this.UV2 = false;
  2795. _this.VERTEXCOLOR = false;
  2796. _this.VERTEXALPHA = false;
  2797. _this.NUM_BONE_INFLUENCERS = 0;
  2798. _this.BonesPerMesh = 0;
  2799. _this.INSTANCES = false;
  2800. _this.MIXMAP2 = false;
  2801. _this.rebuild();
  2802. return _this;
  2803. }
  2804. return MixMaterialDefines;
  2805. }(babylonjs_1.MaterialDefines));
  2806. var MixMaterial = /** @class */ (function (_super) {
  2807. __extends(MixMaterial, _super);
  2808. function MixMaterial(name, scene) {
  2809. var _this = _super.call(this, name, scene) || this;
  2810. /**
  2811. * Uniforms
  2812. */
  2813. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  2814. _this.specularColor = new babylonjs_1.Color3(0, 0, 0);
  2815. _this.specularPower = 64;
  2816. _this._disableLighting = false;
  2817. _this._maxSimultaneousLights = 4;
  2818. return _this;
  2819. }
  2820. MixMaterial.prototype.needAlphaBlending = function () {
  2821. return (this.alpha < 1.0);
  2822. };
  2823. MixMaterial.prototype.needAlphaTesting = function () {
  2824. return false;
  2825. };
  2826. MixMaterial.prototype.getAlphaTestTexture = function () {
  2827. return null;
  2828. };
  2829. // Methods
  2830. MixMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  2831. if (this.isFrozen) {
  2832. if (this._wasPreviouslyReady && subMesh.effect) {
  2833. return true;
  2834. }
  2835. }
  2836. if (!subMesh._materialDefines) {
  2837. subMesh._materialDefines = new MixMaterialDefines();
  2838. }
  2839. var defines = subMesh._materialDefines;
  2840. var scene = this.getScene();
  2841. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  2842. if (this._renderId === scene.getRenderId()) {
  2843. return true;
  2844. }
  2845. }
  2846. var engine = scene.getEngine();
  2847. // Textures
  2848. if (scene.texturesEnabled) {
  2849. if (babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  2850. if (this._mixTexture1) {
  2851. if (!this._mixTexture1.isReady()) {
  2852. return false;
  2853. }
  2854. else {
  2855. defines._needUVs = true;
  2856. defines.DIFFUSE = true;
  2857. }
  2858. }
  2859. if (this._mixTexture2) {
  2860. if (!this._mixTexture2.isReady()) {
  2861. return false;
  2862. }
  2863. else {
  2864. defines.MIXMAP2 = true;
  2865. }
  2866. }
  2867. }
  2868. }
  2869. // Misc.
  2870. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  2871. // Lights
  2872. defines._needNormals = babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  2873. // Values that need to be evaluated on every frame
  2874. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  2875. // Attribs
  2876. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  2877. // Get correct effect
  2878. if (defines.isDirty) {
  2879. defines.markAsProcessed();
  2880. scene.resetCachedMaterial();
  2881. // Fallbacks
  2882. var fallbacks = new babylonjs_1.EffectFallbacks();
  2883. if (defines.FOG) {
  2884. fallbacks.addFallback(1, "FOG");
  2885. }
  2886. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
  2887. if (defines.NUM_BONE_INFLUENCERS > 0) {
  2888. fallbacks.addCPUSkinningFallback(0, mesh);
  2889. }
  2890. //Attributes
  2891. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  2892. if (defines.NORMAL) {
  2893. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  2894. }
  2895. if (defines.UV1) {
  2896. attribs.push(babylonjs_1.VertexBuffer.UVKind);
  2897. }
  2898. if (defines.UV2) {
  2899. attribs.push(babylonjs_1.VertexBuffer.UV2Kind);
  2900. }
  2901. if (defines.VERTEXCOLOR) {
  2902. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  2903. }
  2904. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  2905. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  2906. // Legacy browser patch
  2907. var shaderName = "mix";
  2908. var join = defines.toString();
  2909. var uniforms = [
  2910. "world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
  2911. "vFogInfos", "vFogColor", "pointSize",
  2912. "vTextureInfos",
  2913. "mBones",
  2914. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMatrix",
  2915. "diffuse1Infos", "diffuse2Infos", "diffuse3Infos", "diffuse4Infos",
  2916. "diffuse5Infos", "diffuse6Infos", "diffuse7Infos", "diffuse8Infos"
  2917. ];
  2918. var samplers = [
  2919. "mixMap1Sampler", "mixMap2Sampler",
  2920. "diffuse1Sampler", "diffuse2Sampler", "diffuse3Sampler", "diffuse4Sampler",
  2921. "diffuse5Sampler", "diffuse6Sampler", "diffuse7Sampler", "diffuse8Sampler"
  2922. ];
  2923. var uniformBuffers = new Array();
  2924. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  2925. uniformsNames: uniforms,
  2926. uniformBuffersNames: uniformBuffers,
  2927. samplers: samplers,
  2928. defines: defines,
  2929. maxSimultaneousLights: this.maxSimultaneousLights
  2930. });
  2931. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  2932. attributes: attribs,
  2933. uniformsNames: uniforms,
  2934. uniformBuffersNames: uniformBuffers,
  2935. samplers: samplers,
  2936. defines: join,
  2937. fallbacks: fallbacks,
  2938. onCompiled: this.onCompiled,
  2939. onError: this.onError,
  2940. indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
  2941. }, engine), defines);
  2942. }
  2943. if (!subMesh.effect || !subMesh.effect.isReady()) {
  2944. return false;
  2945. }
  2946. this._renderId = scene.getRenderId();
  2947. this._wasPreviouslyReady = true;
  2948. return true;
  2949. };
  2950. MixMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  2951. var scene = this.getScene();
  2952. var defines = subMesh._materialDefines;
  2953. if (!defines) {
  2954. return;
  2955. }
  2956. var effect = subMesh.effect;
  2957. if (!effect) {
  2958. return;
  2959. }
  2960. this._activeEffect = effect;
  2961. // Matrices
  2962. this.bindOnlyWorldMatrix(world);
  2963. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  2964. // Bones
  2965. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  2966. if (this._mustRebind(scene, effect)) {
  2967. // Textures
  2968. if (this._mixTexture1) {
  2969. this._activeEffect.setTexture("mixMap1Sampler", this._mixTexture1);
  2970. this._activeEffect.setFloat2("vTextureInfos", this._mixTexture1.coordinatesIndex, this._mixTexture1.level);
  2971. this._activeEffect.setMatrix("textureMatrix", this._mixTexture1.getTextureMatrix());
  2972. if (babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  2973. if (this._diffuseTexture1) {
  2974. this._activeEffect.setTexture("diffuse1Sampler", this._diffuseTexture1);
  2975. this._activeEffect.setFloat2("diffuse1Infos", this._diffuseTexture1.uScale, this._diffuseTexture1.vScale);
  2976. }
  2977. if (this._diffuseTexture2) {
  2978. this._activeEffect.setTexture("diffuse2Sampler", this._diffuseTexture2);
  2979. this._activeEffect.setFloat2("diffuse2Infos", this._diffuseTexture2.uScale, this._diffuseTexture2.vScale);
  2980. }
  2981. if (this._diffuseTexture3) {
  2982. this._activeEffect.setTexture("diffuse3Sampler", this._diffuseTexture3);
  2983. this._activeEffect.setFloat2("diffuse3Infos", this._diffuseTexture3.uScale, this._diffuseTexture3.vScale);
  2984. }
  2985. if (this._diffuseTexture4) {
  2986. this._activeEffect.setTexture("diffuse4Sampler", this._diffuseTexture4);
  2987. this._activeEffect.setFloat2("diffuse4Infos", this._diffuseTexture4.uScale, this._diffuseTexture4.vScale);
  2988. }
  2989. }
  2990. }
  2991. if (this._mixTexture2) {
  2992. this._activeEffect.setTexture("mixMap2Sampler", this._mixTexture2);
  2993. if (babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  2994. if (this._diffuseTexture5) {
  2995. this._activeEffect.setTexture("diffuse5Sampler", this._diffuseTexture5);
  2996. this._activeEffect.setFloat2("diffuse5Infos", this._diffuseTexture5.uScale, this._diffuseTexture5.vScale);
  2997. }
  2998. if (this._diffuseTexture6) {
  2999. this._activeEffect.setTexture("diffuse6Sampler", this._diffuseTexture6);
  3000. this._activeEffect.setFloat2("diffuse6Infos", this._diffuseTexture6.uScale, this._diffuseTexture6.vScale);
  3001. }
  3002. if (this._diffuseTexture7) {
  3003. this._activeEffect.setTexture("diffuse7Sampler", this._diffuseTexture7);
  3004. this._activeEffect.setFloat2("diffuse7Infos", this._diffuseTexture7.uScale, this._diffuseTexture7.vScale);
  3005. }
  3006. if (this._diffuseTexture8) {
  3007. this._activeEffect.setTexture("diffuse8Sampler", this._diffuseTexture8);
  3008. this._activeEffect.setFloat2("diffuse8Infos", this._diffuseTexture8.uScale, this._diffuseTexture8.vScale);
  3009. }
  3010. }
  3011. }
  3012. // Clip plane
  3013. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  3014. // Point size
  3015. if (this.pointsCloud) {
  3016. this._activeEffect.setFloat("pointSize", this.pointSize);
  3017. }
  3018. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  3019. }
  3020. this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  3021. if (defines.SPECULARTERM) {
  3022. this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
  3023. }
  3024. if (scene.lightsEnabled && !this.disableLighting) {
  3025. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
  3026. }
  3027. // View
  3028. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  3029. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  3030. }
  3031. // Fog
  3032. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  3033. this._afterBind(mesh, this._activeEffect);
  3034. };
  3035. MixMaterial.prototype.getAnimatables = function () {
  3036. var results = [];
  3037. if (this._mixTexture1 && this._mixTexture1.animations && this._mixTexture1.animations.length > 0) {
  3038. results.push(this._mixTexture1);
  3039. }
  3040. if (this._mixTexture2 && this._mixTexture2.animations && this._mixTexture2.animations.length > 0) {
  3041. results.push(this._mixTexture2);
  3042. }
  3043. return results;
  3044. };
  3045. MixMaterial.prototype.getActiveTextures = function () {
  3046. var activeTextures = _super.prototype.getActiveTextures.call(this);
  3047. // Mix map 1
  3048. if (this._mixTexture1) {
  3049. activeTextures.push(this._mixTexture1);
  3050. }
  3051. if (this._diffuseTexture1) {
  3052. activeTextures.push(this._diffuseTexture1);
  3053. }
  3054. if (this._diffuseTexture2) {
  3055. activeTextures.push(this._diffuseTexture2);
  3056. }
  3057. if (this._diffuseTexture3) {
  3058. activeTextures.push(this._diffuseTexture3);
  3059. }
  3060. if (this._diffuseTexture4) {
  3061. activeTextures.push(this._diffuseTexture4);
  3062. }
  3063. // Mix map 2
  3064. if (this._mixTexture2) {
  3065. activeTextures.push(this._mixTexture2);
  3066. }
  3067. if (this._diffuseTexture5) {
  3068. activeTextures.push(this._diffuseTexture5);
  3069. }
  3070. if (this._diffuseTexture6) {
  3071. activeTextures.push(this._diffuseTexture6);
  3072. }
  3073. if (this._diffuseTexture7) {
  3074. activeTextures.push(this._diffuseTexture7);
  3075. }
  3076. if (this._diffuseTexture8) {
  3077. activeTextures.push(this._diffuseTexture8);
  3078. }
  3079. return activeTextures;
  3080. };
  3081. MixMaterial.prototype.hasTexture = function (texture) {
  3082. if (_super.prototype.hasTexture.call(this, texture)) {
  3083. return true;
  3084. }
  3085. // Mix map 1
  3086. if (this._mixTexture1 === texture) {
  3087. return true;
  3088. }
  3089. if (this._diffuseTexture1 === texture) {
  3090. return true;
  3091. }
  3092. if (this._diffuseTexture2 === texture) {
  3093. return true;
  3094. }
  3095. if (this._diffuseTexture3 === texture) {
  3096. return true;
  3097. }
  3098. if (this._diffuseTexture4 === texture) {
  3099. return true;
  3100. }
  3101. // Mix map 2
  3102. if (this._mixTexture2 === texture) {
  3103. return true;
  3104. }
  3105. if (this._diffuseTexture5 === texture) {
  3106. return true;
  3107. }
  3108. if (this._diffuseTexture6 === texture) {
  3109. return true;
  3110. }
  3111. if (this._diffuseTexture7 === texture) {
  3112. return true;
  3113. }
  3114. if (this._diffuseTexture8 === texture) {
  3115. return true;
  3116. }
  3117. return false;
  3118. };
  3119. MixMaterial.prototype.dispose = function (forceDisposeEffect) {
  3120. if (this._mixTexture1) {
  3121. this._mixTexture1.dispose();
  3122. }
  3123. _super.prototype.dispose.call(this, forceDisposeEffect);
  3124. };
  3125. MixMaterial.prototype.clone = function (name) {
  3126. var _this = this;
  3127. return babylonjs_1.SerializationHelper.Clone(function () { return new MixMaterial(name, _this.getScene()); }, this);
  3128. };
  3129. MixMaterial.prototype.serialize = function () {
  3130. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  3131. serializationObject.customType = "BABYLON.MixMaterial";
  3132. return serializationObject;
  3133. };
  3134. MixMaterial.prototype.getClassName = function () {
  3135. return "MixMaterial";
  3136. };
  3137. // Statics
  3138. MixMaterial.Parse = function (source, scene, rootUrl) {
  3139. return babylonjs_1.SerializationHelper.Parse(function () { return new MixMaterial(source.name, scene); }, source, scene, rootUrl);
  3140. };
  3141. __decorate([
  3142. babylonjs_1.serializeAsTexture("mixTexture1")
  3143. ], MixMaterial.prototype, "_mixTexture1", void 0);
  3144. __decorate([
  3145. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  3146. ], MixMaterial.prototype, "mixTexture1", void 0);
  3147. __decorate([
  3148. babylonjs_1.serializeAsTexture("mixTexture2")
  3149. ], MixMaterial.prototype, "_mixTexture2", void 0);
  3150. __decorate([
  3151. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  3152. ], MixMaterial.prototype, "mixTexture2", void 0);
  3153. __decorate([
  3154. babylonjs_1.serializeAsTexture("diffuseTexture1")
  3155. ], MixMaterial.prototype, "_diffuseTexture1", void 0);
  3156. __decorate([
  3157. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  3158. ], MixMaterial.prototype, "diffuseTexture1", void 0);
  3159. __decorate([
  3160. babylonjs_1.serializeAsTexture("diffuseTexture2")
  3161. ], MixMaterial.prototype, "_diffuseTexture2", void 0);
  3162. __decorate([
  3163. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  3164. ], MixMaterial.prototype, "diffuseTexture2", void 0);
  3165. __decorate([
  3166. babylonjs_1.serializeAsTexture("diffuseTexture3")
  3167. ], MixMaterial.prototype, "_diffuseTexture3", void 0);
  3168. __decorate([
  3169. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  3170. ], MixMaterial.prototype, "diffuseTexture3", void 0);
  3171. __decorate([
  3172. babylonjs_1.serializeAsTexture("diffuseTexture4")
  3173. ], MixMaterial.prototype, "_diffuseTexture4", void 0);
  3174. __decorate([
  3175. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  3176. ], MixMaterial.prototype, "diffuseTexture4", void 0);
  3177. __decorate([
  3178. babylonjs_1.serializeAsTexture("diffuseTexture1")
  3179. ], MixMaterial.prototype, "_diffuseTexture5", void 0);
  3180. __decorate([
  3181. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  3182. ], MixMaterial.prototype, "diffuseTexture5", void 0);
  3183. __decorate([
  3184. babylonjs_1.serializeAsTexture("diffuseTexture2")
  3185. ], MixMaterial.prototype, "_diffuseTexture6", void 0);
  3186. __decorate([
  3187. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  3188. ], MixMaterial.prototype, "diffuseTexture6", void 0);
  3189. __decorate([
  3190. babylonjs_1.serializeAsTexture("diffuseTexture3")
  3191. ], MixMaterial.prototype, "_diffuseTexture7", void 0);
  3192. __decorate([
  3193. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  3194. ], MixMaterial.prototype, "diffuseTexture7", void 0);
  3195. __decorate([
  3196. babylonjs_1.serializeAsTexture("diffuseTexture4")
  3197. ], MixMaterial.prototype, "_diffuseTexture8", void 0);
  3198. __decorate([
  3199. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  3200. ], MixMaterial.prototype, "diffuseTexture8", void 0);
  3201. __decorate([
  3202. babylonjs_1.serializeAsColor3()
  3203. ], MixMaterial.prototype, "diffuseColor", void 0);
  3204. __decorate([
  3205. babylonjs_1.serializeAsColor3()
  3206. ], MixMaterial.prototype, "specularColor", void 0);
  3207. __decorate([
  3208. babylonjs_1.serialize()
  3209. ], MixMaterial.prototype, "specularPower", void 0);
  3210. __decorate([
  3211. babylonjs_1.serialize("disableLighting")
  3212. ], MixMaterial.prototype, "_disableLighting", void 0);
  3213. __decorate([
  3214. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  3215. ], MixMaterial.prototype, "disableLighting", void 0);
  3216. __decorate([
  3217. babylonjs_1.serialize("maxSimultaneousLights")
  3218. ], MixMaterial.prototype, "_maxSimultaneousLights", void 0);
  3219. __decorate([
  3220. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  3221. ], MixMaterial.prototype, "maxSimultaneousLights", void 0);
  3222. return MixMaterial;
  3223. }(babylonjs_1.PushMaterial));
  3224. exports.MixMaterial = MixMaterial;
  3225. /***/ }),
  3226. /***/ "./src/normal/index.ts":
  3227. /*!*****************************!*\
  3228. !*** ./src/normal/index.ts ***!
  3229. \*****************************/
  3230. /*! no static exports found */
  3231. /***/ (function(module, exports, __webpack_require__) {
  3232. "use strict";
  3233. function __export(m) {
  3234. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  3235. }
  3236. Object.defineProperty(exports, "__esModule", { value: true });
  3237. __export(__webpack_require__(/*! ./normalMaterial */ "./src/normal/normalMaterial.ts"));
  3238. /***/ }),
  3239. /***/ "./src/normal/normal.fragment.ts":
  3240. /*!***************************************!*\
  3241. !*** ./src/normal/normal.fragment.ts ***!
  3242. \***************************************/
  3243. /*! no static exports found */
  3244. /***/ (function(module, exports, __webpack_require__) {
  3245. "use strict";
  3246. Object.defineProperty(exports, "__esModule", { value: true });
  3247. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  3248. var name = 'normalPixelShader';
  3249. exports.name = name;
  3250. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0]\n#include<__decl__lightFragment>[1]\n#include<__decl__lightFragment>[2]\n#include<__decl__lightFragment>[3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef NORMAL\nbaseColor=mix(baseColor,vec4(vNormalW,1.0),0.5);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0]\n#include<lightFragment>[1]\n#include<lightFragment>[2]\n#include<lightFragment>[3]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";
  3251. exports.shader = shader;
  3252. babylonjs_1.Effect.ShadersStore[name] = shader;
  3253. /***/ }),
  3254. /***/ "./src/normal/normal.vertex.ts":
  3255. /*!*************************************!*\
  3256. !*** ./src/normal/normal.vertex.ts ***!
  3257. \*************************************/
  3258. /*! no static exports found */
  3259. /***/ (function(module, exports, __webpack_require__) {
  3260. "use strict";
  3261. Object.defineProperty(exports, "__esModule", { value: true });
  3262. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  3263. var name = 'normalVertexShader';
  3264. exports.name = name;
  3265. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  3266. exports.shader = shader;
  3267. babylonjs_1.Effect.ShadersStore[name] = shader;
  3268. /***/ }),
  3269. /***/ "./src/normal/normalMaterial.ts":
  3270. /*!**************************************!*\
  3271. !*** ./src/normal/normalMaterial.ts ***!
  3272. \**************************************/
  3273. /*! no static exports found */
  3274. /***/ (function(module, exports, __webpack_require__) {
  3275. "use strict";
  3276. var __extends = (this && this.__extends) || (function () {
  3277. var extendStatics = function (d, b) {
  3278. extendStatics = Object.setPrototypeOf ||
  3279. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3280. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3281. return extendStatics(d, b);
  3282. }
  3283. return function (d, b) {
  3284. extendStatics(d, b);
  3285. function __() { this.constructor = d; }
  3286. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3287. };
  3288. })();
  3289. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3290. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3291. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  3292. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  3293. return c > 3 && r && Object.defineProperty(target, key, r), r;
  3294. };
  3295. Object.defineProperty(exports, "__esModule", { value: true });
  3296. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  3297. __webpack_require__(/*! ./normal.fragment */ "./src/normal/normal.fragment.ts");
  3298. __webpack_require__(/*! ./normal.vertex */ "./src/normal/normal.vertex.ts");
  3299. var NormalMaterialDefines = /** @class */ (function (_super) {
  3300. __extends(NormalMaterialDefines, _super);
  3301. function NormalMaterialDefines() {
  3302. var _this = _super.call(this) || this;
  3303. _this.DIFFUSE = false;
  3304. _this.CLIPPLANE = false;
  3305. _this.CLIPPLANE2 = false;
  3306. _this.CLIPPLANE3 = false;
  3307. _this.CLIPPLANE4 = false;
  3308. _this.ALPHATEST = false;
  3309. _this.DEPTHPREPASS = false;
  3310. _this.POINTSIZE = false;
  3311. _this.FOG = false;
  3312. _this.LIGHT0 = false;
  3313. _this.LIGHT1 = false;
  3314. _this.LIGHT2 = false;
  3315. _this.LIGHT3 = false;
  3316. _this.SPOTLIGHT0 = false;
  3317. _this.SPOTLIGHT1 = false;
  3318. _this.SPOTLIGHT2 = false;
  3319. _this.SPOTLIGHT3 = false;
  3320. _this.HEMILIGHT0 = false;
  3321. _this.HEMILIGHT1 = false;
  3322. _this.HEMILIGHT2 = false;
  3323. _this.HEMILIGHT3 = false;
  3324. _this.DIRLIGHT0 = false;
  3325. _this.DIRLIGHT1 = false;
  3326. _this.DIRLIGHT2 = false;
  3327. _this.DIRLIGHT3 = false;
  3328. _this.POINTLIGHT0 = false;
  3329. _this.POINTLIGHT1 = false;
  3330. _this.POINTLIGHT2 = false;
  3331. _this.POINTLIGHT3 = false;
  3332. _this.SHADOW0 = false;
  3333. _this.SHADOW1 = false;
  3334. _this.SHADOW2 = false;
  3335. _this.SHADOW3 = false;
  3336. _this.SHADOWS = false;
  3337. _this.SHADOWESM0 = false;
  3338. _this.SHADOWESM1 = false;
  3339. _this.SHADOWESM2 = false;
  3340. _this.SHADOWESM3 = false;
  3341. _this.SHADOWPOISSON0 = false;
  3342. _this.SHADOWPOISSON1 = false;
  3343. _this.SHADOWPOISSON2 = false;
  3344. _this.SHADOWPOISSON3 = false;
  3345. _this.SHADOWPCF0 = false;
  3346. _this.SHADOWPCF1 = false;
  3347. _this.SHADOWPCF2 = false;
  3348. _this.SHADOWPCF3 = false;
  3349. _this.SHADOWPCSS0 = false;
  3350. _this.SHADOWPCSS1 = false;
  3351. _this.SHADOWPCSS2 = false;
  3352. _this.SHADOWPCSS3 = false;
  3353. _this.NORMAL = false;
  3354. _this.UV1 = false;
  3355. _this.UV2 = false;
  3356. _this.VERTEXCOLOR = false;
  3357. _this.VERTEXALPHA = false;
  3358. _this.NUM_BONE_INFLUENCERS = 0;
  3359. _this.BonesPerMesh = 0;
  3360. _this.INSTANCES = false;
  3361. _this.rebuild();
  3362. return _this;
  3363. }
  3364. return NormalMaterialDefines;
  3365. }(babylonjs_1.MaterialDefines));
  3366. var NormalMaterial = /** @class */ (function (_super) {
  3367. __extends(NormalMaterial, _super);
  3368. function NormalMaterial(name, scene) {
  3369. var _this = _super.call(this, name, scene) || this;
  3370. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  3371. _this._disableLighting = false;
  3372. _this._maxSimultaneousLights = 4;
  3373. return _this;
  3374. }
  3375. NormalMaterial.prototype.needAlphaBlending = function () {
  3376. return (this.alpha < 1.0);
  3377. };
  3378. NormalMaterial.prototype.needAlphaTesting = function () {
  3379. return false;
  3380. };
  3381. NormalMaterial.prototype.getAlphaTestTexture = function () {
  3382. return null;
  3383. };
  3384. // Methods
  3385. NormalMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  3386. if (this.isFrozen) {
  3387. if (this._wasPreviouslyReady && subMesh.effect) {
  3388. return true;
  3389. }
  3390. }
  3391. if (!subMesh._materialDefines) {
  3392. subMesh._materialDefines = new NormalMaterialDefines();
  3393. }
  3394. var defines = subMesh._materialDefines;
  3395. var scene = this.getScene();
  3396. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  3397. if (this._renderId === scene.getRenderId()) {
  3398. return true;
  3399. }
  3400. }
  3401. var engine = scene.getEngine();
  3402. // Textures
  3403. if (defines._areTexturesDirty) {
  3404. defines._needUVs = false;
  3405. if (scene.texturesEnabled) {
  3406. if (this._diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  3407. if (!this._diffuseTexture.isReady()) {
  3408. return false;
  3409. }
  3410. else {
  3411. defines._needUVs = true;
  3412. defines.DIFFUSE = true;
  3413. }
  3414. }
  3415. }
  3416. }
  3417. // Misc.
  3418. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  3419. // Lights
  3420. defines._needNormals = babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  3421. // Values that need to be evaluated on every frame
  3422. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  3423. // Attribs
  3424. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  3425. // Get correct effect
  3426. if (defines.isDirty) {
  3427. defines.markAsProcessed();
  3428. scene.resetCachedMaterial();
  3429. // Fallbacks
  3430. var fallbacks = new babylonjs_1.EffectFallbacks();
  3431. if (defines.FOG) {
  3432. fallbacks.addFallback(1, "FOG");
  3433. }
  3434. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks);
  3435. if (defines.NUM_BONE_INFLUENCERS > 0) {
  3436. fallbacks.addCPUSkinningFallback(0, mesh);
  3437. }
  3438. //Attributes
  3439. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  3440. if (defines.NORMAL) {
  3441. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  3442. }
  3443. if (defines.UV1) {
  3444. attribs.push(babylonjs_1.VertexBuffer.UVKind);
  3445. }
  3446. if (defines.UV2) {
  3447. attribs.push(babylonjs_1.VertexBuffer.UV2Kind);
  3448. }
  3449. if (defines.VERTEXCOLOR) {
  3450. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  3451. }
  3452. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  3453. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  3454. var shaderName = "normal";
  3455. var join = defines.toString();
  3456. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
  3457. "vFogInfos", "vFogColor", "pointSize",
  3458. "vDiffuseInfos",
  3459. "mBones",
  3460. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix"
  3461. ];
  3462. var samplers = ["diffuseSampler"];
  3463. var uniformBuffers = new Array();
  3464. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  3465. uniformsNames: uniforms,
  3466. uniformBuffersNames: uniformBuffers,
  3467. samplers: samplers,
  3468. defines: defines,
  3469. maxSimultaneousLights: 4
  3470. });
  3471. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  3472. attributes: attribs,
  3473. uniformsNames: uniforms,
  3474. uniformBuffersNames: uniformBuffers,
  3475. samplers: samplers,
  3476. defines: join,
  3477. fallbacks: fallbacks,
  3478. onCompiled: this.onCompiled,
  3479. onError: this.onError,
  3480. indexParameters: { maxSimultaneousLights: 4 }
  3481. }, engine), defines);
  3482. }
  3483. if (!subMesh.effect || !subMesh.effect.isReady()) {
  3484. return false;
  3485. }
  3486. this._renderId = scene.getRenderId();
  3487. this._wasPreviouslyReady = true;
  3488. return true;
  3489. };
  3490. NormalMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  3491. var scene = this.getScene();
  3492. var defines = subMesh._materialDefines;
  3493. if (!defines) {
  3494. return;
  3495. }
  3496. var effect = subMesh.effect;
  3497. if (!effect) {
  3498. return;
  3499. }
  3500. this._activeEffect = effect;
  3501. // Matrices
  3502. this.bindOnlyWorldMatrix(world);
  3503. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  3504. // Bones
  3505. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  3506. if (this._mustRebind(scene, effect)) {
  3507. // Textures
  3508. if (this.diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  3509. this._activeEffect.setTexture("diffuseSampler", this.diffuseTexture);
  3510. this._activeEffect.setFloat2("vDiffuseInfos", this.diffuseTexture.coordinatesIndex, this.diffuseTexture.level);
  3511. this._activeEffect.setMatrix("diffuseMatrix", this.diffuseTexture.getTextureMatrix());
  3512. }
  3513. // Clip plane
  3514. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  3515. // Point size
  3516. if (this.pointsCloud) {
  3517. this._activeEffect.setFloat("pointSize", this.pointSize);
  3518. }
  3519. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  3520. }
  3521. this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  3522. // Lights
  3523. if (scene.lightsEnabled && !this.disableLighting) {
  3524. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines);
  3525. }
  3526. // View
  3527. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  3528. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  3529. }
  3530. // Fog
  3531. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  3532. this._afterBind(mesh, this._activeEffect);
  3533. };
  3534. NormalMaterial.prototype.getAnimatables = function () {
  3535. var results = [];
  3536. if (this.diffuseTexture && this.diffuseTexture.animations && this.diffuseTexture.animations.length > 0) {
  3537. results.push(this.diffuseTexture);
  3538. }
  3539. return results;
  3540. };
  3541. NormalMaterial.prototype.getActiveTextures = function () {
  3542. var activeTextures = _super.prototype.getActiveTextures.call(this);
  3543. if (this._diffuseTexture) {
  3544. activeTextures.push(this._diffuseTexture);
  3545. }
  3546. return activeTextures;
  3547. };
  3548. NormalMaterial.prototype.hasTexture = function (texture) {
  3549. if (_super.prototype.hasTexture.call(this, texture)) {
  3550. return true;
  3551. }
  3552. if (this.diffuseTexture === texture) {
  3553. return true;
  3554. }
  3555. return false;
  3556. };
  3557. NormalMaterial.prototype.dispose = function (forceDisposeEffect) {
  3558. if (this.diffuseTexture) {
  3559. this.diffuseTexture.dispose();
  3560. }
  3561. _super.prototype.dispose.call(this, forceDisposeEffect);
  3562. };
  3563. NormalMaterial.prototype.clone = function (name) {
  3564. var _this = this;
  3565. return babylonjs_1.SerializationHelper.Clone(function () { return new NormalMaterial(name, _this.getScene()); }, this);
  3566. };
  3567. NormalMaterial.prototype.serialize = function () {
  3568. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  3569. serializationObject.customType = "BABYLON.NormalMaterial";
  3570. return serializationObject;
  3571. };
  3572. NormalMaterial.prototype.getClassName = function () {
  3573. return "NormalMaterial";
  3574. };
  3575. // Statics
  3576. NormalMaterial.Parse = function (source, scene, rootUrl) {
  3577. return babylonjs_1.SerializationHelper.Parse(function () { return new NormalMaterial(source.name, scene); }, source, scene, rootUrl);
  3578. };
  3579. __decorate([
  3580. babylonjs_1.serializeAsTexture("diffuseTexture")
  3581. ], NormalMaterial.prototype, "_diffuseTexture", void 0);
  3582. __decorate([
  3583. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  3584. ], NormalMaterial.prototype, "diffuseTexture", void 0);
  3585. __decorate([
  3586. babylonjs_1.serializeAsColor3()
  3587. ], NormalMaterial.prototype, "diffuseColor", void 0);
  3588. __decorate([
  3589. babylonjs_1.serialize("disableLighting")
  3590. ], NormalMaterial.prototype, "_disableLighting", void 0);
  3591. __decorate([
  3592. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  3593. ], NormalMaterial.prototype, "disableLighting", void 0);
  3594. __decorate([
  3595. babylonjs_1.serialize("maxSimultaneousLights")
  3596. ], NormalMaterial.prototype, "_maxSimultaneousLights", void 0);
  3597. __decorate([
  3598. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  3599. ], NormalMaterial.prototype, "maxSimultaneousLights", void 0);
  3600. return NormalMaterial;
  3601. }(babylonjs_1.PushMaterial));
  3602. exports.NormalMaterial = NormalMaterial;
  3603. /***/ }),
  3604. /***/ "./src/shadowOnly/index.ts":
  3605. /*!*********************************!*\
  3606. !*** ./src/shadowOnly/index.ts ***!
  3607. \*********************************/
  3608. /*! no static exports found */
  3609. /***/ (function(module, exports, __webpack_require__) {
  3610. "use strict";
  3611. function __export(m) {
  3612. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  3613. }
  3614. Object.defineProperty(exports, "__esModule", { value: true });
  3615. __export(__webpack_require__(/*! ./shadowOnlyMaterial */ "./src/shadowOnly/shadowOnlyMaterial.ts"));
  3616. /***/ }),
  3617. /***/ "./src/shadowOnly/shadowOnly.fragment.ts":
  3618. /*!***********************************************!*\
  3619. !*** ./src/shadowOnly/shadowOnly.fragment.ts ***!
  3620. \***********************************************/
  3621. /*! no static exports found */
  3622. /***/ (function(module, exports, __webpack_require__) {
  3623. "use strict";
  3624. Object.defineProperty(exports, "__esModule", { value: true });
  3625. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  3626. var name = 'shadowOnlyPixelShader';
  3627. exports.name = name;
  3628. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform float alpha;\nuniform vec3 shadowColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#include<lightFragment>[0..1]\n\nvec4 color=vec4(shadowColor,(1.0-clamp(shadow,0.,1.))*alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";
  3629. exports.shader = shader;
  3630. babylonjs_1.Effect.ShadersStore[name] = shader;
  3631. /***/ }),
  3632. /***/ "./src/shadowOnly/shadowOnly.vertex.ts":
  3633. /*!*********************************************!*\
  3634. !*** ./src/shadowOnly/shadowOnly.vertex.ts ***!
  3635. \*********************************************/
  3636. /*! no static exports found */
  3637. /***/ (function(module, exports, __webpack_require__) {
  3638. "use strict";
  3639. Object.defineProperty(exports, "__esModule", { value: true });
  3640. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  3641. var name = 'shadowOnlyVertexShader';
  3642. exports.name = name;
  3643. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  3644. exports.shader = shader;
  3645. babylonjs_1.Effect.ShadersStore[name] = shader;
  3646. /***/ }),
  3647. /***/ "./src/shadowOnly/shadowOnlyMaterial.ts":
  3648. /*!**********************************************!*\
  3649. !*** ./src/shadowOnly/shadowOnlyMaterial.ts ***!
  3650. \**********************************************/
  3651. /*! no static exports found */
  3652. /***/ (function(module, exports, __webpack_require__) {
  3653. "use strict";
  3654. var __extends = (this && this.__extends) || (function () {
  3655. var extendStatics = function (d, b) {
  3656. extendStatics = Object.setPrototypeOf ||
  3657. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3658. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3659. return extendStatics(d, b);
  3660. }
  3661. return function (d, b) {
  3662. extendStatics(d, b);
  3663. function __() { this.constructor = d; }
  3664. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3665. };
  3666. })();
  3667. Object.defineProperty(exports, "__esModule", { value: true });
  3668. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  3669. __webpack_require__(/*! ./shadowOnly.fragment */ "./src/shadowOnly/shadowOnly.fragment.ts");
  3670. __webpack_require__(/*! ./shadowOnly.vertex */ "./src/shadowOnly/shadowOnly.vertex.ts");
  3671. var ShadowOnlyMaterialDefines = /** @class */ (function (_super) {
  3672. __extends(ShadowOnlyMaterialDefines, _super);
  3673. function ShadowOnlyMaterialDefines() {
  3674. var _this = _super.call(this) || this;
  3675. _this.CLIPPLANE = false;
  3676. _this.CLIPPLANE2 = false;
  3677. _this.CLIPPLANE3 = false;
  3678. _this.CLIPPLANE4 = false;
  3679. _this.POINTSIZE = false;
  3680. _this.FOG = false;
  3681. _this.NORMAL = false;
  3682. _this.NUM_BONE_INFLUENCERS = 0;
  3683. _this.BonesPerMesh = 0;
  3684. _this.INSTANCES = false;
  3685. _this.rebuild();
  3686. return _this;
  3687. }
  3688. return ShadowOnlyMaterialDefines;
  3689. }(babylonjs_1.MaterialDefines));
  3690. var ShadowOnlyMaterial = /** @class */ (function (_super) {
  3691. __extends(ShadowOnlyMaterial, _super);
  3692. function ShadowOnlyMaterial(name, scene) {
  3693. var _this = _super.call(this, name, scene) || this;
  3694. _this.shadowColor = BABYLON.Color3.Black();
  3695. return _this;
  3696. }
  3697. ShadowOnlyMaterial.prototype.needAlphaBlending = function () {
  3698. return true;
  3699. };
  3700. ShadowOnlyMaterial.prototype.needAlphaTesting = function () {
  3701. return false;
  3702. };
  3703. ShadowOnlyMaterial.prototype.getAlphaTestTexture = function () {
  3704. return null;
  3705. };
  3706. Object.defineProperty(ShadowOnlyMaterial.prototype, "activeLight", {
  3707. get: function () {
  3708. return this._activeLight;
  3709. },
  3710. set: function (light) {
  3711. this._activeLight = light;
  3712. },
  3713. enumerable: true,
  3714. configurable: true
  3715. });
  3716. // Methods
  3717. ShadowOnlyMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  3718. if (this.isFrozen) {
  3719. if (this._wasPreviouslyReady && subMesh.effect) {
  3720. return true;
  3721. }
  3722. }
  3723. if (!subMesh._materialDefines) {
  3724. subMesh._materialDefines = new ShadowOnlyMaterialDefines();
  3725. }
  3726. var defines = subMesh._materialDefines;
  3727. var scene = this.getScene();
  3728. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  3729. if (this._renderId === scene.getRenderId()) {
  3730. return true;
  3731. }
  3732. }
  3733. var engine = scene.getEngine();
  3734. // Ensure that active light is the first shadow light
  3735. if (this._activeLight) {
  3736. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  3737. var light = _a[_i];
  3738. if (light.shadowEnabled) {
  3739. if (this._activeLight === light) {
  3740. break; // We are good
  3741. }
  3742. var lightPosition = mesh._lightSources.indexOf(this._activeLight);
  3743. if (lightPosition !== -1) {
  3744. mesh._lightSources.splice(lightPosition, 1);
  3745. mesh._lightSources.splice(0, 0, this._activeLight);
  3746. }
  3747. break;
  3748. }
  3749. }
  3750. }
  3751. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  3752. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  3753. defines._needNormals = babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, 1);
  3754. // Attribs
  3755. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, false, true);
  3756. // Get correct effect
  3757. if (defines.isDirty) {
  3758. defines.markAsProcessed();
  3759. scene.resetCachedMaterial();
  3760. // Fallbacks
  3761. var fallbacks = new babylonjs_1.EffectFallbacks();
  3762. if (defines.FOG) {
  3763. fallbacks.addFallback(1, "FOG");
  3764. }
  3765. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, 1);
  3766. if (defines.NUM_BONE_INFLUENCERS > 0) {
  3767. fallbacks.addCPUSkinningFallback(0, mesh);
  3768. }
  3769. //Attributes
  3770. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  3771. if (defines.NORMAL) {
  3772. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  3773. }
  3774. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  3775. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  3776. var shaderName = "shadowOnly";
  3777. var join = defines.toString();
  3778. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  3779. "vFogInfos", "vFogColor", "pointSize", "alpha", "shadowColor",
  3780. "mBones",
  3781. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4"
  3782. ];
  3783. var samplers = new Array();
  3784. var uniformBuffers = new Array();
  3785. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  3786. uniformsNames: uniforms,
  3787. uniformBuffersNames: uniformBuffers,
  3788. samplers: samplers,
  3789. defines: defines,
  3790. maxSimultaneousLights: 1
  3791. });
  3792. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  3793. attributes: attribs,
  3794. uniformsNames: uniforms,
  3795. uniformBuffersNames: uniformBuffers,
  3796. samplers: samplers,
  3797. defines: join,
  3798. fallbacks: fallbacks,
  3799. onCompiled: this.onCompiled,
  3800. onError: this.onError,
  3801. indexParameters: { maxSimultaneousLights: 1 }
  3802. }, engine), defines);
  3803. }
  3804. if (!subMesh.effect || !subMesh.effect.isReady()) {
  3805. return false;
  3806. }
  3807. this._renderId = scene.getRenderId();
  3808. this._wasPreviouslyReady = true;
  3809. return true;
  3810. };
  3811. ShadowOnlyMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  3812. var scene = this.getScene();
  3813. var defines = subMesh._materialDefines;
  3814. if (!defines) {
  3815. return;
  3816. }
  3817. var effect = subMesh.effect;
  3818. if (!effect) {
  3819. return;
  3820. }
  3821. this._activeEffect = effect;
  3822. // Matrices
  3823. this.bindOnlyWorldMatrix(world);
  3824. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  3825. // Bones
  3826. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  3827. if (this._mustRebind(scene, effect)) {
  3828. // Clip plane
  3829. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  3830. // Point size
  3831. if (this.pointsCloud) {
  3832. this._activeEffect.setFloat("pointSize", this.pointSize);
  3833. }
  3834. this._activeEffect.setFloat("alpha", this.alpha);
  3835. this._activeEffect.setColor3("shadowColor", this.shadowColor);
  3836. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  3837. }
  3838. // Lights
  3839. if (scene.lightsEnabled) {
  3840. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, 1);
  3841. }
  3842. // View
  3843. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  3844. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  3845. }
  3846. // Fog
  3847. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  3848. this._afterBind(mesh, this._activeEffect);
  3849. };
  3850. ShadowOnlyMaterial.prototype.clone = function (name) {
  3851. var _this = this;
  3852. return babylonjs_1.SerializationHelper.Clone(function () { return new ShadowOnlyMaterial(name, _this.getScene()); }, this);
  3853. };
  3854. ShadowOnlyMaterial.prototype.serialize = function () {
  3855. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  3856. serializationObject.customType = "BABYLON.ShadowOnlyMaterial";
  3857. return serializationObject;
  3858. };
  3859. ShadowOnlyMaterial.prototype.getClassName = function () {
  3860. return "ShadowOnlyMaterial";
  3861. };
  3862. // Statics
  3863. ShadowOnlyMaterial.Parse = function (source, scene, rootUrl) {
  3864. return babylonjs_1.SerializationHelper.Parse(function () { return new ShadowOnlyMaterial(source.name, scene); }, source, scene, rootUrl);
  3865. };
  3866. return ShadowOnlyMaterial;
  3867. }(babylonjs_1.PushMaterial));
  3868. exports.ShadowOnlyMaterial = ShadowOnlyMaterial;
  3869. /***/ }),
  3870. /***/ "./src/simple/index.ts":
  3871. /*!*****************************!*\
  3872. !*** ./src/simple/index.ts ***!
  3873. \*****************************/
  3874. /*! no static exports found */
  3875. /***/ (function(module, exports, __webpack_require__) {
  3876. "use strict";
  3877. function __export(m) {
  3878. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  3879. }
  3880. Object.defineProperty(exports, "__esModule", { value: true });
  3881. __export(__webpack_require__(/*! ./simpleMaterial */ "./src/simple/simpleMaterial.ts"));
  3882. /***/ }),
  3883. /***/ "./src/simple/simple.fragment.ts":
  3884. /*!***************************************!*\
  3885. !*** ./src/simple/simple.fragment.ts ***!
  3886. \***************************************/
  3887. /*! no static exports found */
  3888. /***/ (function(module, exports, __webpack_require__) {
  3889. "use strict";
  3890. Object.defineProperty(exports, "__esModule", { value: true });
  3891. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  3892. var name = 'simplePixelShader';
  3893. exports.name = name;
  3894. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}";
  3895. exports.shader = shader;
  3896. babylonjs_1.Effect.ShadersStore[name] = shader;
  3897. /***/ }),
  3898. /***/ "./src/simple/simple.vertex.ts":
  3899. /*!*************************************!*\
  3900. !*** ./src/simple/simple.vertex.ts ***!
  3901. \*************************************/
  3902. /*! no static exports found */
  3903. /***/ (function(module, exports, __webpack_require__) {
  3904. "use strict";
  3905. Object.defineProperty(exports, "__esModule", { value: true });
  3906. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  3907. var name = 'simpleVertexShader';
  3908. exports.name = name;
  3909. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  3910. exports.shader = shader;
  3911. babylonjs_1.Effect.ShadersStore[name] = shader;
  3912. /***/ }),
  3913. /***/ "./src/simple/simpleMaterial.ts":
  3914. /*!**************************************!*\
  3915. !*** ./src/simple/simpleMaterial.ts ***!
  3916. \**************************************/
  3917. /*! no static exports found */
  3918. /***/ (function(module, exports, __webpack_require__) {
  3919. "use strict";
  3920. var __extends = (this && this.__extends) || (function () {
  3921. var extendStatics = function (d, b) {
  3922. extendStatics = Object.setPrototypeOf ||
  3923. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3924. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3925. return extendStatics(d, b);
  3926. }
  3927. return function (d, b) {
  3928. extendStatics(d, b);
  3929. function __() { this.constructor = d; }
  3930. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3931. };
  3932. })();
  3933. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  3934. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3935. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  3936. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  3937. return c > 3 && r && Object.defineProperty(target, key, r), r;
  3938. };
  3939. Object.defineProperty(exports, "__esModule", { value: true });
  3940. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  3941. __webpack_require__(/*! ./simple.fragment */ "./src/simple/simple.fragment.ts");
  3942. __webpack_require__(/*! ./simple.vertex */ "./src/simple/simple.vertex.ts");
  3943. var SimpleMaterialDefines = /** @class */ (function (_super) {
  3944. __extends(SimpleMaterialDefines, _super);
  3945. function SimpleMaterialDefines() {
  3946. var _this = _super.call(this) || this;
  3947. _this.DIFFUSE = false;
  3948. _this.CLIPPLANE = false;
  3949. _this.CLIPPLANE2 = false;
  3950. _this.CLIPPLANE3 = false;
  3951. _this.CLIPPLANE4 = false;
  3952. _this.ALPHATEST = false;
  3953. _this.DEPTHPREPASS = false;
  3954. _this.POINTSIZE = false;
  3955. _this.FOG = false;
  3956. _this.NORMAL = false;
  3957. _this.UV1 = false;
  3958. _this.UV2 = false;
  3959. _this.VERTEXCOLOR = false;
  3960. _this.VERTEXALPHA = false;
  3961. _this.NUM_BONE_INFLUENCERS = 0;
  3962. _this.BonesPerMesh = 0;
  3963. _this.INSTANCES = false;
  3964. _this.rebuild();
  3965. return _this;
  3966. }
  3967. return SimpleMaterialDefines;
  3968. }(babylonjs_1.MaterialDefines));
  3969. var SimpleMaterial = /** @class */ (function (_super) {
  3970. __extends(SimpleMaterial, _super);
  3971. function SimpleMaterial(name, scene) {
  3972. var _this = _super.call(this, name, scene) || this;
  3973. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  3974. _this._disableLighting = false;
  3975. _this._maxSimultaneousLights = 4;
  3976. return _this;
  3977. }
  3978. SimpleMaterial.prototype.needAlphaBlending = function () {
  3979. return (this.alpha < 1.0);
  3980. };
  3981. SimpleMaterial.prototype.needAlphaTesting = function () {
  3982. return false;
  3983. };
  3984. SimpleMaterial.prototype.getAlphaTestTexture = function () {
  3985. return null;
  3986. };
  3987. // Methods
  3988. SimpleMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  3989. if (this.isFrozen) {
  3990. if (this._wasPreviouslyReady && subMesh.effect) {
  3991. return true;
  3992. }
  3993. }
  3994. if (!subMesh._materialDefines) {
  3995. subMesh._materialDefines = new SimpleMaterialDefines();
  3996. }
  3997. var defines = subMesh._materialDefines;
  3998. var scene = this.getScene();
  3999. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  4000. if (this._renderId === scene.getRenderId()) {
  4001. return true;
  4002. }
  4003. }
  4004. var engine = scene.getEngine();
  4005. // Textures
  4006. if (defines._areTexturesDirty) {
  4007. defines._needUVs = false;
  4008. if (scene.texturesEnabled) {
  4009. if (this._diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  4010. if (!this._diffuseTexture.isReady()) {
  4011. return false;
  4012. }
  4013. else {
  4014. defines._needUVs = true;
  4015. defines.DIFFUSE = true;
  4016. }
  4017. }
  4018. }
  4019. }
  4020. // Misc.
  4021. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  4022. // Lights
  4023. defines._needNormals = babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  4024. // Values that need to be evaluated on every frame
  4025. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  4026. // Attribs
  4027. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  4028. // Get correct effect
  4029. if (defines.isDirty) {
  4030. defines.markAsProcessed();
  4031. scene.resetCachedMaterial();
  4032. // Fallbacks
  4033. var fallbacks = new babylonjs_1.EffectFallbacks();
  4034. if (defines.FOG) {
  4035. fallbacks.addFallback(1, "FOG");
  4036. }
  4037. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
  4038. if (defines.NUM_BONE_INFLUENCERS > 0) {
  4039. fallbacks.addCPUSkinningFallback(0, mesh);
  4040. }
  4041. //Attributes
  4042. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  4043. if (defines.NORMAL) {
  4044. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  4045. }
  4046. if (defines.UV1) {
  4047. attribs.push(babylonjs_1.VertexBuffer.UVKind);
  4048. }
  4049. if (defines.UV2) {
  4050. attribs.push(babylonjs_1.VertexBuffer.UV2Kind);
  4051. }
  4052. if (defines.VERTEXCOLOR) {
  4053. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  4054. }
  4055. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  4056. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  4057. var shaderName = "simple";
  4058. var join = defines.toString();
  4059. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor",
  4060. "vFogInfos", "vFogColor", "pointSize",
  4061. "vDiffuseInfos",
  4062. "mBones",
  4063. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix"
  4064. ];
  4065. var samplers = ["diffuseSampler"];
  4066. var uniformBuffers = new Array();
  4067. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  4068. uniformsNames: uniforms,
  4069. uniformBuffersNames: uniformBuffers,
  4070. samplers: samplers,
  4071. defines: defines,
  4072. maxSimultaneousLights: this.maxSimultaneousLights
  4073. });
  4074. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  4075. attributes: attribs,
  4076. uniformsNames: uniforms,
  4077. uniformBuffersNames: uniformBuffers,
  4078. samplers: samplers,
  4079. defines: join,
  4080. fallbacks: fallbacks,
  4081. onCompiled: this.onCompiled,
  4082. onError: this.onError,
  4083. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights - 1 }
  4084. }, engine), defines);
  4085. }
  4086. if (!subMesh.effect || !subMesh.effect.isReady()) {
  4087. return false;
  4088. }
  4089. this._renderId = scene.getRenderId();
  4090. this._wasPreviouslyReady = true;
  4091. return true;
  4092. };
  4093. SimpleMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  4094. var scene = this.getScene();
  4095. var defines = subMesh._materialDefines;
  4096. if (!defines) {
  4097. return;
  4098. }
  4099. var effect = subMesh.effect;
  4100. if (!effect) {
  4101. return;
  4102. }
  4103. this._activeEffect = effect;
  4104. // Matrices
  4105. this.bindOnlyWorldMatrix(world);
  4106. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  4107. // Bones
  4108. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  4109. if (this._mustRebind(scene, effect)) {
  4110. // Textures
  4111. if (this._diffuseTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  4112. this._activeEffect.setTexture("diffuseSampler", this._diffuseTexture);
  4113. this._activeEffect.setFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  4114. this._activeEffect.setMatrix("diffuseMatrix", this._diffuseTexture.getTextureMatrix());
  4115. }
  4116. // Clip plane
  4117. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  4118. // Point size
  4119. if (this.pointsCloud) {
  4120. this._activeEffect.setFloat("pointSize", this.pointSize);
  4121. }
  4122. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  4123. }
  4124. this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  4125. // Lights
  4126. if (scene.lightsEnabled && !this.disableLighting) {
  4127. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
  4128. }
  4129. // View
  4130. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  4131. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  4132. }
  4133. // Fog
  4134. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  4135. this._afterBind(mesh, this._activeEffect);
  4136. };
  4137. SimpleMaterial.prototype.getAnimatables = function () {
  4138. var results = [];
  4139. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  4140. results.push(this._diffuseTexture);
  4141. }
  4142. return results;
  4143. };
  4144. SimpleMaterial.prototype.getActiveTextures = function () {
  4145. var activeTextures = _super.prototype.getActiveTextures.call(this);
  4146. if (this._diffuseTexture) {
  4147. activeTextures.push(this._diffuseTexture);
  4148. }
  4149. return activeTextures;
  4150. };
  4151. SimpleMaterial.prototype.hasTexture = function (texture) {
  4152. if (_super.prototype.hasTexture.call(this, texture)) {
  4153. return true;
  4154. }
  4155. if (this.diffuseTexture === texture) {
  4156. return true;
  4157. }
  4158. return false;
  4159. };
  4160. SimpleMaterial.prototype.dispose = function (forceDisposeEffect) {
  4161. if (this._diffuseTexture) {
  4162. this._diffuseTexture.dispose();
  4163. }
  4164. _super.prototype.dispose.call(this, forceDisposeEffect);
  4165. };
  4166. SimpleMaterial.prototype.clone = function (name) {
  4167. var _this = this;
  4168. return babylonjs_1.SerializationHelper.Clone(function () { return new SimpleMaterial(name, _this.getScene()); }, this);
  4169. };
  4170. SimpleMaterial.prototype.serialize = function () {
  4171. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  4172. serializationObject.customType = "BABYLON.SimpleMaterial";
  4173. return serializationObject;
  4174. };
  4175. SimpleMaterial.prototype.getClassName = function () {
  4176. return "SimpleMaterial";
  4177. };
  4178. // Statics
  4179. SimpleMaterial.Parse = function (source, scene, rootUrl) {
  4180. return babylonjs_1.SerializationHelper.Parse(function () { return new SimpleMaterial(source.name, scene); }, source, scene, rootUrl);
  4181. };
  4182. __decorate([
  4183. babylonjs_1.serializeAsTexture("diffuseTexture")
  4184. ], SimpleMaterial.prototype, "_diffuseTexture", void 0);
  4185. __decorate([
  4186. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  4187. ], SimpleMaterial.prototype, "diffuseTexture", void 0);
  4188. __decorate([
  4189. babylonjs_1.serializeAsColor3("diffuse")
  4190. ], SimpleMaterial.prototype, "diffuseColor", void 0);
  4191. __decorate([
  4192. babylonjs_1.serialize("disableLighting")
  4193. ], SimpleMaterial.prototype, "_disableLighting", void 0);
  4194. __decorate([
  4195. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  4196. ], SimpleMaterial.prototype, "disableLighting", void 0);
  4197. __decorate([
  4198. babylonjs_1.serialize("maxSimultaneousLights")
  4199. ], SimpleMaterial.prototype, "_maxSimultaneousLights", void 0);
  4200. __decorate([
  4201. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  4202. ], SimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  4203. return SimpleMaterial;
  4204. }(babylonjs_1.PushMaterial));
  4205. exports.SimpleMaterial = SimpleMaterial;
  4206. /***/ }),
  4207. /***/ "./src/sky/index.ts":
  4208. /*!**************************!*\
  4209. !*** ./src/sky/index.ts ***!
  4210. \**************************/
  4211. /*! no static exports found */
  4212. /***/ (function(module, exports, __webpack_require__) {
  4213. "use strict";
  4214. function __export(m) {
  4215. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  4216. }
  4217. Object.defineProperty(exports, "__esModule", { value: true });
  4218. __export(__webpack_require__(/*! ./skyMaterial */ "./src/sky/skyMaterial.ts"));
  4219. /***/ }),
  4220. /***/ "./src/sky/sky.fragment.ts":
  4221. /*!*********************************!*\
  4222. !*** ./src/sky/sky.fragment.ts ***!
  4223. \*********************************/
  4224. /*! no static exports found */
  4225. /***/ (function(module, exports, __webpack_require__) {
  4226. "use strict";
  4227. Object.defineProperty(exports, "__esModule", { value: true });
  4228. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  4229. var name = 'skyPixelShader';
  4230. exports.name = name;
  4231. var shader = "precision highp float;\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneFragmentDeclaration>\n\nuniform vec3 cameraPosition;\nuniform float luminance;\nuniform float turbidity;\nuniform float rayleigh;\nuniform float mieCoefficient;\nuniform float mieDirectionalG;\nuniform vec3 sunPosition;\n\n#include<fogFragmentDeclaration>\n\nconst float e=2.71828182845904523536028747135266249775724709369995957;\nconst float pi=3.141592653589793238462643383279502884197169;\nconst float n=1.0003;\nconst float N=2.545E25;\nconst float pn=0.035;\nconst vec3 lambda=vec3(680E-9,550E-9,450E-9);\nconst vec3 K=vec3(0.686,0.678,0.666);\nconst float v=4.0;\nconst float rayleighZenithLength=8.4E3;\nconst float mieZenithLength=1.25E3;\nconst vec3 up=vec3(0.0,1.0,0.0);\nconst float EE=1000.0;\nconst float sunAngularDiameterCos=0.999956676946448443553574619906976478926848692873900859324;\nconst float cutoffAngle=pi/1.95;\nconst float steepness=1.5;\nvec3 totalRayleigh(vec3 lambda)\n{\nreturn (8.0*pow(pi,3.0)*pow(pow(n,2.0)-1.0,2.0)*(6.0+3.0*pn))/(3.0*N*pow(lambda,vec3(4.0))*(6.0-7.0*pn));\n}\nvec3 simplifiedRayleigh()\n{\nreturn 0.0005/vec3(94,40,18);\n}\nfloat rayleighPhase(float cosTheta)\n{\nreturn (3.0/(16.0*pi))*(1.0+pow(cosTheta,2.0));\n}\nvec3 totalMie(vec3 lambda,vec3 K,float T)\n{\nfloat c=(0.2*T )*10E-18;\nreturn 0.434*c*pi*pow((2.0*pi)/lambda,vec3(v-2.0))*K;\n}\nfloat hgPhase(float cosTheta,float g)\n{\nreturn (1.0/(4.0*pi))*((1.0-pow(g,2.0))/pow(1.0-2.0*g*cosTheta+pow(g,2.0),1.5));\n}\nfloat sunIntensity(float zenithAngleCos)\n{\nreturn EE*max(0.0,1.0-exp((-(cutoffAngle-acos(zenithAngleCos))/steepness)));\n}\nfloat A=0.15;\nfloat B=0.50;\nfloat C=0.10;\nfloat D=0.20;\nfloat EEE=0.02;\nfloat F=0.30;\nfloat W=1000.0;\nvec3 Uncharted2Tonemap(vec3 x)\n{\nreturn ((x*(A*x+C*B)+D*EEE)/(x*(A*x+B)+D*F))-EEE/F;\n}\nvoid main(void) {\n\n#include<clipPlaneFragment>\n\nfloat sunfade=1.0-clamp(1.0-exp((sunPosition.y/450000.0)),0.0,1.0);\nfloat rayleighCoefficient=rayleigh-(1.0*(1.0-sunfade));\nvec3 sunDirection=normalize(sunPosition);\nfloat sunE=sunIntensity(dot(sunDirection,up));\nvec3 betaR=simplifiedRayleigh()*rayleighCoefficient;\nvec3 betaM=totalMie(lambda,K,turbidity)*mieCoefficient;\nfloat zenithAngle=acos(max(0.0,dot(up,normalize(vPositionW-cameraPosition))));\nfloat sR=rayleighZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nfloat sM=mieZenithLength/(cos(zenithAngle)+0.15*pow(93.885-((zenithAngle*180.0)/pi),-1.253));\nvec3 Fex=exp(-(betaR*sR+betaM*sM));\nfloat cosTheta=dot(normalize(vPositionW-cameraPosition),sunDirection);\nfloat rPhase=rayleighPhase(cosTheta*0.5+0.5);\nvec3 betaRTheta=betaR*rPhase;\nfloat mPhase=hgPhase(cosTheta,mieDirectionalG);\nvec3 betaMTheta=betaM*mPhase;\nvec3 Lin=pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*(1.0-Fex),vec3(1.5));\nLin*=mix(vec3(1.0),pow(sunE*((betaRTheta+betaMTheta)/(betaR+betaM))*Fex,vec3(1.0/2.0)),clamp(pow(1.0-dot(up,sunDirection),5.0),0.0,1.0));\nvec3 direction=normalize(vPositionW-cameraPosition);\nfloat theta=acos(direction.y);\nfloat phi=atan(direction.z,direction.x);\nvec2 uv=vec2(phi,theta)/vec2(2.0*pi,pi)+vec2(0.5,0.0);\nvec3 L0=vec3(0.1)*Fex;\nfloat sundisk=smoothstep(sunAngularDiameterCos,sunAngularDiameterCos+0.00002,cosTheta);\nL0+=(sunE*19000.0*Fex)*sundisk;\nvec3 whiteScale=1.0/Uncharted2Tonemap(vec3(W));\nvec3 texColor=(Lin+L0);\ntexColor*=0.04 ;\ntexColor+=vec3(0.0,0.001,0.0025)*0.3;\nfloat g_fMaxLuminance=1.0;\nfloat fLumScaled=0.1/luminance;\nfloat fLumCompressed=(fLumScaled*(1.0+(fLumScaled/(g_fMaxLuminance*g_fMaxLuminance))))/(1.0+fLumScaled);\nfloat ExposureBias=fLumCompressed;\nvec3 curr=Uncharted2Tonemap((log2(2.0/pow(luminance,4.0)))*texColor);\n\n\n\nvec3 retColor=curr*whiteScale;\n\n\nfloat alpha=1.0;\n#ifdef VERTEXCOLOR\nretColor.rgb*=vColor.rgb;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n\nvec4 color=clamp(vec4(retColor.rgb,alpha),0.0,1.0);\n\n#include<fogFragment>\ngl_FragColor=color;\n}\n";
  4232. exports.shader = shader;
  4233. babylonjs_1.Effect.ShadersStore[name] = shader;
  4234. /***/ }),
  4235. /***/ "./src/sky/sky.vertex.ts":
  4236. /*!*******************************!*\
  4237. !*** ./src/sky/sky.vertex.ts ***!
  4238. \*******************************/
  4239. /*! no static exports found */
  4240. /***/ (function(module, exports, __webpack_require__) {
  4241. "use strict";
  4242. Object.defineProperty(exports, "__esModule", { value: true });
  4243. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  4244. var name = 'skyVertexShader';
  4245. exports.name = name;
  4246. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\nvoid main(void) {\ngl_Position=viewProjection*world*vec4(position,1.0);\nvec4 worldPos=world*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  4247. exports.shader = shader;
  4248. babylonjs_1.Effect.ShadersStore[name] = shader;
  4249. /***/ }),
  4250. /***/ "./src/sky/skyMaterial.ts":
  4251. /*!********************************!*\
  4252. !*** ./src/sky/skyMaterial.ts ***!
  4253. \********************************/
  4254. /*! no static exports found */
  4255. /***/ (function(module, exports, __webpack_require__) {
  4256. "use strict";
  4257. var __extends = (this && this.__extends) || (function () {
  4258. var extendStatics = function (d, b) {
  4259. extendStatics = Object.setPrototypeOf ||
  4260. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4261. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4262. return extendStatics(d, b);
  4263. }
  4264. return function (d, b) {
  4265. extendStatics(d, b);
  4266. function __() { this.constructor = d; }
  4267. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4268. };
  4269. })();
  4270. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  4271. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  4272. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  4273. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  4274. return c > 3 && r && Object.defineProperty(target, key, r), r;
  4275. };
  4276. Object.defineProperty(exports, "__esModule", { value: true });
  4277. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  4278. __webpack_require__(/*! ./sky.fragment */ "./src/sky/sky.fragment.ts");
  4279. __webpack_require__(/*! ./sky.vertex */ "./src/sky/sky.vertex.ts");
  4280. var SkyMaterialDefines = /** @class */ (function (_super) {
  4281. __extends(SkyMaterialDefines, _super);
  4282. function SkyMaterialDefines() {
  4283. var _this = _super.call(this) || this;
  4284. _this.CLIPPLANE = false;
  4285. _this.CLIPPLANE2 = false;
  4286. _this.CLIPPLANE3 = false;
  4287. _this.CLIPPLANE4 = false;
  4288. _this.POINTSIZE = false;
  4289. _this.FOG = false;
  4290. _this.VERTEXCOLOR = false;
  4291. _this.VERTEXALPHA = false;
  4292. _this.rebuild();
  4293. return _this;
  4294. }
  4295. return SkyMaterialDefines;
  4296. }(babylonjs_1.MaterialDefines));
  4297. var SkyMaterial = /** @class */ (function (_super) {
  4298. __extends(SkyMaterial, _super);
  4299. function SkyMaterial(name, scene) {
  4300. var _this = _super.call(this, name, scene) || this;
  4301. // Public members
  4302. _this.luminance = 1.0;
  4303. _this.turbidity = 10.0;
  4304. _this.rayleigh = 2.0;
  4305. _this.mieCoefficient = 0.005;
  4306. _this.mieDirectionalG = 0.8;
  4307. _this.distance = 500;
  4308. _this.inclination = 0.49;
  4309. _this.azimuth = 0.25;
  4310. _this.sunPosition = new babylonjs_1.Vector3(0, 100, 0);
  4311. _this.useSunPosition = false;
  4312. // Private members
  4313. _this._cameraPosition = babylonjs_1.Vector3.Zero();
  4314. return _this;
  4315. }
  4316. SkyMaterial.prototype.needAlphaBlending = function () {
  4317. return (this.alpha < 1.0);
  4318. };
  4319. SkyMaterial.prototype.needAlphaTesting = function () {
  4320. return false;
  4321. };
  4322. SkyMaterial.prototype.getAlphaTestTexture = function () {
  4323. return null;
  4324. };
  4325. // Methods
  4326. SkyMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  4327. if (this.isFrozen) {
  4328. if (this._wasPreviouslyReady && subMesh.effect) {
  4329. return true;
  4330. }
  4331. }
  4332. if (!subMesh._materialDefines) {
  4333. subMesh._materialDefines = new SkyMaterialDefines();
  4334. }
  4335. var defines = subMesh._materialDefines;
  4336. var scene = this.getScene();
  4337. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  4338. if (this._renderId === scene.getRenderId()) {
  4339. return true;
  4340. }
  4341. }
  4342. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, false, defines);
  4343. // Attribs
  4344. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, false);
  4345. // Get correct effect
  4346. if (defines.isDirty) {
  4347. defines.markAsProcessed();
  4348. scene.resetCachedMaterial();
  4349. // Fallbacks
  4350. var fallbacks = new babylonjs_1.EffectFallbacks();
  4351. if (defines.FOG) {
  4352. fallbacks.addFallback(1, "FOG");
  4353. }
  4354. //Attributes
  4355. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  4356. if (defines.VERTEXCOLOR) {
  4357. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  4358. }
  4359. var shaderName = "sky";
  4360. var join = defines.toString();
  4361. subMesh.setEffect(scene.getEngine().createEffect(shaderName, attribs, ["world", "viewProjection", "view",
  4362. "vFogInfos", "vFogColor", "pointSize", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4",
  4363. "luminance", "turbidity", "rayleigh", "mieCoefficient", "mieDirectionalG", "sunPosition",
  4364. "cameraPosition"
  4365. ], [], join, fallbacks, this.onCompiled, this.onError), defines);
  4366. }
  4367. if (!subMesh.effect || !subMesh.effect.isReady()) {
  4368. return false;
  4369. }
  4370. this._renderId = scene.getRenderId();
  4371. this._wasPreviouslyReady = true;
  4372. return true;
  4373. };
  4374. SkyMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  4375. var scene = this.getScene();
  4376. var defines = subMesh._materialDefines;
  4377. if (!defines) {
  4378. return;
  4379. }
  4380. var effect = subMesh.effect;
  4381. if (!effect) {
  4382. return;
  4383. }
  4384. this._activeEffect = effect;
  4385. // Matrices
  4386. this.bindOnlyWorldMatrix(world);
  4387. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  4388. if (this._mustRebind(scene, effect)) {
  4389. BABYLON.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  4390. // Point size
  4391. if (this.pointsCloud) {
  4392. this._activeEffect.setFloat("pointSize", this.pointSize);
  4393. }
  4394. }
  4395. // View
  4396. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  4397. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  4398. }
  4399. // Fog
  4400. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  4401. // Sky
  4402. var camera = scene.activeCamera;
  4403. if (camera) {
  4404. var cameraWorldMatrix = camera.getWorldMatrix();
  4405. this._cameraPosition.x = cameraWorldMatrix.m[12];
  4406. this._cameraPosition.y = cameraWorldMatrix.m[13];
  4407. this._cameraPosition.z = cameraWorldMatrix.m[14];
  4408. this._activeEffect.setVector3("cameraPosition", this._cameraPosition);
  4409. }
  4410. if (this.luminance > 0) {
  4411. this._activeEffect.setFloat("luminance", this.luminance);
  4412. }
  4413. this._activeEffect.setFloat("turbidity", this.turbidity);
  4414. this._activeEffect.setFloat("rayleigh", this.rayleigh);
  4415. this._activeEffect.setFloat("mieCoefficient", this.mieCoefficient);
  4416. this._activeEffect.setFloat("mieDirectionalG", this.mieDirectionalG);
  4417. if (!this.useSunPosition) {
  4418. var theta = Math.PI * (this.inclination - 0.5);
  4419. var phi = 2 * Math.PI * (this.azimuth - 0.5);
  4420. this.sunPosition.x = this.distance * Math.cos(phi);
  4421. this.sunPosition.y = this.distance * Math.sin(phi) * Math.sin(theta);
  4422. this.sunPosition.z = this.distance * Math.sin(phi) * Math.cos(theta);
  4423. }
  4424. this._activeEffect.setVector3("sunPosition", this.sunPosition);
  4425. this._afterBind(mesh, this._activeEffect);
  4426. };
  4427. SkyMaterial.prototype.getAnimatables = function () {
  4428. return [];
  4429. };
  4430. SkyMaterial.prototype.dispose = function (forceDisposeEffect) {
  4431. _super.prototype.dispose.call(this, forceDisposeEffect);
  4432. };
  4433. SkyMaterial.prototype.clone = function (name) {
  4434. var _this = this;
  4435. return babylonjs_1.SerializationHelper.Clone(function () { return new SkyMaterial(name, _this.getScene()); }, this);
  4436. };
  4437. SkyMaterial.prototype.serialize = function () {
  4438. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  4439. serializationObject.customType = "BABYLON.SkyMaterial";
  4440. return serializationObject;
  4441. };
  4442. SkyMaterial.prototype.getClassName = function () {
  4443. return "SkyMaterial";
  4444. };
  4445. // Statics
  4446. SkyMaterial.Parse = function (source, scene, rootUrl) {
  4447. return babylonjs_1.SerializationHelper.Parse(function () { return new SkyMaterial(source.name, scene); }, source, scene, rootUrl);
  4448. };
  4449. __decorate([
  4450. babylonjs_1.serialize()
  4451. ], SkyMaterial.prototype, "luminance", void 0);
  4452. __decorate([
  4453. babylonjs_1.serialize()
  4454. ], SkyMaterial.prototype, "turbidity", void 0);
  4455. __decorate([
  4456. babylonjs_1.serialize()
  4457. ], SkyMaterial.prototype, "rayleigh", void 0);
  4458. __decorate([
  4459. babylonjs_1.serialize()
  4460. ], SkyMaterial.prototype, "mieCoefficient", void 0);
  4461. __decorate([
  4462. babylonjs_1.serialize()
  4463. ], SkyMaterial.prototype, "mieDirectionalG", void 0);
  4464. __decorate([
  4465. babylonjs_1.serialize()
  4466. ], SkyMaterial.prototype, "distance", void 0);
  4467. __decorate([
  4468. babylonjs_1.serialize()
  4469. ], SkyMaterial.prototype, "inclination", void 0);
  4470. __decorate([
  4471. babylonjs_1.serialize()
  4472. ], SkyMaterial.prototype, "azimuth", void 0);
  4473. __decorate([
  4474. babylonjs_1.serializeAsVector3()
  4475. ], SkyMaterial.prototype, "sunPosition", void 0);
  4476. __decorate([
  4477. babylonjs_1.serialize()
  4478. ], SkyMaterial.prototype, "useSunPosition", void 0);
  4479. return SkyMaterial;
  4480. }(babylonjs_1.PushMaterial));
  4481. exports.SkyMaterial = SkyMaterial;
  4482. /***/ }),
  4483. /***/ "./src/terrain/index.ts":
  4484. /*!******************************!*\
  4485. !*** ./src/terrain/index.ts ***!
  4486. \******************************/
  4487. /*! no static exports found */
  4488. /***/ (function(module, exports, __webpack_require__) {
  4489. "use strict";
  4490. function __export(m) {
  4491. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  4492. }
  4493. Object.defineProperty(exports, "__esModule", { value: true });
  4494. __export(__webpack_require__(/*! ./terrainMaterial */ "./src/terrain/terrainMaterial.ts"));
  4495. /***/ }),
  4496. /***/ "./src/terrain/terrain.fragment.ts":
  4497. /*!*****************************************!*\
  4498. !*** ./src/terrain/terrain.fragment.ts ***!
  4499. \*****************************************/
  4500. /*! no static exports found */
  4501. /***/ (function(module, exports, __webpack_require__) {
  4502. "use strict";
  4503. Object.defineProperty(exports, "__esModule", { value: true });
  4504. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  4505. var name = 'terrainPixelShader';
  4506. exports.name = name;
  4507. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform sampler2D textureSampler;\nuniform vec2 vTextureInfos;\nuniform sampler2D diffuse1Sampler;\nuniform sampler2D diffuse2Sampler;\nuniform sampler2D diffuse3Sampler;\nuniform vec2 diffuse1Infos;\nuniform vec2 diffuse2Infos;\nuniform vec2 diffuse3Infos;\n#endif\n#ifdef BUMP\nuniform sampler2D bump1Sampler;\nuniform sampler2D bump2Sampler;\nuniform sampler2D bump3Sampler;\n#endif\n\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n\n#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));\nreturn mat3(tangent*invmax,binormal*invmax,normal);\n}\nvec3 perturbNormal(vec3 viewDir,vec3 mixColor)\n{\nvec3 bump1Color=texture2D(bump1Sampler,vTextureUV*diffuse1Infos).xyz;\nvec3 bump2Color=texture2D(bump2Sampler,vTextureUV*diffuse2Infos).xyz;\nvec3 bump3Color=texture2D(bump3Sampler,vTextureUV*diffuse3Infos).xyz;\nbump1Color.rgb*=mixColor.r;\nbump2Color.rgb=mix(bump1Color.rgb,bump2Color.rgb,mixColor.g);\nvec3 map=mix(bump2Color.rgb,bump3Color.rgb,mixColor.b);\nmap=map*255./127.-128./127.;\nmat3 TBN=cotangent_frame(vNormalW*vTextureInfos.y,-viewDir,vTextureUV);\nreturn normalize(TBN*map);\n}\n#endif\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(textureSampler,vTextureUV);\n#if defined(BUMP) && defined(DIFFUSE)\nnormalW=perturbNormal(viewDirectionW,baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\nbaseColor.rgb*=vTextureInfos.y;\nvec4 diffuse1Color=texture2D(diffuse1Sampler,vTextureUV*diffuse1Infos);\nvec4 diffuse2Color=texture2D(diffuse2Sampler,vTextureUV*diffuse2Infos);\nvec4 diffuse3Color=texture2D(diffuse3Sampler,vTextureUV*diffuse3Infos);\ndiffuse1Color.rgb*=baseColor.r;\ndiffuse2Color.rgb=mix(diffuse1Color.rgb,diffuse2Color.rgb,baseColor.g);\nbaseColor.rgb=mix(diffuse2Color.rgb,diffuse3Color.rgb,baseColor.b);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor*baseColor.rgb,0.0,1.0);\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n";
  4508. exports.shader = shader;
  4509. babylonjs_1.Effect.ShadersStore[name] = shader;
  4510. /***/ }),
  4511. /***/ "./src/terrain/terrain.vertex.ts":
  4512. /*!***************************************!*\
  4513. !*** ./src/terrain/terrain.vertex.ts ***!
  4514. \***************************************/
  4515. /*! no static exports found */
  4516. /***/ (function(module, exports, __webpack_require__) {
  4517. "use strict";
  4518. Object.defineProperty(exports, "__esModule", { value: true });
  4519. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  4520. var name = 'terrainVertexShader';
  4521. exports.name = name;
  4522. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vTextureUV;\nuniform mat4 textureMatrix;\nuniform vec2 vTextureInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vTextureInfos.x == 0.)\n{\nvTextureUV=vec2(textureMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvTextureUV=vec2(textureMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  4523. exports.shader = shader;
  4524. babylonjs_1.Effect.ShadersStore[name] = shader;
  4525. /***/ }),
  4526. /***/ "./src/terrain/terrainMaterial.ts":
  4527. /*!****************************************!*\
  4528. !*** ./src/terrain/terrainMaterial.ts ***!
  4529. \****************************************/
  4530. /*! no static exports found */
  4531. /***/ (function(module, exports, __webpack_require__) {
  4532. "use strict";
  4533. var __extends = (this && this.__extends) || (function () {
  4534. var extendStatics = function (d, b) {
  4535. extendStatics = Object.setPrototypeOf ||
  4536. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4537. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4538. return extendStatics(d, b);
  4539. }
  4540. return function (d, b) {
  4541. extendStatics(d, b);
  4542. function __() { this.constructor = d; }
  4543. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4544. };
  4545. })();
  4546. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  4547. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  4548. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  4549. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  4550. return c > 3 && r && Object.defineProperty(target, key, r), r;
  4551. };
  4552. Object.defineProperty(exports, "__esModule", { value: true });
  4553. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  4554. __webpack_require__(/*! ./terrain.fragment */ "./src/terrain/terrain.fragment.ts");
  4555. __webpack_require__(/*! ./terrain.vertex */ "./src/terrain/terrain.vertex.ts");
  4556. var TerrainMaterialDefines = /** @class */ (function (_super) {
  4557. __extends(TerrainMaterialDefines, _super);
  4558. function TerrainMaterialDefines() {
  4559. var _this = _super.call(this) || this;
  4560. _this.DIFFUSE = false;
  4561. _this.BUMP = false;
  4562. _this.CLIPPLANE = false;
  4563. _this.CLIPPLANE2 = false;
  4564. _this.CLIPPLANE3 = false;
  4565. _this.CLIPPLANE4 = false;
  4566. _this.ALPHATEST = false;
  4567. _this.DEPTHPREPASS = false;
  4568. _this.POINTSIZE = false;
  4569. _this.FOG = false;
  4570. _this.SPECULARTERM = false;
  4571. _this.NORMAL = false;
  4572. _this.UV1 = false;
  4573. _this.UV2 = false;
  4574. _this.VERTEXCOLOR = false;
  4575. _this.VERTEXALPHA = false;
  4576. _this.NUM_BONE_INFLUENCERS = 0;
  4577. _this.BonesPerMesh = 0;
  4578. _this.INSTANCES = false;
  4579. _this.rebuild();
  4580. return _this;
  4581. }
  4582. return TerrainMaterialDefines;
  4583. }(babylonjs_1.MaterialDefines));
  4584. var TerrainMaterial = /** @class */ (function (_super) {
  4585. __extends(TerrainMaterial, _super);
  4586. function TerrainMaterial(name, scene) {
  4587. var _this = _super.call(this, name, scene) || this;
  4588. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  4589. _this.specularColor = new babylonjs_1.Color3(0, 0, 0);
  4590. _this.specularPower = 64;
  4591. _this._disableLighting = false;
  4592. _this._maxSimultaneousLights = 4;
  4593. return _this;
  4594. }
  4595. TerrainMaterial.prototype.needAlphaBlending = function () {
  4596. return (this.alpha < 1.0);
  4597. };
  4598. TerrainMaterial.prototype.needAlphaTesting = function () {
  4599. return false;
  4600. };
  4601. TerrainMaterial.prototype.getAlphaTestTexture = function () {
  4602. return null;
  4603. };
  4604. // Methods
  4605. TerrainMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  4606. if (this.isFrozen) {
  4607. if (this._wasPreviouslyReady && subMesh.effect) {
  4608. return true;
  4609. }
  4610. }
  4611. if (!subMesh._materialDefines) {
  4612. subMesh._materialDefines = new TerrainMaterialDefines();
  4613. }
  4614. var defines = subMesh._materialDefines;
  4615. var scene = this.getScene();
  4616. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  4617. if (this._renderId === scene.getRenderId()) {
  4618. return true;
  4619. }
  4620. }
  4621. var engine = scene.getEngine();
  4622. // Textures
  4623. if (scene.texturesEnabled) {
  4624. if (this.mixTexture && babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  4625. if (!this.mixTexture.isReady()) {
  4626. return false;
  4627. }
  4628. else {
  4629. defines._needUVs = true;
  4630. defines.DIFFUSE = true;
  4631. }
  4632. }
  4633. if ((this.bumpTexture1 || this.bumpTexture2 || this.bumpTexture3) && babylonjs_1.StandardMaterial.BumpTextureEnabled) {
  4634. defines._needUVs = true;
  4635. defines._needNormals = true;
  4636. defines.BUMP = true;
  4637. }
  4638. }
  4639. // Misc.
  4640. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  4641. // Lights
  4642. defines._needNormals = babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  4643. // Values that need to be evaluated on every frame
  4644. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  4645. // Attribs
  4646. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  4647. // Get correct effect
  4648. if (defines.isDirty) {
  4649. defines.markAsProcessed();
  4650. scene.resetCachedMaterial();
  4651. // Fallbacks
  4652. var fallbacks = new babylonjs_1.EffectFallbacks();
  4653. if (defines.FOG) {
  4654. fallbacks.addFallback(1, "FOG");
  4655. }
  4656. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
  4657. if (defines.NUM_BONE_INFLUENCERS > 0) {
  4658. fallbacks.addCPUSkinningFallback(0, mesh);
  4659. }
  4660. //Attributes
  4661. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  4662. if (defines.NORMAL) {
  4663. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  4664. }
  4665. if (defines.UV1) {
  4666. attribs.push(babylonjs_1.VertexBuffer.UVKind);
  4667. }
  4668. if (defines.UV2) {
  4669. attribs.push(babylonjs_1.VertexBuffer.UV2Kind);
  4670. }
  4671. if (defines.VERTEXCOLOR) {
  4672. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  4673. }
  4674. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  4675. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  4676. // Legacy browser patch
  4677. var shaderName = "terrain";
  4678. var join = defines.toString();
  4679. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
  4680. "vFogInfos", "vFogColor", "pointSize",
  4681. "vTextureInfos",
  4682. "mBones",
  4683. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMatrix",
  4684. "diffuse1Infos", "diffuse2Infos", "diffuse3Infos"
  4685. ];
  4686. var samplers = ["textureSampler", "diffuse1Sampler", "diffuse2Sampler", "diffuse3Sampler",
  4687. "bump1Sampler", "bump2Sampler", "bump3Sampler"
  4688. ];
  4689. var uniformBuffers = new Array();
  4690. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  4691. uniformsNames: uniforms,
  4692. uniformBuffersNames: uniformBuffers,
  4693. samplers: samplers,
  4694. defines: defines,
  4695. maxSimultaneousLights: this.maxSimultaneousLights
  4696. });
  4697. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  4698. attributes: attribs,
  4699. uniformsNames: uniforms,
  4700. uniformBuffersNames: uniformBuffers,
  4701. samplers: samplers,
  4702. defines: join,
  4703. fallbacks: fallbacks,
  4704. onCompiled: this.onCompiled,
  4705. onError: this.onError,
  4706. indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
  4707. }, engine), defines);
  4708. }
  4709. if (!subMesh.effect || !subMesh.effect.isReady()) {
  4710. return false;
  4711. }
  4712. this._renderId = scene.getRenderId();
  4713. this._wasPreviouslyReady = true;
  4714. return true;
  4715. };
  4716. TerrainMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  4717. var scene = this.getScene();
  4718. var defines = subMesh._materialDefines;
  4719. if (!defines) {
  4720. return;
  4721. }
  4722. var effect = subMesh.effect;
  4723. if (!effect) {
  4724. return;
  4725. }
  4726. this._activeEffect = effect;
  4727. // Matrices
  4728. this.bindOnlyWorldMatrix(world);
  4729. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  4730. // Bones
  4731. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  4732. if (this._mustRebind(scene, effect)) {
  4733. // Textures
  4734. if (this.mixTexture) {
  4735. this._activeEffect.setTexture("textureSampler", this._mixTexture);
  4736. this._activeEffect.setFloat2("vTextureInfos", this._mixTexture.coordinatesIndex, this._mixTexture.level);
  4737. this._activeEffect.setMatrix("textureMatrix", this._mixTexture.getTextureMatrix());
  4738. if (babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  4739. if (this._diffuseTexture1) {
  4740. this._activeEffect.setTexture("diffuse1Sampler", this._diffuseTexture1);
  4741. this._activeEffect.setFloat2("diffuse1Infos", this._diffuseTexture1.uScale, this._diffuseTexture1.vScale);
  4742. }
  4743. if (this._diffuseTexture2) {
  4744. this._activeEffect.setTexture("diffuse2Sampler", this._diffuseTexture2);
  4745. this._activeEffect.setFloat2("diffuse2Infos", this._diffuseTexture2.uScale, this._diffuseTexture2.vScale);
  4746. }
  4747. if (this._diffuseTexture3) {
  4748. this._activeEffect.setTexture("diffuse3Sampler", this._diffuseTexture3);
  4749. this._activeEffect.setFloat2("diffuse3Infos", this._diffuseTexture3.uScale, this._diffuseTexture3.vScale);
  4750. }
  4751. }
  4752. if (babylonjs_1.StandardMaterial.BumpTextureEnabled && scene.getEngine().getCaps().standardDerivatives) {
  4753. if (this._bumpTexture1) {
  4754. this._activeEffect.setTexture("bump1Sampler", this._bumpTexture1);
  4755. }
  4756. if (this._bumpTexture2) {
  4757. this._activeEffect.setTexture("bump2Sampler", this._bumpTexture2);
  4758. }
  4759. if (this._bumpTexture3) {
  4760. this._activeEffect.setTexture("bump3Sampler", this._bumpTexture3);
  4761. }
  4762. }
  4763. }
  4764. // Clip plane
  4765. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  4766. // Point size
  4767. if (this.pointsCloud) {
  4768. this._activeEffect.setFloat("pointSize", this.pointSize);
  4769. }
  4770. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  4771. }
  4772. this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  4773. if (defines.SPECULARTERM) {
  4774. this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
  4775. }
  4776. if (scene.lightsEnabled && !this.disableLighting) {
  4777. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
  4778. }
  4779. // View
  4780. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  4781. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  4782. }
  4783. // Fog
  4784. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  4785. this._afterBind(mesh, this._activeEffect);
  4786. };
  4787. TerrainMaterial.prototype.getAnimatables = function () {
  4788. var results = [];
  4789. if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {
  4790. results.push(this.mixTexture);
  4791. }
  4792. return results;
  4793. };
  4794. TerrainMaterial.prototype.getActiveTextures = function () {
  4795. var activeTextures = _super.prototype.getActiveTextures.call(this);
  4796. if (this._mixTexture) {
  4797. activeTextures.push(this._mixTexture);
  4798. }
  4799. if (this._diffuseTexture1) {
  4800. activeTextures.push(this._diffuseTexture1);
  4801. }
  4802. if (this._diffuseTexture2) {
  4803. activeTextures.push(this._diffuseTexture2);
  4804. }
  4805. if (this._diffuseTexture3) {
  4806. activeTextures.push(this._diffuseTexture3);
  4807. }
  4808. if (this._bumpTexture1) {
  4809. activeTextures.push(this._bumpTexture1);
  4810. }
  4811. if (this._bumpTexture2) {
  4812. activeTextures.push(this._bumpTexture2);
  4813. }
  4814. if (this._bumpTexture3) {
  4815. activeTextures.push(this._bumpTexture3);
  4816. }
  4817. return activeTextures;
  4818. };
  4819. TerrainMaterial.prototype.hasTexture = function (texture) {
  4820. if (_super.prototype.hasTexture.call(this, texture)) {
  4821. return true;
  4822. }
  4823. if (this._mixTexture === texture) {
  4824. return true;
  4825. }
  4826. if (this._diffuseTexture1 === texture) {
  4827. return true;
  4828. }
  4829. if (this._diffuseTexture2 === texture) {
  4830. return true;
  4831. }
  4832. if (this._diffuseTexture3 === texture) {
  4833. return true;
  4834. }
  4835. if (this._bumpTexture1 === texture) {
  4836. return true;
  4837. }
  4838. if (this._bumpTexture2 === texture) {
  4839. return true;
  4840. }
  4841. if (this._bumpTexture3 === texture) {
  4842. return true;
  4843. }
  4844. return false;
  4845. };
  4846. TerrainMaterial.prototype.dispose = function (forceDisposeEffect) {
  4847. if (this.mixTexture) {
  4848. this.mixTexture.dispose();
  4849. }
  4850. _super.prototype.dispose.call(this, forceDisposeEffect);
  4851. };
  4852. TerrainMaterial.prototype.clone = function (name) {
  4853. var _this = this;
  4854. return babylonjs_1.SerializationHelper.Clone(function () { return new TerrainMaterial(name, _this.getScene()); }, this);
  4855. };
  4856. TerrainMaterial.prototype.serialize = function () {
  4857. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  4858. serializationObject.customType = "BABYLON.TerrainMaterial";
  4859. return serializationObject;
  4860. };
  4861. TerrainMaterial.prototype.getClassName = function () {
  4862. return "TerrainMaterial";
  4863. };
  4864. // Statics
  4865. TerrainMaterial.Parse = function (source, scene, rootUrl) {
  4866. return babylonjs_1.SerializationHelper.Parse(function () { return new TerrainMaterial(source.name, scene); }, source, scene, rootUrl);
  4867. };
  4868. __decorate([
  4869. babylonjs_1.serializeAsTexture("mixTexture")
  4870. ], TerrainMaterial.prototype, "_mixTexture", void 0);
  4871. __decorate([
  4872. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  4873. ], TerrainMaterial.prototype, "mixTexture", void 0);
  4874. __decorate([
  4875. babylonjs_1.serializeAsTexture("diffuseTexture1")
  4876. ], TerrainMaterial.prototype, "_diffuseTexture1", void 0);
  4877. __decorate([
  4878. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  4879. ], TerrainMaterial.prototype, "diffuseTexture1", void 0);
  4880. __decorate([
  4881. babylonjs_1.serializeAsTexture("diffuseTexture2")
  4882. ], TerrainMaterial.prototype, "_diffuseTexture2", void 0);
  4883. __decorate([
  4884. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  4885. ], TerrainMaterial.prototype, "diffuseTexture2", void 0);
  4886. __decorate([
  4887. babylonjs_1.serializeAsTexture("diffuseTexture3")
  4888. ], TerrainMaterial.prototype, "_diffuseTexture3", void 0);
  4889. __decorate([
  4890. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  4891. ], TerrainMaterial.prototype, "diffuseTexture3", void 0);
  4892. __decorate([
  4893. babylonjs_1.serializeAsTexture("bumpTexture1")
  4894. ], TerrainMaterial.prototype, "_bumpTexture1", void 0);
  4895. __decorate([
  4896. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  4897. ], TerrainMaterial.prototype, "bumpTexture1", void 0);
  4898. __decorate([
  4899. babylonjs_1.serializeAsTexture("bumpTexture2")
  4900. ], TerrainMaterial.prototype, "_bumpTexture2", void 0);
  4901. __decorate([
  4902. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  4903. ], TerrainMaterial.prototype, "bumpTexture2", void 0);
  4904. __decorate([
  4905. babylonjs_1.serializeAsTexture("bumpTexture3")
  4906. ], TerrainMaterial.prototype, "_bumpTexture3", void 0);
  4907. __decorate([
  4908. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  4909. ], TerrainMaterial.prototype, "bumpTexture3", void 0);
  4910. __decorate([
  4911. babylonjs_1.serializeAsColor3()
  4912. ], TerrainMaterial.prototype, "diffuseColor", void 0);
  4913. __decorate([
  4914. babylonjs_1.serializeAsColor3()
  4915. ], TerrainMaterial.prototype, "specularColor", void 0);
  4916. __decorate([
  4917. babylonjs_1.serialize()
  4918. ], TerrainMaterial.prototype, "specularPower", void 0);
  4919. __decorate([
  4920. babylonjs_1.serialize("disableLighting")
  4921. ], TerrainMaterial.prototype, "_disableLighting", void 0);
  4922. __decorate([
  4923. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  4924. ], TerrainMaterial.prototype, "disableLighting", void 0);
  4925. __decorate([
  4926. babylonjs_1.serialize("maxSimultaneousLights")
  4927. ], TerrainMaterial.prototype, "_maxSimultaneousLights", void 0);
  4928. __decorate([
  4929. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  4930. ], TerrainMaterial.prototype, "maxSimultaneousLights", void 0);
  4931. return TerrainMaterial;
  4932. }(babylonjs_1.PushMaterial));
  4933. exports.TerrainMaterial = TerrainMaterial;
  4934. /***/ }),
  4935. /***/ "./src/triPlanar/index.ts":
  4936. /*!********************************!*\
  4937. !*** ./src/triPlanar/index.ts ***!
  4938. \********************************/
  4939. /*! no static exports found */
  4940. /***/ (function(module, exports, __webpack_require__) {
  4941. "use strict";
  4942. function __export(m) {
  4943. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  4944. }
  4945. Object.defineProperty(exports, "__esModule", { value: true });
  4946. __export(__webpack_require__(/*! ./triPlanarMaterial */ "./src/triPlanar/triPlanarMaterial.ts"));
  4947. /***/ }),
  4948. /***/ "./src/triPlanar/triPlanarMaterial.ts":
  4949. /*!********************************************!*\
  4950. !*** ./src/triPlanar/triPlanarMaterial.ts ***!
  4951. \********************************************/
  4952. /*! no static exports found */
  4953. /***/ (function(module, exports, __webpack_require__) {
  4954. "use strict";
  4955. var __extends = (this && this.__extends) || (function () {
  4956. var extendStatics = function (d, b) {
  4957. extendStatics = Object.setPrototypeOf ||
  4958. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4959. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4960. return extendStatics(d, b);
  4961. }
  4962. return function (d, b) {
  4963. extendStatics(d, b);
  4964. function __() { this.constructor = d; }
  4965. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4966. };
  4967. })();
  4968. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  4969. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  4970. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  4971. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  4972. return c > 3 && r && Object.defineProperty(target, key, r), r;
  4973. };
  4974. Object.defineProperty(exports, "__esModule", { value: true });
  4975. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  4976. __webpack_require__(/*! ./triplanar.fragment */ "./src/triPlanar/triplanar.fragment.ts");
  4977. __webpack_require__(/*! ./triplanar.vertex */ "./src/triPlanar/triplanar.vertex.ts");
  4978. var TriPlanarMaterialDefines = /** @class */ (function (_super) {
  4979. __extends(TriPlanarMaterialDefines, _super);
  4980. function TriPlanarMaterialDefines() {
  4981. var _this = _super.call(this) || this;
  4982. _this.DIFFUSEX = false;
  4983. _this.DIFFUSEY = false;
  4984. _this.DIFFUSEZ = false;
  4985. _this.BUMPX = false;
  4986. _this.BUMPY = false;
  4987. _this.BUMPZ = false;
  4988. _this.CLIPPLANE = false;
  4989. _this.CLIPPLANE2 = false;
  4990. _this.CLIPPLANE3 = false;
  4991. _this.CLIPPLANE4 = false;
  4992. _this.ALPHATEST = false;
  4993. _this.DEPTHPREPASS = false;
  4994. _this.POINTSIZE = false;
  4995. _this.FOG = false;
  4996. _this.SPECULARTERM = false;
  4997. _this.NORMAL = false;
  4998. _this.VERTEXCOLOR = false;
  4999. _this.VERTEXALPHA = false;
  5000. _this.NUM_BONE_INFLUENCERS = 0;
  5001. _this.BonesPerMesh = 0;
  5002. _this.INSTANCES = false;
  5003. _this.rebuild();
  5004. return _this;
  5005. }
  5006. return TriPlanarMaterialDefines;
  5007. }(babylonjs_1.MaterialDefines));
  5008. var TriPlanarMaterial = /** @class */ (function (_super) {
  5009. __extends(TriPlanarMaterial, _super);
  5010. function TriPlanarMaterial(name, scene) {
  5011. var _this = _super.call(this, name, scene) || this;
  5012. _this.tileSize = 1;
  5013. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  5014. _this.specularColor = new babylonjs_1.Color3(0.2, 0.2, 0.2);
  5015. _this.specularPower = 64;
  5016. _this._disableLighting = false;
  5017. _this._maxSimultaneousLights = 4;
  5018. return _this;
  5019. }
  5020. TriPlanarMaterial.prototype.needAlphaBlending = function () {
  5021. return (this.alpha < 1.0);
  5022. };
  5023. TriPlanarMaterial.prototype.needAlphaTesting = function () {
  5024. return false;
  5025. };
  5026. TriPlanarMaterial.prototype.getAlphaTestTexture = function () {
  5027. return null;
  5028. };
  5029. // Methods
  5030. TriPlanarMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  5031. if (this.isFrozen) {
  5032. if (this._wasPreviouslyReady && subMesh.effect) {
  5033. return true;
  5034. }
  5035. }
  5036. if (!subMesh._materialDefines) {
  5037. subMesh._materialDefines = new TriPlanarMaterialDefines();
  5038. }
  5039. var defines = subMesh._materialDefines;
  5040. var scene = this.getScene();
  5041. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  5042. if (this._renderId === scene.getRenderId()) {
  5043. return true;
  5044. }
  5045. }
  5046. var engine = scene.getEngine();
  5047. // Textures
  5048. if (defines._areTexturesDirty) {
  5049. if (scene.texturesEnabled) {
  5050. if (babylonjs_1.StandardMaterial.DiffuseTextureEnabled) {
  5051. var textures = [this.diffuseTextureX, this.diffuseTextureY, this.diffuseTextureZ];
  5052. var textureDefines = ["DIFFUSEX", "DIFFUSEY", "DIFFUSEZ"];
  5053. for (var i = 0; i < textures.length; i++) {
  5054. if (textures[i]) {
  5055. if (!textures[i].isReady()) {
  5056. return false;
  5057. }
  5058. else {
  5059. defines[textureDefines[i]] = true;
  5060. }
  5061. }
  5062. }
  5063. }
  5064. if (babylonjs_1.StandardMaterial.BumpTextureEnabled) {
  5065. var textures = [this.normalTextureX, this.normalTextureY, this.normalTextureZ];
  5066. var textureDefines = ["BUMPX", "BUMPY", "BUMPZ"];
  5067. for (var i = 0; i < textures.length; i++) {
  5068. if (textures[i]) {
  5069. if (!textures[i].isReady()) {
  5070. return false;
  5071. }
  5072. else {
  5073. defines[textureDefines[i]] = true;
  5074. }
  5075. }
  5076. }
  5077. }
  5078. }
  5079. }
  5080. // Misc.
  5081. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  5082. // Lights
  5083. defines._needNormals = babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights, this._disableLighting);
  5084. // Values that need to be evaluated on every frame
  5085. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  5086. // Attribs
  5087. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  5088. // Get correct effect
  5089. if (defines.isDirty) {
  5090. defines.markAsProcessed();
  5091. scene.resetCachedMaterial();
  5092. // Fallbacks
  5093. var fallbacks = new babylonjs_1.EffectFallbacks();
  5094. if (defines.FOG) {
  5095. fallbacks.addFallback(1, "FOG");
  5096. }
  5097. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
  5098. if (defines.NUM_BONE_INFLUENCERS > 0) {
  5099. fallbacks.addCPUSkinningFallback(0, mesh);
  5100. }
  5101. //Attributes
  5102. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  5103. if (defines.NORMAL) {
  5104. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  5105. }
  5106. if (defines.VERTEXCOLOR) {
  5107. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  5108. }
  5109. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  5110. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  5111. // Legacy browser patch
  5112. var shaderName = "triplanar";
  5113. var join = defines.toString();
  5114. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
  5115. "vFogInfos", "vFogColor", "pointSize",
  5116. "mBones",
  5117. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4",
  5118. "tileSize"
  5119. ];
  5120. var samplers = ["diffuseSamplerX", "diffuseSamplerY", "diffuseSamplerZ",
  5121. "normalSamplerX", "normalSamplerY", "normalSamplerZ"
  5122. ];
  5123. var uniformBuffers = new Array();
  5124. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  5125. uniformsNames: uniforms,
  5126. uniformBuffersNames: uniformBuffers,
  5127. samplers: samplers,
  5128. defines: defines,
  5129. maxSimultaneousLights: this.maxSimultaneousLights
  5130. });
  5131. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  5132. attributes: attribs,
  5133. uniformsNames: uniforms,
  5134. uniformBuffersNames: uniformBuffers,
  5135. samplers: samplers,
  5136. defines: join,
  5137. fallbacks: fallbacks,
  5138. onCompiled: this.onCompiled,
  5139. onError: this.onError,
  5140. indexParameters: { maxSimultaneousLights: this.maxSimultaneousLights }
  5141. }, engine), defines);
  5142. }
  5143. if (!subMesh.effect || !subMesh.effect.isReady()) {
  5144. return false;
  5145. }
  5146. this._renderId = scene.getRenderId();
  5147. this._wasPreviouslyReady = true;
  5148. return true;
  5149. };
  5150. TriPlanarMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  5151. var scene = this.getScene();
  5152. var defines = subMesh._materialDefines;
  5153. if (!defines) {
  5154. return;
  5155. }
  5156. var effect = subMesh.effect;
  5157. if (!effect) {
  5158. return;
  5159. }
  5160. this._activeEffect = effect;
  5161. // Matrices
  5162. this.bindOnlyWorldMatrix(world);
  5163. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  5164. // Bones
  5165. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  5166. this._activeEffect.setFloat("tileSize", this.tileSize);
  5167. if (scene.getCachedMaterial() !== this) {
  5168. // Textures
  5169. if (this.diffuseTextureX) {
  5170. this._activeEffect.setTexture("diffuseSamplerX", this.diffuseTextureX);
  5171. }
  5172. if (this.diffuseTextureY) {
  5173. this._activeEffect.setTexture("diffuseSamplerY", this.diffuseTextureY);
  5174. }
  5175. if (this.diffuseTextureZ) {
  5176. this._activeEffect.setTexture("diffuseSamplerZ", this.diffuseTextureZ);
  5177. }
  5178. if (this.normalTextureX) {
  5179. this._activeEffect.setTexture("normalSamplerX", this.normalTextureX);
  5180. }
  5181. if (this.normalTextureY) {
  5182. this._activeEffect.setTexture("normalSamplerY", this.normalTextureY);
  5183. }
  5184. if (this.normalTextureZ) {
  5185. this._activeEffect.setTexture("normalSamplerZ", this.normalTextureZ);
  5186. }
  5187. // Clip plane
  5188. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  5189. // Point size
  5190. if (this.pointsCloud) {
  5191. this._activeEffect.setFloat("pointSize", this.pointSize);
  5192. }
  5193. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  5194. }
  5195. this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  5196. if (defines.SPECULARTERM) {
  5197. this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
  5198. }
  5199. if (scene.lightsEnabled && !this.disableLighting) {
  5200. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
  5201. }
  5202. // View
  5203. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  5204. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  5205. }
  5206. // Fog
  5207. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  5208. this._afterBind(mesh, this._activeEffect);
  5209. };
  5210. TriPlanarMaterial.prototype.getAnimatables = function () {
  5211. var results = [];
  5212. if (this.mixTexture && this.mixTexture.animations && this.mixTexture.animations.length > 0) {
  5213. results.push(this.mixTexture);
  5214. }
  5215. return results;
  5216. };
  5217. TriPlanarMaterial.prototype.getActiveTextures = function () {
  5218. var activeTextures = _super.prototype.getActiveTextures.call(this);
  5219. if (this._diffuseTextureX) {
  5220. activeTextures.push(this._diffuseTextureX);
  5221. }
  5222. if (this._diffuseTextureY) {
  5223. activeTextures.push(this._diffuseTextureY);
  5224. }
  5225. if (this._diffuseTextureZ) {
  5226. activeTextures.push(this._diffuseTextureZ);
  5227. }
  5228. if (this._normalTextureX) {
  5229. activeTextures.push(this._normalTextureX);
  5230. }
  5231. if (this._normalTextureY) {
  5232. activeTextures.push(this._normalTextureY);
  5233. }
  5234. if (this._normalTextureZ) {
  5235. activeTextures.push(this._normalTextureZ);
  5236. }
  5237. return activeTextures;
  5238. };
  5239. TriPlanarMaterial.prototype.hasTexture = function (texture) {
  5240. if (_super.prototype.hasTexture.call(this, texture)) {
  5241. return true;
  5242. }
  5243. if (this._diffuseTextureX === texture) {
  5244. return true;
  5245. }
  5246. if (this._diffuseTextureY === texture) {
  5247. return true;
  5248. }
  5249. if (this._diffuseTextureZ === texture) {
  5250. return true;
  5251. }
  5252. if (this._normalTextureX === texture) {
  5253. return true;
  5254. }
  5255. if (this._normalTextureY === texture) {
  5256. return true;
  5257. }
  5258. if (this._normalTextureZ === texture) {
  5259. return true;
  5260. }
  5261. return false;
  5262. };
  5263. TriPlanarMaterial.prototype.dispose = function (forceDisposeEffect) {
  5264. if (this.mixTexture) {
  5265. this.mixTexture.dispose();
  5266. }
  5267. _super.prototype.dispose.call(this, forceDisposeEffect);
  5268. };
  5269. TriPlanarMaterial.prototype.clone = function (name) {
  5270. var _this = this;
  5271. return babylonjs_1.SerializationHelper.Clone(function () { return new TriPlanarMaterial(name, _this.getScene()); }, this);
  5272. };
  5273. TriPlanarMaterial.prototype.serialize = function () {
  5274. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  5275. serializationObject.customType = "BABYLON.TriPlanarMaterial";
  5276. return serializationObject;
  5277. };
  5278. TriPlanarMaterial.prototype.getClassName = function () {
  5279. return "TriPlanarMaterial";
  5280. };
  5281. // Statics
  5282. TriPlanarMaterial.Parse = function (source, scene, rootUrl) {
  5283. return babylonjs_1.SerializationHelper.Parse(function () { return new TriPlanarMaterial(source.name, scene); }, source, scene, rootUrl);
  5284. };
  5285. __decorate([
  5286. babylonjs_1.serializeAsTexture()
  5287. ], TriPlanarMaterial.prototype, "mixTexture", void 0);
  5288. __decorate([
  5289. babylonjs_1.serializeAsTexture("diffuseTextureX")
  5290. ], TriPlanarMaterial.prototype, "_diffuseTextureX", void 0);
  5291. __decorate([
  5292. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  5293. ], TriPlanarMaterial.prototype, "diffuseTextureX", void 0);
  5294. __decorate([
  5295. babylonjs_1.serializeAsTexture("diffuseTexturY")
  5296. ], TriPlanarMaterial.prototype, "_diffuseTextureY", void 0);
  5297. __decorate([
  5298. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  5299. ], TriPlanarMaterial.prototype, "diffuseTextureY", void 0);
  5300. __decorate([
  5301. babylonjs_1.serializeAsTexture("diffuseTextureZ")
  5302. ], TriPlanarMaterial.prototype, "_diffuseTextureZ", void 0);
  5303. __decorate([
  5304. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  5305. ], TriPlanarMaterial.prototype, "diffuseTextureZ", void 0);
  5306. __decorate([
  5307. babylonjs_1.serializeAsTexture("normalTextureX")
  5308. ], TriPlanarMaterial.prototype, "_normalTextureX", void 0);
  5309. __decorate([
  5310. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  5311. ], TriPlanarMaterial.prototype, "normalTextureX", void 0);
  5312. __decorate([
  5313. babylonjs_1.serializeAsTexture("normalTextureY")
  5314. ], TriPlanarMaterial.prototype, "_normalTextureY", void 0);
  5315. __decorate([
  5316. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  5317. ], TriPlanarMaterial.prototype, "normalTextureY", void 0);
  5318. __decorate([
  5319. babylonjs_1.serializeAsTexture("normalTextureZ")
  5320. ], TriPlanarMaterial.prototype, "_normalTextureZ", void 0);
  5321. __decorate([
  5322. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  5323. ], TriPlanarMaterial.prototype, "normalTextureZ", void 0);
  5324. __decorate([
  5325. babylonjs_1.serialize()
  5326. ], TriPlanarMaterial.prototype, "tileSize", void 0);
  5327. __decorate([
  5328. babylonjs_1.serializeAsColor3()
  5329. ], TriPlanarMaterial.prototype, "diffuseColor", void 0);
  5330. __decorate([
  5331. babylonjs_1.serializeAsColor3()
  5332. ], TriPlanarMaterial.prototype, "specularColor", void 0);
  5333. __decorate([
  5334. babylonjs_1.serialize()
  5335. ], TriPlanarMaterial.prototype, "specularPower", void 0);
  5336. __decorate([
  5337. babylonjs_1.serialize("disableLighting")
  5338. ], TriPlanarMaterial.prototype, "_disableLighting", void 0);
  5339. __decorate([
  5340. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  5341. ], TriPlanarMaterial.prototype, "disableLighting", void 0);
  5342. __decorate([
  5343. babylonjs_1.serialize("maxSimultaneousLights")
  5344. ], TriPlanarMaterial.prototype, "_maxSimultaneousLights", void 0);
  5345. __decorate([
  5346. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  5347. ], TriPlanarMaterial.prototype, "maxSimultaneousLights", void 0);
  5348. return TriPlanarMaterial;
  5349. }(babylonjs_1.PushMaterial));
  5350. exports.TriPlanarMaterial = TriPlanarMaterial;
  5351. /***/ }),
  5352. /***/ "./src/triPlanar/triplanar.fragment.ts":
  5353. /*!*********************************************!*\
  5354. !*** ./src/triPlanar/triplanar.fragment.ts ***!
  5355. \*********************************************/
  5356. /*! no static exports found */
  5357. /***/ (function(module, exports, __webpack_require__) {
  5358. "use strict";
  5359. Object.defineProperty(exports, "__esModule", { value: true });
  5360. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  5361. var name = 'triplanarPixelShader';
  5362. exports.name = name;
  5363. var shader = "precision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\nuniform sampler2D diffuseSamplerX;\n#ifdef BUMPX\nuniform sampler2D normalSamplerX;\n#endif\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\nuniform sampler2D diffuseSamplerY;\n#ifdef BUMPY\nuniform sampler2D normalSamplerY;\n#endif\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\nuniform sampler2D diffuseSamplerZ;\n#ifdef BUMPZ\nuniform sampler2D normalSamplerZ;\n#endif\n#endif\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(0.,0.,0.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=tangentSpace[2];\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\nvec4 baseNormal=vec4(0.0,0.0,0.0,1.0);\nnormalW*=normalW;\n#ifdef DIFFUSEX\nbaseColor+=texture2D(diffuseSamplerX,vTextureUVX)*normalW.x;\n#ifdef BUMPX\nbaseNormal+=texture2D(normalSamplerX,vTextureUVX)*normalW.x;\n#endif\n#endif\n#ifdef DIFFUSEY\nbaseColor+=texture2D(diffuseSamplerY,vTextureUVY)*normalW.y;\n#ifdef BUMPY\nbaseNormal+=texture2D(normalSamplerY,vTextureUVY)*normalW.y;\n#endif\n#endif\n#ifdef DIFFUSEZ\nbaseColor+=texture2D(diffuseSamplerZ,vTextureUVZ)*normalW.z;\n#ifdef BUMPZ\nbaseNormal+=texture2D(normalSamplerZ,vTextureUVZ)*normalW.z;\n#endif\n#endif\n#ifdef NORMAL\nnormalW=normalize((2.0*baseNormal.xyz-1.0)*tangentSpace);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor,0.0,1.0)*baseColor.rgb;\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}\n";
  5364. exports.shader = shader;
  5365. babylonjs_1.Effect.ShadersStore[name] = shader;
  5366. /***/ }),
  5367. /***/ "./src/triPlanar/triplanar.vertex.ts":
  5368. /*!*******************************************!*\
  5369. !*** ./src/triPlanar/triplanar.vertex.ts ***!
  5370. \*******************************************/
  5371. /*! no static exports found */
  5372. /***/ (function(module, exports, __webpack_require__) {
  5373. "use strict";
  5374. Object.defineProperty(exports, "__esModule", { value: true });
  5375. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  5376. var name = 'triplanarVertexShader';
  5377. exports.name = name;
  5378. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSEX\nvarying vec2 vTextureUVX;\n#endif\n#ifdef DIFFUSEY\nvarying vec2 vTextureUVY;\n#endif\n#ifdef DIFFUSEZ\nvarying vec2 vTextureUVZ;\n#endif\nuniform float tileSize;\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying mat3 tangentSpace;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef DIFFUSEX\nvTextureUVX=worldPos.zy/tileSize;\n#endif\n#ifdef DIFFUSEY\nvTextureUVY=worldPos.xz/tileSize;\n#endif\n#ifdef DIFFUSEZ\nvTextureUVZ=worldPos.xy/tileSize;\n#endif\n#ifdef NORMAL\n\nvec3 xtan=vec3(0,0,1);\nvec3 xbin=vec3(0,1,0);\nvec3 ytan=vec3(1,0,0);\nvec3 ybin=vec3(0,0,1);\nvec3 ztan=vec3(1,0,0);\nvec3 zbin=vec3(0,1,0);\nvec3 normalizedNormal=normalize(normal);\nnormalizedNormal*=normalizedNormal;\nvec3 worldBinormal=normalize(xbin*normalizedNormal.x+ybin*normalizedNormal.y+zbin*normalizedNormal.z);\nvec3 worldTangent=normalize(xtan*normalizedNormal.x+ytan*normalizedNormal.y+ztan*normalizedNormal.z);\nworldTangent=(world*vec4(worldTangent,1.0)).xyz;\nworldBinormal=(world*vec4(worldBinormal,1.0)).xyz;\nvec3 worldNormal=normalize(cross(worldTangent,worldBinormal));\ntangentSpace[0]=worldTangent;\ntangentSpace[1]=worldBinormal;\ntangentSpace[2]=worldNormal;\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  5379. exports.shader = shader;
  5380. babylonjs_1.Effect.ShadersStore[name] = shader;
  5381. /***/ }),
  5382. /***/ "./src/water/index.ts":
  5383. /*!****************************!*\
  5384. !*** ./src/water/index.ts ***!
  5385. \****************************/
  5386. /*! no static exports found */
  5387. /***/ (function(module, exports, __webpack_require__) {
  5388. "use strict";
  5389. function __export(m) {
  5390. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  5391. }
  5392. Object.defineProperty(exports, "__esModule", { value: true });
  5393. __export(__webpack_require__(/*! ./waterMaterial */ "./src/water/waterMaterial.ts"));
  5394. /***/ }),
  5395. /***/ "./src/water/water.fragment.ts":
  5396. /*!*************************************!*\
  5397. !*** ./src/water/water.fragment.ts ***!
  5398. \*************************************/
  5399. /*! no static exports found */
  5400. /***/ (function(module, exports, __webpack_require__) {
  5401. "use strict";
  5402. Object.defineProperty(exports, "__esModule", { value: true });
  5403. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  5404. var name = 'waterPixelShader';
  5405. exports.name = name;
  5406. var shader = "#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n\nuniform vec3 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef BUMP\nvarying vec2 vNormalUV;\nvarying vec2 vNormalUV2;\nuniform sampler2D normalSampler;\nuniform vec2 vNormalInfos;\n#endif\nuniform sampler2D refractionSampler;\nuniform sampler2D reflectionSampler;\n\nconst float LOG2=1.442695;\nuniform vec3 cameraPosition;\nuniform vec4 waterColor;\nuniform float colorBlendFactor;\nuniform vec4 waterColor2;\nuniform float colorBlendFactor2;\nuniform float bumpHeight;\nuniform float time;\n\nvarying vec3 vRefractionMapTexCoord;\nvarying vec3 vReflectionMapTexCoord;\nvarying vec3 vPosition;\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n#ifdef BUMP\n#ifdef BUMPSUPERIMPOSE\nbaseColor=0.6*texture2D(normalSampler,vNormalUV)+0.4*texture2D(normalSampler,vec2(vNormalUV2.x,vNormalUV2.y));\n#else\nbaseColor=texture2D(normalSampler,vNormalUV);\n#endif\nvec3 bumpColor=baseColor.rgb;\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\nbaseColor.rgb*=vNormalInfos.y;\n#else\nvec3 bumpColor=vec3(1.0);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\n#ifdef NORMAL\nvec2 perturbation=bumpHeight*(baseColor.rg-0.5);\n#ifdef BUMPAFFECTSREFLECTION\nvec3 normalW=normalize(vNormalW+vec3(perturbation.x*8.0,0.0,perturbation.y*8.0));\nif (normalW.y<0.0) {\nnormalW.y=-normalW.y;\n}\n#else\nvec3 normalW=normalize(vNormalW);\n#endif\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\nvec2 perturbation=bumpHeight*(vec2(1.0,1.0)-0.5);\n#endif\n#ifdef FRESNELSEPARATE\n#ifdef REFLECTION\n\nvec3 eyeVector=normalize(vEyePosition-vPosition);\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation*0.5,0.0,1.0);\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\nvec2 projectedReflectionTexCoords=clamp(vec2(\nvReflectionMapTexCoord.x/vReflectionMapTexCoord.z+perturbation.x*0.3,\nvReflectionMapTexCoord.y/vReflectionMapTexCoord.z+perturbation.y\n),0.0,1.0);\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\nvec3 upVector=vec3(0.0,1.0,0.0);\nfloat fresnelTerm=clamp(abs(pow(dot(eyeVector,upVector),3.0)),0.05,0.65);\nfloat IfresnelTerm=1.0-fresnelTerm;\nrefractiveColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*refractiveColor;\nreflectiveColor=IfresnelTerm*colorBlendFactor2*waterColor+(1.0-colorBlendFactor2*IfresnelTerm)*reflectiveColor;\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*IfresnelTerm;\nbaseColor=combinedColor;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#else\n#ifdef REFLECTION\n\nvec3 eyeVector=normalize(vEyePosition-vPosition);\nvec2 projectedRefractionTexCoords=clamp(vRefractionMapTexCoord.xy/vRefractionMapTexCoord.z+perturbation,0.0,1.0);\nvec4 refractiveColor=texture2D(refractionSampler,projectedRefractionTexCoords);\nvec2 projectedReflectionTexCoords=clamp(vReflectionMapTexCoord.xy/vReflectionMapTexCoord.z+perturbation,0.0,1.0);\nvec4 reflectiveColor=texture2D(reflectionSampler,projectedReflectionTexCoords);\nvec3 upVector=vec3(0.0,1.0,0.0);\nfloat fresnelTerm=max(dot(eyeVector,upVector),0.0);\nvec4 combinedColor=refractiveColor*fresnelTerm+reflectiveColor*(1.0-fresnelTerm);\nbaseColor=colorBlendFactor*waterColor+(1.0-colorBlendFactor)*combinedColor;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat shadow=1.;\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularBase=vec3(0.,0.,0.);\nvec3 specularColor=vSpecularColor.rgb;\n#else\nfloat glossiness=0.;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\nvec3 finalDiffuse=clamp(baseColor.rgb,0.0,1.0);\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#endif\n\nvec4 color=vec4(finalDiffuse+finalSpecular,alpha);\n#include<logDepthFragment>\n#include<fogFragment>\ngl_FragColor=color;\n}\n";
  5407. exports.shader = shader;
  5408. babylonjs_1.Effect.ShadersStore[name] = shader;
  5409. /***/ }),
  5410. /***/ "./src/water/water.vertex.ts":
  5411. /*!***********************************!*\
  5412. !*** ./src/water/water.vertex.ts ***!
  5413. \***********************************/
  5414. /*! no static exports found */
  5415. /***/ (function(module, exports, __webpack_require__) {
  5416. "use strict";
  5417. Object.defineProperty(exports, "__esModule", { value: true });
  5418. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  5419. var name = 'waterVertexShader';
  5420. exports.name = name;
  5421. var shader = "precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef BUMP\nvarying vec2 vNormalUV;\n#ifdef BUMPSUPERIMPOSE\nvarying vec2 vNormalUV2;\n#endif\nuniform mat4 normalMatrix;\nuniform vec2 vNormalInfos;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<logDepthDeclaration>\n\nuniform mat4 worldReflectionViewProjection;\nuniform vec2 windDirection;\nuniform float waveLength;\nuniform float time;\nuniform float windForce;\nuniform float waveHeight;\nuniform float waveSpeed;\n\nvarying vec3 vPosition;\nvarying vec3 vRefractionMapTexCoord;\nvarying vec3 vReflectionMapTexCoord;\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef BUMP\nif (vNormalInfos.x == 0.)\n{\nvNormalUV=vec2(normalMatrix*vec4((uv*1.0)/waveLength+time*windForce*windDirection,1.0,0.0));\n#ifdef BUMPSUPERIMPOSE\nvNormalUV2=vec2(normalMatrix*vec4((uv*0.721)/waveLength+time*1.2*windForce*windDirection,1.0,0.0));\n#endif\n}\nelse\n{\nvNormalUV=vec2(normalMatrix*vec4((uv2*1.0)/waveLength+time*windForce*windDirection ,1.0,0.0));\n#ifdef BUMPSUPERIMPOSE\nvNormalUV2=vec2(normalMatrix*vec4((uv2*0.721)/waveLength+time*1.2*windForce*windDirection ,1.0,0.0));\n#endif\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\nvec3 p=position;\nfloat newY=(sin(((p.x/0.05)+time*waveSpeed))*waveHeight*windDirection.x*5.0)\n+(cos(((p.z/0.05)+time*waveSpeed))*waveHeight*windDirection.y*5.0);\np.y+=abs(newY);\ngl_Position=viewProjection*finalWorld*vec4(p,1.0);\n#ifdef REFLECTION\nworldPos=viewProjection*finalWorld*vec4(p,1.0);\n\nvPosition=position;\nvRefractionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\nvRefractionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\nvRefractionMapTexCoord.z=worldPos.w;\nworldPos=worldReflectionViewProjection*vec4(position,1.0);\nvReflectionMapTexCoord.x=0.5*(worldPos.w+worldPos.x);\nvReflectionMapTexCoord.y=0.5*(worldPos.w+worldPos.y);\nvReflectionMapTexCoord.z=worldPos.w;\n#endif\n#include<logDepthVertex>\n}\n";
  5422. exports.shader = shader;
  5423. babylonjs_1.Effect.ShadersStore[name] = shader;
  5424. /***/ }),
  5425. /***/ "./src/water/waterMaterial.ts":
  5426. /*!************************************!*\
  5427. !*** ./src/water/waterMaterial.ts ***!
  5428. \************************************/
  5429. /*! no static exports found */
  5430. /***/ (function(module, exports, __webpack_require__) {
  5431. "use strict";
  5432. var __extends = (this && this.__extends) || (function () {
  5433. var extendStatics = function (d, b) {
  5434. extendStatics = Object.setPrototypeOf ||
  5435. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5436. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5437. return extendStatics(d, b);
  5438. }
  5439. return function (d, b) {
  5440. extendStatics(d, b);
  5441. function __() { this.constructor = d; }
  5442. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5443. };
  5444. })();
  5445. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  5446. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  5447. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  5448. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5449. return c > 3 && r && Object.defineProperty(target, key, r), r;
  5450. };
  5451. Object.defineProperty(exports, "__esModule", { value: true });
  5452. var babylonjs_1 = __webpack_require__(/*! babylonjs */ "babylonjs");
  5453. __webpack_require__(/*! ./water.fragment */ "./src/water/water.fragment.ts");
  5454. __webpack_require__(/*! ./water.vertex */ "./src/water/water.vertex.ts");
  5455. var WaterMaterialDefines = /** @class */ (function (_super) {
  5456. __extends(WaterMaterialDefines, _super);
  5457. function WaterMaterialDefines() {
  5458. var _this = _super.call(this) || this;
  5459. _this.BUMP = false;
  5460. _this.REFLECTION = false;
  5461. _this.CLIPPLANE = false;
  5462. _this.CLIPPLANE2 = false;
  5463. _this.CLIPPLANE3 = false;
  5464. _this.CLIPPLANE4 = false;
  5465. _this.ALPHATEST = false;
  5466. _this.DEPTHPREPASS = false;
  5467. _this.POINTSIZE = false;
  5468. _this.FOG = false;
  5469. _this.NORMAL = false;
  5470. _this.UV1 = false;
  5471. _this.UV2 = false;
  5472. _this.VERTEXCOLOR = false;
  5473. _this.VERTEXALPHA = false;
  5474. _this.NUM_BONE_INFLUENCERS = 0;
  5475. _this.BonesPerMesh = 0;
  5476. _this.INSTANCES = false;
  5477. _this.SPECULARTERM = false;
  5478. _this.LOGARITHMICDEPTH = false;
  5479. _this.FRESNELSEPARATE = false;
  5480. _this.BUMPSUPERIMPOSE = false;
  5481. _this.BUMPAFFECTSREFLECTION = false;
  5482. _this.rebuild();
  5483. return _this;
  5484. }
  5485. return WaterMaterialDefines;
  5486. }(babylonjs_1.MaterialDefines));
  5487. var WaterMaterial = /** @class */ (function (_super) {
  5488. __extends(WaterMaterial, _super);
  5489. /**
  5490. * Constructor
  5491. */
  5492. function WaterMaterial(name, scene, renderTargetSize) {
  5493. if (renderTargetSize === void 0) { renderTargetSize = new babylonjs_1.Vector2(512, 512); }
  5494. var _this = _super.call(this, name, scene) || this;
  5495. _this.renderTargetSize = renderTargetSize;
  5496. _this.diffuseColor = new babylonjs_1.Color3(1, 1, 1);
  5497. _this.specularColor = new babylonjs_1.Color3(0, 0, 0);
  5498. _this.specularPower = 64;
  5499. _this._disableLighting = false;
  5500. _this._maxSimultaneousLights = 4;
  5501. /**
  5502. * @param {number}: Represents the wind force
  5503. */
  5504. _this.windForce = 6;
  5505. /**
  5506. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  5507. */
  5508. _this.windDirection = new babylonjs_1.Vector2(0, 1);
  5509. /**
  5510. * @param {number}: Wave height, represents the height of the waves
  5511. */
  5512. _this.waveHeight = 0.4;
  5513. /**
  5514. * @param {number}: Bump height, represents the bump height related to the bump map
  5515. */
  5516. _this.bumpHeight = 0.4;
  5517. /**
  5518. * @param {boolean}: Add a smaller moving bump to less steady waves.
  5519. */
  5520. _this._bumpSuperimpose = false;
  5521. /**
  5522. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  5523. */
  5524. _this._fresnelSeparate = false;
  5525. /**
  5526. * @param {boolean}: bump Waves modify the reflection.
  5527. */
  5528. _this._bumpAffectsReflection = false;
  5529. /**
  5530. * @param {number}: The water color blended with the refraction (near)
  5531. */
  5532. _this.waterColor = new babylonjs_1.Color3(0.1, 0.1, 0.6);
  5533. /**
  5534. * @param {number}: The blend factor related to the water color
  5535. */
  5536. _this.colorBlendFactor = 0.2;
  5537. /**
  5538. * @param {number}: The water color blended with the reflection (far)
  5539. */
  5540. _this.waterColor2 = new babylonjs_1.Color3(0.1, 0.1, 0.6);
  5541. /**
  5542. * @param {number}: The blend factor related to the water color (reflection, far)
  5543. */
  5544. _this.colorBlendFactor2 = 0.2;
  5545. /**
  5546. * @param {number}: Represents the maximum length of a wave
  5547. */
  5548. _this.waveLength = 0.1;
  5549. /**
  5550. * @param {number}: Defines the waves speed
  5551. */
  5552. _this.waveSpeed = 1.0;
  5553. _this._renderTargets = new babylonjs_1.SmartArray(16);
  5554. /*
  5555. * Private members
  5556. */
  5557. _this._mesh = null;
  5558. _this._reflectionTransform = babylonjs_1.Matrix.Zero();
  5559. _this._lastTime = 0;
  5560. _this._lastDeltaTime = 0;
  5561. _this._createRenderTargets(scene, renderTargetSize);
  5562. // Create render targets
  5563. _this.getRenderTargetTextures = function () {
  5564. _this._renderTargets.reset();
  5565. _this._renderTargets.push(_this._reflectionRTT);
  5566. _this._renderTargets.push(_this._refractionRTT);
  5567. return _this._renderTargets;
  5568. };
  5569. return _this;
  5570. }
  5571. Object.defineProperty(WaterMaterial.prototype, "hasRenderTargetTextures", {
  5572. /**
  5573. * Gets a boolean indicating that current material needs to register RTT
  5574. */
  5575. get: function () {
  5576. return true;
  5577. },
  5578. enumerable: true,
  5579. configurable: true
  5580. });
  5581. Object.defineProperty(WaterMaterial.prototype, "useLogarithmicDepth", {
  5582. get: function () {
  5583. return this._useLogarithmicDepth;
  5584. },
  5585. set: function (value) {
  5586. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  5587. this._markAllSubMeshesAsMiscDirty();
  5588. },
  5589. enumerable: true,
  5590. configurable: true
  5591. });
  5592. Object.defineProperty(WaterMaterial.prototype, "refractionTexture", {
  5593. // Get / Set
  5594. get: function () {
  5595. return this._refractionRTT;
  5596. },
  5597. enumerable: true,
  5598. configurable: true
  5599. });
  5600. Object.defineProperty(WaterMaterial.prototype, "reflectionTexture", {
  5601. get: function () {
  5602. return this._reflectionRTT;
  5603. },
  5604. enumerable: true,
  5605. configurable: true
  5606. });
  5607. // Methods
  5608. WaterMaterial.prototype.addToRenderList = function (node) {
  5609. if (this._refractionRTT && this._refractionRTT.renderList) {
  5610. this._refractionRTT.renderList.push(node);
  5611. }
  5612. if (this._reflectionRTT && this._reflectionRTT.renderList) {
  5613. this._reflectionRTT.renderList.push(node);
  5614. }
  5615. };
  5616. WaterMaterial.prototype.enableRenderTargets = function (enable) {
  5617. var refreshRate = enable ? 1 : 0;
  5618. if (this._refractionRTT) {
  5619. this._refractionRTT.refreshRate = refreshRate;
  5620. }
  5621. if (this._reflectionRTT) {
  5622. this._reflectionRTT.refreshRate = refreshRate;
  5623. }
  5624. };
  5625. WaterMaterial.prototype.getRenderList = function () {
  5626. return this._refractionRTT ? this._refractionRTT.renderList : [];
  5627. };
  5628. Object.defineProperty(WaterMaterial.prototype, "renderTargetsEnabled", {
  5629. get: function () {
  5630. return !(this._refractionRTT && this._refractionRTT.refreshRate === 0);
  5631. },
  5632. enumerable: true,
  5633. configurable: true
  5634. });
  5635. WaterMaterial.prototype.needAlphaBlending = function () {
  5636. return (this.alpha < 1.0);
  5637. };
  5638. WaterMaterial.prototype.needAlphaTesting = function () {
  5639. return false;
  5640. };
  5641. WaterMaterial.prototype.getAlphaTestTexture = function () {
  5642. return null;
  5643. };
  5644. WaterMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  5645. if (this.isFrozen) {
  5646. if (this._wasPreviouslyReady && subMesh.effect) {
  5647. return true;
  5648. }
  5649. }
  5650. if (!subMesh._materialDefines) {
  5651. subMesh._materialDefines = new WaterMaterialDefines();
  5652. }
  5653. var defines = subMesh._materialDefines;
  5654. var scene = this.getScene();
  5655. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  5656. if (this._renderId === scene.getRenderId()) {
  5657. return true;
  5658. }
  5659. }
  5660. var engine = scene.getEngine();
  5661. // Textures
  5662. if (defines._areTexturesDirty) {
  5663. defines._needUVs = false;
  5664. if (scene.texturesEnabled) {
  5665. if (this.bumpTexture && babylonjs_1.StandardMaterial.BumpTextureEnabled) {
  5666. if (!this.bumpTexture.isReady()) {
  5667. return false;
  5668. }
  5669. else {
  5670. defines._needUVs = true;
  5671. defines.BUMP = true;
  5672. }
  5673. }
  5674. if (babylonjs_1.StandardMaterial.ReflectionTextureEnabled) {
  5675. defines.REFLECTION = true;
  5676. }
  5677. }
  5678. }
  5679. babylonjs_1.MaterialHelper.PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false);
  5680. babylonjs_1.MaterialHelper.PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  5681. if (defines._areMiscDirty) {
  5682. if (this._fresnelSeparate) {
  5683. defines.FRESNELSEPARATE = true;
  5684. }
  5685. if (this._bumpSuperimpose) {
  5686. defines.BUMPSUPERIMPOSE = true;
  5687. }
  5688. if (this._bumpAffectsReflection) {
  5689. defines.BUMPAFFECTSREFLECTION = true;
  5690. }
  5691. }
  5692. // Lights
  5693. defines._needNormals = babylonjs_1.MaterialHelper.PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  5694. // Attribs
  5695. babylonjs_1.MaterialHelper.PrepareDefinesForAttributes(mesh, defines, true, true);
  5696. // Configure this
  5697. this._mesh = mesh;
  5698. if (this._waitingRenderList) {
  5699. for (var i = 0; i < this._waitingRenderList.length; i++) {
  5700. this.addToRenderList(scene.getNodeByID(this._waitingRenderList[i]));
  5701. }
  5702. this._waitingRenderList = null;
  5703. }
  5704. // Get correct effect
  5705. if (defines.isDirty) {
  5706. defines.markAsProcessed();
  5707. scene.resetCachedMaterial();
  5708. // Fallbacks
  5709. var fallbacks = new babylonjs_1.EffectFallbacks();
  5710. if (defines.FOG) {
  5711. fallbacks.addFallback(1, "FOG");
  5712. }
  5713. if (defines.LOGARITHMICDEPTH) {
  5714. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  5715. }
  5716. babylonjs_1.MaterialHelper.HandleFallbacksForShadows(defines, fallbacks, this.maxSimultaneousLights);
  5717. if (defines.NUM_BONE_INFLUENCERS > 0) {
  5718. fallbacks.addCPUSkinningFallback(0, mesh);
  5719. }
  5720. //Attributes
  5721. var attribs = [babylonjs_1.VertexBuffer.PositionKind];
  5722. if (defines.NORMAL) {
  5723. attribs.push(babylonjs_1.VertexBuffer.NormalKind);
  5724. }
  5725. if (defines.UV1) {
  5726. attribs.push(babylonjs_1.VertexBuffer.UVKind);
  5727. }
  5728. if (defines.UV2) {
  5729. attribs.push(babylonjs_1.VertexBuffer.UV2Kind);
  5730. }
  5731. if (defines.VERTEXCOLOR) {
  5732. attribs.push(babylonjs_1.VertexBuffer.ColorKind);
  5733. }
  5734. babylonjs_1.MaterialHelper.PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  5735. babylonjs_1.MaterialHelper.PrepareAttributesForInstances(attribs, defines);
  5736. // Legacy browser patch
  5737. var shaderName = "water";
  5738. var join = defines.toString();
  5739. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
  5740. "vFogInfos", "vFogColor", "pointSize",
  5741. "vNormalInfos",
  5742. "mBones",
  5743. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "normalMatrix",
  5744. "logarithmicDepthConstant",
  5745. // Water
  5746. "worldReflectionViewProjection", "windDirection", "waveLength", "time", "windForce",
  5747. "cameraPosition", "bumpHeight", "waveHeight", "waterColor", "waterColor2", "colorBlendFactor", "colorBlendFactor2", "waveSpeed"
  5748. ];
  5749. var samplers = ["normalSampler",
  5750. // Water
  5751. "refractionSampler", "reflectionSampler"
  5752. ];
  5753. var uniformBuffers = new Array();
  5754. babylonjs_1.MaterialHelper.PrepareUniformsAndSamplersList({
  5755. uniformsNames: uniforms,
  5756. uniformBuffersNames: uniformBuffers,
  5757. samplers: samplers,
  5758. defines: defines,
  5759. maxSimultaneousLights: this.maxSimultaneousLights
  5760. });
  5761. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  5762. attributes: attribs,
  5763. uniformsNames: uniforms,
  5764. uniformBuffersNames: uniformBuffers,
  5765. samplers: samplers,
  5766. defines: join,
  5767. fallbacks: fallbacks,
  5768. onCompiled: this.onCompiled,
  5769. onError: this.onError,
  5770. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  5771. }, engine), defines);
  5772. }
  5773. if (!subMesh.effect || !subMesh.effect.isReady()) {
  5774. return false;
  5775. }
  5776. this._renderId = scene.getRenderId();
  5777. this._wasPreviouslyReady = true;
  5778. return true;
  5779. };
  5780. WaterMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  5781. var scene = this.getScene();
  5782. var defines = subMesh._materialDefines;
  5783. if (!defines) {
  5784. return;
  5785. }
  5786. var effect = subMesh.effect;
  5787. if (!effect || !this._mesh) {
  5788. return;
  5789. }
  5790. this._activeEffect = effect;
  5791. // Matrices
  5792. this.bindOnlyWorldMatrix(world);
  5793. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  5794. // Bones
  5795. babylonjs_1.MaterialHelper.BindBonesParameters(mesh, this._activeEffect);
  5796. if (this._mustRebind(scene, effect)) {
  5797. // Textures
  5798. if (this.bumpTexture && babylonjs_1.StandardMaterial.BumpTextureEnabled) {
  5799. this._activeEffect.setTexture("normalSampler", this.bumpTexture);
  5800. this._activeEffect.setFloat2("vNormalInfos", this.bumpTexture.coordinatesIndex, this.bumpTexture.level);
  5801. this._activeEffect.setMatrix("normalMatrix", this.bumpTexture.getTextureMatrix());
  5802. }
  5803. // Clip plane
  5804. babylonjs_1.MaterialHelper.BindClipPlane(this._activeEffect, scene);
  5805. // Point size
  5806. if (this.pointsCloud) {
  5807. this._activeEffect.setFloat("pointSize", this.pointSize);
  5808. }
  5809. babylonjs_1.MaterialHelper.BindEyePosition(effect, scene);
  5810. }
  5811. this._activeEffect.setColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  5812. if (defines.SPECULARTERM) {
  5813. this._activeEffect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
  5814. }
  5815. if (scene.lightsEnabled && !this.disableLighting) {
  5816. babylonjs_1.MaterialHelper.BindLights(scene, mesh, this._activeEffect, defines, this.maxSimultaneousLights);
  5817. }
  5818. // View
  5819. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== babylonjs_1.Scene.FOGMODE_NONE) {
  5820. this._activeEffect.setMatrix("view", scene.getViewMatrix());
  5821. }
  5822. // Fog
  5823. babylonjs_1.MaterialHelper.BindFogParameters(scene, mesh, this._activeEffect);
  5824. // Log. depth
  5825. babylonjs_1.MaterialHelper.BindLogDepth(defines, this._activeEffect, scene);
  5826. // Water
  5827. if (babylonjs_1.StandardMaterial.ReflectionTextureEnabled) {
  5828. this._activeEffect.setTexture("refractionSampler", this._refractionRTT);
  5829. this._activeEffect.setTexture("reflectionSampler", this._reflectionRTT);
  5830. }
  5831. var wrvp = this._mesh.getWorldMatrix().multiply(this._reflectionTransform).multiply(scene.getProjectionMatrix());
  5832. // Add delta time. Prevent adding delta time if it hasn't changed.
  5833. var deltaTime = scene.getEngine().getDeltaTime();
  5834. if (deltaTime !== this._lastDeltaTime) {
  5835. this._lastDeltaTime = deltaTime;
  5836. this._lastTime += this._lastDeltaTime;
  5837. }
  5838. this._activeEffect.setMatrix("worldReflectionViewProjection", wrvp);
  5839. this._activeEffect.setVector2("windDirection", this.windDirection);
  5840. this._activeEffect.setFloat("waveLength", this.waveLength);
  5841. this._activeEffect.setFloat("time", this._lastTime / 100000);
  5842. this._activeEffect.setFloat("windForce", this.windForce);
  5843. this._activeEffect.setFloat("waveHeight", this.waveHeight);
  5844. this._activeEffect.setFloat("bumpHeight", this.bumpHeight);
  5845. this._activeEffect.setColor4("waterColor", this.waterColor, 1.0);
  5846. this._activeEffect.setFloat("colorBlendFactor", this.colorBlendFactor);
  5847. this._activeEffect.setColor4("waterColor2", this.waterColor2, 1.0);
  5848. this._activeEffect.setFloat("colorBlendFactor2", this.colorBlendFactor2);
  5849. this._activeEffect.setFloat("waveSpeed", this.waveSpeed);
  5850. this._afterBind(mesh, this._activeEffect);
  5851. };
  5852. WaterMaterial.prototype._createRenderTargets = function (scene, renderTargetSize) {
  5853. var _this = this;
  5854. // Render targets
  5855. this._refractionRTT = new babylonjs_1.RenderTargetTexture(name + "_refraction", { width: renderTargetSize.x, height: renderTargetSize.y }, scene, false, true);
  5856. this._refractionRTT.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
  5857. this._refractionRTT.wrapV = BABYLON.Texture.MIRROR_ADDRESSMODE;
  5858. this._refractionRTT.ignoreCameraViewport = true;
  5859. this._reflectionRTT = new babylonjs_1.RenderTargetTexture(name + "_reflection", { width: renderTargetSize.x, height: renderTargetSize.y }, scene, false, true);
  5860. this._reflectionRTT.wrapU = BABYLON.Texture.MIRROR_ADDRESSMODE;
  5861. this._reflectionRTT.wrapV = BABYLON.Texture.MIRROR_ADDRESSMODE;
  5862. this._reflectionRTT.ignoreCameraViewport = true;
  5863. var isVisible;
  5864. var clipPlane = null;
  5865. var savedViewMatrix;
  5866. var mirrorMatrix = babylonjs_1.Matrix.Zero();
  5867. this._refractionRTT.onBeforeRender = function () {
  5868. if (_this._mesh) {
  5869. isVisible = _this._mesh.isVisible;
  5870. _this._mesh.isVisible = false;
  5871. }
  5872. // Clip plane
  5873. clipPlane = scene.clipPlane;
  5874. var positiony = _this._mesh ? _this._mesh.position.y : 0.0;
  5875. scene.clipPlane = babylonjs_1.Plane.FromPositionAndNormal(new babylonjs_1.Vector3(0, positiony + 0.05, 0), new babylonjs_1.Vector3(0, 1, 0));
  5876. };
  5877. this._refractionRTT.onAfterRender = function () {
  5878. if (_this._mesh) {
  5879. _this._mesh.isVisible = isVisible;
  5880. }
  5881. // Clip plane
  5882. scene.clipPlane = clipPlane;
  5883. };
  5884. this._reflectionRTT.onBeforeRender = function () {
  5885. if (_this._mesh) {
  5886. isVisible = _this._mesh.isVisible;
  5887. _this._mesh.isVisible = false;
  5888. }
  5889. // Clip plane
  5890. clipPlane = scene.clipPlane;
  5891. var positiony = _this._mesh ? _this._mesh.position.y : 0.0;
  5892. scene.clipPlane = babylonjs_1.Plane.FromPositionAndNormal(new babylonjs_1.Vector3(0, positiony - 0.05, 0), new babylonjs_1.Vector3(0, -1, 0));
  5893. // Transform
  5894. babylonjs_1.Matrix.ReflectionToRef(scene.clipPlane, mirrorMatrix);
  5895. savedViewMatrix = scene.getViewMatrix();
  5896. mirrorMatrix.multiplyToRef(savedViewMatrix, _this._reflectionTransform);
  5897. scene.setTransformMatrix(_this._reflectionTransform, scene.getProjectionMatrix());
  5898. scene.getEngine().cullBackFaces = false;
  5899. scene._mirroredCameraPosition = babylonjs_1.Vector3.TransformCoordinates(scene.activeCamera.position, mirrorMatrix);
  5900. };
  5901. this._reflectionRTT.onAfterRender = function () {
  5902. if (_this._mesh) {
  5903. _this._mesh.isVisible = isVisible;
  5904. }
  5905. // Clip plane
  5906. scene.clipPlane = clipPlane;
  5907. // Transform
  5908. scene.setTransformMatrix(savedViewMatrix, scene.getProjectionMatrix());
  5909. scene.getEngine().cullBackFaces = true;
  5910. scene._mirroredCameraPosition = null;
  5911. };
  5912. };
  5913. WaterMaterial.prototype.getAnimatables = function () {
  5914. var results = [];
  5915. if (this.bumpTexture && this.bumpTexture.animations && this.bumpTexture.animations.length > 0) {
  5916. results.push(this.bumpTexture);
  5917. }
  5918. if (this._reflectionRTT && this._reflectionRTT.animations && this._reflectionRTT.animations.length > 0) {
  5919. results.push(this._reflectionRTT);
  5920. }
  5921. if (this._refractionRTT && this._refractionRTT.animations && this._refractionRTT.animations.length > 0) {
  5922. results.push(this._refractionRTT);
  5923. }
  5924. return results;
  5925. };
  5926. WaterMaterial.prototype.getActiveTextures = function () {
  5927. var activeTextures = _super.prototype.getActiveTextures.call(this);
  5928. if (this._bumpTexture) {
  5929. activeTextures.push(this._bumpTexture);
  5930. }
  5931. return activeTextures;
  5932. };
  5933. WaterMaterial.prototype.hasTexture = function (texture) {
  5934. if (_super.prototype.hasTexture.call(this, texture)) {
  5935. return true;
  5936. }
  5937. if (this._bumpTexture === texture) {
  5938. return true;
  5939. }
  5940. return false;
  5941. };
  5942. WaterMaterial.prototype.dispose = function (forceDisposeEffect) {
  5943. if (this.bumpTexture) {
  5944. this.bumpTexture.dispose();
  5945. }
  5946. var index = this.getScene().customRenderTargets.indexOf(this._refractionRTT);
  5947. if (index != -1) {
  5948. this.getScene().customRenderTargets.splice(index, 1);
  5949. }
  5950. index = -1;
  5951. index = this.getScene().customRenderTargets.indexOf(this._reflectionRTT);
  5952. if (index != -1) {
  5953. this.getScene().customRenderTargets.splice(index, 1);
  5954. }
  5955. if (this._reflectionRTT) {
  5956. this._reflectionRTT.dispose();
  5957. }
  5958. if (this._refractionRTT) {
  5959. this._refractionRTT.dispose();
  5960. }
  5961. _super.prototype.dispose.call(this, forceDisposeEffect);
  5962. };
  5963. WaterMaterial.prototype.clone = function (name) {
  5964. var _this = this;
  5965. return babylonjs_1.SerializationHelper.Clone(function () { return new WaterMaterial(name, _this.getScene()); }, this);
  5966. };
  5967. WaterMaterial.prototype.serialize = function () {
  5968. var serializationObject = babylonjs_1.SerializationHelper.Serialize(this);
  5969. serializationObject.customType = "BABYLON.WaterMaterial";
  5970. serializationObject.renderList = [];
  5971. if (this._refractionRTT && this._refractionRTT.renderList) {
  5972. for (var i = 0; i < this._refractionRTT.renderList.length; i++) {
  5973. serializationObject.renderList.push(this._refractionRTT.renderList[i].id);
  5974. }
  5975. }
  5976. return serializationObject;
  5977. };
  5978. WaterMaterial.prototype.getClassName = function () {
  5979. return "WaterMaterial";
  5980. };
  5981. // Statics
  5982. WaterMaterial.Parse = function (source, scene, rootUrl) {
  5983. var mat = babylonjs_1.SerializationHelper.Parse(function () { return new WaterMaterial(source.name, scene); }, source, scene, rootUrl);
  5984. mat._waitingRenderList = source.renderList;
  5985. return mat;
  5986. };
  5987. WaterMaterial.CreateDefaultMesh = function (name, scene) {
  5988. var mesh = babylonjs_1.Mesh.CreateGround(name, 512, 512, 32, scene, false);
  5989. return mesh;
  5990. };
  5991. __decorate([
  5992. babylonjs_1.serializeAsTexture("bumpTexture")
  5993. ], WaterMaterial.prototype, "_bumpTexture", void 0);
  5994. __decorate([
  5995. babylonjs_1.expandToProperty("_markAllSubMeshesAsTexturesDirty")
  5996. ], WaterMaterial.prototype, "bumpTexture", void 0);
  5997. __decorate([
  5998. babylonjs_1.serializeAsColor3()
  5999. ], WaterMaterial.prototype, "diffuseColor", void 0);
  6000. __decorate([
  6001. babylonjs_1.serializeAsColor3()
  6002. ], WaterMaterial.prototype, "specularColor", void 0);
  6003. __decorate([
  6004. babylonjs_1.serialize()
  6005. ], WaterMaterial.prototype, "specularPower", void 0);
  6006. __decorate([
  6007. babylonjs_1.serialize("disableLighting")
  6008. ], WaterMaterial.prototype, "_disableLighting", void 0);
  6009. __decorate([
  6010. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  6011. ], WaterMaterial.prototype, "disableLighting", void 0);
  6012. __decorate([
  6013. babylonjs_1.serialize("maxSimultaneousLights")
  6014. ], WaterMaterial.prototype, "_maxSimultaneousLights", void 0);
  6015. __decorate([
  6016. babylonjs_1.expandToProperty("_markAllSubMeshesAsLightsDirty")
  6017. ], WaterMaterial.prototype, "maxSimultaneousLights", void 0);
  6018. __decorate([
  6019. babylonjs_1.serialize()
  6020. ], WaterMaterial.prototype, "windForce", void 0);
  6021. __decorate([
  6022. babylonjs_1.serializeAsVector2()
  6023. ], WaterMaterial.prototype, "windDirection", void 0);
  6024. __decorate([
  6025. babylonjs_1.serialize()
  6026. ], WaterMaterial.prototype, "waveHeight", void 0);
  6027. __decorate([
  6028. babylonjs_1.serialize()
  6029. ], WaterMaterial.prototype, "bumpHeight", void 0);
  6030. __decorate([
  6031. babylonjs_1.serialize("bumpSuperimpose")
  6032. ], WaterMaterial.prototype, "_bumpSuperimpose", void 0);
  6033. __decorate([
  6034. babylonjs_1.expandToProperty("_markAllSubMeshesAsMiscDirty")
  6035. ], WaterMaterial.prototype, "bumpSuperimpose", void 0);
  6036. __decorate([
  6037. babylonjs_1.serialize("fresnelSeparate")
  6038. ], WaterMaterial.prototype, "_fresnelSeparate", void 0);
  6039. __decorate([
  6040. babylonjs_1.expandToProperty("_markAllSubMeshesAsMiscDirty")
  6041. ], WaterMaterial.prototype, "fresnelSeparate", void 0);
  6042. __decorate([
  6043. babylonjs_1.serialize("bumpAffectsReflection")
  6044. ], WaterMaterial.prototype, "_bumpAffectsReflection", void 0);
  6045. __decorate([
  6046. babylonjs_1.expandToProperty("_markAllSubMeshesAsMiscDirty")
  6047. ], WaterMaterial.prototype, "bumpAffectsReflection", void 0);
  6048. __decorate([
  6049. babylonjs_1.serializeAsColor3()
  6050. ], WaterMaterial.prototype, "waterColor", void 0);
  6051. __decorate([
  6052. babylonjs_1.serialize()
  6053. ], WaterMaterial.prototype, "colorBlendFactor", void 0);
  6054. __decorate([
  6055. babylonjs_1.serializeAsColor3()
  6056. ], WaterMaterial.prototype, "waterColor2", void 0);
  6057. __decorate([
  6058. babylonjs_1.serialize()
  6059. ], WaterMaterial.prototype, "colorBlendFactor2", void 0);
  6060. __decorate([
  6061. babylonjs_1.serialize()
  6062. ], WaterMaterial.prototype, "waveLength", void 0);
  6063. __decorate([
  6064. babylonjs_1.serialize()
  6065. ], WaterMaterial.prototype, "waveSpeed", void 0);
  6066. __decorate([
  6067. babylonjs_1.serialize()
  6068. ], WaterMaterial.prototype, "useLogarithmicDepth", null);
  6069. return WaterMaterial;
  6070. }(babylonjs_1.PushMaterial));
  6071. exports.WaterMaterial = WaterMaterial;
  6072. /***/ }),
  6073. /***/ "babylonjs":
  6074. /*!****************************************************************************************************!*\
  6075. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  6076. \****************************************************************************************************/
  6077. /*! no static exports found */
  6078. /***/ (function(module, exports) {
  6079. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs__;
  6080. /***/ })
  6081. /******/ });
  6082. });
  6083. //# sourceMappingURL=babylonjs.materials.js.map