babylon.d.txt 3.0 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */ private _willBeUnregistered: boolean;
  111. /**
  112. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  113. */
  114. unregisterOnNextCall: boolean;
  115. /**
  116. * Creates a new observer
  117. * @param callback defines the callback to call when the observer is notified
  118. * @param mask defines the mask of the observer (used to filter notifications)
  119. * @param scope defines the current scope used to restore the JS context
  120. */
  121. constructor(
  122. /**
  123. * Defines the callback to call when the observer is notified
  124. */
  125. callback: (eventData: T, eventState: EventState) => void,
  126. /**
  127. * Defines the mask of the observer (used to filter notifications)
  128. */
  129. mask: number,
  130. /**
  131. * Defines the current scope used to restore the JS context
  132. */
  133. scope?: any);
  134. }
  135. /**
  136. * Represent a list of observers registered to multiple Observables object.
  137. */
  138. export class MultiObserver<T> {
  139. private _observers;
  140. private _observables;
  141. /**
  142. * Release associated resources
  143. */
  144. dispose(): void;
  145. /**
  146. * Raise a callback when one of the observable will notify
  147. * @param observables defines a list of observables to watch
  148. * @param callback defines the callback to call on notification
  149. * @param mask defines the mask used to filter notifications
  150. * @param scope defines the current scope used to restore the JS context
  151. * @returns the new MultiObserver
  152. */
  153. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  154. }
  155. /**
  156. * The Observable class is a simple implementation of the Observable pattern.
  157. *
  158. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  159. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  160. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  161. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  162. */
  163. export class Observable<T> {
  164. private _observers;
  165. private _eventState;
  166. private _onObserverAdded;
  167. /**
  168. * Gets the list of observers
  169. */
  170. readonly observers: Array<Observer<T>>;
  171. /**
  172. * Creates a new observable
  173. * @param onObserverAdded defines a callback to call when a new observer is added
  174. */
  175. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  176. /**
  177. * Create a new Observer with the specified callback
  178. * @param callback the callback that will be executed for that Observer
  179. * @param mask the mask used to filter observers
  180. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  181. * @param scope optional scope for the callback to be called from
  182. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  183. * @returns the new observer created for the callback
  184. */
  185. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  186. /**
  187. * Create a new Observer with the specified callback and unregisters after the next notification
  188. * @param callback the callback that will be executed for that Observer
  189. * @returns the new observer created for the callback
  190. */
  191. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  192. /**
  193. * Remove an Observer from the Observable object
  194. * @param observer the instance of the Observer to remove
  195. * @returns false if it doesn't belong to this Observable
  196. */
  197. remove(observer: Nullable<Observer<T>>): boolean;
  198. /**
  199. * Remove a callback from the Observable object
  200. * @param callback the callback to remove
  201. * @param scope optional scope. If used only the callbacks with this scope will be removed
  202. * @returns false if it doesn't belong to this Observable
  203. */
  204. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  205. private _deferUnregister;
  206. private _remove;
  207. /**
  208. * Moves the observable to the top of the observer list making it get called first when notified
  209. * @param observer the observer to move
  210. */
  211. makeObserverTopPriority(observer: Observer<T>): void;
  212. /**
  213. * Moves the observable to the bottom of the observer list making it get called last when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverBottomPriority(observer: Observer<T>): void;
  217. /**
  218. * Notify all Observers by calling their respective callback with the given data
  219. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  220. * @param eventData defines the data to send to all observers
  221. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  222. * @param target defines the original target of the state
  223. * @param currentTarget defines the current target of the state
  224. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  225. */
  226. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  227. /**
  228. * Calling this will execute each callback, expecting it to be a promise or return a value.
  229. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  230. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  231. * and it is crucial that all callbacks will be executed.
  232. * The order of the callbacks is kept, callbacks are not executed parallel.
  233. *
  234. * @param eventData The data to be sent to each callback
  235. * @param mask is used to filter observers defaults to -1
  236. * @param target defines the callback target (see EventState)
  237. * @param currentTarget defines he current object in the bubbling phase
  238. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  239. */
  240. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  241. /**
  242. * Notify a specific observer
  243. * @param observer defines the observer to notify
  244. * @param eventData defines the data to be sent to each callback
  245. * @param mask is used to filter observers defaults to -1
  246. */
  247. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  248. /**
  249. * Gets a boolean indicating if the observable has at least one observer
  250. * @returns true is the Observable has at least one Observer registered
  251. */
  252. hasObservers(): boolean;
  253. /**
  254. * Clear the list of observers
  255. */
  256. clear(): void;
  257. /**
  258. * Clone the current observable
  259. * @returns a new observable
  260. */
  261. clone(): Observable<T>;
  262. /**
  263. * Does this observable handles observer registered with a given mask
  264. * @param mask defines the mask to be tested
  265. * @return whether or not one observer registered with the given mask is handeled
  266. **/
  267. hasSpecificMask(mask?: number): boolean;
  268. }
  269. }
  270. declare module BABYLON {
  271. /**
  272. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  273. * Babylon.js
  274. */
  275. export class DomManagement {
  276. /**
  277. * Checks if the window object exists
  278. * @returns true if the window object exists
  279. */
  280. static IsWindowObjectExist(): boolean;
  281. /**
  282. * Checks if the navigator object exists
  283. * @returns true if the navigator object exists
  284. */
  285. static IsNavigatorAvailable(): boolean;
  286. /**
  287. * Extracts text content from a DOM element hierarchy
  288. * @param element defines the root element
  289. * @returns a string
  290. */
  291. static GetDOMTextContent(element: HTMLElement): string;
  292. }
  293. }
  294. declare module BABYLON {
  295. /**
  296. * Logger used througouht the application to allow configuration of
  297. * the log level required for the messages.
  298. */
  299. export class Logger {
  300. /**
  301. * No log
  302. */
  303. static readonly NoneLogLevel: number;
  304. /**
  305. * Only message logs
  306. */
  307. static readonly MessageLogLevel: number;
  308. /**
  309. * Only warning logs
  310. */
  311. static readonly WarningLogLevel: number;
  312. /**
  313. * Only error logs
  314. */
  315. static readonly ErrorLogLevel: number;
  316. /**
  317. * All logs
  318. */
  319. static readonly AllLogLevel: number;
  320. private static _LogCache;
  321. /**
  322. * Gets a value indicating the number of loading errors
  323. * @ignorenaming
  324. */
  325. static errorsCount: number;
  326. /**
  327. * Callback called when a new log is added
  328. */
  329. static OnNewCacheEntry: (entry: string) => void;
  330. private static _AddLogEntry;
  331. private static _FormatMessage;
  332. private static _LogDisabled;
  333. private static _LogEnabled;
  334. private static _WarnDisabled;
  335. private static _WarnEnabled;
  336. private static _ErrorDisabled;
  337. private static _ErrorEnabled;
  338. /**
  339. * Log a message to the console
  340. */
  341. static Log: (message: string) => void;
  342. /**
  343. * Write a warning message to the console
  344. */
  345. static Warn: (message: string) => void;
  346. /**
  347. * Write an error message to the console
  348. */
  349. static Error: (message: string) => void;
  350. /**
  351. * Gets current log cache (list of logs)
  352. */
  353. static readonly LogCache: string;
  354. /**
  355. * Clears the log cache
  356. */
  357. static ClearLogCache(): void;
  358. /**
  359. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  360. */
  361. static LogLevels: number;
  362. }
  363. }
  364. declare module BABYLON {
  365. /** @hidden */
  366. export class _TypeStore {
  367. /** @hidden */
  368. static RegisteredTypes: {
  369. [key: string]: Object;
  370. };
  371. /** @hidden */
  372. static GetClass(fqdn: string): any;
  373. }
  374. }
  375. declare module BABYLON {
  376. /**
  377. * Class containing a set of static utilities functions for deep copy.
  378. */
  379. export class DeepCopier {
  380. /**
  381. * Tries to copy an object by duplicating every property
  382. * @param source defines the source object
  383. * @param destination defines the target object
  384. * @param doNotCopyList defines a list of properties to avoid
  385. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  386. */
  387. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  388. }
  389. }
  390. declare module BABYLON {
  391. /**
  392. * Class containing a set of static utilities functions for precision date
  393. */
  394. export class PrecisionDate {
  395. /**
  396. * Gets either window.performance.now() if supported or Date.now() else
  397. */
  398. static readonly Now: number;
  399. }
  400. }
  401. declare module BABYLON {
  402. /** @hidden */
  403. export class _DevTools {
  404. static WarnImport(name: string): string;
  405. }
  406. }
  407. declare module BABYLON {
  408. /**
  409. * Interface used to define the mechanism to get data from the network
  410. */
  411. export interface IWebRequest {
  412. /**
  413. * Returns client's response url
  414. */
  415. responseURL: string;
  416. /**
  417. * Returns client's status
  418. */
  419. status: number;
  420. /**
  421. * Returns client's status as a text
  422. */
  423. statusText: string;
  424. }
  425. }
  426. declare module BABYLON {
  427. /**
  428. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  429. */
  430. export class WebRequest implements IWebRequest {
  431. private _xhr;
  432. /**
  433. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  434. * i.e. when loading files, where the server/service expects an Authorization header
  435. */
  436. static CustomRequestHeaders: {
  437. [key: string]: string;
  438. };
  439. /**
  440. * Add callback functions in this array to update all the requests before they get sent to the network
  441. */
  442. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  443. private _injectCustomRequestHeaders;
  444. /**
  445. * Gets or sets a function to be called when loading progress changes
  446. */
  447. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  448. /**
  449. * Returns client's state
  450. */
  451. readonly readyState: number;
  452. /**
  453. * Returns client's status
  454. */
  455. readonly status: number;
  456. /**
  457. * Returns client's status as a text
  458. */
  459. readonly statusText: string;
  460. /**
  461. * Returns client's response
  462. */
  463. readonly response: any;
  464. /**
  465. * Returns client's response url
  466. */
  467. readonly responseURL: string;
  468. /**
  469. * Returns client's response as text
  470. */
  471. readonly responseText: string;
  472. /**
  473. * Gets or sets the expected response type
  474. */
  475. responseType: XMLHttpRequestResponseType;
  476. /** @hidden */
  477. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  478. /** @hidden */
  479. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  480. /**
  481. * Cancels any network activity
  482. */
  483. abort(): void;
  484. /**
  485. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  486. * @param body defines an optional request body
  487. */
  488. send(body?: Document | BodyInit | null): void;
  489. /**
  490. * Sets the request method, request URL
  491. * @param method defines the method to use (GET, POST, etc..)
  492. * @param url defines the url to connect with
  493. */
  494. open(method: string, url: string): void;
  495. }
  496. }
  497. declare module BABYLON {
  498. /**
  499. * File request interface
  500. */
  501. export interface IFileRequest {
  502. /**
  503. * Raised when the request is complete (success or error).
  504. */
  505. onCompleteObservable: Observable<IFileRequest>;
  506. /**
  507. * Aborts the request for a file.
  508. */
  509. abort: () => void;
  510. }
  511. }
  512. declare module BABYLON {
  513. /**
  514. * Define options used to create a render target texture
  515. */
  516. export class RenderTargetCreationOptions {
  517. /**
  518. * Specifies is mipmaps must be generated
  519. */
  520. generateMipMaps?: boolean;
  521. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  522. generateDepthBuffer?: boolean;
  523. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  524. generateStencilBuffer?: boolean;
  525. /** Defines texture type (int by default) */
  526. type?: number;
  527. /** Defines sampling mode (trilinear by default) */
  528. samplingMode?: number;
  529. /** Defines format (RGBA by default) */
  530. format?: number;
  531. }
  532. }
  533. declare module BABYLON {
  534. /**
  535. * @hidden
  536. **/
  537. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  538. }
  539. }
  540. declare module BABYLON {
  541. /** Defines the cross module used constants to avoid circular dependncies */
  542. export class Constants {
  543. /** Defines that alpha blending is disabled */
  544. static readonly ALPHA_DISABLE: number;
  545. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  546. static readonly ALPHA_ADD: number;
  547. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  548. static readonly ALPHA_COMBINE: number;
  549. /** Defines that alpha blending to DEST - SRC * DEST */
  550. static readonly ALPHA_SUBTRACT: number;
  551. /** Defines that alpha blending to SRC * DEST */
  552. static readonly ALPHA_MULTIPLY: number;
  553. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  554. static readonly ALPHA_MAXIMIZED: number;
  555. /** Defines that alpha blending to SRC + DEST */
  556. static readonly ALPHA_ONEONE: number;
  557. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  558. static readonly ALPHA_PREMULTIPLIED: number;
  559. /**
  560. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  561. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  562. */
  563. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  564. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  565. static readonly ALPHA_INTERPOLATE: number;
  566. /**
  567. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  568. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  569. */
  570. static readonly ALPHA_SCREENMODE: number;
  571. /**
  572. * Defines that alpha blending to SRC + DST
  573. * Alpha will be set to SRC ALPHA + DST ALPHA
  574. */
  575. static readonly ALPHA_ONEONE_ONEONE: number;
  576. /**
  577. * Defines that alpha blending to SRC * DST ALPHA + DST
  578. * Alpha will be set to 0
  579. */
  580. static readonly ALPHA_ALPHATOCOLOR: number;
  581. /**
  582. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  583. */
  584. static readonly ALPHA_REVERSEONEMINUS: number;
  585. /**
  586. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  587. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  588. */
  589. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  590. /**
  591. * Defines that alpha blending to SRC + DST
  592. * Alpha will be set to SRC ALPHA
  593. */
  594. static readonly ALPHA_ONEONE_ONEZERO: number;
  595. /** Defines that alpha blending equation a SUM */
  596. static readonly ALPHA_EQUATION_ADD: number;
  597. /** Defines that alpha blending equation a SUBSTRACTION */
  598. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  599. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  600. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  601. /** Defines that alpha blending equation a MAX operation */
  602. static readonly ALPHA_EQUATION_MAX: number;
  603. /** Defines that alpha blending equation a MIN operation */
  604. static readonly ALPHA_EQUATION_MIN: number;
  605. /**
  606. * Defines that alpha blending equation a DARKEN operation:
  607. * It takes the min of the src and sums the alpha channels.
  608. */
  609. static readonly ALPHA_EQUATION_DARKEN: number;
  610. /** Defines that the ressource is not delayed*/
  611. static readonly DELAYLOADSTATE_NONE: number;
  612. /** Defines that the ressource was successfully delay loaded */
  613. static readonly DELAYLOADSTATE_LOADED: number;
  614. /** Defines that the ressource is currently delay loading */
  615. static readonly DELAYLOADSTATE_LOADING: number;
  616. /** Defines that the ressource is delayed and has not started loading */
  617. static readonly DELAYLOADSTATE_NOTLOADED: number;
  618. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  619. static readonly NEVER: number;
  620. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  621. static readonly ALWAYS: number;
  622. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  623. static readonly LESS: number;
  624. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  625. static readonly EQUAL: number;
  626. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  627. static readonly LEQUAL: number;
  628. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  629. static readonly GREATER: number;
  630. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  631. static readonly GEQUAL: number;
  632. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  633. static readonly NOTEQUAL: number;
  634. /** Passed to stencilOperation to specify that stencil value must be kept */
  635. static readonly KEEP: number;
  636. /** Passed to stencilOperation to specify that stencil value must be replaced */
  637. static readonly REPLACE: number;
  638. /** Passed to stencilOperation to specify that stencil value must be incremented */
  639. static readonly INCR: number;
  640. /** Passed to stencilOperation to specify that stencil value must be decremented */
  641. static readonly DECR: number;
  642. /** Passed to stencilOperation to specify that stencil value must be inverted */
  643. static readonly INVERT: number;
  644. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  645. static readonly INCR_WRAP: number;
  646. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  647. static readonly DECR_WRAP: number;
  648. /** Texture is not repeating outside of 0..1 UVs */
  649. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  650. /** Texture is repeating outside of 0..1 UVs */
  651. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  652. /** Texture is repeating and mirrored */
  653. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  654. /** ALPHA */
  655. static readonly TEXTUREFORMAT_ALPHA: number;
  656. /** LUMINANCE */
  657. static readonly TEXTUREFORMAT_LUMINANCE: number;
  658. /** LUMINANCE_ALPHA */
  659. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  660. /** RGB */
  661. static readonly TEXTUREFORMAT_RGB: number;
  662. /** RGBA */
  663. static readonly TEXTUREFORMAT_RGBA: number;
  664. /** RED */
  665. static readonly TEXTUREFORMAT_RED: number;
  666. /** RED (2nd reference) */
  667. static readonly TEXTUREFORMAT_R: number;
  668. /** RG */
  669. static readonly TEXTUREFORMAT_RG: number;
  670. /** RED_INTEGER */
  671. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  672. /** RED_INTEGER (2nd reference) */
  673. static readonly TEXTUREFORMAT_R_INTEGER: number;
  674. /** RG_INTEGER */
  675. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  676. /** RGB_INTEGER */
  677. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  678. /** RGBA_INTEGER */
  679. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  680. /** UNSIGNED_BYTE */
  681. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  682. /** UNSIGNED_BYTE (2nd reference) */
  683. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  684. /** FLOAT */
  685. static readonly TEXTURETYPE_FLOAT: number;
  686. /** HALF_FLOAT */
  687. static readonly TEXTURETYPE_HALF_FLOAT: number;
  688. /** BYTE */
  689. static readonly TEXTURETYPE_BYTE: number;
  690. /** SHORT */
  691. static readonly TEXTURETYPE_SHORT: number;
  692. /** UNSIGNED_SHORT */
  693. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  694. /** INT */
  695. static readonly TEXTURETYPE_INT: number;
  696. /** UNSIGNED_INT */
  697. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  698. /** UNSIGNED_SHORT_4_4_4_4 */
  699. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  700. /** UNSIGNED_SHORT_5_5_5_1 */
  701. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  702. /** UNSIGNED_SHORT_5_6_5 */
  703. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  704. /** UNSIGNED_INT_2_10_10_10_REV */
  705. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  706. /** UNSIGNED_INT_24_8 */
  707. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  708. /** UNSIGNED_INT_10F_11F_11F_REV */
  709. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  710. /** UNSIGNED_INT_5_9_9_9_REV */
  711. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  712. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  713. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  714. /** nearest is mag = nearest and min = nearest and mip = linear */
  715. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  716. /** Bilinear is mag = linear and min = linear and mip = nearest */
  717. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  718. /** Trilinear is mag = linear and min = linear and mip = linear */
  719. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  720. /** nearest is mag = nearest and min = nearest and mip = linear */
  721. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  722. /** Bilinear is mag = linear and min = linear and mip = nearest */
  723. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  724. /** Trilinear is mag = linear and min = linear and mip = linear */
  725. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  726. /** mag = nearest and min = nearest and mip = nearest */
  727. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  728. /** mag = nearest and min = linear and mip = nearest */
  729. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  730. /** mag = nearest and min = linear and mip = linear */
  731. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  732. /** mag = nearest and min = linear and mip = none */
  733. static readonly TEXTURE_NEAREST_LINEAR: number;
  734. /** mag = nearest and min = nearest and mip = none */
  735. static readonly TEXTURE_NEAREST_NEAREST: number;
  736. /** mag = linear and min = nearest and mip = nearest */
  737. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  738. /** mag = linear and min = nearest and mip = linear */
  739. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  740. /** mag = linear and min = linear and mip = none */
  741. static readonly TEXTURE_LINEAR_LINEAR: number;
  742. /** mag = linear and min = nearest and mip = none */
  743. static readonly TEXTURE_LINEAR_NEAREST: number;
  744. /** Explicit coordinates mode */
  745. static readonly TEXTURE_EXPLICIT_MODE: number;
  746. /** Spherical coordinates mode */
  747. static readonly TEXTURE_SPHERICAL_MODE: number;
  748. /** Planar coordinates mode */
  749. static readonly TEXTURE_PLANAR_MODE: number;
  750. /** Cubic coordinates mode */
  751. static readonly TEXTURE_CUBIC_MODE: number;
  752. /** Projection coordinates mode */
  753. static readonly TEXTURE_PROJECTION_MODE: number;
  754. /** Skybox coordinates mode */
  755. static readonly TEXTURE_SKYBOX_MODE: number;
  756. /** Inverse Cubic coordinates mode */
  757. static readonly TEXTURE_INVCUBIC_MODE: number;
  758. /** Equirectangular coordinates mode */
  759. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  760. /** Equirectangular Fixed coordinates mode */
  761. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  762. /** Equirectangular Fixed Mirrored coordinates mode */
  763. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  764. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  765. static readonly SCALEMODE_FLOOR: number;
  766. /** Defines that texture rescaling will look for the nearest power of 2 size */
  767. static readonly SCALEMODE_NEAREST: number;
  768. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  769. static readonly SCALEMODE_CEILING: number;
  770. /**
  771. * The dirty texture flag value
  772. */
  773. static readonly MATERIAL_TextureDirtyFlag: number;
  774. /**
  775. * The dirty light flag value
  776. */
  777. static readonly MATERIAL_LightDirtyFlag: number;
  778. /**
  779. * The dirty fresnel flag value
  780. */
  781. static readonly MATERIAL_FresnelDirtyFlag: number;
  782. /**
  783. * The dirty attribute flag value
  784. */
  785. static readonly MATERIAL_AttributesDirtyFlag: number;
  786. /**
  787. * The dirty misc flag value
  788. */
  789. static readonly MATERIAL_MiscDirtyFlag: number;
  790. /**
  791. * The all dirty flag value
  792. */
  793. static readonly MATERIAL_AllDirtyFlag: number;
  794. /**
  795. * Returns the triangle fill mode
  796. */
  797. static readonly MATERIAL_TriangleFillMode: number;
  798. /**
  799. * Returns the wireframe mode
  800. */
  801. static readonly MATERIAL_WireFrameFillMode: number;
  802. /**
  803. * Returns the point fill mode
  804. */
  805. static readonly MATERIAL_PointFillMode: number;
  806. /**
  807. * Returns the point list draw mode
  808. */
  809. static readonly MATERIAL_PointListDrawMode: number;
  810. /**
  811. * Returns the line list draw mode
  812. */
  813. static readonly MATERIAL_LineListDrawMode: number;
  814. /**
  815. * Returns the line loop draw mode
  816. */
  817. static readonly MATERIAL_LineLoopDrawMode: number;
  818. /**
  819. * Returns the line strip draw mode
  820. */
  821. static readonly MATERIAL_LineStripDrawMode: number;
  822. /**
  823. * Returns the triangle strip draw mode
  824. */
  825. static readonly MATERIAL_TriangleStripDrawMode: number;
  826. /**
  827. * Returns the triangle fan draw mode
  828. */
  829. static readonly MATERIAL_TriangleFanDrawMode: number;
  830. /**
  831. * Stores the clock-wise side orientation
  832. */
  833. static readonly MATERIAL_ClockWiseSideOrientation: number;
  834. /**
  835. * Stores the counter clock-wise side orientation
  836. */
  837. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  838. /**
  839. * Nothing
  840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  841. */
  842. static readonly ACTION_NothingTrigger: number;
  843. /**
  844. * On pick
  845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  846. */
  847. static readonly ACTION_OnPickTrigger: number;
  848. /**
  849. * On left pick
  850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  851. */
  852. static readonly ACTION_OnLeftPickTrigger: number;
  853. /**
  854. * On right pick
  855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  856. */
  857. static readonly ACTION_OnRightPickTrigger: number;
  858. /**
  859. * On center pick
  860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  861. */
  862. static readonly ACTION_OnCenterPickTrigger: number;
  863. /**
  864. * On pick down
  865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  866. */
  867. static readonly ACTION_OnPickDownTrigger: number;
  868. /**
  869. * On double pick
  870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  871. */
  872. static readonly ACTION_OnDoublePickTrigger: number;
  873. /**
  874. * On pick up
  875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  876. */
  877. static readonly ACTION_OnPickUpTrigger: number;
  878. /**
  879. * On pick out.
  880. * This trigger will only be raised if you also declared a OnPickDown
  881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  882. */
  883. static readonly ACTION_OnPickOutTrigger: number;
  884. /**
  885. * On long press
  886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  887. */
  888. static readonly ACTION_OnLongPressTrigger: number;
  889. /**
  890. * On pointer over
  891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  892. */
  893. static readonly ACTION_OnPointerOverTrigger: number;
  894. /**
  895. * On pointer out
  896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  897. */
  898. static readonly ACTION_OnPointerOutTrigger: number;
  899. /**
  900. * On every frame
  901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  902. */
  903. static readonly ACTION_OnEveryFrameTrigger: number;
  904. /**
  905. * On intersection enter
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_OnIntersectionEnterTrigger: number;
  909. /**
  910. * On intersection exit
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnIntersectionExitTrigger: number;
  914. /**
  915. * On key down
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnKeyDownTrigger: number;
  919. /**
  920. * On key up
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnKeyUpTrigger: number;
  924. /**
  925. * Billboard mode will only apply to Y axis
  926. */
  927. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  928. /**
  929. * Billboard mode will apply to all axes
  930. */
  931. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  932. /**
  933. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  934. */
  935. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  936. /**
  937. * Gets or sets base Assets URL
  938. */
  939. static PARTICLES_BaseAssetsUrl: string;
  940. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  941. * Test order :
  942. * Is the bounding sphere outside the frustum ?
  943. * If not, are the bounding box vertices outside the frustum ?
  944. * It not, then the cullable object is in the frustum.
  945. */
  946. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  947. /** Culling strategy : Bounding Sphere Only.
  948. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  949. * It's also less accurate than the standard because some not visible objects can still be selected.
  950. * Test : is the bounding sphere outside the frustum ?
  951. * If not, then the cullable object is in the frustum.
  952. */
  953. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  954. /** Culling strategy : Optimistic Inclusion.
  955. * This in an inclusion test first, then the standard exclusion test.
  956. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  957. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  958. * Anyway, it's as accurate as the standard strategy.
  959. * Test :
  960. * Is the cullable object bounding sphere center in the frustum ?
  961. * If not, apply the default culling strategy.
  962. */
  963. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  964. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  965. * This in an inclusion test first, then the bounding sphere only exclusion test.
  966. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  967. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  968. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  969. * Test :
  970. * Is the cullable object bounding sphere center in the frustum ?
  971. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  972. */
  973. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  974. /**
  975. * No logging while loading
  976. */
  977. static readonly SCENELOADER_NO_LOGGING: number;
  978. /**
  979. * Minimal logging while loading
  980. */
  981. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  982. /**
  983. * Summary logging while loading
  984. */
  985. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  986. /**
  987. * Detailled logging while loading
  988. */
  989. static readonly SCENELOADER_DETAILED_LOGGING: number;
  990. }
  991. }
  992. declare module BABYLON {
  993. /**
  994. * This represents the required contract to create a new type of texture loader.
  995. */
  996. export interface IInternalTextureLoader {
  997. /**
  998. * Defines wether the loader supports cascade loading the different faces.
  999. */
  1000. supportCascades: boolean;
  1001. /**
  1002. * This returns if the loader support the current file information.
  1003. * @param extension defines the file extension of the file being loaded
  1004. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1005. * @param fallback defines the fallback internal texture if any
  1006. * @param isBase64 defines whether the texture is encoded as a base64
  1007. * @param isBuffer defines whether the texture data are stored as a buffer
  1008. * @returns true if the loader can load the specified file
  1009. */
  1010. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1011. /**
  1012. * Transform the url before loading if required.
  1013. * @param rootUrl the url of the texture
  1014. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1015. * @returns the transformed texture
  1016. */
  1017. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1018. /**
  1019. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1020. * @param rootUrl the url of the texture
  1021. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1022. * @returns the fallback texture
  1023. */
  1024. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1025. /**
  1026. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1027. * @param data contains the texture data
  1028. * @param texture defines the BabylonJS internal texture
  1029. * @param createPolynomials will be true if polynomials have been requested
  1030. * @param onLoad defines the callback to trigger once the texture is ready
  1031. * @param onError defines the callback to trigger in case of error
  1032. */
  1033. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1034. /**
  1035. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1036. * @param data contains the texture data
  1037. * @param texture defines the BabylonJS internal texture
  1038. * @param callback defines the method to call once ready to upload
  1039. */
  1040. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1041. }
  1042. }
  1043. declare module BABYLON {
  1044. /**
  1045. * Class used to store and describe the pipeline context associated with an effect
  1046. */
  1047. export interface IPipelineContext {
  1048. /**
  1049. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1050. */
  1051. isAsync: boolean;
  1052. /**
  1053. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1054. */
  1055. isReady: boolean;
  1056. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1057. }
  1058. }
  1059. declare module BABYLON {
  1060. /**
  1061. * Class used to store gfx data (like WebGLBuffer)
  1062. */
  1063. export class DataBuffer {
  1064. /**
  1065. * Gets or sets the number of objects referencing this buffer
  1066. */
  1067. references: number;
  1068. /** Gets or sets the size of the underlying buffer */
  1069. capacity: number;
  1070. /**
  1071. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1072. */
  1073. is32Bits: boolean;
  1074. /**
  1075. * Gets the underlying buffer
  1076. */
  1077. readonly underlyingResource: any;
  1078. }
  1079. }
  1080. declare module BABYLON {
  1081. /** @hidden */
  1082. export interface IShaderProcessor {
  1083. attributeProcessor?: (attribute: string) => string;
  1084. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1085. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1086. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1087. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1088. lineProcessor?: (line: string, isFragment: boolean) => string;
  1089. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1090. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1091. }
  1092. }
  1093. declare module BABYLON {
  1094. /** @hidden */
  1095. export interface ProcessingOptions {
  1096. defines: string[];
  1097. indexParameters: any;
  1098. isFragment: boolean;
  1099. shouldUseHighPrecisionShader: boolean;
  1100. supportsUniformBuffers: boolean;
  1101. shadersRepository: string;
  1102. includesShadersStore: {
  1103. [key: string]: string;
  1104. };
  1105. processor?: IShaderProcessor;
  1106. version: string;
  1107. platformName: string;
  1108. lookForClosingBracketForUniformBuffer?: boolean;
  1109. }
  1110. }
  1111. declare module BABYLON {
  1112. /**
  1113. * Helper to manipulate strings
  1114. */
  1115. export class StringTools {
  1116. /**
  1117. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1118. * @param str Source string
  1119. * @param suffix Suffix to search for in the source string
  1120. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1121. */
  1122. static EndsWith(str: string, suffix: string): boolean;
  1123. /**
  1124. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1125. * @param str Source string
  1126. * @param suffix Suffix to search for in the source string
  1127. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1128. */
  1129. static StartsWith(str: string, suffix: string): boolean;
  1130. }
  1131. }
  1132. declare module BABYLON {
  1133. /** @hidden */
  1134. export class ShaderCodeNode {
  1135. line: string;
  1136. children: ShaderCodeNode[];
  1137. additionalDefineKey?: string;
  1138. additionalDefineValue?: string;
  1139. isValid(preprocessors: {
  1140. [key: string]: string;
  1141. }): boolean;
  1142. process(preprocessors: {
  1143. [key: string]: string;
  1144. }, options: ProcessingOptions): string;
  1145. }
  1146. }
  1147. declare module BABYLON {
  1148. /** @hidden */
  1149. export class ShaderCodeCursor {
  1150. private _lines;
  1151. lineIndex: number;
  1152. readonly currentLine: string;
  1153. readonly canRead: boolean;
  1154. lines: string[];
  1155. }
  1156. }
  1157. declare module BABYLON {
  1158. /** @hidden */
  1159. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1160. process(preprocessors: {
  1161. [key: string]: string;
  1162. }, options: ProcessingOptions): string;
  1163. }
  1164. }
  1165. declare module BABYLON {
  1166. /** @hidden */
  1167. export class ShaderDefineExpression {
  1168. isTrue(preprocessors: {
  1169. [key: string]: string;
  1170. }): boolean;
  1171. }
  1172. }
  1173. declare module BABYLON {
  1174. /** @hidden */
  1175. export class ShaderCodeTestNode extends ShaderCodeNode {
  1176. testExpression: ShaderDefineExpression;
  1177. isValid(preprocessors: {
  1178. [key: string]: string;
  1179. }): boolean;
  1180. }
  1181. }
  1182. declare module BABYLON {
  1183. /** @hidden */
  1184. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1185. define: string;
  1186. not: boolean;
  1187. constructor(define: string, not?: boolean);
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. }
  1192. }
  1193. declare module BABYLON {
  1194. /** @hidden */
  1195. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1196. leftOperand: ShaderDefineExpression;
  1197. rightOperand: ShaderDefineExpression;
  1198. isTrue(preprocessors: {
  1199. [key: string]: string;
  1200. }): boolean;
  1201. }
  1202. }
  1203. declare module BABYLON {
  1204. /** @hidden */
  1205. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1206. leftOperand: ShaderDefineExpression;
  1207. rightOperand: ShaderDefineExpression;
  1208. isTrue(preprocessors: {
  1209. [key: string]: string;
  1210. }): boolean;
  1211. }
  1212. }
  1213. declare module BABYLON {
  1214. /** @hidden */
  1215. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1216. define: string;
  1217. operand: string;
  1218. testValue: string;
  1219. constructor(define: string, operand: string, testValue: string);
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /**
  1227. * @ignore
  1228. * Application error to support additional information when loading a file
  1229. */
  1230. export class LoadFileError extends Error {
  1231. /** defines the optional web request */
  1232. request?: WebRequest | undefined;
  1233. private static _setPrototypeOf;
  1234. /**
  1235. * Creates a new LoadFileError
  1236. * @param message defines the message of the error
  1237. * @param request defines the optional web request
  1238. */
  1239. constructor(message: string,
  1240. /** defines the optional web request */
  1241. request?: WebRequest | undefined);
  1242. }
  1243. }
  1244. declare module BABYLON {
  1245. /**
  1246. * Class used to enable access to offline support
  1247. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1248. */
  1249. export interface IOfflineProvider {
  1250. /**
  1251. * Gets a boolean indicating if scene must be saved in the database
  1252. */
  1253. enableSceneOffline: boolean;
  1254. /**
  1255. * Gets a boolean indicating if textures must be saved in the database
  1256. */
  1257. enableTexturesOffline: boolean;
  1258. /**
  1259. * Open the offline support and make it available
  1260. * @param successCallback defines the callback to call on success
  1261. * @param errorCallback defines the callback to call on error
  1262. */
  1263. open(successCallback: () => void, errorCallback: () => void): void;
  1264. /**
  1265. * Loads an image from the offline support
  1266. * @param url defines the url to load from
  1267. * @param image defines the target DOM image
  1268. */
  1269. loadImage(url: string, image: HTMLImageElement): void;
  1270. /**
  1271. * Loads a file from offline support
  1272. * @param url defines the URL to load from
  1273. * @param sceneLoaded defines a callback to call on success
  1274. * @param progressCallBack defines a callback to call when progress changed
  1275. * @param errorCallback defines a callback to call on error
  1276. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1277. */
  1278. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1279. }
  1280. }
  1281. declare module BABYLON {
  1282. /**
  1283. * Class used to help managing file picking and drag'n'drop
  1284. * File Storage
  1285. */
  1286. export class FilesInputStore {
  1287. /**
  1288. * List of files ready to be loaded
  1289. */
  1290. static FilesToLoad: {
  1291. [key: string]: File;
  1292. };
  1293. }
  1294. }
  1295. declare module BABYLON {
  1296. /**
  1297. * Class used to define a retry strategy when error happens while loading assets
  1298. */
  1299. export class RetryStrategy {
  1300. /**
  1301. * Function used to defines an exponential back off strategy
  1302. * @param maxRetries defines the maximum number of retries (3 by default)
  1303. * @param baseInterval defines the interval between retries
  1304. * @returns the strategy function to use
  1305. */
  1306. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1307. }
  1308. }
  1309. declare module BABYLON {
  1310. /**
  1311. * @hidden
  1312. */
  1313. export class FileTools {
  1314. /**
  1315. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1316. */
  1317. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1318. /**
  1319. * Gets or sets the base URL to use to load assets
  1320. */
  1321. static BaseUrl: string;
  1322. /**
  1323. * Default behaviour for cors in the application.
  1324. * It can be a string if the expected behavior is identical in the entire app.
  1325. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1326. */
  1327. static CorsBehavior: string | ((url: string | string[]) => string);
  1328. /**
  1329. * Gets or sets a function used to pre-process url before using them to load assets
  1330. */
  1331. static PreprocessUrl: (url: string) => string;
  1332. /**
  1333. * Removes unwanted characters from an url
  1334. * @param url defines the url to clean
  1335. * @returns the cleaned url
  1336. */
  1337. private static _CleanUrl;
  1338. /**
  1339. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1340. * @param url define the url we are trying
  1341. * @param element define the dom element where to configure the cors policy
  1342. */
  1343. static SetCorsBehavior(url: string | string[], element: {
  1344. crossOrigin: string | null;
  1345. }): void;
  1346. /**
  1347. * Loads an image as an HTMLImageElement.
  1348. * @param input url string, ArrayBuffer, or Blob to load
  1349. * @param onLoad callback called when the image successfully loads
  1350. * @param onError callback called when the image fails to load
  1351. * @param offlineProvider offline provider for caching
  1352. * @returns the HTMLImageElement of the loaded image
  1353. */
  1354. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  1355. /**
  1356. * Loads a file
  1357. * @param fileToLoad defines the file to load
  1358. * @param callback defines the callback to call when data is loaded
  1359. * @param progressCallBack defines the callback to call during loading process
  1360. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1361. * @returns a file request object
  1362. */
  1363. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1364. /**
  1365. * Loads a file
  1366. * @param url url string, ArrayBuffer, or Blob to load
  1367. * @param onSuccess callback called when the file successfully loads
  1368. * @param onProgress callback called while file is loading (if the server supports this mode)
  1369. * @param offlineProvider defines the offline provider for caching
  1370. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1371. * @param onError callback called when the file fails to load
  1372. * @returns a file request object
  1373. */
  1374. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  1375. /**
  1376. * Checks if the loaded document was accessed via `file:`-Protocol.
  1377. * @returns boolean
  1378. */
  1379. static IsFileURL(): boolean;
  1380. }
  1381. }
  1382. declare module BABYLON {
  1383. /** @hidden */
  1384. export class ShaderProcessor {
  1385. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1386. private static _ProcessPrecision;
  1387. private static _ExtractOperation;
  1388. private static _BuildSubExpression;
  1389. private static _BuildExpression;
  1390. private static _MoveCursorWithinIf;
  1391. private static _MoveCursor;
  1392. private static _EvaluatePreProcessors;
  1393. private static _PreparePreProcessors;
  1394. private static _ProcessShaderConversion;
  1395. private static _ProcessIncludes;
  1396. }
  1397. }
  1398. declare module BABYLON {
  1399. /**
  1400. * @hidden
  1401. */
  1402. export interface IColor4Like {
  1403. r: float;
  1404. g: float;
  1405. b: float;
  1406. a: float;
  1407. }
  1408. /**
  1409. * @hidden
  1410. */
  1411. export interface IColor3Like {
  1412. r: float;
  1413. g: float;
  1414. b: float;
  1415. }
  1416. /**
  1417. * @hidden
  1418. */
  1419. export interface IVector4Like {
  1420. x: float;
  1421. y: float;
  1422. z: float;
  1423. w: float;
  1424. }
  1425. /**
  1426. * @hidden
  1427. */
  1428. export interface IVector3Like {
  1429. x: float;
  1430. y: float;
  1431. z: float;
  1432. }
  1433. /**
  1434. * @hidden
  1435. */
  1436. export interface IVector2Like {
  1437. x: float;
  1438. y: float;
  1439. }
  1440. /**
  1441. * @hidden
  1442. */
  1443. export interface IMatrixLike {
  1444. toArray(): DeepImmutable<Float32Array>;
  1445. updateFlag: int;
  1446. }
  1447. /**
  1448. * @hidden
  1449. */
  1450. export interface IViewportLike {
  1451. x: float;
  1452. y: float;
  1453. width: float;
  1454. height: float;
  1455. }
  1456. /**
  1457. * @hidden
  1458. */
  1459. export interface IPlaneLike {
  1460. normal: IVector3Like;
  1461. d: float;
  1462. normalize(): void;
  1463. }
  1464. }
  1465. declare module BABYLON {
  1466. /**
  1467. * Interface used to define common properties for effect fallbacks
  1468. */
  1469. export interface IEffectFallbacks {
  1470. /**
  1471. * Removes the defines that should be removed when falling back.
  1472. * @param currentDefines defines the current define statements for the shader.
  1473. * @param effect defines the current effect we try to compile
  1474. * @returns The resulting defines with defines of the current rank removed.
  1475. */
  1476. reduce(currentDefines: string, effect: Effect): string;
  1477. /**
  1478. * Removes the fallback from the bound mesh.
  1479. */
  1480. unBindMesh(): void;
  1481. /**
  1482. * Checks to see if more fallbacks are still availible.
  1483. */
  1484. hasMoreFallbacks: boolean;
  1485. }
  1486. }
  1487. declare module BABYLON {
  1488. /**
  1489. * Class used to evalaute queries containing `and` and `or` operators
  1490. */
  1491. export class AndOrNotEvaluator {
  1492. /**
  1493. * Evaluate a query
  1494. * @param query defines the query to evaluate
  1495. * @param evaluateCallback defines the callback used to filter result
  1496. * @returns true if the query matches
  1497. */
  1498. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1499. private static _HandleParenthesisContent;
  1500. private static _SimplifyNegation;
  1501. }
  1502. }
  1503. declare module BABYLON {
  1504. /**
  1505. * Class used to store custom tags
  1506. */
  1507. export class Tags {
  1508. /**
  1509. * Adds support for tags on the given object
  1510. * @param obj defines the object to use
  1511. */
  1512. static EnableFor(obj: any): void;
  1513. /**
  1514. * Removes tags support
  1515. * @param obj defines the object to use
  1516. */
  1517. static DisableFor(obj: any): void;
  1518. /**
  1519. * Gets a boolean indicating if the given object has tags
  1520. * @param obj defines the object to use
  1521. * @returns a boolean
  1522. */
  1523. static HasTags(obj: any): boolean;
  1524. /**
  1525. * Gets the tags available on a given object
  1526. * @param obj defines the object to use
  1527. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1528. * @returns the tags
  1529. */
  1530. static GetTags(obj: any, asString?: boolean): any;
  1531. /**
  1532. * Adds tags to an object
  1533. * @param obj defines the object to use
  1534. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1535. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1536. */
  1537. static AddTagsTo(obj: any, tagsString: string): void;
  1538. /**
  1539. * @hidden
  1540. */ private static _AddTagTo(obj: any, tag: string): void;
  1541. /**
  1542. * Removes specific tags from a specific object
  1543. * @param obj defines the object to use
  1544. * @param tagsString defines the tags to remove
  1545. */
  1546. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1547. /**
  1548. * @hidden
  1549. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  1550. /**
  1551. * Defines if tags hosted on an object match a given query
  1552. * @param obj defines the object to use
  1553. * @param tagsQuery defines the tag query
  1554. * @returns a boolean
  1555. */
  1556. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1557. }
  1558. }
  1559. declare module BABYLON {
  1560. /**
  1561. * Scalar computation library
  1562. */
  1563. export class Scalar {
  1564. /**
  1565. * Two pi constants convenient for computation.
  1566. */
  1567. static TwoPi: number;
  1568. /**
  1569. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1570. * @param a number
  1571. * @param b number
  1572. * @param epsilon (default = 1.401298E-45)
  1573. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1574. */
  1575. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1576. /**
  1577. * Returns a string : the upper case translation of the number i to hexadecimal.
  1578. * @param i number
  1579. * @returns the upper case translation of the number i to hexadecimal.
  1580. */
  1581. static ToHex(i: number): string;
  1582. /**
  1583. * Returns -1 if value is negative and +1 is value is positive.
  1584. * @param value the value
  1585. * @returns the value itself if it's equal to zero.
  1586. */
  1587. static Sign(value: number): number;
  1588. /**
  1589. * Returns the value itself if it's between min and max.
  1590. * Returns min if the value is lower than min.
  1591. * Returns max if the value is greater than max.
  1592. * @param value the value to clmap
  1593. * @param min the min value to clamp to (default: 0)
  1594. * @param max the max value to clamp to (default: 1)
  1595. * @returns the clamped value
  1596. */
  1597. static Clamp(value: number, min?: number, max?: number): number;
  1598. /**
  1599. * the log2 of value.
  1600. * @param value the value to compute log2 of
  1601. * @returns the log2 of value.
  1602. */
  1603. static Log2(value: number): number;
  1604. /**
  1605. * Loops the value, so that it is never larger than length and never smaller than 0.
  1606. *
  1607. * This is similar to the modulo operator but it works with floating point numbers.
  1608. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1609. * With t = 5 and length = 2.5, the result would be 0.0.
  1610. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1611. * @param value the value
  1612. * @param length the length
  1613. * @returns the looped value
  1614. */
  1615. static Repeat(value: number, length: number): number;
  1616. /**
  1617. * Normalize the value between 0.0 and 1.0 using min and max values
  1618. * @param value value to normalize
  1619. * @param min max to normalize between
  1620. * @param max min to normalize between
  1621. * @returns the normalized value
  1622. */
  1623. static Normalize(value: number, min: number, max: number): number;
  1624. /**
  1625. * Denormalize the value from 0.0 and 1.0 using min and max values
  1626. * @param normalized value to denormalize
  1627. * @param min max to denormalize between
  1628. * @param max min to denormalize between
  1629. * @returns the denormalized value
  1630. */
  1631. static Denormalize(normalized: number, min: number, max: number): number;
  1632. /**
  1633. * Calculates the shortest difference between two given angles given in degrees.
  1634. * @param current current angle in degrees
  1635. * @param target target angle in degrees
  1636. * @returns the delta
  1637. */
  1638. static DeltaAngle(current: number, target: number): number;
  1639. /**
  1640. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1641. * @param tx value
  1642. * @param length length
  1643. * @returns The returned value will move back and forth between 0 and length
  1644. */
  1645. static PingPong(tx: number, length: number): number;
  1646. /**
  1647. * Interpolates between min and max with smoothing at the limits.
  1648. *
  1649. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1650. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1651. * @param from from
  1652. * @param to to
  1653. * @param tx value
  1654. * @returns the smooth stepped value
  1655. */
  1656. static SmoothStep(from: number, to: number, tx: number): number;
  1657. /**
  1658. * Moves a value current towards target.
  1659. *
  1660. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1661. * Negative values of maxDelta pushes the value away from target.
  1662. * @param current current value
  1663. * @param target target value
  1664. * @param maxDelta max distance to move
  1665. * @returns resulting value
  1666. */
  1667. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1668. /**
  1669. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1670. *
  1671. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1672. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1673. * @param current current value
  1674. * @param target target value
  1675. * @param maxDelta max distance to move
  1676. * @returns resulting angle
  1677. */
  1678. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1679. /**
  1680. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1681. * @param start start value
  1682. * @param end target value
  1683. * @param amount amount to lerp between
  1684. * @returns the lerped value
  1685. */
  1686. static Lerp(start: number, end: number, amount: number): number;
  1687. /**
  1688. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1689. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1690. * @param start start value
  1691. * @param end target value
  1692. * @param amount amount to lerp between
  1693. * @returns the lerped value
  1694. */
  1695. static LerpAngle(start: number, end: number, amount: number): number;
  1696. /**
  1697. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1698. * @param a start value
  1699. * @param b target value
  1700. * @param value value between a and b
  1701. * @returns the inverseLerp value
  1702. */
  1703. static InverseLerp(a: number, b: number, value: number): number;
  1704. /**
  1705. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1706. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1707. * @param value1 spline value
  1708. * @param tangent1 spline value
  1709. * @param value2 spline value
  1710. * @param tangent2 spline value
  1711. * @param amount input value
  1712. * @returns hermite result
  1713. */
  1714. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1715. /**
  1716. * Returns a random float number between and min and max values
  1717. * @param min min value of random
  1718. * @param max max value of random
  1719. * @returns random value
  1720. */
  1721. static RandomRange(min: number, max: number): number;
  1722. /**
  1723. * This function returns percentage of a number in a given range.
  1724. *
  1725. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1726. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1727. * @param number to convert to percentage
  1728. * @param min min range
  1729. * @param max max range
  1730. * @returns the percentage
  1731. */
  1732. static RangeToPercent(number: number, min: number, max: number): number;
  1733. /**
  1734. * This function returns number that corresponds to the percentage in a given range.
  1735. *
  1736. * PercentToRange(0.34,0,100) will return 34.
  1737. * @param percent to convert to number
  1738. * @param min min range
  1739. * @param max max range
  1740. * @returns the number
  1741. */
  1742. static PercentToRange(percent: number, min: number, max: number): number;
  1743. /**
  1744. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1745. * @param angle The angle to normalize in radian.
  1746. * @return The converted angle.
  1747. */
  1748. static NormalizeRadians(angle: number): number;
  1749. }
  1750. }
  1751. declare module BABYLON {
  1752. /**
  1753. * Constant used to convert a value to gamma space
  1754. * @ignorenaming
  1755. */
  1756. export const ToGammaSpace: number;
  1757. /**
  1758. * Constant used to convert a value to linear space
  1759. * @ignorenaming
  1760. */
  1761. export const ToLinearSpace = 2.2;
  1762. /**
  1763. * Constant used to define the minimal number value in Babylon.js
  1764. * @ignorenaming
  1765. */
  1766. let Epsilon: number;
  1767. }
  1768. declare module BABYLON {
  1769. /**
  1770. * Class used to represent a viewport on screen
  1771. */
  1772. export class Viewport {
  1773. /** viewport left coordinate */
  1774. x: number;
  1775. /** viewport top coordinate */
  1776. y: number;
  1777. /**viewport width */
  1778. width: number;
  1779. /** viewport height */
  1780. height: number;
  1781. /**
  1782. * Creates a Viewport object located at (x, y) and sized (width, height)
  1783. * @param x defines viewport left coordinate
  1784. * @param y defines viewport top coordinate
  1785. * @param width defines the viewport width
  1786. * @param height defines the viewport height
  1787. */
  1788. constructor(
  1789. /** viewport left coordinate */
  1790. x: number,
  1791. /** viewport top coordinate */
  1792. y: number,
  1793. /**viewport width */
  1794. width: number,
  1795. /** viewport height */
  1796. height: number);
  1797. /**
  1798. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1799. * @param renderWidth defines the rendering width
  1800. * @param renderHeight defines the rendering height
  1801. * @returns a new Viewport
  1802. */
  1803. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1804. /**
  1805. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1806. * @param renderWidth defines the rendering width
  1807. * @param renderHeight defines the rendering height
  1808. * @param ref defines the target viewport
  1809. * @returns the current viewport
  1810. */
  1811. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1812. /**
  1813. * Returns a new Viewport copied from the current one
  1814. * @returns a new Viewport
  1815. */
  1816. clone(): Viewport;
  1817. }
  1818. }
  1819. declare module BABYLON {
  1820. /**
  1821. * Class containing a set of static utilities functions for arrays.
  1822. */
  1823. export class ArrayTools {
  1824. /**
  1825. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1826. * @param size the number of element to construct and put in the array
  1827. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1828. * @returns a new array filled with new objects
  1829. */
  1830. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1831. }
  1832. }
  1833. declare module BABYLON {
  1834. /**
  1835. * Class representing a vector containing 2 coordinates
  1836. */
  1837. export class Vector2 {
  1838. /** defines the first coordinate */
  1839. x: number;
  1840. /** defines the second coordinate */
  1841. y: number;
  1842. /**
  1843. * Creates a new Vector2 from the given x and y coordinates
  1844. * @param x defines the first coordinate
  1845. * @param y defines the second coordinate
  1846. */
  1847. constructor(
  1848. /** defines the first coordinate */
  1849. x?: number,
  1850. /** defines the second coordinate */
  1851. y?: number);
  1852. /**
  1853. * Gets a string with the Vector2 coordinates
  1854. * @returns a string with the Vector2 coordinates
  1855. */
  1856. toString(): string;
  1857. /**
  1858. * Gets class name
  1859. * @returns the string "Vector2"
  1860. */
  1861. getClassName(): string;
  1862. /**
  1863. * Gets current vector hash code
  1864. * @returns the Vector2 hash code as a number
  1865. */
  1866. getHashCode(): number;
  1867. /**
  1868. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1869. * @param array defines the source array
  1870. * @param index defines the offset in source array
  1871. * @returns the current Vector2
  1872. */
  1873. toArray(array: FloatArray, index?: number): Vector2;
  1874. /**
  1875. * Copy the current vector to an array
  1876. * @returns a new array with 2 elements: the Vector2 coordinates.
  1877. */
  1878. asArray(): number[];
  1879. /**
  1880. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1881. * @param source defines the source Vector2
  1882. * @returns the current updated Vector2
  1883. */
  1884. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1885. /**
  1886. * Sets the Vector2 coordinates with the given floats
  1887. * @param x defines the first coordinate
  1888. * @param y defines the second coordinate
  1889. * @returns the current updated Vector2
  1890. */
  1891. copyFromFloats(x: number, y: number): Vector2;
  1892. /**
  1893. * Sets the Vector2 coordinates with the given floats
  1894. * @param x defines the first coordinate
  1895. * @param y defines the second coordinate
  1896. * @returns the current updated Vector2
  1897. */
  1898. set(x: number, y: number): Vector2;
  1899. /**
  1900. * Add another vector with the current one
  1901. * @param otherVector defines the other vector
  1902. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1903. */
  1904. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1905. /**
  1906. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1907. * @param otherVector defines the other vector
  1908. * @param result defines the target vector
  1909. * @returns the unmodified current Vector2
  1910. */
  1911. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1912. /**
  1913. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1914. * @param otherVector defines the other vector
  1915. * @returns the current updated Vector2
  1916. */
  1917. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1918. /**
  1919. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1920. * @param otherVector defines the other vector
  1921. * @returns a new Vector2
  1922. */
  1923. addVector3(otherVector: Vector3): Vector2;
  1924. /**
  1925. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1926. * @param otherVector defines the other vector
  1927. * @returns a new Vector2
  1928. */
  1929. subtract(otherVector: Vector2): Vector2;
  1930. /**
  1931. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1932. * @param otherVector defines the other vector
  1933. * @param result defines the target vector
  1934. * @returns the unmodified current Vector2
  1935. */
  1936. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1937. /**
  1938. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1939. * @param otherVector defines the other vector
  1940. * @returns the current updated Vector2
  1941. */
  1942. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1943. /**
  1944. * Multiplies in place the current Vector2 coordinates by the given ones
  1945. * @param otherVector defines the other vector
  1946. * @returns the current updated Vector2
  1947. */
  1948. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1949. /**
  1950. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1951. * @param otherVector defines the other vector
  1952. * @returns a new Vector2
  1953. */
  1954. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1955. /**
  1956. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1957. * @param otherVector defines the other vector
  1958. * @param result defines the target vector
  1959. * @returns the unmodified current Vector2
  1960. */
  1961. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1962. /**
  1963. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1964. * @param x defines the first coordinate
  1965. * @param y defines the second coordinate
  1966. * @returns a new Vector2
  1967. */
  1968. multiplyByFloats(x: number, y: number): Vector2;
  1969. /**
  1970. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1971. * @param otherVector defines the other vector
  1972. * @returns a new Vector2
  1973. */
  1974. divide(otherVector: Vector2): Vector2;
  1975. /**
  1976. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1977. * @param otherVector defines the other vector
  1978. * @param result defines the target vector
  1979. * @returns the unmodified current Vector2
  1980. */
  1981. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1982. /**
  1983. * Divides the current Vector2 coordinates by the given ones
  1984. * @param otherVector defines the other vector
  1985. * @returns the current updated Vector2
  1986. */
  1987. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1988. /**
  1989. * Gets a new Vector2 with current Vector2 negated coordinates
  1990. * @returns a new Vector2
  1991. */
  1992. negate(): Vector2;
  1993. /**
  1994. * Multiply the Vector2 coordinates by scale
  1995. * @param scale defines the scaling factor
  1996. * @returns the current updated Vector2
  1997. */
  1998. scaleInPlace(scale: number): Vector2;
  1999. /**
  2000. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2001. * @param scale defines the scaling factor
  2002. * @returns a new Vector2
  2003. */
  2004. scale(scale: number): Vector2;
  2005. /**
  2006. * Scale the current Vector2 values by a factor to a given Vector2
  2007. * @param scale defines the scale factor
  2008. * @param result defines the Vector2 object where to store the result
  2009. * @returns the unmodified current Vector2
  2010. */
  2011. scaleToRef(scale: number, result: Vector2): Vector2;
  2012. /**
  2013. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2014. * @param scale defines the scale factor
  2015. * @param result defines the Vector2 object where to store the result
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2019. /**
  2020. * Gets a boolean if two vectors are equals
  2021. * @param otherVector defines the other vector
  2022. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2023. */
  2024. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2025. /**
  2026. * Gets a boolean if two vectors are equals (using an epsilon value)
  2027. * @param otherVector defines the other vector
  2028. * @param epsilon defines the minimal distance to consider equality
  2029. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2030. */
  2031. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2032. /**
  2033. * Gets a new Vector2 from current Vector2 floored values
  2034. * @returns a new Vector2
  2035. */
  2036. floor(): Vector2;
  2037. /**
  2038. * Gets a new Vector2 from current Vector2 floored values
  2039. * @returns a new Vector2
  2040. */
  2041. fract(): Vector2;
  2042. /**
  2043. * Gets the length of the vector
  2044. * @returns the vector length (float)
  2045. */
  2046. length(): number;
  2047. /**
  2048. * Gets the vector squared length
  2049. * @returns the vector squared length (float)
  2050. */
  2051. lengthSquared(): number;
  2052. /**
  2053. * Normalize the vector
  2054. * @returns the current updated Vector2
  2055. */
  2056. normalize(): Vector2;
  2057. /**
  2058. * Gets a new Vector2 copied from the Vector2
  2059. * @returns a new Vector2
  2060. */
  2061. clone(): Vector2;
  2062. /**
  2063. * Gets a new Vector2(0, 0)
  2064. * @returns a new Vector2
  2065. */
  2066. static Zero(): Vector2;
  2067. /**
  2068. * Gets a new Vector2(1, 1)
  2069. * @returns a new Vector2
  2070. */
  2071. static One(): Vector2;
  2072. /**
  2073. * Gets a new Vector2 set from the given index element of the given array
  2074. * @param array defines the data source
  2075. * @param offset defines the offset in the data source
  2076. * @returns a new Vector2
  2077. */
  2078. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2079. /**
  2080. * Sets "result" from the given index element of the given array
  2081. * @param array defines the data source
  2082. * @param offset defines the offset in the data source
  2083. * @param result defines the target vector
  2084. */
  2085. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2086. /**
  2087. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2088. * @param value1 defines 1st point of control
  2089. * @param value2 defines 2nd point of control
  2090. * @param value3 defines 3rd point of control
  2091. * @param value4 defines 4th point of control
  2092. * @param amount defines the interpolation factor
  2093. * @returns a new Vector2
  2094. */
  2095. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2096. /**
  2097. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2098. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2099. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2100. * @param value defines the value to clamp
  2101. * @param min defines the lower limit
  2102. * @param max defines the upper limit
  2103. * @returns a new Vector2
  2104. */
  2105. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2106. /**
  2107. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2108. * @param value1 defines the 1st control point
  2109. * @param tangent1 defines the outgoing tangent
  2110. * @param value2 defines the 2nd control point
  2111. * @param tangent2 defines the incoming tangent
  2112. * @param amount defines the interpolation factor
  2113. * @returns a new Vector2
  2114. */
  2115. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2116. /**
  2117. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2118. * @param start defines the start vector
  2119. * @param end defines the end vector
  2120. * @param amount defines the interpolation factor
  2121. * @returns a new Vector2
  2122. */
  2123. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2124. /**
  2125. * Gets the dot product of the vector "left" and the vector "right"
  2126. * @param left defines first vector
  2127. * @param right defines second vector
  2128. * @returns the dot product (float)
  2129. */
  2130. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2131. /**
  2132. * Returns a new Vector2 equal to the normalized given vector
  2133. * @param vector defines the vector to normalize
  2134. * @returns a new Vector2
  2135. */
  2136. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2137. /**
  2138. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2139. * @param left defines 1st vector
  2140. * @param right defines 2nd vector
  2141. * @returns a new Vector2
  2142. */
  2143. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2144. /**
  2145. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2146. * @param left defines 1st vector
  2147. * @param right defines 2nd vector
  2148. * @returns a new Vector2
  2149. */
  2150. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2151. /**
  2152. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2153. * @param vector defines the vector to transform
  2154. * @param transformation defines the matrix to apply
  2155. * @returns a new Vector2
  2156. */
  2157. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2158. /**
  2159. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2160. * @param vector defines the vector to transform
  2161. * @param transformation defines the matrix to apply
  2162. * @param result defines the target vector
  2163. */
  2164. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2165. /**
  2166. * Determines if a given vector is included in a triangle
  2167. * @param p defines the vector to test
  2168. * @param p0 defines 1st triangle point
  2169. * @param p1 defines 2nd triangle point
  2170. * @param p2 defines 3rd triangle point
  2171. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2172. */
  2173. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2174. /**
  2175. * Gets the distance between the vectors "value1" and "value2"
  2176. * @param value1 defines first vector
  2177. * @param value2 defines second vector
  2178. * @returns the distance between vectors
  2179. */
  2180. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2181. /**
  2182. * Returns the squared distance between the vectors "value1" and "value2"
  2183. * @param value1 defines first vector
  2184. * @param value2 defines second vector
  2185. * @returns the squared distance between vectors
  2186. */
  2187. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2188. /**
  2189. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2190. * @param value1 defines first vector
  2191. * @param value2 defines second vector
  2192. * @returns a new Vector2
  2193. */
  2194. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2195. /**
  2196. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2197. * @param p defines the middle point
  2198. * @param segA defines one point of the segment
  2199. * @param segB defines the other point of the segment
  2200. * @returns the shortest distance
  2201. */
  2202. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2203. }
  2204. /**
  2205. * Classed used to store (x,y,z) vector representation
  2206. * A Vector3 is the main object used in 3D geometry
  2207. * It can represent etiher the coordinates of a point the space, either a direction
  2208. * Reminder: js uses a left handed forward facing system
  2209. */
  2210. export class Vector3 {
  2211. /**
  2212. * Defines the first coordinates (on X axis)
  2213. */
  2214. x: number;
  2215. /**
  2216. * Defines the second coordinates (on Y axis)
  2217. */
  2218. y: number;
  2219. /**
  2220. * Defines the third coordinates (on Z axis)
  2221. */
  2222. z: number;
  2223. private static _UpReadOnly;
  2224. private static _ZeroReadOnly;
  2225. /**
  2226. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2227. * @param x defines the first coordinates (on X axis)
  2228. * @param y defines the second coordinates (on Y axis)
  2229. * @param z defines the third coordinates (on Z axis)
  2230. */
  2231. constructor(
  2232. /**
  2233. * Defines the first coordinates (on X axis)
  2234. */
  2235. x?: number,
  2236. /**
  2237. * Defines the second coordinates (on Y axis)
  2238. */
  2239. y?: number,
  2240. /**
  2241. * Defines the third coordinates (on Z axis)
  2242. */
  2243. z?: number);
  2244. /**
  2245. * Creates a string representation of the Vector3
  2246. * @returns a string with the Vector3 coordinates.
  2247. */
  2248. toString(): string;
  2249. /**
  2250. * Gets the class name
  2251. * @returns the string "Vector3"
  2252. */
  2253. getClassName(): string;
  2254. /**
  2255. * Creates the Vector3 hash code
  2256. * @returns a number which tends to be unique between Vector3 instances
  2257. */
  2258. getHashCode(): number;
  2259. /**
  2260. * Creates an array containing three elements : the coordinates of the Vector3
  2261. * @returns a new array of numbers
  2262. */
  2263. asArray(): number[];
  2264. /**
  2265. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2266. * @param array defines the destination array
  2267. * @param index defines the offset in the destination array
  2268. * @returns the current Vector3
  2269. */
  2270. toArray(array: FloatArray, index?: number): Vector3;
  2271. /**
  2272. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2273. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2274. */
  2275. toQuaternion(): Quaternion;
  2276. /**
  2277. * Adds the given vector to the current Vector3
  2278. * @param otherVector defines the second operand
  2279. * @returns the current updated Vector3
  2280. */
  2281. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2282. /**
  2283. * Adds the given coordinates to the current Vector3
  2284. * @param x defines the x coordinate of the operand
  2285. * @param y defines the y coordinate of the operand
  2286. * @param z defines the z coordinate of the operand
  2287. * @returns the current updated Vector3
  2288. */
  2289. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2290. /**
  2291. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2292. * @param otherVector defines the second operand
  2293. * @returns the resulting Vector3
  2294. */
  2295. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2296. /**
  2297. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2298. * @param otherVector defines the second operand
  2299. * @param result defines the Vector3 object where to store the result
  2300. * @returns the current Vector3
  2301. */
  2302. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2303. /**
  2304. * Subtract the given vector from the current Vector3
  2305. * @param otherVector defines the second operand
  2306. * @returns the current updated Vector3
  2307. */
  2308. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2309. /**
  2310. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2311. * @param otherVector defines the second operand
  2312. * @returns the resulting Vector3
  2313. */
  2314. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2315. /**
  2316. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2317. * @param otherVector defines the second operand
  2318. * @param result defines the Vector3 object where to store the result
  2319. * @returns the current Vector3
  2320. */
  2321. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2322. /**
  2323. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2324. * @param x defines the x coordinate of the operand
  2325. * @param y defines the y coordinate of the operand
  2326. * @param z defines the z coordinate of the operand
  2327. * @returns the resulting Vector3
  2328. */
  2329. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2330. /**
  2331. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2332. * @param x defines the x coordinate of the operand
  2333. * @param y defines the y coordinate of the operand
  2334. * @param z defines the z coordinate of the operand
  2335. * @param result defines the Vector3 object where to store the result
  2336. * @returns the current Vector3
  2337. */
  2338. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2339. /**
  2340. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2341. * @returns a new Vector3
  2342. */
  2343. negate(): Vector3;
  2344. /**
  2345. * Multiplies the Vector3 coordinates by the float "scale"
  2346. * @param scale defines the multiplier factor
  2347. * @returns the current updated Vector3
  2348. */
  2349. scaleInPlace(scale: number): Vector3;
  2350. /**
  2351. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2352. * @param scale defines the multiplier factor
  2353. * @returns a new Vector3
  2354. */
  2355. scale(scale: number): Vector3;
  2356. /**
  2357. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2358. * @param scale defines the multiplier factor
  2359. * @param result defines the Vector3 object where to store the result
  2360. * @returns the current Vector3
  2361. */
  2362. scaleToRef(scale: number, result: Vector3): Vector3;
  2363. /**
  2364. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2365. * @param scale defines the scale factor
  2366. * @param result defines the Vector3 object where to store the result
  2367. * @returns the unmodified current Vector3
  2368. */
  2369. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2370. /**
  2371. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2372. * @param otherVector defines the second operand
  2373. * @returns true if both vectors are equals
  2374. */
  2375. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2376. /**
  2377. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2378. * @param otherVector defines the second operand
  2379. * @param epsilon defines the minimal distance to define values as equals
  2380. * @returns true if both vectors are distant less than epsilon
  2381. */
  2382. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2383. /**
  2384. * Returns true if the current Vector3 coordinates equals the given floats
  2385. * @param x defines the x coordinate of the operand
  2386. * @param y defines the y coordinate of the operand
  2387. * @param z defines the z coordinate of the operand
  2388. * @returns true if both vectors are equals
  2389. */
  2390. equalsToFloats(x: number, y: number, z: number): boolean;
  2391. /**
  2392. * Multiplies the current Vector3 coordinates by the given ones
  2393. * @param otherVector defines the second operand
  2394. * @returns the current updated Vector3
  2395. */
  2396. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2399. * @param otherVector defines the second operand
  2400. * @returns the new Vector3
  2401. */
  2402. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2403. /**
  2404. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2405. * @param otherVector defines the second operand
  2406. * @param result defines the Vector3 object where to store the result
  2407. * @returns the current Vector3
  2408. */
  2409. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2410. /**
  2411. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2412. * @param x defines the x coordinate of the operand
  2413. * @param y defines the y coordinate of the operand
  2414. * @param z defines the z coordinate of the operand
  2415. * @returns the new Vector3
  2416. */
  2417. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2418. /**
  2419. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2420. * @param otherVector defines the second operand
  2421. * @returns the new Vector3
  2422. */
  2423. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2424. /**
  2425. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2426. * @param otherVector defines the second operand
  2427. * @param result defines the Vector3 object where to store the result
  2428. * @returns the current Vector3
  2429. */
  2430. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2431. /**
  2432. * Divides the current Vector3 coordinates by the given ones.
  2433. * @param otherVector defines the second operand
  2434. * @returns the current updated Vector3
  2435. */
  2436. divideInPlace(otherVector: Vector3): Vector3;
  2437. /**
  2438. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2439. * @param other defines the second operand
  2440. * @returns the current updated Vector3
  2441. */
  2442. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2443. /**
  2444. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2445. * @param other defines the second operand
  2446. * @returns the current updated Vector3
  2447. */
  2448. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2449. /**
  2450. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2451. * @param x defines the x coordinate of the operand
  2452. * @param y defines the y coordinate of the operand
  2453. * @param z defines the z coordinate of the operand
  2454. * @returns the current updated Vector3
  2455. */
  2456. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2457. /**
  2458. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2459. * @param x defines the x coordinate of the operand
  2460. * @param y defines the y coordinate of the operand
  2461. * @param z defines the z coordinate of the operand
  2462. * @returns the current updated Vector3
  2463. */
  2464. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2465. /**
  2466. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2467. * Check if is non uniform within a certain amount of decimal places to account for this
  2468. * @param epsilon the amount the values can differ
  2469. * @returns if the the vector is non uniform to a certain number of decimal places
  2470. */
  2471. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2472. /**
  2473. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2474. */
  2475. readonly isNonUniform: boolean;
  2476. /**
  2477. * Gets a new Vector3 from current Vector3 floored values
  2478. * @returns a new Vector3
  2479. */
  2480. floor(): Vector3;
  2481. /**
  2482. * Gets a new Vector3 from current Vector3 floored values
  2483. * @returns a new Vector3
  2484. */
  2485. fract(): Vector3;
  2486. /**
  2487. * Gets the length of the Vector3
  2488. * @returns the length of the Vector3
  2489. */
  2490. length(): number;
  2491. /**
  2492. * Gets the squared length of the Vector3
  2493. * @returns squared length of the Vector3
  2494. */
  2495. lengthSquared(): number;
  2496. /**
  2497. * Normalize the current Vector3.
  2498. * Please note that this is an in place operation.
  2499. * @returns the current updated Vector3
  2500. */
  2501. normalize(): Vector3;
  2502. /**
  2503. * Reorders the x y z properties of the vector in place
  2504. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2505. * @returns the current updated vector
  2506. */
  2507. reorderInPlace(order: string): this;
  2508. /**
  2509. * Rotates the vector around 0,0,0 by a quaternion
  2510. * @param quaternion the rotation quaternion
  2511. * @param result vector to store the result
  2512. * @returns the resulting vector
  2513. */
  2514. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2515. /**
  2516. * Rotates a vector around a given point
  2517. * @param quaternion the rotation quaternion
  2518. * @param point the point to rotate around
  2519. * @param result vector to store the result
  2520. * @returns the resulting vector
  2521. */
  2522. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2523. /**
  2524. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2525. * The cross product is then orthogonal to both current and "other"
  2526. * @param other defines the right operand
  2527. * @returns the cross product
  2528. */
  2529. cross(other: Vector3): Vector3;
  2530. /**
  2531. * Normalize the current Vector3 with the given input length.
  2532. * Please note that this is an in place operation.
  2533. * @param len the length of the vector
  2534. * @returns the current updated Vector3
  2535. */
  2536. normalizeFromLength(len: number): Vector3;
  2537. /**
  2538. * Normalize the current Vector3 to a new vector
  2539. * @returns the new Vector3
  2540. */
  2541. normalizeToNew(): Vector3;
  2542. /**
  2543. * Normalize the current Vector3 to the reference
  2544. * @param reference define the Vector3 to update
  2545. * @returns the updated Vector3
  2546. */
  2547. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Creates a new Vector3 copied from the current Vector3
  2550. * @returns the new Vector3
  2551. */
  2552. clone(): Vector3;
  2553. /**
  2554. * Copies the given vector coordinates to the current Vector3 ones
  2555. * @param source defines the source Vector3
  2556. * @returns the current updated Vector3
  2557. */
  2558. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2559. /**
  2560. * Copies the given floats to the current Vector3 coordinates
  2561. * @param x defines the x coordinate of the operand
  2562. * @param y defines the y coordinate of the operand
  2563. * @param z defines the z coordinate of the operand
  2564. * @returns the current updated Vector3
  2565. */
  2566. copyFromFloats(x: number, y: number, z: number): Vector3;
  2567. /**
  2568. * Copies the given floats to the current Vector3 coordinates
  2569. * @param x defines the x coordinate of the operand
  2570. * @param y defines the y coordinate of the operand
  2571. * @param z defines the z coordinate of the operand
  2572. * @returns the current updated Vector3
  2573. */
  2574. set(x: number, y: number, z: number): Vector3;
  2575. /**
  2576. * Copies the given float to the current Vector3 coordinates
  2577. * @param v defines the x, y and z coordinates of the operand
  2578. * @returns the current updated Vector3
  2579. */
  2580. setAll(v: number): Vector3;
  2581. /**
  2582. * Get the clip factor between two vectors
  2583. * @param vector0 defines the first operand
  2584. * @param vector1 defines the second operand
  2585. * @param axis defines the axis to use
  2586. * @param size defines the size along the axis
  2587. * @returns the clip factor
  2588. */
  2589. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2590. /**
  2591. * Get angle between two vectors
  2592. * @param vector0 angle between vector0 and vector1
  2593. * @param vector1 angle between vector0 and vector1
  2594. * @param normal direction of the normal
  2595. * @return the angle between vector0 and vector1
  2596. */
  2597. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2598. /**
  2599. * Returns a new Vector3 set from the index "offset" of the given array
  2600. * @param array defines the source array
  2601. * @param offset defines the offset in the source array
  2602. * @returns the new Vector3
  2603. */
  2604. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2605. /**
  2606. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2607. * This function is deprecated. Use FromArray instead
  2608. * @param array defines the source array
  2609. * @param offset defines the offset in the source array
  2610. * @returns the new Vector3
  2611. */
  2612. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2613. /**
  2614. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2615. * @param array defines the source array
  2616. * @param offset defines the offset in the source array
  2617. * @param result defines the Vector3 where to store the result
  2618. */
  2619. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2620. /**
  2621. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2622. * This function is deprecated. Use FromArrayToRef instead.
  2623. * @param array defines the source array
  2624. * @param offset defines the offset in the source array
  2625. * @param result defines the Vector3 where to store the result
  2626. */
  2627. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2628. /**
  2629. * Sets the given vector "result" with the given floats.
  2630. * @param x defines the x coordinate of the source
  2631. * @param y defines the y coordinate of the source
  2632. * @param z defines the z coordinate of the source
  2633. * @param result defines the Vector3 where to store the result
  2634. */
  2635. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2636. /**
  2637. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2638. * @returns a new empty Vector3
  2639. */
  2640. static Zero(): Vector3;
  2641. /**
  2642. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2643. * @returns a new unit Vector3
  2644. */
  2645. static One(): Vector3;
  2646. /**
  2647. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2648. * @returns a new up Vector3
  2649. */
  2650. static Up(): Vector3;
  2651. /**
  2652. * Gets a up Vector3 that must not be updated
  2653. */
  2654. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2655. /**
  2656. * Gets a zero Vector3 that must not be updated
  2657. */
  2658. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2659. /**
  2660. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2661. * @returns a new down Vector3
  2662. */
  2663. static Down(): Vector3;
  2664. /**
  2665. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2666. * @returns a new forward Vector3
  2667. */
  2668. static Forward(): Vector3;
  2669. /**
  2670. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2671. * @returns a new forward Vector3
  2672. */
  2673. static Backward(): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2676. * @returns a new right Vector3
  2677. */
  2678. static Right(): Vector3;
  2679. /**
  2680. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2681. * @returns a new left Vector3
  2682. */
  2683. static Left(): Vector3;
  2684. /**
  2685. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2686. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2687. * @param vector defines the Vector3 to transform
  2688. * @param transformation defines the transformation matrix
  2689. * @returns the transformed Vector3
  2690. */
  2691. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2692. /**
  2693. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2694. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2695. * @param vector defines the Vector3 to transform
  2696. * @param transformation defines the transformation matrix
  2697. * @param result defines the Vector3 where to store the result
  2698. */
  2699. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2700. /**
  2701. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2702. * This method computes tranformed coordinates only, not transformed direction vectors
  2703. * @param x define the x coordinate of the source vector
  2704. * @param y define the y coordinate of the source vector
  2705. * @param z define the z coordinate of the source vector
  2706. * @param transformation defines the transformation matrix
  2707. * @param result defines the Vector3 where to store the result
  2708. */
  2709. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2710. /**
  2711. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2713. * @param vector defines the Vector3 to transform
  2714. * @param transformation defines the transformation matrix
  2715. * @returns the new Vector3
  2716. */
  2717. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2718. /**
  2719. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2720. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2721. * @param vector defines the Vector3 to transform
  2722. * @param transformation defines the transformation matrix
  2723. * @param result defines the Vector3 where to store the result
  2724. */
  2725. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2726. /**
  2727. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2728. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2729. * @param x define the x coordinate of the source vector
  2730. * @param y define the y coordinate of the source vector
  2731. * @param z define the z coordinate of the source vector
  2732. * @param transformation defines the transformation matrix
  2733. * @param result defines the Vector3 where to store the result
  2734. */
  2735. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2736. /**
  2737. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2738. * @param value1 defines the first control point
  2739. * @param value2 defines the second control point
  2740. * @param value3 defines the third control point
  2741. * @param value4 defines the fourth control point
  2742. * @param amount defines the amount on the spline to use
  2743. * @returns the new Vector3
  2744. */
  2745. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2746. /**
  2747. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2748. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2749. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2750. * @param value defines the current value
  2751. * @param min defines the lower range value
  2752. * @param max defines the upper range value
  2753. * @returns the new Vector3
  2754. */
  2755. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2756. /**
  2757. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2758. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2759. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2760. * @param value defines the current value
  2761. * @param min defines the lower range value
  2762. * @param max defines the upper range value
  2763. * @param result defines the Vector3 where to store the result
  2764. */
  2765. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2766. /**
  2767. * Checks if a given vector is inside a specific range
  2768. * @param v defines the vector to test
  2769. * @param min defines the minimum range
  2770. * @param max defines the maximum range
  2771. */
  2772. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2773. /**
  2774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2775. * @param value1 defines the first control point
  2776. * @param tangent1 defines the first tangent vector
  2777. * @param value2 defines the second control point
  2778. * @param tangent2 defines the second tangent vector
  2779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2780. * @returns the new Vector3
  2781. */
  2782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2783. /**
  2784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2785. * @param start defines the start value
  2786. * @param end defines the end value
  2787. * @param amount max defines amount between both (between 0 and 1)
  2788. * @returns the new Vector3
  2789. */
  2790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2791. /**
  2792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2793. * @param start defines the start value
  2794. * @param end defines the end value
  2795. * @param amount max defines amount between both (between 0 and 1)
  2796. * @param result defines the Vector3 where to store the result
  2797. */
  2798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2799. /**
  2800. * Returns the dot product (float) between the vectors "left" and "right"
  2801. * @param left defines the left operand
  2802. * @param right defines the right operand
  2803. * @returns the dot product
  2804. */
  2805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2806. /**
  2807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2808. * The cross product is then orthogonal to both "left" and "right"
  2809. * @param left defines the left operand
  2810. * @param right defines the right operand
  2811. * @returns the cross product
  2812. */
  2813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2814. /**
  2815. * Sets the given vector "result" with the cross product of "left" and "right"
  2816. * The cross product is then orthogonal to both "left" and "right"
  2817. * @param left defines the left operand
  2818. * @param right defines the right operand
  2819. * @param result defines the Vector3 where to store the result
  2820. */
  2821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2822. /**
  2823. * Returns a new Vector3 as the normalization of the given vector
  2824. * @param vector defines the Vector3 to normalize
  2825. * @returns the new Vector3
  2826. */
  2827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2828. /**
  2829. * Sets the given vector "result" with the normalization of the given first vector
  2830. * @param vector defines the Vector3 to normalize
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2834. /**
  2835. * Project a Vector3 onto screen space
  2836. * @param vector defines the Vector3 to project
  2837. * @param world defines the world matrix to use
  2838. * @param transform defines the transform (view x projection) matrix to use
  2839. * @param viewport defines the screen viewport to use
  2840. * @returns the new Vector3
  2841. */
  2842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2843. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2844. /**
  2845. * Unproject from screen space to object space
  2846. * @param source defines the screen space Vector3 to use
  2847. * @param viewportWidth defines the current width of the viewport
  2848. * @param viewportHeight defines the current height of the viewport
  2849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2850. * @param transform defines the transform (view x projection) matrix to use
  2851. * @returns the new Vector3
  2852. */
  2853. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2854. /**
  2855. * Unproject from screen space to object space
  2856. * @param source defines the screen space Vector3 to use
  2857. * @param viewportWidth defines the current width of the viewport
  2858. * @param viewportHeight defines the current height of the viewport
  2859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2860. * @param view defines the view matrix to use
  2861. * @param projection defines the projection matrix to use
  2862. * @returns the new Vector3
  2863. */
  2864. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2865. /**
  2866. * Unproject from screen space to object space
  2867. * @param source defines the screen space Vector3 to use
  2868. * @param viewportWidth defines the current width of the viewport
  2869. * @param viewportHeight defines the current height of the viewport
  2870. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2871. * @param view defines the view matrix to use
  2872. * @param projection defines the projection matrix to use
  2873. * @param result defines the Vector3 where to store the result
  2874. */
  2875. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2876. /**
  2877. * Unproject from screen space to object space
  2878. * @param sourceX defines the screen space x coordinate to use
  2879. * @param sourceY defines the screen space y coordinate to use
  2880. * @param sourceZ defines the screen space z coordinate to use
  2881. * @param viewportWidth defines the current width of the viewport
  2882. * @param viewportHeight defines the current height of the viewport
  2883. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2884. * @param view defines the view matrix to use
  2885. * @param projection defines the projection matrix to use
  2886. * @param result defines the Vector3 where to store the result
  2887. */
  2888. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2889. /**
  2890. * Gets the minimal coordinate values between two Vector3
  2891. * @param left defines the first operand
  2892. * @param right defines the second operand
  2893. * @returns the new Vector3
  2894. */
  2895. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2896. /**
  2897. * Gets the maximal coordinate values between two Vector3
  2898. * @param left defines the first operand
  2899. * @param right defines the second operand
  2900. * @returns the new Vector3
  2901. */
  2902. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2903. /**
  2904. * Returns the distance between the vectors "value1" and "value2"
  2905. * @param value1 defines the first operand
  2906. * @param value2 defines the second operand
  2907. * @returns the distance
  2908. */
  2909. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2910. /**
  2911. * Returns the squared distance between the vectors "value1" and "value2"
  2912. * @param value1 defines the first operand
  2913. * @param value2 defines the second operand
  2914. * @returns the squared distance
  2915. */
  2916. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2917. /**
  2918. * Returns a new Vector3 located at the center between "value1" and "value2"
  2919. * @param value1 defines the first operand
  2920. * @param value2 defines the second operand
  2921. * @returns the new Vector3
  2922. */
  2923. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2924. /**
  2925. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2926. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2927. * to something in order to rotate it from its local system to the given target system
  2928. * Note: axis1, axis2 and axis3 are normalized during this operation
  2929. * @param axis1 defines the first axis
  2930. * @param axis2 defines the second axis
  2931. * @param axis3 defines the third axis
  2932. * @returns a new Vector3
  2933. */
  2934. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2935. /**
  2936. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2937. * @param axis1 defines the first axis
  2938. * @param axis2 defines the second axis
  2939. * @param axis3 defines the third axis
  2940. * @param ref defines the Vector3 where to store the result
  2941. */
  2942. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2943. }
  2944. /**
  2945. * Vector4 class created for EulerAngle class conversion to Quaternion
  2946. */
  2947. export class Vector4 {
  2948. /** x value of the vector */
  2949. x: number;
  2950. /** y value of the vector */
  2951. y: number;
  2952. /** z value of the vector */
  2953. z: number;
  2954. /** w value of the vector */
  2955. w: number;
  2956. /**
  2957. * Creates a Vector4 object from the given floats.
  2958. * @param x x value of the vector
  2959. * @param y y value of the vector
  2960. * @param z z value of the vector
  2961. * @param w w value of the vector
  2962. */
  2963. constructor(
  2964. /** x value of the vector */
  2965. x: number,
  2966. /** y value of the vector */
  2967. y: number,
  2968. /** z value of the vector */
  2969. z: number,
  2970. /** w value of the vector */
  2971. w: number);
  2972. /**
  2973. * Returns the string with the Vector4 coordinates.
  2974. * @returns a string containing all the vector values
  2975. */
  2976. toString(): string;
  2977. /**
  2978. * Returns the string "Vector4".
  2979. * @returns "Vector4"
  2980. */
  2981. getClassName(): string;
  2982. /**
  2983. * Returns the Vector4 hash code.
  2984. * @returns a unique hash code
  2985. */
  2986. getHashCode(): number;
  2987. /**
  2988. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2989. * @returns the resulting array
  2990. */
  2991. asArray(): number[];
  2992. /**
  2993. * Populates the given array from the given index with the Vector4 coordinates.
  2994. * @param array array to populate
  2995. * @param index index of the array to start at (default: 0)
  2996. * @returns the Vector4.
  2997. */
  2998. toArray(array: FloatArray, index?: number): Vector4;
  2999. /**
  3000. * Adds the given vector to the current Vector4.
  3001. * @param otherVector the vector to add
  3002. * @returns the updated Vector4.
  3003. */
  3004. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3005. /**
  3006. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3007. * @param otherVector the vector to add
  3008. * @returns the resulting vector
  3009. */
  3010. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3011. /**
  3012. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3013. * @param otherVector the vector to add
  3014. * @param result the vector to store the result
  3015. * @returns the current Vector4.
  3016. */
  3017. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3018. /**
  3019. * Subtract in place the given vector from the current Vector4.
  3020. * @param otherVector the vector to subtract
  3021. * @returns the updated Vector4.
  3022. */
  3023. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3024. /**
  3025. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3026. * @param otherVector the vector to add
  3027. * @returns the new vector with the result
  3028. */
  3029. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3030. /**
  3031. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3032. * @param otherVector the vector to subtract
  3033. * @param result the vector to store the result
  3034. * @returns the current Vector4.
  3035. */
  3036. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3037. /**
  3038. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3039. */
  3040. /**
  3041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3042. * @param x value to subtract
  3043. * @param y value to subtract
  3044. * @param z value to subtract
  3045. * @param w value to subtract
  3046. * @returns new vector containing the result
  3047. */
  3048. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3049. /**
  3050. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3051. * @param x value to subtract
  3052. * @param y value to subtract
  3053. * @param z value to subtract
  3054. * @param w value to subtract
  3055. * @param result the vector to store the result in
  3056. * @returns the current Vector4.
  3057. */
  3058. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3059. /**
  3060. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3061. * @returns a new vector with the negated values
  3062. */
  3063. negate(): Vector4;
  3064. /**
  3065. * Multiplies the current Vector4 coordinates by scale (float).
  3066. * @param scale the number to scale with
  3067. * @returns the updated Vector4.
  3068. */
  3069. scaleInPlace(scale: number): Vector4;
  3070. /**
  3071. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3072. * @param scale the number to scale with
  3073. * @returns a new vector with the result
  3074. */
  3075. scale(scale: number): Vector4;
  3076. /**
  3077. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3078. * @param scale the number to scale with
  3079. * @param result a vector to store the result in
  3080. * @returns the current Vector4.
  3081. */
  3082. scaleToRef(scale: number, result: Vector4): Vector4;
  3083. /**
  3084. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Vector4 object where to store the result
  3087. * @returns the unmodified current Vector4
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3090. /**
  3091. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3092. * @param otherVector the vector to compare against
  3093. * @returns true if they are equal
  3094. */
  3095. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3096. /**
  3097. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3098. * @param otherVector vector to compare against
  3099. * @param epsilon (Default: very small number)
  3100. * @returns true if they are equal
  3101. */
  3102. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3103. /**
  3104. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3105. * @param x x value to compare against
  3106. * @param y y value to compare against
  3107. * @param z z value to compare against
  3108. * @param w w value to compare against
  3109. * @returns true if equal
  3110. */
  3111. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3112. /**
  3113. * Multiplies in place the current Vector4 by the given one.
  3114. * @param otherVector vector to multiple with
  3115. * @returns the updated Vector4.
  3116. */
  3117. multiplyInPlace(otherVector: Vector4): Vector4;
  3118. /**
  3119. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3120. * @param otherVector vector to multiple with
  3121. * @returns resulting new vector
  3122. */
  3123. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3126. * @param otherVector vector to multiple with
  3127. * @param result vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3133. * @param x x value multiply with
  3134. * @param y y value multiply with
  3135. * @param z z value multiply with
  3136. * @param w w value multiply with
  3137. * @returns resulting new vector
  3138. */
  3139. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3140. /**
  3141. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3142. * @param otherVector vector to devide with
  3143. * @returns resulting new vector
  3144. */
  3145. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3146. /**
  3147. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3148. * @param otherVector vector to devide with
  3149. * @param result vector to store the result
  3150. * @returns the current Vector4.
  3151. */
  3152. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3153. /**
  3154. * Divides the current Vector3 coordinates by the given ones.
  3155. * @param otherVector vector to devide with
  3156. * @returns the updated Vector3.
  3157. */
  3158. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3159. /**
  3160. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3161. * @param other defines the second operand
  3162. * @returns the current updated Vector4
  3163. */
  3164. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3165. /**
  3166. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3167. * @param other defines the second operand
  3168. * @returns the current updated Vector4
  3169. */
  3170. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3171. /**
  3172. * Gets a new Vector4 from current Vector4 floored values
  3173. * @returns a new Vector4
  3174. */
  3175. floor(): Vector4;
  3176. /**
  3177. * Gets a new Vector4 from current Vector3 floored values
  3178. * @returns a new Vector4
  3179. */
  3180. fract(): Vector4;
  3181. /**
  3182. * Returns the Vector4 length (float).
  3183. * @returns the length
  3184. */
  3185. length(): number;
  3186. /**
  3187. * Returns the Vector4 squared length (float).
  3188. * @returns the length squared
  3189. */
  3190. lengthSquared(): number;
  3191. /**
  3192. * Normalizes in place the Vector4.
  3193. * @returns the updated Vector4.
  3194. */
  3195. normalize(): Vector4;
  3196. /**
  3197. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3198. * @returns this converted to a new vector3
  3199. */
  3200. toVector3(): Vector3;
  3201. /**
  3202. * Returns a new Vector4 copied from the current one.
  3203. * @returns the new cloned vector
  3204. */
  3205. clone(): Vector4;
  3206. /**
  3207. * Updates the current Vector4 with the given one coordinates.
  3208. * @param source the source vector to copy from
  3209. * @returns the updated Vector4.
  3210. */
  3211. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3212. /**
  3213. * Updates the current Vector4 coordinates with the given floats.
  3214. * @param x float to copy from
  3215. * @param y float to copy from
  3216. * @param z float to copy from
  3217. * @param w float to copy from
  3218. * @returns the updated Vector4.
  3219. */
  3220. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3221. /**
  3222. * Updates the current Vector4 coordinates with the given floats.
  3223. * @param x float to set from
  3224. * @param y float to set from
  3225. * @param z float to set from
  3226. * @param w float to set from
  3227. * @returns the updated Vector4.
  3228. */
  3229. set(x: number, y: number, z: number, w: number): Vector4;
  3230. /**
  3231. * Copies the given float to the current Vector3 coordinates
  3232. * @param v defines the x, y, z and w coordinates of the operand
  3233. * @returns the current updated Vector3
  3234. */
  3235. setAll(v: number): Vector4;
  3236. /**
  3237. * Returns a new Vector4 set from the starting index of the given array.
  3238. * @param array the array to pull values from
  3239. * @param offset the offset into the array to start at
  3240. * @returns the new vector
  3241. */
  3242. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3243. /**
  3244. * Updates the given vector "result" from the starting index of the given array.
  3245. * @param array the array to pull values from
  3246. * @param offset the offset into the array to start at
  3247. * @param result the vector to store the result in
  3248. */
  3249. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3250. /**
  3251. * Updates the given vector "result" from the starting index of the given Float32Array.
  3252. * @param array the array to pull values from
  3253. * @param offset the offset into the array to start at
  3254. * @param result the vector to store the result in
  3255. */
  3256. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3257. /**
  3258. * Updates the given vector "result" coordinates from the given floats.
  3259. * @param x float to set from
  3260. * @param y float to set from
  3261. * @param z float to set from
  3262. * @param w float to set from
  3263. * @param result the vector to the floats in
  3264. */
  3265. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3266. /**
  3267. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3268. * @returns the new vector
  3269. */
  3270. static Zero(): Vector4;
  3271. /**
  3272. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3273. * @returns the new vector
  3274. */
  3275. static One(): Vector4;
  3276. /**
  3277. * Returns a new normalized Vector4 from the given one.
  3278. * @param vector the vector to normalize
  3279. * @returns the vector
  3280. */
  3281. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3282. /**
  3283. * Updates the given vector "result" from the normalization of the given one.
  3284. * @param vector the vector to normalize
  3285. * @param result the vector to store the result in
  3286. */
  3287. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3288. /**
  3289. * Returns a vector with the minimum values from the left and right vectors
  3290. * @param left left vector to minimize
  3291. * @param right right vector to minimize
  3292. * @returns a new vector with the minimum of the left and right vector values
  3293. */
  3294. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3295. /**
  3296. * Returns a vector with the maximum values from the left and right vectors
  3297. * @param left left vector to maximize
  3298. * @param right right vector to maximize
  3299. * @returns a new vector with the maximum of the left and right vector values
  3300. */
  3301. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3302. /**
  3303. * Returns the distance (float) between the vectors "value1" and "value2".
  3304. * @param value1 value to calulate the distance between
  3305. * @param value2 value to calulate the distance between
  3306. * @return the distance between the two vectors
  3307. */
  3308. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3309. /**
  3310. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3311. * @param value1 value to calulate the distance between
  3312. * @param value2 value to calulate the distance between
  3313. * @return the distance between the two vectors squared
  3314. */
  3315. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3316. /**
  3317. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3318. * @param value1 value to calulate the center between
  3319. * @param value2 value to calulate the center between
  3320. * @return the center between the two vectors
  3321. */
  3322. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3323. /**
  3324. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3325. * This methods computes transformed normalized direction vectors only.
  3326. * @param vector the vector to transform
  3327. * @param transformation the transformation matrix to apply
  3328. * @returns the new vector
  3329. */
  3330. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3331. /**
  3332. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3333. * This methods computes transformed normalized direction vectors only.
  3334. * @param vector the vector to transform
  3335. * @param transformation the transformation matrix to apply
  3336. * @param result the vector to store the result in
  3337. */
  3338. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3339. /**
  3340. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3341. * This methods computes transformed normalized direction vectors only.
  3342. * @param x value to transform
  3343. * @param y value to transform
  3344. * @param z value to transform
  3345. * @param w value to transform
  3346. * @param transformation the transformation matrix to apply
  3347. * @param result the vector to store the results in
  3348. */
  3349. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3350. /**
  3351. * Creates a new Vector4 from a Vector3
  3352. * @param source defines the source data
  3353. * @param w defines the 4th component (default is 0)
  3354. * @returns a new Vector4
  3355. */
  3356. static FromVector3(source: Vector3, w?: number): Vector4;
  3357. }
  3358. /**
  3359. * Class used to store quaternion data
  3360. * @see https://en.wikipedia.org/wiki/Quaternion
  3361. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3362. */
  3363. export class Quaternion {
  3364. /** defines the first component (0 by default) */
  3365. x: number;
  3366. /** defines the second component (0 by default) */
  3367. y: number;
  3368. /** defines the third component (0 by default) */
  3369. z: number;
  3370. /** defines the fourth component (1.0 by default) */
  3371. w: number;
  3372. /**
  3373. * Creates a new Quaternion from the given floats
  3374. * @param x defines the first component (0 by default)
  3375. * @param y defines the second component (0 by default)
  3376. * @param z defines the third component (0 by default)
  3377. * @param w defines the fourth component (1.0 by default)
  3378. */
  3379. constructor(
  3380. /** defines the first component (0 by default) */
  3381. x?: number,
  3382. /** defines the second component (0 by default) */
  3383. y?: number,
  3384. /** defines the third component (0 by default) */
  3385. z?: number,
  3386. /** defines the fourth component (1.0 by default) */
  3387. w?: number);
  3388. /**
  3389. * Gets a string representation for the current quaternion
  3390. * @returns a string with the Quaternion coordinates
  3391. */
  3392. toString(): string;
  3393. /**
  3394. * Gets the class name of the quaternion
  3395. * @returns the string "Quaternion"
  3396. */
  3397. getClassName(): string;
  3398. /**
  3399. * Gets a hash code for this quaternion
  3400. * @returns the quaternion hash code
  3401. */
  3402. getHashCode(): number;
  3403. /**
  3404. * Copy the quaternion to an array
  3405. * @returns a new array populated with 4 elements from the quaternion coordinates
  3406. */
  3407. asArray(): number[];
  3408. /**
  3409. * Check if two quaternions are equals
  3410. * @param otherQuaternion defines the second operand
  3411. * @return true if the current quaternion and the given one coordinates are strictly equals
  3412. */
  3413. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3414. /**
  3415. * Clone the current quaternion
  3416. * @returns a new quaternion copied from the current one
  3417. */
  3418. clone(): Quaternion;
  3419. /**
  3420. * Copy a quaternion to the current one
  3421. * @param other defines the other quaternion
  3422. * @returns the updated current quaternion
  3423. */
  3424. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3425. /**
  3426. * Updates the current quaternion with the given float coordinates
  3427. * @param x defines the x coordinate
  3428. * @param y defines the y coordinate
  3429. * @param z defines the z coordinate
  3430. * @param w defines the w coordinate
  3431. * @returns the updated current quaternion
  3432. */
  3433. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3434. /**
  3435. * Updates the current quaternion from the given float coordinates
  3436. * @param x defines the x coordinate
  3437. * @param y defines the y coordinate
  3438. * @param z defines the z coordinate
  3439. * @param w defines the w coordinate
  3440. * @returns the updated current quaternion
  3441. */
  3442. set(x: number, y: number, z: number, w: number): Quaternion;
  3443. /**
  3444. * Adds two quaternions
  3445. * @param other defines the second operand
  3446. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3447. */
  3448. add(other: DeepImmutable<Quaternion>): Quaternion;
  3449. /**
  3450. * Add a quaternion to the current one
  3451. * @param other defines the quaternion to add
  3452. * @returns the current quaternion
  3453. */
  3454. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3455. /**
  3456. * Subtract two quaternions
  3457. * @param other defines the second operand
  3458. * @returns a new quaternion as the subtraction result of the given one from the current one
  3459. */
  3460. subtract(other: Quaternion): Quaternion;
  3461. /**
  3462. * Multiplies the current quaternion by a scale factor
  3463. * @param value defines the scale factor
  3464. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3465. */
  3466. scale(value: number): Quaternion;
  3467. /**
  3468. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3469. * @param scale defines the scale factor
  3470. * @param result defines the Quaternion object where to store the result
  3471. * @returns the unmodified current quaternion
  3472. */
  3473. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3474. /**
  3475. * Multiplies in place the current quaternion by a scale factor
  3476. * @param value defines the scale factor
  3477. * @returns the current modified quaternion
  3478. */
  3479. scaleInPlace(value: number): Quaternion;
  3480. /**
  3481. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3482. * @param scale defines the scale factor
  3483. * @param result defines the Quaternion object where to store the result
  3484. * @returns the unmodified current quaternion
  3485. */
  3486. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3487. /**
  3488. * Multiplies two quaternions
  3489. * @param q1 defines the second operand
  3490. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3491. */
  3492. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3493. /**
  3494. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3495. * @param q1 defines the second operand
  3496. * @param result defines the target quaternion
  3497. * @returns the current quaternion
  3498. */
  3499. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3500. /**
  3501. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3502. * @param q1 defines the second operand
  3503. * @returns the currentupdated quaternion
  3504. */
  3505. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3506. /**
  3507. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3508. * @param ref defines the target quaternion
  3509. * @returns the current quaternion
  3510. */
  3511. conjugateToRef(ref: Quaternion): Quaternion;
  3512. /**
  3513. * Conjugates in place (1-q) the current quaternion
  3514. * @returns the current updated quaternion
  3515. */
  3516. conjugateInPlace(): Quaternion;
  3517. /**
  3518. * Conjugates in place (1-q) the current quaternion
  3519. * @returns a new quaternion
  3520. */
  3521. conjugate(): Quaternion;
  3522. /**
  3523. * Gets length of current quaternion
  3524. * @returns the quaternion length (float)
  3525. */
  3526. length(): number;
  3527. /**
  3528. * Normalize in place the current quaternion
  3529. * @returns the current updated quaternion
  3530. */
  3531. normalize(): Quaternion;
  3532. /**
  3533. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3534. * @param order is a reserved parameter and is ignore for now
  3535. * @returns a new Vector3 containing the Euler angles
  3536. */
  3537. toEulerAngles(order?: string): Vector3;
  3538. /**
  3539. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3540. * @param result defines the vector which will be filled with the Euler angles
  3541. * @param order is a reserved parameter and is ignore for now
  3542. * @returns the current unchanged quaternion
  3543. */
  3544. toEulerAnglesToRef(result: Vector3): Quaternion;
  3545. /**
  3546. * Updates the given rotation matrix with the current quaternion values
  3547. * @param result defines the target matrix
  3548. * @returns the current unchanged quaternion
  3549. */
  3550. toRotationMatrix(result: Matrix): Quaternion;
  3551. /**
  3552. * Updates the current quaternion from the given rotation matrix values
  3553. * @param matrix defines the source matrix
  3554. * @returns the current updated quaternion
  3555. */
  3556. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3557. /**
  3558. * Creates a new quaternion from a rotation matrix
  3559. * @param matrix defines the source matrix
  3560. * @returns a new quaternion created from the given rotation matrix values
  3561. */
  3562. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3563. /**
  3564. * Updates the given quaternion with the given rotation matrix values
  3565. * @param matrix defines the source matrix
  3566. * @param result defines the target quaternion
  3567. */
  3568. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3569. /**
  3570. * Returns the dot product (float) between the quaternions "left" and "right"
  3571. * @param left defines the left operand
  3572. * @param right defines the right operand
  3573. * @returns the dot product
  3574. */
  3575. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3576. /**
  3577. * Checks if the two quaternions are close to each other
  3578. * @param quat0 defines the first quaternion to check
  3579. * @param quat1 defines the second quaternion to check
  3580. * @returns true if the two quaternions are close to each other
  3581. */
  3582. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3583. /**
  3584. * Creates an empty quaternion
  3585. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3586. */
  3587. static Zero(): Quaternion;
  3588. /**
  3589. * Inverse a given quaternion
  3590. * @param q defines the source quaternion
  3591. * @returns a new quaternion as the inverted current quaternion
  3592. */
  3593. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3594. /**
  3595. * Inverse a given quaternion
  3596. * @param q defines the source quaternion
  3597. * @param result the quaternion the result will be stored in
  3598. * @returns the result quaternion
  3599. */
  3600. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3601. /**
  3602. * Creates an identity quaternion
  3603. * @returns the identity quaternion
  3604. */
  3605. static Identity(): Quaternion;
  3606. /**
  3607. * Gets a boolean indicating if the given quaternion is identity
  3608. * @param quaternion defines the quaternion to check
  3609. * @returns true if the quaternion is identity
  3610. */
  3611. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3612. /**
  3613. * Creates a quaternion from a rotation around an axis
  3614. * @param axis defines the axis to use
  3615. * @param angle defines the angle to use
  3616. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3617. */
  3618. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3619. /**
  3620. * Creates a rotation around an axis and stores it into the given quaternion
  3621. * @param axis defines the axis to use
  3622. * @param angle defines the angle to use
  3623. * @param result defines the target quaternion
  3624. * @returns the target quaternion
  3625. */
  3626. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3627. /**
  3628. * Creates a new quaternion from data stored into an array
  3629. * @param array defines the data source
  3630. * @param offset defines the offset in the source array where the data starts
  3631. * @returns a new quaternion
  3632. */
  3633. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3634. /**
  3635. * Create a quaternion from Euler rotation angles
  3636. * @param x Pitch
  3637. * @param y Yaw
  3638. * @param z Roll
  3639. * @returns the new Quaternion
  3640. */
  3641. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3642. /**
  3643. * Updates a quaternion from Euler rotation angles
  3644. * @param x Pitch
  3645. * @param y Yaw
  3646. * @param z Roll
  3647. * @param result the quaternion to store the result
  3648. * @returns the updated quaternion
  3649. */
  3650. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3651. /**
  3652. * Create a quaternion from Euler rotation vector
  3653. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3654. * @returns the new Quaternion
  3655. */
  3656. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3657. /**
  3658. * Updates a quaternion from Euler rotation vector
  3659. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3660. * @param result the quaternion to store the result
  3661. * @returns the updated quaternion
  3662. */
  3663. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3664. /**
  3665. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3666. * @param yaw defines the rotation around Y axis
  3667. * @param pitch defines the rotation around X axis
  3668. * @param roll defines the rotation around Z axis
  3669. * @returns the new quaternion
  3670. */
  3671. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3672. /**
  3673. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3674. * @param yaw defines the rotation around Y axis
  3675. * @param pitch defines the rotation around X axis
  3676. * @param roll defines the rotation around Z axis
  3677. * @param result defines the target quaternion
  3678. */
  3679. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3680. /**
  3681. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3682. * @param alpha defines the rotation around first axis
  3683. * @param beta defines the rotation around second axis
  3684. * @param gamma defines the rotation around third axis
  3685. * @returns the new quaternion
  3686. */
  3687. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3688. /**
  3689. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3690. * @param alpha defines the rotation around first axis
  3691. * @param beta defines the rotation around second axis
  3692. * @param gamma defines the rotation around third axis
  3693. * @param result defines the target quaternion
  3694. */
  3695. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3696. /**
  3697. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3698. * @param axis1 defines the first axis
  3699. * @param axis2 defines the second axis
  3700. * @param axis3 defines the third axis
  3701. * @returns the new quaternion
  3702. */
  3703. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3704. /**
  3705. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3706. * @param axis1 defines the first axis
  3707. * @param axis2 defines the second axis
  3708. * @param axis3 defines the third axis
  3709. * @param ref defines the target quaternion
  3710. */
  3711. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3712. /**
  3713. * Interpolates between two quaternions
  3714. * @param left defines first quaternion
  3715. * @param right defines second quaternion
  3716. * @param amount defines the gradient to use
  3717. * @returns the new interpolated quaternion
  3718. */
  3719. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3720. /**
  3721. * Interpolates between two quaternions and stores it into a target quaternion
  3722. * @param left defines first quaternion
  3723. * @param right defines second quaternion
  3724. * @param amount defines the gradient to use
  3725. * @param result defines the target quaternion
  3726. */
  3727. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3728. /**
  3729. * Interpolate between two quaternions using Hermite interpolation
  3730. * @param value1 defines first quaternion
  3731. * @param tangent1 defines the incoming tangent
  3732. * @param value2 defines second quaternion
  3733. * @param tangent2 defines the outgoing tangent
  3734. * @param amount defines the target quaternion
  3735. * @returns the new interpolated quaternion
  3736. */
  3737. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3738. }
  3739. /**
  3740. * Class used to store matrix data (4x4)
  3741. */
  3742. export class Matrix {
  3743. private static _updateFlagSeed;
  3744. private static _identityReadOnly;
  3745. private _isIdentity;
  3746. private _isIdentityDirty;
  3747. private _isIdentity3x2;
  3748. private _isIdentity3x2Dirty;
  3749. /**
  3750. * Gets the update flag of the matrix which is an unique number for the matrix.
  3751. * It will be incremented every time the matrix data change.
  3752. * You can use it to speed the comparison between two versions of the same matrix.
  3753. */
  3754. updateFlag: number;
  3755. private readonly _m;
  3756. /**
  3757. * Gets the internal data of the matrix
  3758. */
  3759. readonly m: DeepImmutable<Float32Array>;
  3760. /** @hidden */ private _markAsUpdated(): void;
  3761. /** @hidden */
  3762. private _updateIdentityStatus;
  3763. /**
  3764. * Creates an empty matrix (filled with zeros)
  3765. */
  3766. constructor();
  3767. /**
  3768. * Check if the current matrix is identity
  3769. * @returns true is the matrix is the identity matrix
  3770. */
  3771. isIdentity(): boolean;
  3772. /**
  3773. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3774. * @returns true is the matrix is the identity matrix
  3775. */
  3776. isIdentityAs3x2(): boolean;
  3777. /**
  3778. * Gets the determinant of the matrix
  3779. * @returns the matrix determinant
  3780. */
  3781. determinant(): number;
  3782. /**
  3783. * Returns the matrix as a Float32Array
  3784. * @returns the matrix underlying array
  3785. */
  3786. toArray(): DeepImmutable<Float32Array>;
  3787. /**
  3788. * Returns the matrix as a Float32Array
  3789. * @returns the matrix underlying array.
  3790. */
  3791. asArray(): DeepImmutable<Float32Array>;
  3792. /**
  3793. * Inverts the current matrix in place
  3794. * @returns the current inverted matrix
  3795. */
  3796. invert(): Matrix;
  3797. /**
  3798. * Sets all the matrix elements to zero
  3799. * @returns the current matrix
  3800. */
  3801. reset(): Matrix;
  3802. /**
  3803. * Adds the current matrix with a second one
  3804. * @param other defines the matrix to add
  3805. * @returns a new matrix as the addition of the current matrix and the given one
  3806. */
  3807. add(other: DeepImmutable<Matrix>): Matrix;
  3808. /**
  3809. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3810. * @param other defines the matrix to add
  3811. * @param result defines the target matrix
  3812. * @returns the current matrix
  3813. */
  3814. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3815. /**
  3816. * Adds in place the given matrix to the current matrix
  3817. * @param other defines the second operand
  3818. * @returns the current updated matrix
  3819. */
  3820. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3821. /**
  3822. * Sets the given matrix to the current inverted Matrix
  3823. * @param other defines the target matrix
  3824. * @returns the unmodified current matrix
  3825. */
  3826. invertToRef(other: Matrix): Matrix;
  3827. /**
  3828. * add a value at the specified position in the current Matrix
  3829. * @param index the index of the value within the matrix. between 0 and 15.
  3830. * @param value the value to be added
  3831. * @returns the current updated matrix
  3832. */
  3833. addAtIndex(index: number, value: number): Matrix;
  3834. /**
  3835. * mutiply the specified position in the current Matrix by a value
  3836. * @param index the index of the value within the matrix. between 0 and 15.
  3837. * @param value the value to be added
  3838. * @returns the current updated matrix
  3839. */
  3840. multiplyAtIndex(index: number, value: number): Matrix;
  3841. /**
  3842. * Inserts the translation vector (using 3 floats) in the current matrix
  3843. * @param x defines the 1st component of the translation
  3844. * @param y defines the 2nd component of the translation
  3845. * @param z defines the 3rd component of the translation
  3846. * @returns the current updated matrix
  3847. */
  3848. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3849. /**
  3850. * Adds the translation vector (using 3 floats) in the current matrix
  3851. * @param x defines the 1st component of the translation
  3852. * @param y defines the 2nd component of the translation
  3853. * @param z defines the 3rd component of the translation
  3854. * @returns the current updated matrix
  3855. */
  3856. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3857. /**
  3858. * Inserts the translation vector in the current matrix
  3859. * @param vector3 defines the translation to insert
  3860. * @returns the current updated matrix
  3861. */
  3862. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3863. /**
  3864. * Gets the translation value of the current matrix
  3865. * @returns a new Vector3 as the extracted translation from the matrix
  3866. */
  3867. getTranslation(): Vector3;
  3868. /**
  3869. * Fill a Vector3 with the extracted translation from the matrix
  3870. * @param result defines the Vector3 where to store the translation
  3871. * @returns the current matrix
  3872. */
  3873. getTranslationToRef(result: Vector3): Matrix;
  3874. /**
  3875. * Remove rotation and scaling part from the matrix
  3876. * @returns the updated matrix
  3877. */
  3878. removeRotationAndScaling(): Matrix;
  3879. /**
  3880. * Multiply two matrices
  3881. * @param other defines the second operand
  3882. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3883. */
  3884. multiply(other: DeepImmutable<Matrix>): Matrix;
  3885. /**
  3886. * Copy the current matrix from the given one
  3887. * @param other defines the source matrix
  3888. * @returns the current updated matrix
  3889. */
  3890. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3891. /**
  3892. * Populates the given array from the starting index with the current matrix values
  3893. * @param array defines the target array
  3894. * @param offset defines the offset in the target array where to start storing values
  3895. * @returns the current matrix
  3896. */
  3897. copyToArray(array: Float32Array, offset?: number): Matrix;
  3898. /**
  3899. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3900. * @param other defines the second operand
  3901. * @param result defines the matrix where to store the multiplication
  3902. * @returns the current matrix
  3903. */
  3904. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3905. /**
  3906. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3907. * @param other defines the second operand
  3908. * @param result defines the array where to store the multiplication
  3909. * @param offset defines the offset in the target array where to start storing values
  3910. * @returns the current matrix
  3911. */
  3912. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3913. /**
  3914. * Check equality between this matrix and a second one
  3915. * @param value defines the second matrix to compare
  3916. * @returns true is the current matrix and the given one values are strictly equal
  3917. */
  3918. equals(value: DeepImmutable<Matrix>): boolean;
  3919. /**
  3920. * Clone the current matrix
  3921. * @returns a new matrix from the current matrix
  3922. */
  3923. clone(): Matrix;
  3924. /**
  3925. * Returns the name of the current matrix class
  3926. * @returns the string "Matrix"
  3927. */
  3928. getClassName(): string;
  3929. /**
  3930. * Gets the hash code of the current matrix
  3931. * @returns the hash code
  3932. */
  3933. getHashCode(): number;
  3934. /**
  3935. * Decomposes the current Matrix into a translation, rotation and scaling components
  3936. * @param scale defines the scale vector3 given as a reference to update
  3937. * @param rotation defines the rotation quaternion given as a reference to update
  3938. * @param translation defines the translation vector3 given as a reference to update
  3939. * @returns true if operation was successful
  3940. */
  3941. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3942. /**
  3943. * Gets specific row of the matrix
  3944. * @param index defines the number of the row to get
  3945. * @returns the index-th row of the current matrix as a new Vector4
  3946. */
  3947. getRow(index: number): Nullable<Vector4>;
  3948. /**
  3949. * Sets the index-th row of the current matrix to the vector4 values
  3950. * @param index defines the number of the row to set
  3951. * @param row defines the target vector4
  3952. * @returns the updated current matrix
  3953. */
  3954. setRow(index: number, row: Vector4): Matrix;
  3955. /**
  3956. * Compute the transpose of the matrix
  3957. * @returns the new transposed matrix
  3958. */
  3959. transpose(): Matrix;
  3960. /**
  3961. * Compute the transpose of the matrix and store it in a given matrix
  3962. * @param result defines the target matrix
  3963. * @returns the current matrix
  3964. */
  3965. transposeToRef(result: Matrix): Matrix;
  3966. /**
  3967. * Sets the index-th row of the current matrix with the given 4 x float values
  3968. * @param index defines the row index
  3969. * @param x defines the x component to set
  3970. * @param y defines the y component to set
  3971. * @param z defines the z component to set
  3972. * @param w defines the w component to set
  3973. * @returns the updated current matrix
  3974. */
  3975. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3976. /**
  3977. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3978. * @param scale defines the scale factor
  3979. * @returns a new matrix
  3980. */
  3981. scale(scale: number): Matrix;
  3982. /**
  3983. * Scale the current matrix values by a factor to a given result matrix
  3984. * @param scale defines the scale factor
  3985. * @param result defines the matrix to store the result
  3986. * @returns the current matrix
  3987. */
  3988. scaleToRef(scale: number, result: Matrix): Matrix;
  3989. /**
  3990. * Scale the current matrix values by a factor and add the result to a given matrix
  3991. * @param scale defines the scale factor
  3992. * @param result defines the Matrix to store the result
  3993. * @returns the current matrix
  3994. */
  3995. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3996. /**
  3997. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3998. * @param ref matrix to store the result
  3999. */
  4000. toNormalMatrix(ref: Matrix): void;
  4001. /**
  4002. * Gets only rotation part of the current matrix
  4003. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4004. */
  4005. getRotationMatrix(): Matrix;
  4006. /**
  4007. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4008. * @param result defines the target matrix to store data to
  4009. * @returns the current matrix
  4010. */
  4011. getRotationMatrixToRef(result: Matrix): Matrix;
  4012. /**
  4013. * Toggles model matrix from being right handed to left handed in place and vice versa
  4014. */
  4015. toggleModelMatrixHandInPlace(): void;
  4016. /**
  4017. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4018. */
  4019. toggleProjectionMatrixHandInPlace(): void;
  4020. /**
  4021. * Creates a matrix from an array
  4022. * @param array defines the source array
  4023. * @param offset defines an offset in the source array
  4024. * @returns a new Matrix set from the starting index of the given array
  4025. */
  4026. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4027. /**
  4028. * Copy the content of an array into a given matrix
  4029. * @param array defines the source array
  4030. * @param offset defines an offset in the source array
  4031. * @param result defines the target matrix
  4032. */
  4033. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4034. /**
  4035. * Stores an array into a matrix after having multiplied each component by a given factor
  4036. * @param array defines the source array
  4037. * @param offset defines the offset in the source array
  4038. * @param scale defines the scaling factor
  4039. * @param result defines the target matrix
  4040. */
  4041. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4042. /**
  4043. * Gets an identity matrix that must not be updated
  4044. */
  4045. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4046. /**
  4047. * Stores a list of values (16) inside a given matrix
  4048. * @param initialM11 defines 1st value of 1st row
  4049. * @param initialM12 defines 2nd value of 1st row
  4050. * @param initialM13 defines 3rd value of 1st row
  4051. * @param initialM14 defines 4th value of 1st row
  4052. * @param initialM21 defines 1st value of 2nd row
  4053. * @param initialM22 defines 2nd value of 2nd row
  4054. * @param initialM23 defines 3rd value of 2nd row
  4055. * @param initialM24 defines 4th value of 2nd row
  4056. * @param initialM31 defines 1st value of 3rd row
  4057. * @param initialM32 defines 2nd value of 3rd row
  4058. * @param initialM33 defines 3rd value of 3rd row
  4059. * @param initialM34 defines 4th value of 3rd row
  4060. * @param initialM41 defines 1st value of 4th row
  4061. * @param initialM42 defines 2nd value of 4th row
  4062. * @param initialM43 defines 3rd value of 4th row
  4063. * @param initialM44 defines 4th value of 4th row
  4064. * @param result defines the target matrix
  4065. */
  4066. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4067. /**
  4068. * Creates new matrix from a list of values (16)
  4069. * @param initialM11 defines 1st value of 1st row
  4070. * @param initialM12 defines 2nd value of 1st row
  4071. * @param initialM13 defines 3rd value of 1st row
  4072. * @param initialM14 defines 4th value of 1st row
  4073. * @param initialM21 defines 1st value of 2nd row
  4074. * @param initialM22 defines 2nd value of 2nd row
  4075. * @param initialM23 defines 3rd value of 2nd row
  4076. * @param initialM24 defines 4th value of 2nd row
  4077. * @param initialM31 defines 1st value of 3rd row
  4078. * @param initialM32 defines 2nd value of 3rd row
  4079. * @param initialM33 defines 3rd value of 3rd row
  4080. * @param initialM34 defines 4th value of 3rd row
  4081. * @param initialM41 defines 1st value of 4th row
  4082. * @param initialM42 defines 2nd value of 4th row
  4083. * @param initialM43 defines 3rd value of 4th row
  4084. * @param initialM44 defines 4th value of 4th row
  4085. * @returns the new matrix
  4086. */
  4087. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4088. /**
  4089. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4090. * @param scale defines the scale vector3
  4091. * @param rotation defines the rotation quaternion
  4092. * @param translation defines the translation vector3
  4093. * @returns a new matrix
  4094. */
  4095. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4096. /**
  4097. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4098. * @param scale defines the scale vector3
  4099. * @param rotation defines the rotation quaternion
  4100. * @param translation defines the translation vector3
  4101. * @param result defines the target matrix
  4102. */
  4103. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4104. /**
  4105. * Creates a new identity matrix
  4106. * @returns a new identity matrix
  4107. */
  4108. static Identity(): Matrix;
  4109. /**
  4110. * Creates a new identity matrix and stores the result in a given matrix
  4111. * @param result defines the target matrix
  4112. */
  4113. static IdentityToRef(result: Matrix): void;
  4114. /**
  4115. * Creates a new zero matrix
  4116. * @returns a new zero matrix
  4117. */
  4118. static Zero(): Matrix;
  4119. /**
  4120. * Creates a new rotation matrix for "angle" radians around the X axis
  4121. * @param angle defines the angle (in radians) to use
  4122. * @return the new matrix
  4123. */
  4124. static RotationX(angle: number): Matrix;
  4125. /**
  4126. * Creates a new matrix as the invert of a given matrix
  4127. * @param source defines the source matrix
  4128. * @returns the new matrix
  4129. */
  4130. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4133. * @param angle defines the angle (in radians) to use
  4134. * @param result defines the target matrix
  4135. */
  4136. static RotationXToRef(angle: number, result: Matrix): void;
  4137. /**
  4138. * Creates a new rotation matrix for "angle" radians around the Y axis
  4139. * @param angle defines the angle (in radians) to use
  4140. * @return the new matrix
  4141. */
  4142. static RotationY(angle: number): Matrix;
  4143. /**
  4144. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4145. * @param angle defines the angle (in radians) to use
  4146. * @param result defines the target matrix
  4147. */
  4148. static RotationYToRef(angle: number, result: Matrix): void;
  4149. /**
  4150. * Creates a new rotation matrix for "angle" radians around the Z axis
  4151. * @param angle defines the angle (in radians) to use
  4152. * @return the new matrix
  4153. */
  4154. static RotationZ(angle: number): Matrix;
  4155. /**
  4156. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4157. * @param angle defines the angle (in radians) to use
  4158. * @param result defines the target matrix
  4159. */
  4160. static RotationZToRef(angle: number, result: Matrix): void;
  4161. /**
  4162. * Creates a new rotation matrix for "angle" radians around the given axis
  4163. * @param axis defines the axis to use
  4164. * @param angle defines the angle (in radians) to use
  4165. * @return the new matrix
  4166. */
  4167. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4168. /**
  4169. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4170. * @param axis defines the axis to use
  4171. * @param angle defines the angle (in radians) to use
  4172. * @param result defines the target matrix
  4173. */
  4174. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4175. /**
  4176. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4177. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4178. * @param from defines the vector to align
  4179. * @param to defines the vector to align to
  4180. * @param result defines the target matrix
  4181. */
  4182. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4183. /**
  4184. * Creates a rotation matrix
  4185. * @param yaw defines the yaw angle in radians (Y axis)
  4186. * @param pitch defines the pitch angle in radians (X axis)
  4187. * @param roll defines the roll angle in radians (X axis)
  4188. * @returns the new rotation matrix
  4189. */
  4190. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4191. /**
  4192. * Creates a rotation matrix and stores it in a given matrix
  4193. * @param yaw defines the yaw angle in radians (Y axis)
  4194. * @param pitch defines the pitch angle in radians (X axis)
  4195. * @param roll defines the roll angle in radians (X axis)
  4196. * @param result defines the target matrix
  4197. */
  4198. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4199. /**
  4200. * Creates a scaling matrix
  4201. * @param x defines the scale factor on X axis
  4202. * @param y defines the scale factor on Y axis
  4203. * @param z defines the scale factor on Z axis
  4204. * @returns the new matrix
  4205. */
  4206. static Scaling(x: number, y: number, z: number): Matrix;
  4207. /**
  4208. * Creates a scaling matrix and stores it in a given matrix
  4209. * @param x defines the scale factor on X axis
  4210. * @param y defines the scale factor on Y axis
  4211. * @param z defines the scale factor on Z axis
  4212. * @param result defines the target matrix
  4213. */
  4214. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4215. /**
  4216. * Creates a translation matrix
  4217. * @param x defines the translation on X axis
  4218. * @param y defines the translation on Y axis
  4219. * @param z defines the translationon Z axis
  4220. * @returns the new matrix
  4221. */
  4222. static Translation(x: number, y: number, z: number): Matrix;
  4223. /**
  4224. * Creates a translation matrix and stores it in a given matrix
  4225. * @param x defines the translation on X axis
  4226. * @param y defines the translation on Y axis
  4227. * @param z defines the translationon Z axis
  4228. * @param result defines the target matrix
  4229. */
  4230. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4231. /**
  4232. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4233. * @param startValue defines the start value
  4234. * @param endValue defines the end value
  4235. * @param gradient defines the gradient factor
  4236. * @returns the new matrix
  4237. */
  4238. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4239. /**
  4240. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4241. * @param startValue defines the start value
  4242. * @param endValue defines the end value
  4243. * @param gradient defines the gradient factor
  4244. * @param result defines the Matrix object where to store data
  4245. */
  4246. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4247. /**
  4248. * Builds a new matrix whose values are computed by:
  4249. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4250. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4251. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4252. * @param startValue defines the first matrix
  4253. * @param endValue defines the second matrix
  4254. * @param gradient defines the gradient between the two matrices
  4255. * @returns the new matrix
  4256. */
  4257. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4258. /**
  4259. * Update a matrix to values which are computed by:
  4260. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4261. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4262. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4263. * @param startValue defines the first matrix
  4264. * @param endValue defines the second matrix
  4265. * @param gradient defines the gradient between the two matrices
  4266. * @param result defines the target matrix
  4267. */
  4268. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4269. /**
  4270. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4271. * This function works in left handed mode
  4272. * @param eye defines the final position of the entity
  4273. * @param target defines where the entity should look at
  4274. * @param up defines the up vector for the entity
  4275. * @returns the new matrix
  4276. */
  4277. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4278. /**
  4279. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4280. * This function works in left handed mode
  4281. * @param eye defines the final position of the entity
  4282. * @param target defines where the entity should look at
  4283. * @param up defines the up vector for the entity
  4284. * @param result defines the target matrix
  4285. */
  4286. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4287. /**
  4288. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4289. * This function works in right handed mode
  4290. * @param eye defines the final position of the entity
  4291. * @param target defines where the entity should look at
  4292. * @param up defines the up vector for the entity
  4293. * @returns the new matrix
  4294. */
  4295. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4296. /**
  4297. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4298. * This function works in right handed mode
  4299. * @param eye defines the final position of the entity
  4300. * @param target defines where the entity should look at
  4301. * @param up defines the up vector for the entity
  4302. * @param result defines the target matrix
  4303. */
  4304. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4305. /**
  4306. * Create a left-handed orthographic projection matrix
  4307. * @param width defines the viewport width
  4308. * @param height defines the viewport height
  4309. * @param znear defines the near clip plane
  4310. * @param zfar defines the far clip plane
  4311. * @returns a new matrix as a left-handed orthographic projection matrix
  4312. */
  4313. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4314. /**
  4315. * Store a left-handed orthographic projection to a given matrix
  4316. * @param width defines the viewport width
  4317. * @param height defines the viewport height
  4318. * @param znear defines the near clip plane
  4319. * @param zfar defines the far clip plane
  4320. * @param result defines the target matrix
  4321. */
  4322. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4323. /**
  4324. * Create a left-handed orthographic projection matrix
  4325. * @param left defines the viewport left coordinate
  4326. * @param right defines the viewport right coordinate
  4327. * @param bottom defines the viewport bottom coordinate
  4328. * @param top defines the viewport top coordinate
  4329. * @param znear defines the near clip plane
  4330. * @param zfar defines the far clip plane
  4331. * @returns a new matrix as a left-handed orthographic projection matrix
  4332. */
  4333. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4334. /**
  4335. * Stores a left-handed orthographic projection into a given matrix
  4336. * @param left defines the viewport left coordinate
  4337. * @param right defines the viewport right coordinate
  4338. * @param bottom defines the viewport bottom coordinate
  4339. * @param top defines the viewport top coordinate
  4340. * @param znear defines the near clip plane
  4341. * @param zfar defines the far clip plane
  4342. * @param result defines the target matrix
  4343. */
  4344. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4345. /**
  4346. * Creates a right-handed orthographic projection matrix
  4347. * @param left defines the viewport left coordinate
  4348. * @param right defines the viewport right coordinate
  4349. * @param bottom defines the viewport bottom coordinate
  4350. * @param top defines the viewport top coordinate
  4351. * @param znear defines the near clip plane
  4352. * @param zfar defines the far clip plane
  4353. * @returns a new matrix as a right-handed orthographic projection matrix
  4354. */
  4355. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4356. /**
  4357. * Stores a right-handed orthographic projection into a given matrix
  4358. * @param left defines the viewport left coordinate
  4359. * @param right defines the viewport right coordinate
  4360. * @param bottom defines the viewport bottom coordinate
  4361. * @param top defines the viewport top coordinate
  4362. * @param znear defines the near clip plane
  4363. * @param zfar defines the far clip plane
  4364. * @param result defines the target matrix
  4365. */
  4366. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4367. /**
  4368. * Creates a left-handed perspective projection matrix
  4369. * @param width defines the viewport width
  4370. * @param height defines the viewport height
  4371. * @param znear defines the near clip plane
  4372. * @param zfar defines the far clip plane
  4373. * @returns a new matrix as a left-handed perspective projection matrix
  4374. */
  4375. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4376. /**
  4377. * Creates a left-handed perspective projection matrix
  4378. * @param fov defines the horizontal field of view
  4379. * @param aspect defines the aspect ratio
  4380. * @param znear defines the near clip plane
  4381. * @param zfar defines the far clip plane
  4382. * @returns a new matrix as a left-handed perspective projection matrix
  4383. */
  4384. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4385. /**
  4386. * Stores a left-handed perspective projection into a given matrix
  4387. * @param fov defines the horizontal field of view
  4388. * @param aspect defines the aspect ratio
  4389. * @param znear defines the near clip plane
  4390. * @param zfar defines the far clip plane
  4391. * @param result defines the target matrix
  4392. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4393. */
  4394. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4395. /**
  4396. * Creates a right-handed perspective projection matrix
  4397. * @param fov defines the horizontal field of view
  4398. * @param aspect defines the aspect ratio
  4399. * @param znear defines the near clip plane
  4400. * @param zfar defines the far clip plane
  4401. * @returns a new matrix as a right-handed perspective projection matrix
  4402. */
  4403. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4404. /**
  4405. * Stores a right-handed perspective projection into a given matrix
  4406. * @param fov defines the horizontal field of view
  4407. * @param aspect defines the aspect ratio
  4408. * @param znear defines the near clip plane
  4409. * @param zfar defines the far clip plane
  4410. * @param result defines the target matrix
  4411. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4412. */
  4413. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4414. /**
  4415. * Stores a perspective projection for WebVR info a given matrix
  4416. * @param fov defines the field of view
  4417. * @param znear defines the near clip plane
  4418. * @param zfar defines the far clip plane
  4419. * @param result defines the target matrix
  4420. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4421. */
  4422. static PerspectiveFovWebVRToRef(fov: {
  4423. upDegrees: number;
  4424. downDegrees: number;
  4425. leftDegrees: number;
  4426. rightDegrees: number;
  4427. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4428. /**
  4429. * Computes a complete transformation matrix
  4430. * @param viewport defines the viewport to use
  4431. * @param world defines the world matrix
  4432. * @param view defines the view matrix
  4433. * @param projection defines the projection matrix
  4434. * @param zmin defines the near clip plane
  4435. * @param zmax defines the far clip plane
  4436. * @returns the transformation matrix
  4437. */
  4438. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4439. /**
  4440. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4441. * @param matrix defines the matrix to use
  4442. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4443. */
  4444. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4445. /**
  4446. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4447. * @param matrix defines the matrix to use
  4448. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4449. */
  4450. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4451. /**
  4452. * Compute the transpose of a given matrix
  4453. * @param matrix defines the matrix to transpose
  4454. * @returns the new matrix
  4455. */
  4456. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4457. /**
  4458. * Compute the transpose of a matrix and store it in a target matrix
  4459. * @param matrix defines the matrix to transpose
  4460. * @param result defines the target matrix
  4461. */
  4462. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4463. /**
  4464. * Computes a reflection matrix from a plane
  4465. * @param plane defines the reflection plane
  4466. * @returns a new matrix
  4467. */
  4468. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4469. /**
  4470. * Computes a reflection matrix from a plane
  4471. * @param plane defines the reflection plane
  4472. * @param result defines the target matrix
  4473. */
  4474. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4475. /**
  4476. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4477. * @param xaxis defines the value of the 1st axis
  4478. * @param yaxis defines the value of the 2nd axis
  4479. * @param zaxis defines the value of the 3rd axis
  4480. * @param result defines the target matrix
  4481. */
  4482. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4483. /**
  4484. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4485. * @param quat defines the quaternion to use
  4486. * @param result defines the target matrix
  4487. */
  4488. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4489. }
  4490. /**
  4491. * @hidden
  4492. */
  4493. export class TmpVectors {
  4494. static Vector2: Vector2[];
  4495. static Vector3: Vector3[];
  4496. static Vector4: Vector4[];
  4497. static Quaternion: Quaternion[];
  4498. static Matrix: Matrix[];
  4499. }
  4500. }
  4501. declare module BABYLON {
  4502. /**
  4503. * Defines potential orientation for back face culling
  4504. */
  4505. export enum Orientation {
  4506. /**
  4507. * Clockwise
  4508. */
  4509. CW = 0,
  4510. /** Counter clockwise */
  4511. CCW = 1
  4512. }
  4513. /** Class used to represent a Bezier curve */
  4514. export class BezierCurve {
  4515. /**
  4516. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4517. * @param t defines the time
  4518. * @param x1 defines the left coordinate on X axis
  4519. * @param y1 defines the left coordinate on Y axis
  4520. * @param x2 defines the right coordinate on X axis
  4521. * @param y2 defines the right coordinate on Y axis
  4522. * @returns the interpolated value
  4523. */
  4524. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4525. }
  4526. /**
  4527. * Defines angle representation
  4528. */
  4529. export class Angle {
  4530. private _radians;
  4531. /**
  4532. * Creates an Angle object of "radians" radians (float).
  4533. * @param radians the angle in radians
  4534. */
  4535. constructor(radians: number);
  4536. /**
  4537. * Get value in degrees
  4538. * @returns the Angle value in degrees (float)
  4539. */
  4540. degrees(): number;
  4541. /**
  4542. * Get value in radians
  4543. * @returns the Angle value in radians (float)
  4544. */
  4545. radians(): number;
  4546. /**
  4547. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4548. * @param a defines first vector
  4549. * @param b defines second vector
  4550. * @returns a new Angle
  4551. */
  4552. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4553. /**
  4554. * Gets a new Angle object from the given float in radians
  4555. * @param radians defines the angle value in radians
  4556. * @returns a new Angle
  4557. */
  4558. static FromRadians(radians: number): Angle;
  4559. /**
  4560. * Gets a new Angle object from the given float in degrees
  4561. * @param degrees defines the angle value in degrees
  4562. * @returns a new Angle
  4563. */
  4564. static FromDegrees(degrees: number): Angle;
  4565. }
  4566. /**
  4567. * This represents an arc in a 2d space.
  4568. */
  4569. export class Arc2 {
  4570. /** Defines the start point of the arc */
  4571. startPoint: Vector2;
  4572. /** Defines the mid point of the arc */
  4573. midPoint: Vector2;
  4574. /** Defines the end point of the arc */
  4575. endPoint: Vector2;
  4576. /**
  4577. * Defines the center point of the arc.
  4578. */
  4579. centerPoint: Vector2;
  4580. /**
  4581. * Defines the radius of the arc.
  4582. */
  4583. radius: number;
  4584. /**
  4585. * Defines the angle of the arc (from mid point to end point).
  4586. */
  4587. angle: Angle;
  4588. /**
  4589. * Defines the start angle of the arc (from start point to middle point).
  4590. */
  4591. startAngle: Angle;
  4592. /**
  4593. * Defines the orientation of the arc (clock wise/counter clock wise).
  4594. */
  4595. orientation: Orientation;
  4596. /**
  4597. * Creates an Arc object from the three given points : start, middle and end.
  4598. * @param startPoint Defines the start point of the arc
  4599. * @param midPoint Defines the midlle point of the arc
  4600. * @param endPoint Defines the end point of the arc
  4601. */
  4602. constructor(
  4603. /** Defines the start point of the arc */
  4604. startPoint: Vector2,
  4605. /** Defines the mid point of the arc */
  4606. midPoint: Vector2,
  4607. /** Defines the end point of the arc */
  4608. endPoint: Vector2);
  4609. }
  4610. /**
  4611. * Represents a 2D path made up of multiple 2D points
  4612. */
  4613. export class Path2 {
  4614. private _points;
  4615. private _length;
  4616. /**
  4617. * If the path start and end point are the same
  4618. */
  4619. closed: boolean;
  4620. /**
  4621. * Creates a Path2 object from the starting 2D coordinates x and y.
  4622. * @param x the starting points x value
  4623. * @param y the starting points y value
  4624. */
  4625. constructor(x: number, y: number);
  4626. /**
  4627. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4628. * @param x the added points x value
  4629. * @param y the added points y value
  4630. * @returns the updated Path2.
  4631. */
  4632. addLineTo(x: number, y: number): Path2;
  4633. /**
  4634. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4635. * @param midX middle point x value
  4636. * @param midY middle point y value
  4637. * @param endX end point x value
  4638. * @param endY end point y value
  4639. * @param numberOfSegments (default: 36)
  4640. * @returns the updated Path2.
  4641. */
  4642. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4643. /**
  4644. * Closes the Path2.
  4645. * @returns the Path2.
  4646. */
  4647. close(): Path2;
  4648. /**
  4649. * Gets the sum of the distance between each sequential point in the path
  4650. * @returns the Path2 total length (float).
  4651. */
  4652. length(): number;
  4653. /**
  4654. * Gets the points which construct the path
  4655. * @returns the Path2 internal array of points.
  4656. */
  4657. getPoints(): Vector2[];
  4658. /**
  4659. * Retreives the point at the distance aways from the starting point
  4660. * @param normalizedLengthPosition the length along the path to retreive the point from
  4661. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4662. */
  4663. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4664. /**
  4665. * Creates a new path starting from an x and y position
  4666. * @param x starting x value
  4667. * @param y starting y value
  4668. * @returns a new Path2 starting at the coordinates (x, y).
  4669. */
  4670. static StartingAt(x: number, y: number): Path2;
  4671. }
  4672. /**
  4673. * Represents a 3D path made up of multiple 3D points
  4674. */
  4675. export class Path3D {
  4676. /**
  4677. * an array of Vector3, the curve axis of the Path3D
  4678. */
  4679. path: Vector3[];
  4680. private _curve;
  4681. private _distances;
  4682. private _tangents;
  4683. private _normals;
  4684. private _binormals;
  4685. private _raw;
  4686. /**
  4687. * new Path3D(path, normal, raw)
  4688. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4689. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4690. * @param path an array of Vector3, the curve axis of the Path3D
  4691. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4692. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4693. */
  4694. constructor(
  4695. /**
  4696. * an array of Vector3, the curve axis of the Path3D
  4697. */
  4698. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4699. /**
  4700. * Returns the Path3D array of successive Vector3 designing its curve.
  4701. * @returns the Path3D array of successive Vector3 designing its curve.
  4702. */
  4703. getCurve(): Vector3[];
  4704. /**
  4705. * Returns an array populated with tangent vectors on each Path3D curve point.
  4706. * @returns an array populated with tangent vectors on each Path3D curve point.
  4707. */
  4708. getTangents(): Vector3[];
  4709. /**
  4710. * Returns an array populated with normal vectors on each Path3D curve point.
  4711. * @returns an array populated with normal vectors on each Path3D curve point.
  4712. */
  4713. getNormals(): Vector3[];
  4714. /**
  4715. * Returns an array populated with binormal vectors on each Path3D curve point.
  4716. * @returns an array populated with binormal vectors on each Path3D curve point.
  4717. */
  4718. getBinormals(): Vector3[];
  4719. /**
  4720. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4721. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4722. */
  4723. getDistances(): number[];
  4724. /**
  4725. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4726. * @param path path which all values are copied into the curves points
  4727. * @param firstNormal which should be projected onto the curve
  4728. * @returns the same object updated.
  4729. */
  4730. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4731. private _compute;
  4732. private _getFirstNonNullVector;
  4733. private _getLastNonNullVector;
  4734. private _normalVector;
  4735. }
  4736. /**
  4737. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4738. * A Curve3 is designed from a series of successive Vector3.
  4739. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4740. */
  4741. export class Curve3 {
  4742. private _points;
  4743. private _length;
  4744. /**
  4745. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4746. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4747. * @param v1 (Vector3) the control point
  4748. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4749. * @param nbPoints (integer) the wanted number of points in the curve
  4750. * @returns the created Curve3
  4751. */
  4752. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4753. /**
  4754. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4755. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4756. * @param v1 (Vector3) the first control point
  4757. * @param v2 (Vector3) the second control point
  4758. * @param v3 (Vector3) the end point of the Cubic Bezier
  4759. * @param nbPoints (integer) the wanted number of points in the curve
  4760. * @returns the created Curve3
  4761. */
  4762. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4763. /**
  4764. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4765. * @param p1 (Vector3) the origin point of the Hermite Spline
  4766. * @param t1 (Vector3) the tangent vector at the origin point
  4767. * @param p2 (Vector3) the end point of the Hermite Spline
  4768. * @param t2 (Vector3) the tangent vector at the end point
  4769. * @param nbPoints (integer) the wanted number of points in the curve
  4770. * @returns the created Curve3
  4771. */
  4772. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4773. /**
  4774. * Returns a Curve3 object along a CatmullRom Spline curve :
  4775. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4776. * @param nbPoints (integer) the wanted number of points between each curve control points
  4777. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4778. * @returns the created Curve3
  4779. */
  4780. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4781. /**
  4782. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4783. * A Curve3 is designed from a series of successive Vector3.
  4784. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4785. * @param points points which make up the curve
  4786. */
  4787. constructor(points: Vector3[]);
  4788. /**
  4789. * @returns the Curve3 stored array of successive Vector3
  4790. */
  4791. getPoints(): Vector3[];
  4792. /**
  4793. * @returns the computed length (float) of the curve.
  4794. */
  4795. length(): number;
  4796. /**
  4797. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4798. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4799. * curveA and curveB keep unchanged.
  4800. * @param curve the curve to continue from this curve
  4801. * @returns the newly constructed curve
  4802. */
  4803. continue(curve: DeepImmutable<Curve3>): Curve3;
  4804. private _computeLength;
  4805. }
  4806. }
  4807. declare module BABYLON {
  4808. /**
  4809. * This represents the main contract an easing function should follow.
  4810. * Easing functions are used throughout the animation system.
  4811. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4812. */
  4813. export interface IEasingFunction {
  4814. /**
  4815. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4816. * of the easing function.
  4817. * The link below provides some of the most common examples of easing functions.
  4818. * @see https://easings.net/
  4819. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4820. * @returns the corresponding value on the curve defined by the easing function
  4821. */
  4822. ease(gradient: number): number;
  4823. }
  4824. /**
  4825. * Base class used for every default easing function.
  4826. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4827. */
  4828. export class EasingFunction implements IEasingFunction {
  4829. /**
  4830. * Interpolation follows the mathematical formula associated with the easing function.
  4831. */
  4832. static readonly EASINGMODE_EASEIN: number;
  4833. /**
  4834. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4835. */
  4836. static readonly EASINGMODE_EASEOUT: number;
  4837. /**
  4838. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4839. */
  4840. static readonly EASINGMODE_EASEINOUT: number;
  4841. private _easingMode;
  4842. /**
  4843. * Sets the easing mode of the current function.
  4844. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4845. */
  4846. setEasingMode(easingMode: number): void;
  4847. /**
  4848. * Gets the current easing mode.
  4849. * @returns the easing mode
  4850. */
  4851. getEasingMode(): number;
  4852. /**
  4853. * @hidden
  4854. */
  4855. easeInCore(gradient: number): number;
  4856. /**
  4857. * Given an input gradient between 0 and 1, this returns the corresponding value
  4858. * of the easing function.
  4859. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4860. * @returns the corresponding value on the curve defined by the easing function
  4861. */
  4862. ease(gradient: number): number;
  4863. }
  4864. /**
  4865. * Easing function with a circle shape (see link below).
  4866. * @see https://easings.net/#easeInCirc
  4867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4868. */
  4869. export class CircleEase extends EasingFunction implements IEasingFunction {
  4870. /** @hidden */
  4871. easeInCore(gradient: number): number;
  4872. }
  4873. /**
  4874. * Easing function with a ease back shape (see link below).
  4875. * @see https://easings.net/#easeInBack
  4876. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4877. */
  4878. export class BackEase extends EasingFunction implements IEasingFunction {
  4879. /** Defines the amplitude of the function */
  4880. amplitude: number;
  4881. /**
  4882. * Instantiates a back ease easing
  4883. * @see https://easings.net/#easeInBack
  4884. * @param amplitude Defines the amplitude of the function
  4885. */
  4886. constructor(
  4887. /** Defines the amplitude of the function */
  4888. amplitude?: number);
  4889. /** @hidden */
  4890. easeInCore(gradient: number): number;
  4891. }
  4892. /**
  4893. * Easing function with a bouncing shape (see link below).
  4894. * @see https://easings.net/#easeInBounce
  4895. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4896. */
  4897. export class BounceEase extends EasingFunction implements IEasingFunction {
  4898. /** Defines the number of bounces */
  4899. bounces: number;
  4900. /** Defines the amplitude of the bounce */
  4901. bounciness: number;
  4902. /**
  4903. * Instantiates a bounce easing
  4904. * @see https://easings.net/#easeInBounce
  4905. * @param bounces Defines the number of bounces
  4906. * @param bounciness Defines the amplitude of the bounce
  4907. */
  4908. constructor(
  4909. /** Defines the number of bounces */
  4910. bounces?: number,
  4911. /** Defines the amplitude of the bounce */
  4912. bounciness?: number);
  4913. /** @hidden */
  4914. easeInCore(gradient: number): number;
  4915. }
  4916. /**
  4917. * Easing function with a power of 3 shape (see link below).
  4918. * @see https://easings.net/#easeInCubic
  4919. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4920. */
  4921. export class CubicEase extends EasingFunction implements IEasingFunction {
  4922. /** @hidden */
  4923. easeInCore(gradient: number): number;
  4924. }
  4925. /**
  4926. * Easing function with an elastic shape (see link below).
  4927. * @see https://easings.net/#easeInElastic
  4928. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4929. */
  4930. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4931. /** Defines the number of oscillations*/
  4932. oscillations: number;
  4933. /** Defines the amplitude of the oscillations*/
  4934. springiness: number;
  4935. /**
  4936. * Instantiates an elastic easing function
  4937. * @see https://easings.net/#easeInElastic
  4938. * @param oscillations Defines the number of oscillations
  4939. * @param springiness Defines the amplitude of the oscillations
  4940. */
  4941. constructor(
  4942. /** Defines the number of oscillations*/
  4943. oscillations?: number,
  4944. /** Defines the amplitude of the oscillations*/
  4945. springiness?: number);
  4946. /** @hidden */
  4947. easeInCore(gradient: number): number;
  4948. }
  4949. /**
  4950. * Easing function with an exponential shape (see link below).
  4951. * @see https://easings.net/#easeInExpo
  4952. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4953. */
  4954. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4955. /** Defines the exponent of the function */
  4956. exponent: number;
  4957. /**
  4958. * Instantiates an exponential easing function
  4959. * @see https://easings.net/#easeInExpo
  4960. * @param exponent Defines the exponent of the function
  4961. */
  4962. constructor(
  4963. /** Defines the exponent of the function */
  4964. exponent?: number);
  4965. /** @hidden */
  4966. easeInCore(gradient: number): number;
  4967. }
  4968. /**
  4969. * Easing function with a power shape (see link below).
  4970. * @see https://easings.net/#easeInQuad
  4971. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4972. */
  4973. export class PowerEase extends EasingFunction implements IEasingFunction {
  4974. /** Defines the power of the function */
  4975. power: number;
  4976. /**
  4977. * Instantiates an power base easing function
  4978. * @see https://easings.net/#easeInQuad
  4979. * @param power Defines the power of the function
  4980. */
  4981. constructor(
  4982. /** Defines the power of the function */
  4983. power?: number);
  4984. /** @hidden */
  4985. easeInCore(gradient: number): number;
  4986. }
  4987. /**
  4988. * Easing function with a power of 2 shape (see link below).
  4989. * @see https://easings.net/#easeInQuad
  4990. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4991. */
  4992. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  4993. /** @hidden */
  4994. easeInCore(gradient: number): number;
  4995. }
  4996. /**
  4997. * Easing function with a power of 4 shape (see link below).
  4998. * @see https://easings.net/#easeInQuart
  4999. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5000. */
  5001. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5002. /** @hidden */
  5003. easeInCore(gradient: number): number;
  5004. }
  5005. /**
  5006. * Easing function with a power of 5 shape (see link below).
  5007. * @see https://easings.net/#easeInQuint
  5008. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5009. */
  5010. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5011. /** @hidden */
  5012. easeInCore(gradient: number): number;
  5013. }
  5014. /**
  5015. * Easing function with a sin shape (see link below).
  5016. * @see https://easings.net/#easeInSine
  5017. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5018. */
  5019. export class SineEase extends EasingFunction implements IEasingFunction {
  5020. /** @hidden */
  5021. easeInCore(gradient: number): number;
  5022. }
  5023. /**
  5024. * Easing function with a bezier shape (see link below).
  5025. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5026. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5027. */
  5028. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5029. /** Defines the x component of the start tangent in the bezier curve */
  5030. x1: number;
  5031. /** Defines the y component of the start tangent in the bezier curve */
  5032. y1: number;
  5033. /** Defines the x component of the end tangent in the bezier curve */
  5034. x2: number;
  5035. /** Defines the y component of the end tangent in the bezier curve */
  5036. y2: number;
  5037. /**
  5038. * Instantiates a bezier function
  5039. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5040. * @param x1 Defines the x component of the start tangent in the bezier curve
  5041. * @param y1 Defines the y component of the start tangent in the bezier curve
  5042. * @param x2 Defines the x component of the end tangent in the bezier curve
  5043. * @param y2 Defines the y component of the end tangent in the bezier curve
  5044. */
  5045. constructor(
  5046. /** Defines the x component of the start tangent in the bezier curve */
  5047. x1?: number,
  5048. /** Defines the y component of the start tangent in the bezier curve */
  5049. y1?: number,
  5050. /** Defines the x component of the end tangent in the bezier curve */
  5051. x2?: number,
  5052. /** Defines the y component of the end tangent in the bezier curve */
  5053. y2?: number);
  5054. /** @hidden */
  5055. easeInCore(gradient: number): number;
  5056. }
  5057. }
  5058. declare module BABYLON {
  5059. /**
  5060. * Class used to hold a RBG color
  5061. */
  5062. export class Color3 {
  5063. /**
  5064. * Defines the red component (between 0 and 1, default is 0)
  5065. */
  5066. r: number;
  5067. /**
  5068. * Defines the green component (between 0 and 1, default is 0)
  5069. */
  5070. g: number;
  5071. /**
  5072. * Defines the blue component (between 0 and 1, default is 0)
  5073. */
  5074. b: number;
  5075. /**
  5076. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5077. * @param r defines the red component (between 0 and 1, default is 0)
  5078. * @param g defines the green component (between 0 and 1, default is 0)
  5079. * @param b defines the blue component (between 0 and 1, default is 0)
  5080. */
  5081. constructor(
  5082. /**
  5083. * Defines the red component (between 0 and 1, default is 0)
  5084. */
  5085. r?: number,
  5086. /**
  5087. * Defines the green component (between 0 and 1, default is 0)
  5088. */
  5089. g?: number,
  5090. /**
  5091. * Defines the blue component (between 0 and 1, default is 0)
  5092. */
  5093. b?: number);
  5094. /**
  5095. * Creates a string with the Color3 current values
  5096. * @returns the string representation of the Color3 object
  5097. */
  5098. toString(): string;
  5099. /**
  5100. * Returns the string "Color3"
  5101. * @returns "Color3"
  5102. */
  5103. getClassName(): string;
  5104. /**
  5105. * Compute the Color3 hash code
  5106. * @returns an unique number that can be used to hash Color3 objects
  5107. */
  5108. getHashCode(): number;
  5109. /**
  5110. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5111. * @param array defines the array where to store the r,g,b components
  5112. * @param index defines an optional index in the target array to define where to start storing values
  5113. * @returns the current Color3 object
  5114. */
  5115. toArray(array: FloatArray, index?: number): Color3;
  5116. /**
  5117. * Returns a new Color4 object from the current Color3 and the given alpha
  5118. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5119. * @returns a new Color4 object
  5120. */
  5121. toColor4(alpha?: number): Color4;
  5122. /**
  5123. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5124. * @returns the new array
  5125. */
  5126. asArray(): number[];
  5127. /**
  5128. * Returns the luminance value
  5129. * @returns a float value
  5130. */
  5131. toLuminance(): number;
  5132. /**
  5133. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5134. * @param otherColor defines the second operand
  5135. * @returns the new Color3 object
  5136. */
  5137. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5138. /**
  5139. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5140. * @param otherColor defines the second operand
  5141. * @param result defines the Color3 object where to store the result
  5142. * @returns the current Color3
  5143. */
  5144. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5145. /**
  5146. * Determines equality between Color3 objects
  5147. * @param otherColor defines the second operand
  5148. * @returns true if the rgb values are equal to the given ones
  5149. */
  5150. equals(otherColor: DeepImmutable<Color3>): boolean;
  5151. /**
  5152. * Determines equality between the current Color3 object and a set of r,b,g values
  5153. * @param r defines the red component to check
  5154. * @param g defines the green component to check
  5155. * @param b defines the blue component to check
  5156. * @returns true if the rgb values are equal to the given ones
  5157. */
  5158. equalsFloats(r: number, g: number, b: number): boolean;
  5159. /**
  5160. * Multiplies in place each rgb value by scale
  5161. * @param scale defines the scaling factor
  5162. * @returns the updated Color3
  5163. */
  5164. scale(scale: number): Color3;
  5165. /**
  5166. * Multiplies the rgb values by scale and stores the result into "result"
  5167. * @param scale defines the scaling factor
  5168. * @param result defines the Color3 object where to store the result
  5169. * @returns the unmodified current Color3
  5170. */
  5171. scaleToRef(scale: number, result: Color3): Color3;
  5172. /**
  5173. * Scale the current Color3 values by a factor and add the result to a given Color3
  5174. * @param scale defines the scale factor
  5175. * @param result defines color to store the result into
  5176. * @returns the unmodified current Color3
  5177. */
  5178. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5179. /**
  5180. * Clamps the rgb values by the min and max values and stores the result into "result"
  5181. * @param min defines minimum clamping value (default is 0)
  5182. * @param max defines maximum clamping value (default is 1)
  5183. * @param result defines color to store the result into
  5184. * @returns the original Color3
  5185. */
  5186. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5187. /**
  5188. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5189. * @param otherColor defines the second operand
  5190. * @returns the new Color3
  5191. */
  5192. add(otherColor: DeepImmutable<Color3>): Color3;
  5193. /**
  5194. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5195. * @param otherColor defines the second operand
  5196. * @param result defines Color3 object to store the result into
  5197. * @returns the unmodified current Color3
  5198. */
  5199. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5200. /**
  5201. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5202. * @param otherColor defines the second operand
  5203. * @returns the new Color3
  5204. */
  5205. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5206. /**
  5207. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5208. * @param otherColor defines the second operand
  5209. * @param result defines Color3 object to store the result into
  5210. * @returns the unmodified current Color3
  5211. */
  5212. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5213. /**
  5214. * Copy the current object
  5215. * @returns a new Color3 copied the current one
  5216. */
  5217. clone(): Color3;
  5218. /**
  5219. * Copies the rgb values from the source in the current Color3
  5220. * @param source defines the source Color3 object
  5221. * @returns the updated Color3 object
  5222. */
  5223. copyFrom(source: DeepImmutable<Color3>): Color3;
  5224. /**
  5225. * Updates the Color3 rgb values from the given floats
  5226. * @param r defines the red component to read from
  5227. * @param g defines the green component to read from
  5228. * @param b defines the blue component to read from
  5229. * @returns the current Color3 object
  5230. */
  5231. copyFromFloats(r: number, g: number, b: number): Color3;
  5232. /**
  5233. * Updates the Color3 rgb values from the given floats
  5234. * @param r defines the red component to read from
  5235. * @param g defines the green component to read from
  5236. * @param b defines the blue component to read from
  5237. * @returns the current Color3 object
  5238. */
  5239. set(r: number, g: number, b: number): Color3;
  5240. /**
  5241. * Compute the Color3 hexadecimal code as a string
  5242. * @returns a string containing the hexadecimal representation of the Color3 object
  5243. */
  5244. toHexString(): string;
  5245. /**
  5246. * Computes a new Color3 converted from the current one to linear space
  5247. * @returns a new Color3 object
  5248. */
  5249. toLinearSpace(): Color3;
  5250. /**
  5251. * Converts current color in rgb space to HSV values
  5252. * @returns a new color3 representing the HSV values
  5253. */
  5254. toHSV(): Color3;
  5255. /**
  5256. * Converts current color in rgb space to HSV values
  5257. * @param result defines the Color3 where to store the HSV values
  5258. */
  5259. toHSVToRef(result: Color3): void;
  5260. /**
  5261. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5262. * @param convertedColor defines the Color3 object where to store the linear space version
  5263. * @returns the unmodified Color3
  5264. */
  5265. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5266. /**
  5267. * Computes a new Color3 converted from the current one to gamma space
  5268. * @returns a new Color3 object
  5269. */
  5270. toGammaSpace(): Color3;
  5271. /**
  5272. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5273. * @param convertedColor defines the Color3 object where to store the gamma space version
  5274. * @returns the unmodified Color3
  5275. */
  5276. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5277. private static _BlackReadOnly;
  5278. /**
  5279. * Convert Hue, saturation and value to a Color3 (RGB)
  5280. * @param hue defines the hue
  5281. * @param saturation defines the saturation
  5282. * @param value defines the value
  5283. * @param result defines the Color3 where to store the RGB values
  5284. */
  5285. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5286. /**
  5287. * Creates a new Color3 from the string containing valid hexadecimal values
  5288. * @param hex defines a string containing valid hexadecimal values
  5289. * @returns a new Color3 object
  5290. */
  5291. static FromHexString(hex: string): Color3;
  5292. /**
  5293. * Creates a new Color3 from the starting index of the given array
  5294. * @param array defines the source array
  5295. * @param offset defines an offset in the source array
  5296. * @returns a new Color3 object
  5297. */
  5298. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5299. /**
  5300. * Creates a new Color3 from integer values (< 256)
  5301. * @param r defines the red component to read from (value between 0 and 255)
  5302. * @param g defines the green component to read from (value between 0 and 255)
  5303. * @param b defines the blue component to read from (value between 0 and 255)
  5304. * @returns a new Color3 object
  5305. */
  5306. static FromInts(r: number, g: number, b: number): Color3;
  5307. /**
  5308. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5309. * @param start defines the start Color3 value
  5310. * @param end defines the end Color3 value
  5311. * @param amount defines the gradient value between start and end
  5312. * @returns a new Color3 object
  5313. */
  5314. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5315. /**
  5316. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5317. * @param left defines the start value
  5318. * @param right defines the end value
  5319. * @param amount defines the gradient factor
  5320. * @param result defines the Color3 object where to store the result
  5321. */
  5322. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5323. /**
  5324. * Returns a Color3 value containing a red color
  5325. * @returns a new Color3 object
  5326. */
  5327. static Red(): Color3;
  5328. /**
  5329. * Returns a Color3 value containing a green color
  5330. * @returns a new Color3 object
  5331. */
  5332. static Green(): Color3;
  5333. /**
  5334. * Returns a Color3 value containing a blue color
  5335. * @returns a new Color3 object
  5336. */
  5337. static Blue(): Color3;
  5338. /**
  5339. * Returns a Color3 value containing a black color
  5340. * @returns a new Color3 object
  5341. */
  5342. static Black(): Color3;
  5343. /**
  5344. * Gets a Color3 value containing a black color that must not be updated
  5345. */
  5346. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5347. /**
  5348. * Returns a Color3 value containing a white color
  5349. * @returns a new Color3 object
  5350. */
  5351. static White(): Color3;
  5352. /**
  5353. * Returns a Color3 value containing a purple color
  5354. * @returns a new Color3 object
  5355. */
  5356. static Purple(): Color3;
  5357. /**
  5358. * Returns a Color3 value containing a magenta color
  5359. * @returns a new Color3 object
  5360. */
  5361. static Magenta(): Color3;
  5362. /**
  5363. * Returns a Color3 value containing a yellow color
  5364. * @returns a new Color3 object
  5365. */
  5366. static Yellow(): Color3;
  5367. /**
  5368. * Returns a Color3 value containing a gray color
  5369. * @returns a new Color3 object
  5370. */
  5371. static Gray(): Color3;
  5372. /**
  5373. * Returns a Color3 value containing a teal color
  5374. * @returns a new Color3 object
  5375. */
  5376. static Teal(): Color3;
  5377. /**
  5378. * Returns a Color3 value containing a random color
  5379. * @returns a new Color3 object
  5380. */
  5381. static Random(): Color3;
  5382. }
  5383. /**
  5384. * Class used to hold a RBGA color
  5385. */
  5386. export class Color4 {
  5387. /**
  5388. * Defines the red component (between 0 and 1, default is 0)
  5389. */
  5390. r: number;
  5391. /**
  5392. * Defines the green component (between 0 and 1, default is 0)
  5393. */
  5394. g: number;
  5395. /**
  5396. * Defines the blue component (between 0 and 1, default is 0)
  5397. */
  5398. b: number;
  5399. /**
  5400. * Defines the alpha component (between 0 and 1, default is 1)
  5401. */
  5402. a: number;
  5403. /**
  5404. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5405. * @param r defines the red component (between 0 and 1, default is 0)
  5406. * @param g defines the green component (between 0 and 1, default is 0)
  5407. * @param b defines the blue component (between 0 and 1, default is 0)
  5408. * @param a defines the alpha component (between 0 and 1, default is 1)
  5409. */
  5410. constructor(
  5411. /**
  5412. * Defines the red component (between 0 and 1, default is 0)
  5413. */
  5414. r?: number,
  5415. /**
  5416. * Defines the green component (between 0 and 1, default is 0)
  5417. */
  5418. g?: number,
  5419. /**
  5420. * Defines the blue component (between 0 and 1, default is 0)
  5421. */
  5422. b?: number,
  5423. /**
  5424. * Defines the alpha component (between 0 and 1, default is 1)
  5425. */
  5426. a?: number);
  5427. /**
  5428. * Adds in place the given Color4 values to the current Color4 object
  5429. * @param right defines the second operand
  5430. * @returns the current updated Color4 object
  5431. */
  5432. addInPlace(right: DeepImmutable<Color4>): Color4;
  5433. /**
  5434. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5435. * @returns the new array
  5436. */
  5437. asArray(): number[];
  5438. /**
  5439. * Stores from the starting index in the given array the Color4 successive values
  5440. * @param array defines the array where to store the r,g,b components
  5441. * @param index defines an optional index in the target array to define where to start storing values
  5442. * @returns the current Color4 object
  5443. */
  5444. toArray(array: number[], index?: number): Color4;
  5445. /**
  5446. * Determines equality between Color4 objects
  5447. * @param otherColor defines the second operand
  5448. * @returns true if the rgba values are equal to the given ones
  5449. */
  5450. equals(otherColor: DeepImmutable<Color4>): boolean;
  5451. /**
  5452. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5453. * @param right defines the second operand
  5454. * @returns a new Color4 object
  5455. */
  5456. add(right: DeepImmutable<Color4>): Color4;
  5457. /**
  5458. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5459. * @param right defines the second operand
  5460. * @returns a new Color4 object
  5461. */
  5462. subtract(right: DeepImmutable<Color4>): Color4;
  5463. /**
  5464. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5465. * @param right defines the second operand
  5466. * @param result defines the Color4 object where to store the result
  5467. * @returns the current Color4 object
  5468. */
  5469. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5470. /**
  5471. * Creates a new Color4 with the current Color4 values multiplied by scale
  5472. * @param scale defines the scaling factor to apply
  5473. * @returns a new Color4 object
  5474. */
  5475. scale(scale: number): Color4;
  5476. /**
  5477. * Multiplies the current Color4 values by scale and stores the result in "result"
  5478. * @param scale defines the scaling factor to apply
  5479. * @param result defines the Color4 object where to store the result
  5480. * @returns the current unmodified Color4
  5481. */
  5482. scaleToRef(scale: number, result: Color4): Color4;
  5483. /**
  5484. * Scale the current Color4 values by a factor and add the result to a given Color4
  5485. * @param scale defines the scale factor
  5486. * @param result defines the Color4 object where to store the result
  5487. * @returns the unmodified current Color4
  5488. */
  5489. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5490. /**
  5491. * Clamps the rgb values by the min and max values and stores the result into "result"
  5492. * @param min defines minimum clamping value (default is 0)
  5493. * @param max defines maximum clamping value (default is 1)
  5494. * @param result defines color to store the result into.
  5495. * @returns the cuurent Color4
  5496. */
  5497. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5498. /**
  5499. * Multipy an Color4 value by another and return a new Color4 object
  5500. * @param color defines the Color4 value to multiply by
  5501. * @returns a new Color4 object
  5502. */
  5503. multiply(color: Color4): Color4;
  5504. /**
  5505. * Multipy a Color4 value by another and push the result in a reference value
  5506. * @param color defines the Color4 value to multiply by
  5507. * @param result defines the Color4 to fill the result in
  5508. * @returns the result Color4
  5509. */
  5510. multiplyToRef(color: Color4, result: Color4): Color4;
  5511. /**
  5512. * Creates a string with the Color4 current values
  5513. * @returns the string representation of the Color4 object
  5514. */
  5515. toString(): string;
  5516. /**
  5517. * Returns the string "Color4"
  5518. * @returns "Color4"
  5519. */
  5520. getClassName(): string;
  5521. /**
  5522. * Compute the Color4 hash code
  5523. * @returns an unique number that can be used to hash Color4 objects
  5524. */
  5525. getHashCode(): number;
  5526. /**
  5527. * Creates a new Color4 copied from the current one
  5528. * @returns a new Color4 object
  5529. */
  5530. clone(): Color4;
  5531. /**
  5532. * Copies the given Color4 values into the current one
  5533. * @param source defines the source Color4 object
  5534. * @returns the current updated Color4 object
  5535. */
  5536. copyFrom(source: Color4): Color4;
  5537. /**
  5538. * Copies the given float values into the current one
  5539. * @param r defines the red component to read from
  5540. * @param g defines the green component to read from
  5541. * @param b defines the blue component to read from
  5542. * @param a defines the alpha component to read from
  5543. * @returns the current updated Color4 object
  5544. */
  5545. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5546. /**
  5547. * Copies the given float values into the current one
  5548. * @param r defines the red component to read from
  5549. * @param g defines the green component to read from
  5550. * @param b defines the blue component to read from
  5551. * @param a defines the alpha component to read from
  5552. * @returns the current updated Color4 object
  5553. */
  5554. set(r: number, g: number, b: number, a: number): Color4;
  5555. /**
  5556. * Compute the Color4 hexadecimal code as a string
  5557. * @returns a string containing the hexadecimal representation of the Color4 object
  5558. */
  5559. toHexString(): string;
  5560. /**
  5561. * Computes a new Color4 converted from the current one to linear space
  5562. * @returns a new Color4 object
  5563. */
  5564. toLinearSpace(): Color4;
  5565. /**
  5566. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5567. * @param convertedColor defines the Color4 object where to store the linear space version
  5568. * @returns the unmodified Color4
  5569. */
  5570. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5571. /**
  5572. * Computes a new Color4 converted from the current one to gamma space
  5573. * @returns a new Color4 object
  5574. */
  5575. toGammaSpace(): Color4;
  5576. /**
  5577. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5578. * @param convertedColor defines the Color4 object where to store the gamma space version
  5579. * @returns the unmodified Color4
  5580. */
  5581. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5582. /**
  5583. * Creates a new Color4 from the string containing valid hexadecimal values
  5584. * @param hex defines a string containing valid hexadecimal values
  5585. * @returns a new Color4 object
  5586. */
  5587. static FromHexString(hex: string): Color4;
  5588. /**
  5589. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5590. * @param left defines the start value
  5591. * @param right defines the end value
  5592. * @param amount defines the gradient factor
  5593. * @returns a new Color4 object
  5594. */
  5595. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5596. /**
  5597. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5598. * @param left defines the start value
  5599. * @param right defines the end value
  5600. * @param amount defines the gradient factor
  5601. * @param result defines the Color4 object where to store data
  5602. */
  5603. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5604. /**
  5605. * Creates a new Color4 from a Color3 and an alpha value
  5606. * @param color3 defines the source Color3 to read from
  5607. * @param alpha defines the alpha component (1.0 by default)
  5608. * @returns a new Color4 object
  5609. */
  5610. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5611. /**
  5612. * Creates a new Color4 from the starting index element of the given array
  5613. * @param array defines the source array to read from
  5614. * @param offset defines the offset in the source array
  5615. * @returns a new Color4 object
  5616. */
  5617. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5618. /**
  5619. * Creates a new Color3 from integer values (< 256)
  5620. * @param r defines the red component to read from (value between 0 and 255)
  5621. * @param g defines the green component to read from (value between 0 and 255)
  5622. * @param b defines the blue component to read from (value between 0 and 255)
  5623. * @param a defines the alpha component to read from (value between 0 and 255)
  5624. * @returns a new Color3 object
  5625. */
  5626. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5627. /**
  5628. * Check the content of a given array and convert it to an array containing RGBA data
  5629. * If the original array was already containing count * 4 values then it is returned directly
  5630. * @param colors defines the array to check
  5631. * @param count defines the number of RGBA data to expect
  5632. * @returns an array containing count * 4 values (RGBA)
  5633. */
  5634. static CheckColors4(colors: number[], count: number): number[];
  5635. }
  5636. /**
  5637. * @hidden
  5638. */
  5639. export class TmpColors {
  5640. static Color3: Color3[];
  5641. static Color4: Color4[];
  5642. }
  5643. }
  5644. declare module BABYLON {
  5645. /**
  5646. * Defines an interface which represents an animation key frame
  5647. */
  5648. export interface IAnimationKey {
  5649. /**
  5650. * Frame of the key frame
  5651. */
  5652. frame: number;
  5653. /**
  5654. * Value at the specifies key frame
  5655. */
  5656. value: any;
  5657. /**
  5658. * The input tangent for the cubic hermite spline
  5659. */
  5660. inTangent?: any;
  5661. /**
  5662. * The output tangent for the cubic hermite spline
  5663. */
  5664. outTangent?: any;
  5665. /**
  5666. * The animation interpolation type
  5667. */
  5668. interpolation?: AnimationKeyInterpolation;
  5669. }
  5670. /**
  5671. * Enum for the animation key frame interpolation type
  5672. */
  5673. export enum AnimationKeyInterpolation {
  5674. /**
  5675. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5676. */
  5677. STEP = 1
  5678. }
  5679. }
  5680. declare module BABYLON {
  5681. /**
  5682. * Represents the range of an animation
  5683. */
  5684. export class AnimationRange {
  5685. /**The name of the animation range**/
  5686. name: string;
  5687. /**The starting frame of the animation */
  5688. from: number;
  5689. /**The ending frame of the animation*/
  5690. to: number;
  5691. /**
  5692. * Initializes the range of an animation
  5693. * @param name The name of the animation range
  5694. * @param from The starting frame of the animation
  5695. * @param to The ending frame of the animation
  5696. */
  5697. constructor(
  5698. /**The name of the animation range**/
  5699. name: string,
  5700. /**The starting frame of the animation */
  5701. from: number,
  5702. /**The ending frame of the animation*/
  5703. to: number);
  5704. /**
  5705. * Makes a copy of the animation range
  5706. * @returns A copy of the animation range
  5707. */
  5708. clone(): AnimationRange;
  5709. }
  5710. }
  5711. declare module BABYLON {
  5712. /**
  5713. * Composed of a frame, and an action function
  5714. */
  5715. export class AnimationEvent {
  5716. /** The frame for which the event is triggered **/
  5717. frame: number;
  5718. /** The event to perform when triggered **/
  5719. action: (currentFrame: number) => void;
  5720. /** Specifies if the event should be triggered only once**/
  5721. onlyOnce?: boolean | undefined;
  5722. /**
  5723. * Specifies if the animation event is done
  5724. */
  5725. isDone: boolean;
  5726. /**
  5727. * Initializes the animation event
  5728. * @param frame The frame for which the event is triggered
  5729. * @param action The event to perform when triggered
  5730. * @param onlyOnce Specifies if the event should be triggered only once
  5731. */
  5732. constructor(
  5733. /** The frame for which the event is triggered **/
  5734. frame: number,
  5735. /** The event to perform when triggered **/
  5736. action: (currentFrame: number) => void,
  5737. /** Specifies if the event should be triggered only once**/
  5738. onlyOnce?: boolean | undefined);
  5739. /** @hidden */ private _clone(): AnimationEvent;
  5740. }
  5741. }
  5742. declare module BABYLON {
  5743. /**
  5744. * Interface used to define a behavior
  5745. */
  5746. export interface Behavior<T> {
  5747. /** gets or sets behavior's name */
  5748. name: string;
  5749. /**
  5750. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5751. */
  5752. init(): void;
  5753. /**
  5754. * Called when the behavior is attached to a target
  5755. * @param target defines the target where the behavior is attached to
  5756. */
  5757. attach(target: T): void;
  5758. /**
  5759. * Called when the behavior is detached from its target
  5760. */
  5761. detach(): void;
  5762. }
  5763. /**
  5764. * Interface implemented by classes supporting behaviors
  5765. */
  5766. export interface IBehaviorAware<T> {
  5767. /**
  5768. * Attach a behavior
  5769. * @param behavior defines the behavior to attach
  5770. * @returns the current host
  5771. */
  5772. addBehavior(behavior: Behavior<T>): T;
  5773. /**
  5774. * Remove a behavior from the current object
  5775. * @param behavior defines the behavior to detach
  5776. * @returns the current host
  5777. */
  5778. removeBehavior(behavior: Behavior<T>): T;
  5779. /**
  5780. * Gets a behavior using its name to search
  5781. * @param name defines the name to search
  5782. * @returns the behavior or null if not found
  5783. */
  5784. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5785. }
  5786. }
  5787. declare module BABYLON {
  5788. /**
  5789. * Defines an array and its length.
  5790. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5791. */
  5792. export interface ISmartArrayLike<T> {
  5793. /**
  5794. * The data of the array.
  5795. */
  5796. data: Array<T>;
  5797. /**
  5798. * The active length of the array.
  5799. */
  5800. length: number;
  5801. }
  5802. /**
  5803. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5804. */
  5805. export class SmartArray<T> implements ISmartArrayLike<T> {
  5806. /**
  5807. * The full set of data from the array.
  5808. */
  5809. data: Array<T>;
  5810. /**
  5811. * The active length of the array.
  5812. */
  5813. length: number;
  5814. protected _id: number;
  5815. /**
  5816. * Instantiates a Smart Array.
  5817. * @param capacity defines the default capacity of the array.
  5818. */
  5819. constructor(capacity: number);
  5820. /**
  5821. * Pushes a value at the end of the active data.
  5822. * @param value defines the object to push in the array.
  5823. */
  5824. push(value: T): void;
  5825. /**
  5826. * Iterates over the active data and apply the lambda to them.
  5827. * @param func defines the action to apply on each value.
  5828. */
  5829. forEach(func: (content: T) => void): void;
  5830. /**
  5831. * Sorts the full sets of data.
  5832. * @param compareFn defines the comparison function to apply.
  5833. */
  5834. sort(compareFn: (a: T, b: T) => number): void;
  5835. /**
  5836. * Resets the active data to an empty array.
  5837. */
  5838. reset(): void;
  5839. /**
  5840. * Releases all the data from the array as well as the array.
  5841. */
  5842. dispose(): void;
  5843. /**
  5844. * Concats the active data with a given array.
  5845. * @param array defines the data to concatenate with.
  5846. */
  5847. concat(array: any): void;
  5848. /**
  5849. * Returns the position of a value in the active data.
  5850. * @param value defines the value to find the index for
  5851. * @returns the index if found in the active data otherwise -1
  5852. */
  5853. indexOf(value: T): number;
  5854. /**
  5855. * Returns whether an element is part of the active data.
  5856. * @param value defines the value to look for
  5857. * @returns true if found in the active data otherwise false
  5858. */
  5859. contains(value: T): boolean;
  5860. private static _GlobalId;
  5861. }
  5862. /**
  5863. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5864. * The data in this array can only be present once
  5865. */
  5866. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5867. private _duplicateId;
  5868. /**
  5869. * Pushes a value at the end of the active data.
  5870. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5871. * @param value defines the object to push in the array.
  5872. */
  5873. push(value: T): void;
  5874. /**
  5875. * Pushes a value at the end of the active data.
  5876. * If the data is already present, it won t be added again
  5877. * @param value defines the object to push in the array.
  5878. * @returns true if added false if it was already present
  5879. */
  5880. pushNoDuplicate(value: T): boolean;
  5881. /**
  5882. * Resets the active data to an empty array.
  5883. */
  5884. reset(): void;
  5885. /**
  5886. * Concats the active data with a given array.
  5887. * This ensures no dupplicate will be present in the result.
  5888. * @param array defines the data to concatenate with.
  5889. */
  5890. concatWithNoDuplicate(array: any): void;
  5891. }
  5892. }
  5893. declare module BABYLON {
  5894. /**
  5895. * @ignore
  5896. * This is a list of all the different input types that are available in the application.
  5897. * Fo instance: ArcRotateCameraGamepadInput...
  5898. */
  5899. export var CameraInputTypes: {};
  5900. /**
  5901. * This is the contract to implement in order to create a new input class.
  5902. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5903. */
  5904. export interface ICameraInput<TCamera extends Camera> {
  5905. /**
  5906. * Defines the camera the input is attached to.
  5907. */
  5908. camera: Nullable<TCamera>;
  5909. /**
  5910. * Gets the class name of the current intput.
  5911. * @returns the class name
  5912. */
  5913. getClassName(): string;
  5914. /**
  5915. * Get the friendly name associated with the input class.
  5916. * @returns the input friendly name
  5917. */
  5918. getSimpleName(): string;
  5919. /**
  5920. * Attach the input controls to a specific dom element to get the input from.
  5921. * @param element Defines the element the controls should be listened from
  5922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5923. */
  5924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5925. /**
  5926. * Detach the current controls from the specified dom element.
  5927. * @param element Defines the element to stop listening the inputs from
  5928. */
  5929. detachControl(element: Nullable<HTMLElement>): void;
  5930. /**
  5931. * Update the current camera state depending on the inputs that have been used this frame.
  5932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5933. */
  5934. checkInputs?: () => void;
  5935. }
  5936. /**
  5937. * Represents a map of input types to input instance or input index to input instance.
  5938. */
  5939. export interface CameraInputsMap<TCamera extends Camera> {
  5940. /**
  5941. * Accessor to the input by input type.
  5942. */
  5943. [name: string]: ICameraInput<TCamera>;
  5944. /**
  5945. * Accessor to the input by input index.
  5946. */
  5947. [idx: number]: ICameraInput<TCamera>;
  5948. }
  5949. /**
  5950. * This represents the input manager used within a camera.
  5951. * It helps dealing with all the different kind of input attached to a camera.
  5952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5953. */
  5954. export class CameraInputsManager<TCamera extends Camera> {
  5955. /**
  5956. * Defines the list of inputs attahed to the camera.
  5957. */
  5958. attached: CameraInputsMap<TCamera>;
  5959. /**
  5960. * Defines the dom element the camera is collecting inputs from.
  5961. * This is null if the controls have not been attached.
  5962. */
  5963. attachedElement: Nullable<HTMLElement>;
  5964. /**
  5965. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5966. */
  5967. noPreventDefault: boolean;
  5968. /**
  5969. * Defined the camera the input manager belongs to.
  5970. */
  5971. camera: TCamera;
  5972. /**
  5973. * Update the current camera state depending on the inputs that have been used this frame.
  5974. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5975. */
  5976. checkInputs: () => void;
  5977. /**
  5978. * Instantiate a new Camera Input Manager.
  5979. * @param camera Defines the camera the input manager blongs to
  5980. */
  5981. constructor(camera: TCamera);
  5982. /**
  5983. * Add an input method to a camera
  5984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5985. * @param input camera input method
  5986. */
  5987. add(input: ICameraInput<TCamera>): void;
  5988. /**
  5989. * Remove a specific input method from a camera
  5990. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  5991. * @param inputToRemove camera input method
  5992. */
  5993. remove(inputToRemove: ICameraInput<TCamera>): void;
  5994. /**
  5995. * Remove a specific input type from a camera
  5996. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  5997. * @param inputType the type of the input to remove
  5998. */
  5999. removeByType(inputType: string): void;
  6000. private _addCheckInputs;
  6001. /**
  6002. * Attach the input controls to the currently attached dom element to listen the events from.
  6003. * @param input Defines the input to attach
  6004. */
  6005. attachInput(input: ICameraInput<TCamera>): void;
  6006. /**
  6007. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6008. * @param element Defines the dom element to collect the events from
  6009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6010. */
  6011. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6012. /**
  6013. * Detach the current manager inputs controls from a specific dom element.
  6014. * @param element Defines the dom element to collect the events from
  6015. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6016. */
  6017. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6018. /**
  6019. * Rebuild the dynamic inputCheck function from the current list of
  6020. * defined inputs in the manager.
  6021. */
  6022. rebuildInputCheck(): void;
  6023. /**
  6024. * Remove all attached input methods from a camera
  6025. */
  6026. clear(): void;
  6027. /**
  6028. * Serialize the current input manager attached to a camera.
  6029. * This ensures than once parsed,
  6030. * the input associated to the camera will be identical to the current ones
  6031. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6032. */
  6033. serialize(serializedCamera: any): void;
  6034. /**
  6035. * Parses an input manager serialized JSON to restore the previous list of inputs
  6036. * and states associated to a camera.
  6037. * @param parsedCamera Defines the JSON to parse
  6038. */
  6039. parse(parsedCamera: any): void;
  6040. }
  6041. }
  6042. declare module BABYLON {
  6043. /**
  6044. * Class used to store data that will be store in GPU memory
  6045. */
  6046. export class Buffer {
  6047. private _engine;
  6048. private _buffer;
  6049. /** @hidden */ private _data: Nullable<DataArray>;
  6050. private _updatable;
  6051. private _instanced;
  6052. /**
  6053. * Gets the byte stride.
  6054. */
  6055. readonly byteStride: number;
  6056. /**
  6057. * Constructor
  6058. * @param engine the engine
  6059. * @param data the data to use for this buffer
  6060. * @param updatable whether the data is updatable
  6061. * @param stride the stride (optional)
  6062. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6063. * @param instanced whether the buffer is instanced (optional)
  6064. * @param useBytes set to true if the stride in in bytes (optional)
  6065. */
  6066. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6067. /**
  6068. * Create a new VertexBuffer based on the current buffer
  6069. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6070. * @param offset defines offset in the buffer (0 by default)
  6071. * @param size defines the size in floats of attributes (position is 3 for instance)
  6072. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6073. * @param instanced defines if the vertex buffer contains indexed data
  6074. * @param useBytes defines if the offset and stride are in bytes
  6075. * @returns the new vertex buffer
  6076. */
  6077. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6078. /**
  6079. * Gets a boolean indicating if the Buffer is updatable?
  6080. * @returns true if the buffer is updatable
  6081. */
  6082. isUpdatable(): boolean;
  6083. /**
  6084. * Gets current buffer's data
  6085. * @returns a DataArray or null
  6086. */
  6087. getData(): Nullable<DataArray>;
  6088. /**
  6089. * Gets underlying native buffer
  6090. * @returns underlying native buffer
  6091. */
  6092. getBuffer(): Nullable<DataBuffer>;
  6093. /**
  6094. * Gets the stride in float32 units (i.e. byte stride / 4).
  6095. * May not be an integer if the byte stride is not divisible by 4.
  6096. * DEPRECATED. Use byteStride instead.
  6097. * @returns the stride in float32 units
  6098. */
  6099. getStrideSize(): number;
  6100. /**
  6101. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6102. * @param data defines the data to store
  6103. */
  6104. create(data?: Nullable<DataArray>): void;
  6105. /** @hidden */ private _rebuild(): void;
  6106. /**
  6107. * Update current buffer data
  6108. * @param data defines the data to store
  6109. */
  6110. update(data: DataArray): void;
  6111. /**
  6112. * Updates the data directly.
  6113. * @param data the new data
  6114. * @param offset the new offset
  6115. * @param vertexCount the vertex count (optional)
  6116. * @param useBytes set to true if the offset is in bytes
  6117. */
  6118. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6119. /**
  6120. * Release all resources
  6121. */
  6122. dispose(): void;
  6123. }
  6124. /**
  6125. * Specialized buffer used to store vertex data
  6126. */
  6127. export class VertexBuffer {
  6128. /** @hidden */ private _buffer: Buffer;
  6129. private _kind;
  6130. private _size;
  6131. private _ownsBuffer;
  6132. private _instanced;
  6133. private _instanceDivisor;
  6134. /**
  6135. * The byte type.
  6136. */
  6137. static readonly BYTE: number;
  6138. /**
  6139. * The unsigned byte type.
  6140. */
  6141. static readonly UNSIGNED_BYTE: number;
  6142. /**
  6143. * The short type.
  6144. */
  6145. static readonly SHORT: number;
  6146. /**
  6147. * The unsigned short type.
  6148. */
  6149. static readonly UNSIGNED_SHORT: number;
  6150. /**
  6151. * The integer type.
  6152. */
  6153. static readonly INT: number;
  6154. /**
  6155. * The unsigned integer type.
  6156. */
  6157. static readonly UNSIGNED_INT: number;
  6158. /**
  6159. * The float type.
  6160. */
  6161. static readonly FLOAT: number;
  6162. /**
  6163. * Gets or sets the instance divisor when in instanced mode
  6164. */
  6165. instanceDivisor: number;
  6166. /**
  6167. * Gets the byte stride.
  6168. */
  6169. readonly byteStride: number;
  6170. /**
  6171. * Gets the byte offset.
  6172. */
  6173. readonly byteOffset: number;
  6174. /**
  6175. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6176. */
  6177. readonly normalized: boolean;
  6178. /**
  6179. * Gets the data type of each component in the array.
  6180. */
  6181. readonly type: number;
  6182. /**
  6183. * Constructor
  6184. * @param engine the engine
  6185. * @param data the data to use for this vertex buffer
  6186. * @param kind the vertex buffer kind
  6187. * @param updatable whether the data is updatable
  6188. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6189. * @param stride the stride (optional)
  6190. * @param instanced whether the buffer is instanced (optional)
  6191. * @param offset the offset of the data (optional)
  6192. * @param size the number of components (optional)
  6193. * @param type the type of the component (optional)
  6194. * @param normalized whether the data contains normalized data (optional)
  6195. * @param useBytes set to true if stride and offset are in bytes (optional)
  6196. */
  6197. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  6198. /** @hidden */ private _rebuild(): void;
  6199. /**
  6200. * Returns the kind of the VertexBuffer (string)
  6201. * @returns a string
  6202. */
  6203. getKind(): string;
  6204. /**
  6205. * Gets a boolean indicating if the VertexBuffer is updatable?
  6206. * @returns true if the buffer is updatable
  6207. */
  6208. isUpdatable(): boolean;
  6209. /**
  6210. * Gets current buffer's data
  6211. * @returns a DataArray or null
  6212. */
  6213. getData(): Nullable<DataArray>;
  6214. /**
  6215. * Gets underlying native buffer
  6216. * @returns underlying native buffer
  6217. */
  6218. getBuffer(): Nullable<DataBuffer>;
  6219. /**
  6220. * Gets the stride in float32 units (i.e. byte stride / 4).
  6221. * May not be an integer if the byte stride is not divisible by 4.
  6222. * DEPRECATED. Use byteStride instead.
  6223. * @returns the stride in float32 units
  6224. */
  6225. getStrideSize(): number;
  6226. /**
  6227. * Returns the offset as a multiple of the type byte length.
  6228. * DEPRECATED. Use byteOffset instead.
  6229. * @returns the offset in bytes
  6230. */
  6231. getOffset(): number;
  6232. /**
  6233. * Returns the number of components per vertex attribute (integer)
  6234. * @returns the size in float
  6235. */
  6236. getSize(): number;
  6237. /**
  6238. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6239. * @returns true if this buffer is instanced
  6240. */
  6241. getIsInstanced(): boolean;
  6242. /**
  6243. * Returns the instancing divisor, zero for non-instanced (integer).
  6244. * @returns a number
  6245. */
  6246. getInstanceDivisor(): number;
  6247. /**
  6248. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6249. * @param data defines the data to store
  6250. */
  6251. create(data?: DataArray): void;
  6252. /**
  6253. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6254. * This function will create a new buffer if the current one is not updatable
  6255. * @param data defines the data to store
  6256. */
  6257. update(data: DataArray): void;
  6258. /**
  6259. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6260. * Returns the directly updated WebGLBuffer.
  6261. * @param data the new data
  6262. * @param offset the new offset
  6263. * @param useBytes set to true if the offset is in bytes
  6264. */
  6265. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6266. /**
  6267. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6268. */
  6269. dispose(): void;
  6270. /**
  6271. * Enumerates each value of this vertex buffer as numbers.
  6272. * @param count the number of values to enumerate
  6273. * @param callback the callback function called for each value
  6274. */
  6275. forEach(count: number, callback: (value: number, index: number) => void): void;
  6276. /**
  6277. * Positions
  6278. */
  6279. static readonly PositionKind: string;
  6280. /**
  6281. * Normals
  6282. */
  6283. static readonly NormalKind: string;
  6284. /**
  6285. * Tangents
  6286. */
  6287. static readonly TangentKind: string;
  6288. /**
  6289. * Texture coordinates
  6290. */
  6291. static readonly UVKind: string;
  6292. /**
  6293. * Texture coordinates 2
  6294. */
  6295. static readonly UV2Kind: string;
  6296. /**
  6297. * Texture coordinates 3
  6298. */
  6299. static readonly UV3Kind: string;
  6300. /**
  6301. * Texture coordinates 4
  6302. */
  6303. static readonly UV4Kind: string;
  6304. /**
  6305. * Texture coordinates 5
  6306. */
  6307. static readonly UV5Kind: string;
  6308. /**
  6309. * Texture coordinates 6
  6310. */
  6311. static readonly UV6Kind: string;
  6312. /**
  6313. * Colors
  6314. */
  6315. static readonly ColorKind: string;
  6316. /**
  6317. * Matrix indices (for bones)
  6318. */
  6319. static readonly MatricesIndicesKind: string;
  6320. /**
  6321. * Matrix weights (for bones)
  6322. */
  6323. static readonly MatricesWeightsKind: string;
  6324. /**
  6325. * Additional matrix indices (for bones)
  6326. */
  6327. static readonly MatricesIndicesExtraKind: string;
  6328. /**
  6329. * Additional matrix weights (for bones)
  6330. */
  6331. static readonly MatricesWeightsExtraKind: string;
  6332. /**
  6333. * Deduces the stride given a kind.
  6334. * @param kind The kind string to deduce
  6335. * @returns The deduced stride
  6336. */
  6337. static DeduceStride(kind: string): number;
  6338. /**
  6339. * Gets the byte length of the given type.
  6340. * @param type the type
  6341. * @returns the number of bytes
  6342. */
  6343. static GetTypeByteLength(type: number): number;
  6344. /**
  6345. * Enumerates each value of the given parameters as numbers.
  6346. * @param data the data to enumerate
  6347. * @param byteOffset the byte offset of the data
  6348. * @param byteStride the byte stride of the data
  6349. * @param componentCount the number of components per element
  6350. * @param componentType the type of the component
  6351. * @param count the number of values to enumerate
  6352. * @param normalized whether the data is normalized
  6353. * @param callback the callback function called for each value
  6354. */
  6355. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6356. private static _GetFloatValue;
  6357. }
  6358. }
  6359. declare module BABYLON {
  6360. /**
  6361. * @hidden
  6362. */
  6363. export class IntersectionInfo {
  6364. bu: Nullable<number>;
  6365. bv: Nullable<number>;
  6366. distance: number;
  6367. faceId: number;
  6368. subMeshId: number;
  6369. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6370. }
  6371. }
  6372. declare module BABYLON {
  6373. /**
  6374. * Represens a plane by the equation ax + by + cz + d = 0
  6375. */
  6376. export class Plane {
  6377. private static _TmpMatrix;
  6378. /**
  6379. * Normal of the plane (a,b,c)
  6380. */
  6381. normal: Vector3;
  6382. /**
  6383. * d component of the plane
  6384. */
  6385. d: number;
  6386. /**
  6387. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6388. * @param a a component of the plane
  6389. * @param b b component of the plane
  6390. * @param c c component of the plane
  6391. * @param d d component of the plane
  6392. */
  6393. constructor(a: number, b: number, c: number, d: number);
  6394. /**
  6395. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6396. */
  6397. asArray(): number[];
  6398. /**
  6399. * @returns a new plane copied from the current Plane.
  6400. */
  6401. clone(): Plane;
  6402. /**
  6403. * @returns the string "Plane".
  6404. */
  6405. getClassName(): string;
  6406. /**
  6407. * @returns the Plane hash code.
  6408. */
  6409. getHashCode(): number;
  6410. /**
  6411. * Normalize the current Plane in place.
  6412. * @returns the updated Plane.
  6413. */
  6414. normalize(): Plane;
  6415. /**
  6416. * Applies a transformation the plane and returns the result
  6417. * @param transformation the transformation matrix to be applied to the plane
  6418. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6419. */
  6420. transform(transformation: DeepImmutable<Matrix>): Plane;
  6421. /**
  6422. * Calcualtte the dot product between the point and the plane normal
  6423. * @param point point to calculate the dot product with
  6424. * @returns the dot product (float) of the point coordinates and the plane normal.
  6425. */
  6426. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6427. /**
  6428. * Updates the current Plane from the plane defined by the three given points.
  6429. * @param point1 one of the points used to contruct the plane
  6430. * @param point2 one of the points used to contruct the plane
  6431. * @param point3 one of the points used to contruct the plane
  6432. * @returns the updated Plane.
  6433. */
  6434. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6435. /**
  6436. * Checks if the plane is facing a given direction
  6437. * @param direction the direction to check if the plane is facing
  6438. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6439. * @returns True is the vector "direction" is the same side than the plane normal.
  6440. */
  6441. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6442. /**
  6443. * Calculates the distance to a point
  6444. * @param point point to calculate distance to
  6445. * @returns the signed distance (float) from the given point to the Plane.
  6446. */
  6447. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6448. /**
  6449. * Creates a plane from an array
  6450. * @param array the array to create a plane from
  6451. * @returns a new Plane from the given array.
  6452. */
  6453. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6454. /**
  6455. * Creates a plane from three points
  6456. * @param point1 point used to create the plane
  6457. * @param point2 point used to create the plane
  6458. * @param point3 point used to create the plane
  6459. * @returns a new Plane defined by the three given points.
  6460. */
  6461. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6462. /**
  6463. * Creates a plane from an origin point and a normal
  6464. * @param origin origin of the plane to be constructed
  6465. * @param normal normal of the plane to be constructed
  6466. * @returns a new Plane the normal vector to this plane at the given origin point.
  6467. * Note : the vector "normal" is updated because normalized.
  6468. */
  6469. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6470. /**
  6471. * Calculates the distance from a plane and a point
  6472. * @param origin origin of the plane to be constructed
  6473. * @param normal normal of the plane to be constructed
  6474. * @param point point to calculate distance to
  6475. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6476. */
  6477. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6478. }
  6479. }
  6480. declare module BABYLON {
  6481. /**
  6482. * Class used to store bounding sphere information
  6483. */
  6484. export class BoundingSphere {
  6485. /**
  6486. * Gets the center of the bounding sphere in local space
  6487. */
  6488. readonly center: Vector3;
  6489. /**
  6490. * Radius of the bounding sphere in local space
  6491. */
  6492. radius: number;
  6493. /**
  6494. * Gets the center of the bounding sphere in world space
  6495. */
  6496. readonly centerWorld: Vector3;
  6497. /**
  6498. * Radius of the bounding sphere in world space
  6499. */
  6500. radiusWorld: number;
  6501. /**
  6502. * Gets the minimum vector in local space
  6503. */
  6504. readonly minimum: Vector3;
  6505. /**
  6506. * Gets the maximum vector in local space
  6507. */
  6508. readonly maximum: Vector3;
  6509. private _worldMatrix;
  6510. private static readonly TmpVector3;
  6511. /**
  6512. * Creates a new bounding sphere
  6513. * @param min defines the minimum vector (in local space)
  6514. * @param max defines the maximum vector (in local space)
  6515. * @param worldMatrix defines the new world matrix
  6516. */
  6517. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6518. /**
  6519. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6520. * @param min defines the new minimum vector (in local space)
  6521. * @param max defines the new maximum vector (in local space)
  6522. * @param worldMatrix defines the new world matrix
  6523. */
  6524. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6525. /**
  6526. * Scale the current bounding sphere by applying a scale factor
  6527. * @param factor defines the scale factor to apply
  6528. * @returns the current bounding box
  6529. */
  6530. scale(factor: number): BoundingSphere;
  6531. /**
  6532. * Gets the world matrix of the bounding box
  6533. * @returns a matrix
  6534. */
  6535. getWorldMatrix(): DeepImmutable<Matrix>;
  6536. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6537. /**
  6538. * Tests if the bounding sphere is intersecting the frustum planes
  6539. * @param frustumPlanes defines the frustum planes to test
  6540. * @returns true if there is an intersection
  6541. */
  6542. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6543. /**
  6544. * Tests if the bounding sphere center is in between the frustum planes.
  6545. * Used for optimistic fast inclusion.
  6546. * @param frustumPlanes defines the frustum planes to test
  6547. * @returns true if the sphere center is in between the frustum planes
  6548. */
  6549. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6550. /**
  6551. * Tests if a point is inside the bounding sphere
  6552. * @param point defines the point to test
  6553. * @returns true if the point is inside the bounding sphere
  6554. */
  6555. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6556. /**
  6557. * Checks if two sphere intersct
  6558. * @param sphere0 sphere 0
  6559. * @param sphere1 sphere 1
  6560. * @returns true if the speres intersect
  6561. */
  6562. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6563. }
  6564. }
  6565. declare module BABYLON {
  6566. /**
  6567. * Class used to store bounding box information
  6568. */
  6569. export class BoundingBox implements ICullable {
  6570. /**
  6571. * Gets the 8 vectors representing the bounding box in local space
  6572. */
  6573. readonly vectors: Vector3[];
  6574. /**
  6575. * Gets the center of the bounding box in local space
  6576. */
  6577. readonly center: Vector3;
  6578. /**
  6579. * Gets the center of the bounding box in world space
  6580. */
  6581. readonly centerWorld: Vector3;
  6582. /**
  6583. * Gets the extend size in local space
  6584. */
  6585. readonly extendSize: Vector3;
  6586. /**
  6587. * Gets the extend size in world space
  6588. */
  6589. readonly extendSizeWorld: Vector3;
  6590. /**
  6591. * Gets the OBB (object bounding box) directions
  6592. */
  6593. readonly directions: Vector3[];
  6594. /**
  6595. * Gets the 8 vectors representing the bounding box in world space
  6596. */
  6597. readonly vectorsWorld: Vector3[];
  6598. /**
  6599. * Gets the minimum vector in world space
  6600. */
  6601. readonly minimumWorld: Vector3;
  6602. /**
  6603. * Gets the maximum vector in world space
  6604. */
  6605. readonly maximumWorld: Vector3;
  6606. /**
  6607. * Gets the minimum vector in local space
  6608. */
  6609. readonly minimum: Vector3;
  6610. /**
  6611. * Gets the maximum vector in local space
  6612. */
  6613. readonly maximum: Vector3;
  6614. private _worldMatrix;
  6615. private static readonly TmpVector3;
  6616. /**
  6617. * @hidden
  6618. */ private _tag: number;
  6619. /**
  6620. * Creates a new bounding box
  6621. * @param min defines the minimum vector (in local space)
  6622. * @param max defines the maximum vector (in local space)
  6623. * @param worldMatrix defines the new world matrix
  6624. */
  6625. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6626. /**
  6627. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6628. * @param min defines the new minimum vector (in local space)
  6629. * @param max defines the new maximum vector (in local space)
  6630. * @param worldMatrix defines the new world matrix
  6631. */
  6632. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6633. /**
  6634. * Scale the current bounding box by applying a scale factor
  6635. * @param factor defines the scale factor to apply
  6636. * @returns the current bounding box
  6637. */
  6638. scale(factor: number): BoundingBox;
  6639. /**
  6640. * Gets the world matrix of the bounding box
  6641. * @returns a matrix
  6642. */
  6643. getWorldMatrix(): DeepImmutable<Matrix>;
  6644. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6645. /**
  6646. * Tests if the bounding box is intersecting the frustum planes
  6647. * @param frustumPlanes defines the frustum planes to test
  6648. * @returns true if there is an intersection
  6649. */
  6650. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6651. /**
  6652. * Tests if the bounding box is entirely inside the frustum planes
  6653. * @param frustumPlanes defines the frustum planes to test
  6654. * @returns true if there is an inclusion
  6655. */
  6656. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6657. /**
  6658. * Tests if a point is inside the bounding box
  6659. * @param point defines the point to test
  6660. * @returns true if the point is inside the bounding box
  6661. */
  6662. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6663. /**
  6664. * Tests if the bounding box intersects with a bounding sphere
  6665. * @param sphere defines the sphere to test
  6666. * @returns true if there is an intersection
  6667. */
  6668. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6669. /**
  6670. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6671. * @param min defines the min vector to use
  6672. * @param max defines the max vector to use
  6673. * @returns true if there is an intersection
  6674. */
  6675. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6676. /**
  6677. * Tests if two bounding boxes are intersections
  6678. * @param box0 defines the first box to test
  6679. * @param box1 defines the second box to test
  6680. * @returns true if there is an intersection
  6681. */
  6682. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6683. /**
  6684. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6685. * @param minPoint defines the minimum vector of the bounding box
  6686. * @param maxPoint defines the maximum vector of the bounding box
  6687. * @param sphereCenter defines the sphere center
  6688. * @param sphereRadius defines the sphere radius
  6689. * @returns true if there is an intersection
  6690. */
  6691. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6692. /**
  6693. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6694. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6695. * @param frustumPlanes defines the frustum planes to test
  6696. * @return true if there is an inclusion
  6697. */
  6698. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6699. /**
  6700. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6701. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6702. * @param frustumPlanes defines the frustum planes to test
  6703. * @return true if there is an intersection
  6704. */
  6705. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6706. }
  6707. }
  6708. declare module BABYLON {
  6709. /** @hidden */
  6710. export class Collider {
  6711. /** Define if a collision was found */
  6712. collisionFound: boolean;
  6713. /**
  6714. * Define last intersection point in local space
  6715. */
  6716. intersectionPoint: Vector3;
  6717. /**
  6718. * Define last collided mesh
  6719. */
  6720. collidedMesh: Nullable<AbstractMesh>;
  6721. private _collisionPoint;
  6722. private _planeIntersectionPoint;
  6723. private _tempVector;
  6724. private _tempVector2;
  6725. private _tempVector3;
  6726. private _tempVector4;
  6727. private _edge;
  6728. private _baseToVertex;
  6729. private _destinationPoint;
  6730. private _slidePlaneNormal;
  6731. private _displacementVector;
  6732. /** @hidden */ private _radius: Vector3;
  6733. /** @hidden */ private _retry: number;
  6734. private _velocity;
  6735. private _basePoint;
  6736. private _epsilon;
  6737. /** @hidden */ private _velocityWorldLength: number;
  6738. /** @hidden */ private _basePointWorld: Vector3;
  6739. private _velocityWorld;
  6740. private _normalizedVelocity;
  6741. /** @hidden */ private _initialVelocity: Vector3;
  6742. /** @hidden */ private _initialPosition: Vector3;
  6743. private _nearestDistance;
  6744. private _collisionMask;
  6745. collisionMask: number;
  6746. /**
  6747. * Gets the plane normal used to compute the sliding response (in local space)
  6748. */
  6749. readonly slidePlaneNormal: Vector3;
  6750. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  6751. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6752. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6753. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6754. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6755. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  6756. }
  6757. }
  6758. declare module BABYLON {
  6759. /**
  6760. * Interface for cullable objects
  6761. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6762. */
  6763. export interface ICullable {
  6764. /**
  6765. * Checks if the object or part of the object is in the frustum
  6766. * @param frustumPlanes Camera near/planes
  6767. * @returns true if the object is in frustum otherwise false
  6768. */
  6769. isInFrustum(frustumPlanes: Plane[]): boolean;
  6770. /**
  6771. * Checks if a cullable object (mesh...) is in the camera frustum
  6772. * Unlike isInFrustum this cheks the full bounding box
  6773. * @param frustumPlanes Camera near/planes
  6774. * @returns true if the object is in frustum otherwise false
  6775. */
  6776. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6777. }
  6778. /**
  6779. * Info for a bounding data of a mesh
  6780. */
  6781. export class BoundingInfo implements ICullable {
  6782. /**
  6783. * Bounding box for the mesh
  6784. */
  6785. readonly boundingBox: BoundingBox;
  6786. /**
  6787. * Bounding sphere for the mesh
  6788. */
  6789. readonly boundingSphere: BoundingSphere;
  6790. private _isLocked;
  6791. private static readonly TmpVector3;
  6792. /**
  6793. * Constructs bounding info
  6794. * @param minimum min vector of the bounding box/sphere
  6795. * @param maximum max vector of the bounding box/sphere
  6796. * @param worldMatrix defines the new world matrix
  6797. */
  6798. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6799. /**
  6800. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6801. * @param min defines the new minimum vector (in local space)
  6802. * @param max defines the new maximum vector (in local space)
  6803. * @param worldMatrix defines the new world matrix
  6804. */
  6805. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6806. /**
  6807. * min vector of the bounding box/sphere
  6808. */
  6809. readonly minimum: Vector3;
  6810. /**
  6811. * max vector of the bounding box/sphere
  6812. */
  6813. readonly maximum: Vector3;
  6814. /**
  6815. * If the info is locked and won't be updated to avoid perf overhead
  6816. */
  6817. isLocked: boolean;
  6818. /**
  6819. * Updates the bounding sphere and box
  6820. * @param world world matrix to be used to update
  6821. */
  6822. update(world: DeepImmutable<Matrix>): void;
  6823. /**
  6824. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6825. * @param center New center of the bounding info
  6826. * @param extend New extend of the bounding info
  6827. * @returns the current bounding info
  6828. */
  6829. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6830. /**
  6831. * Scale the current bounding info by applying a scale factor
  6832. * @param factor defines the scale factor to apply
  6833. * @returns the current bounding info
  6834. */
  6835. scale(factor: number): BoundingInfo;
  6836. /**
  6837. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6838. * @param frustumPlanes defines the frustum to test
  6839. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6840. * @returns true if the bounding info is in the frustum planes
  6841. */
  6842. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6843. /**
  6844. * Gets the world distance between the min and max points of the bounding box
  6845. */
  6846. readonly diagonalLength: number;
  6847. /**
  6848. * Checks if a cullable object (mesh...) is in the camera frustum
  6849. * Unlike isInFrustum this cheks the full bounding box
  6850. * @param frustumPlanes Camera near/planes
  6851. * @returns true if the object is in frustum otherwise false
  6852. */
  6853. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6854. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  6855. /**
  6856. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6857. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6858. * @param point the point to check intersection with
  6859. * @returns if the point intersects
  6860. */
  6861. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6862. /**
  6863. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6864. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6865. * @param boundingInfo the bounding info to check intersection with
  6866. * @param precise if the intersection should be done using OBB
  6867. * @returns if the bounding info intersects
  6868. */
  6869. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6870. }
  6871. }
  6872. declare module BABYLON {
  6873. /**
  6874. * Extracts minimum and maximum values from a list of indexed positions
  6875. * @param positions defines the positions to use
  6876. * @param indices defines the indices to the positions
  6877. * @param indexStart defines the start index
  6878. * @param indexCount defines the end index
  6879. * @param bias defines bias value to add to the result
  6880. * @return minimum and maximum values
  6881. */
  6882. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6883. minimum: Vector3;
  6884. maximum: Vector3;
  6885. };
  6886. /**
  6887. * Extracts minimum and maximum values from a list of positions
  6888. * @param positions defines the positions to use
  6889. * @param start defines the start index in the positions array
  6890. * @param count defines the number of positions to handle
  6891. * @param bias defines bias value to add to the result
  6892. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6893. * @return minimum and maximum values
  6894. */
  6895. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6896. minimum: Vector3;
  6897. maximum: Vector3;
  6898. };
  6899. }
  6900. declare module BABYLON {
  6901. /** @hidden */
  6902. export class WebGLDataBuffer extends DataBuffer {
  6903. private _buffer;
  6904. constructor(resource: WebGLBuffer);
  6905. readonly underlyingResource: any;
  6906. }
  6907. }
  6908. declare module BABYLON {
  6909. /** @hidden */
  6910. export class WebGLPipelineContext implements IPipelineContext {
  6911. engine: ThinEngine;
  6912. program: Nullable<WebGLProgram>;
  6913. context?: WebGLRenderingContext;
  6914. vertexShader?: WebGLShader;
  6915. fragmentShader?: WebGLShader;
  6916. isParallelCompiled: boolean;
  6917. onCompiled?: () => void;
  6918. transformFeedback?: WebGLTransformFeedback | null;
  6919. readonly isAsync: boolean;
  6920. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  6921. }
  6922. }
  6923. declare module BABYLON {
  6924. interface ThinEngine {
  6925. /**
  6926. * Create an uniform buffer
  6927. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6928. * @param elements defines the content of the uniform buffer
  6929. * @returns the webGL uniform buffer
  6930. */
  6931. createUniformBuffer(elements: FloatArray): DataBuffer;
  6932. /**
  6933. * Create a dynamic uniform buffer
  6934. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6935. * @param elements defines the content of the uniform buffer
  6936. * @returns the webGL uniform buffer
  6937. */
  6938. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  6939. /**
  6940. * Update an existing uniform buffer
  6941. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  6942. * @param uniformBuffer defines the target uniform buffer
  6943. * @param elements defines the content to update
  6944. * @param offset defines the offset in the uniform buffer where update should start
  6945. * @param count defines the size of the data to update
  6946. */
  6947. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  6948. /**
  6949. * Bind an uniform buffer to the current webGL context
  6950. * @param buffer defines the buffer to bind
  6951. */
  6952. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  6953. /**
  6954. * Bind a buffer to the current webGL context at a given location
  6955. * @param buffer defines the buffer to bind
  6956. * @param location defines the index where to bind the buffer
  6957. */
  6958. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  6959. /**
  6960. * Bind a specific block at a given index in a specific shader program
  6961. * @param pipelineContext defines the pipeline context to use
  6962. * @param blockName defines the block name
  6963. * @param index defines the index where to bind the block
  6964. */
  6965. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  6966. }
  6967. }
  6968. declare module BABYLON {
  6969. /**
  6970. * Uniform buffer objects.
  6971. *
  6972. * Handles blocks of uniform on the GPU.
  6973. *
  6974. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  6975. *
  6976. * For more information, please refer to :
  6977. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  6978. */
  6979. export class UniformBuffer {
  6980. private _engine;
  6981. private _buffer;
  6982. private _data;
  6983. private _bufferData;
  6984. private _dynamic?;
  6985. private _uniformLocations;
  6986. private _uniformSizes;
  6987. private _uniformLocationPointer;
  6988. private _needSync;
  6989. private _noUBO;
  6990. private _currentEffect;
  6991. private static _MAX_UNIFORM_SIZE;
  6992. private static _tempBuffer;
  6993. /**
  6994. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  6995. * This is dynamic to allow compat with webgl 1 and 2.
  6996. * You will need to pass the name of the uniform as well as the value.
  6997. */
  6998. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  6999. /**
  7000. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7001. * This is dynamic to allow compat with webgl 1 and 2.
  7002. * You will need to pass the name of the uniform as well as the value.
  7003. */
  7004. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7005. /**
  7006. * Lambda to Update a single float in a uniform buffer.
  7007. * This is dynamic to allow compat with webgl 1 and 2.
  7008. * You will need to pass the name of the uniform as well as the value.
  7009. */
  7010. updateFloat: (name: string, x: number) => void;
  7011. /**
  7012. * Lambda to Update a vec2 of float in a uniform buffer.
  7013. * This is dynamic to allow compat with webgl 1 and 2.
  7014. * You will need to pass the name of the uniform as well as the value.
  7015. */
  7016. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7017. /**
  7018. * Lambda to Update a vec3 of float in a uniform buffer.
  7019. * This is dynamic to allow compat with webgl 1 and 2.
  7020. * You will need to pass the name of the uniform as well as the value.
  7021. */
  7022. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7023. /**
  7024. * Lambda to Update a vec4 of float in a uniform buffer.
  7025. * This is dynamic to allow compat with webgl 1 and 2.
  7026. * You will need to pass the name of the uniform as well as the value.
  7027. */
  7028. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7029. /**
  7030. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7031. * This is dynamic to allow compat with webgl 1 and 2.
  7032. * You will need to pass the name of the uniform as well as the value.
  7033. */
  7034. updateMatrix: (name: string, mat: Matrix) => void;
  7035. /**
  7036. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7037. * This is dynamic to allow compat with webgl 1 and 2.
  7038. * You will need to pass the name of the uniform as well as the value.
  7039. */
  7040. updateVector3: (name: string, vector: Vector3) => void;
  7041. /**
  7042. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7043. * This is dynamic to allow compat with webgl 1 and 2.
  7044. * You will need to pass the name of the uniform as well as the value.
  7045. */
  7046. updateVector4: (name: string, vector: Vector4) => void;
  7047. /**
  7048. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7049. * This is dynamic to allow compat with webgl 1 and 2.
  7050. * You will need to pass the name of the uniform as well as the value.
  7051. */
  7052. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7053. /**
  7054. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7055. * This is dynamic to allow compat with webgl 1 and 2.
  7056. * You will need to pass the name of the uniform as well as the value.
  7057. */
  7058. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7059. /**
  7060. * Instantiates a new Uniform buffer objects.
  7061. *
  7062. * Handles blocks of uniform on the GPU.
  7063. *
  7064. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7065. *
  7066. * For more information, please refer to :
  7067. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7068. * @param engine Define the engine the buffer is associated with
  7069. * @param data Define the data contained in the buffer
  7070. * @param dynamic Define if the buffer is updatable
  7071. */
  7072. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7073. /**
  7074. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7075. * or just falling back on setUniformXXX calls.
  7076. */
  7077. readonly useUbo: boolean;
  7078. /**
  7079. * Indicates if the WebGL underlying uniform buffer is in sync
  7080. * with the javascript cache data.
  7081. */
  7082. readonly isSync: boolean;
  7083. /**
  7084. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7085. * Also, a dynamic UniformBuffer will disable cache verification and always
  7086. * update the underlying WebGL uniform buffer to the GPU.
  7087. * @returns if Dynamic, otherwise false
  7088. */
  7089. isDynamic(): boolean;
  7090. /**
  7091. * The data cache on JS side.
  7092. * @returns the underlying data as a float array
  7093. */
  7094. getData(): Float32Array;
  7095. /**
  7096. * The underlying WebGL Uniform buffer.
  7097. * @returns the webgl buffer
  7098. */
  7099. getBuffer(): Nullable<DataBuffer>;
  7100. /**
  7101. * std140 layout specifies how to align data within an UBO structure.
  7102. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7103. * for specs.
  7104. */
  7105. private _fillAlignment;
  7106. /**
  7107. * Adds an uniform in the buffer.
  7108. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7109. * for the layout to be correct !
  7110. * @param name Name of the uniform, as used in the uniform block in the shader.
  7111. * @param size Data size, or data directly.
  7112. */
  7113. addUniform(name: string, size: number | number[]): void;
  7114. /**
  7115. * Adds a Matrix 4x4 to the uniform buffer.
  7116. * @param name Name of the uniform, as used in the uniform block in the shader.
  7117. * @param mat A 4x4 matrix.
  7118. */
  7119. addMatrix(name: string, mat: Matrix): void;
  7120. /**
  7121. * Adds a vec2 to the uniform buffer.
  7122. * @param name Name of the uniform, as used in the uniform block in the shader.
  7123. * @param x Define the x component value of the vec2
  7124. * @param y Define the y component value of the vec2
  7125. */
  7126. addFloat2(name: string, x: number, y: number): void;
  7127. /**
  7128. * Adds a vec3 to the uniform buffer.
  7129. * @param name Name of the uniform, as used in the uniform block in the shader.
  7130. * @param x Define the x component value of the vec3
  7131. * @param y Define the y component value of the vec3
  7132. * @param z Define the z component value of the vec3
  7133. */
  7134. addFloat3(name: string, x: number, y: number, z: number): void;
  7135. /**
  7136. * Adds a vec3 to the uniform buffer.
  7137. * @param name Name of the uniform, as used in the uniform block in the shader.
  7138. * @param color Define the vec3 from a Color
  7139. */
  7140. addColor3(name: string, color: Color3): void;
  7141. /**
  7142. * Adds a vec4 to the uniform buffer.
  7143. * @param name Name of the uniform, as used in the uniform block in the shader.
  7144. * @param color Define the rgb components from a Color
  7145. * @param alpha Define the a component of the vec4
  7146. */
  7147. addColor4(name: string, color: Color3, alpha: number): void;
  7148. /**
  7149. * Adds a vec3 to the uniform buffer.
  7150. * @param name Name of the uniform, as used in the uniform block in the shader.
  7151. * @param vector Define the vec3 components from a Vector
  7152. */
  7153. addVector3(name: string, vector: Vector3): void;
  7154. /**
  7155. * Adds a Matrix 3x3 to the uniform buffer.
  7156. * @param name Name of the uniform, as used in the uniform block in the shader.
  7157. */
  7158. addMatrix3x3(name: string): void;
  7159. /**
  7160. * Adds a Matrix 2x2 to the uniform buffer.
  7161. * @param name Name of the uniform, as used in the uniform block in the shader.
  7162. */
  7163. addMatrix2x2(name: string): void;
  7164. /**
  7165. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7166. */
  7167. create(): void;
  7168. /** @hidden */ private _rebuild(): void;
  7169. /**
  7170. * Updates the WebGL Uniform Buffer on the GPU.
  7171. * If the `dynamic` flag is set to true, no cache comparison is done.
  7172. * Otherwise, the buffer will be updated only if the cache differs.
  7173. */
  7174. update(): void;
  7175. /**
  7176. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7177. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7178. * @param data Define the flattened data
  7179. * @param size Define the size of the data.
  7180. */
  7181. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7182. private _valueCache;
  7183. private _cacheMatrix;
  7184. private _updateMatrix3x3ForUniform;
  7185. private _updateMatrix3x3ForEffect;
  7186. private _updateMatrix2x2ForEffect;
  7187. private _updateMatrix2x2ForUniform;
  7188. private _updateFloatForEffect;
  7189. private _updateFloatForUniform;
  7190. private _updateFloat2ForEffect;
  7191. private _updateFloat2ForUniform;
  7192. private _updateFloat3ForEffect;
  7193. private _updateFloat3ForUniform;
  7194. private _updateFloat4ForEffect;
  7195. private _updateFloat4ForUniform;
  7196. private _updateMatrixForEffect;
  7197. private _updateMatrixForUniform;
  7198. private _updateVector3ForEffect;
  7199. private _updateVector3ForUniform;
  7200. private _updateVector4ForEffect;
  7201. private _updateVector4ForUniform;
  7202. private _updateColor3ForEffect;
  7203. private _updateColor3ForUniform;
  7204. private _updateColor4ForEffect;
  7205. private _updateColor4ForUniform;
  7206. /**
  7207. * Sets a sampler uniform on the effect.
  7208. * @param name Define the name of the sampler.
  7209. * @param texture Define the texture to set in the sampler
  7210. */
  7211. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7212. /**
  7213. * Directly updates the value of the uniform in the cache AND on the GPU.
  7214. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7215. * @param data Define the flattened data
  7216. */
  7217. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7218. /**
  7219. * Binds this uniform buffer to an effect.
  7220. * @param effect Define the effect to bind the buffer to
  7221. * @param name Name of the uniform block in the shader.
  7222. */
  7223. bindToEffect(effect: Effect, name: string): void;
  7224. /**
  7225. * Disposes the uniform buffer.
  7226. */
  7227. dispose(): void;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. /**
  7232. * Enum that determines the text-wrapping mode to use.
  7233. */
  7234. export enum InspectableType {
  7235. /**
  7236. * Checkbox for booleans
  7237. */
  7238. Checkbox = 0,
  7239. /**
  7240. * Sliders for numbers
  7241. */
  7242. Slider = 1,
  7243. /**
  7244. * Vector3
  7245. */
  7246. Vector3 = 2,
  7247. /**
  7248. * Quaternions
  7249. */
  7250. Quaternion = 3,
  7251. /**
  7252. * Color3
  7253. */
  7254. Color3 = 4,
  7255. /**
  7256. * String
  7257. */
  7258. String = 5
  7259. }
  7260. /**
  7261. * Interface used to define custom inspectable properties.
  7262. * This interface is used by the inspector to display custom property grids
  7263. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7264. */
  7265. export interface IInspectable {
  7266. /**
  7267. * Gets the label to display
  7268. */
  7269. label: string;
  7270. /**
  7271. * Gets the name of the property to edit
  7272. */
  7273. propertyName: string;
  7274. /**
  7275. * Gets the type of the editor to use
  7276. */
  7277. type: InspectableType;
  7278. /**
  7279. * Gets the minimum value of the property when using in "slider" mode
  7280. */
  7281. min?: number;
  7282. /**
  7283. * Gets the maximum value of the property when using in "slider" mode
  7284. */
  7285. max?: number;
  7286. /**
  7287. * Gets the setp to use when using in "slider" mode
  7288. */
  7289. step?: number;
  7290. }
  7291. }
  7292. declare module BABYLON {
  7293. /**
  7294. * Class used to provide helper for timing
  7295. */
  7296. export class TimingTools {
  7297. /**
  7298. * Polyfill for setImmediate
  7299. * @param action defines the action to execute after the current execution block
  7300. */
  7301. static SetImmediate(action: () => void): void;
  7302. }
  7303. }
  7304. declare module BABYLON {
  7305. /**
  7306. * Class used to enable instatition of objects by class name
  7307. */
  7308. export class InstantiationTools {
  7309. /**
  7310. * Use this object to register external classes like custom textures or material
  7311. * to allow the laoders to instantiate them
  7312. */
  7313. static RegisteredExternalClasses: {
  7314. [key: string]: Object;
  7315. };
  7316. /**
  7317. * Tries to instantiate a new object from a given class name
  7318. * @param className defines the class name to instantiate
  7319. * @returns the new object or null if the system was not able to do the instantiation
  7320. */
  7321. static Instantiate(className: string): any;
  7322. }
  7323. }
  7324. declare module BABYLON {
  7325. /**
  7326. * Define options used to create a depth texture
  7327. */
  7328. export class DepthTextureCreationOptions {
  7329. /** Specifies whether or not a stencil should be allocated in the texture */
  7330. generateStencil?: boolean;
  7331. /** Specifies whether or not bilinear filtering is enable on the texture */
  7332. bilinearFiltering?: boolean;
  7333. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7334. comparisonFunction?: number;
  7335. /** Specifies if the created texture is a cube texture */
  7336. isCube?: boolean;
  7337. }
  7338. }
  7339. declare module BABYLON {
  7340. interface ThinEngine {
  7341. /**
  7342. * Creates a depth stencil cube texture.
  7343. * This is only available in WebGL 2.
  7344. * @param size The size of face edge in the cube texture.
  7345. * @param options The options defining the cube texture.
  7346. * @returns The cube texture
  7347. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7348. /**
  7349. * Creates a cube texture
  7350. * @param rootUrl defines the url where the files to load is located
  7351. * @param scene defines the current scene
  7352. * @param files defines the list of files to load (1 per face)
  7353. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7354. * @param onLoad defines an optional callback raised when the texture is loaded
  7355. * @param onError defines an optional callback raised if there is an issue to load the texture
  7356. * @param format defines the format of the data
  7357. * @param forcedExtension defines the extension to use to pick the right loader
  7358. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7359. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7360. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7361. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7362. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7363. * @returns the cube texture as an InternalTexture
  7364. */
  7365. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7366. /**
  7367. * Creates a cube texture
  7368. * @param rootUrl defines the url where the files to load is located
  7369. * @param scene defines the current scene
  7370. * @param files defines the list of files to load (1 per face)
  7371. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7372. * @param onLoad defines an optional callback raised when the texture is loaded
  7373. * @param onError defines an optional callback raised if there is an issue to load the texture
  7374. * @param format defines the format of the data
  7375. * @param forcedExtension defines the extension to use to pick the right loader
  7376. * @returns the cube texture as an InternalTexture
  7377. */
  7378. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7379. /**
  7380. * Creates a cube texture
  7381. * @param rootUrl defines the url where the files to load is located
  7382. * @param scene defines the current scene
  7383. * @param files defines the list of files to load (1 per face)
  7384. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7385. * @param onLoad defines an optional callback raised when the texture is loaded
  7386. * @param onError defines an optional callback raised if there is an issue to load the texture
  7387. * @param format defines the format of the data
  7388. * @param forcedExtension defines the extension to use to pick the right loader
  7389. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7390. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7391. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7392. * @returns the cube texture as an InternalTexture
  7393. */
  7394. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7395. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7396. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7397. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7398. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7399. }
  7400. }
  7401. declare module BABYLON {
  7402. /**
  7403. * Class for creating a cube texture
  7404. */
  7405. export class CubeTexture extends BaseTexture {
  7406. private _delayedOnLoad;
  7407. /**
  7408. * The url of the texture
  7409. */
  7410. url: string;
  7411. /**
  7412. * Gets or sets the center of the bounding box associated with the cube texture.
  7413. * It must define where the camera used to render the texture was set
  7414. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7415. */
  7416. boundingBoxPosition: Vector3;
  7417. private _boundingBoxSize;
  7418. /**
  7419. * Gets or sets the size of the bounding box associated with the cube texture
  7420. * When defined, the cubemap will switch to local mode
  7421. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7422. * @example https://www.babylonjs-playground.com/#RNASML
  7423. */
  7424. /**
  7425. * Returns the bounding box size
  7426. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7427. */
  7428. boundingBoxSize: Vector3;
  7429. protected _rotationY: number;
  7430. /**
  7431. * Sets texture matrix rotation angle around Y axis in radians.
  7432. */
  7433. /**
  7434. * Gets texture matrix rotation angle around Y axis radians.
  7435. */
  7436. rotationY: number;
  7437. /**
  7438. * Are mip maps generated for this texture or not.
  7439. */
  7440. readonly noMipmap: boolean;
  7441. private _noMipmap;
  7442. private _files;
  7443. protected _forcedExtension: Nullable<string>;
  7444. private _extensions;
  7445. private _textureMatrix;
  7446. private _format;
  7447. private _createPolynomials;
  7448. /** @hidden */ private _prefiltered: boolean;
  7449. /**
  7450. * Creates a cube texture from an array of image urls
  7451. * @param files defines an array of image urls
  7452. * @param scene defines the hosting scene
  7453. * @param noMipmap specifies if mip maps are not used
  7454. * @returns a cube texture
  7455. */
  7456. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7457. /**
  7458. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7459. * @param url defines the url of the prefiltered texture
  7460. * @param scene defines the scene the texture is attached to
  7461. * @param forcedExtension defines the extension of the file if different from the url
  7462. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7463. * @return the prefiltered texture
  7464. */
  7465. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7466. /**
  7467. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7468. * as prefiltered data.
  7469. * @param rootUrl defines the url of the texture or the root name of the six images
  7470. * @param scene defines the scene the texture is attached to
  7471. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7472. * @param noMipmap defines if mipmaps should be created or not
  7473. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7474. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7475. * @param onError defines a callback triggered in case of error during load
  7476. * @param format defines the internal format to use for the texture once loaded
  7477. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7478. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7479. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7480. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7481. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7482. * @return the cube texture
  7483. */
  7484. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7485. /**
  7486. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7487. */
  7488. readonly isPrefiltered: boolean;
  7489. /**
  7490. * Get the current class name of the texture useful for serialization or dynamic coding.
  7491. * @returns "CubeTexture"
  7492. */
  7493. getClassName(): string;
  7494. /**
  7495. * Update the url (and optional buffer) of this texture if url was null during construction.
  7496. * @param url the url of the texture
  7497. * @param forcedExtension defines the extension to use
  7498. * @param onLoad callback called when the texture is loaded (defaults to null)
  7499. */
  7500. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7501. /**
  7502. * Delays loading of the cube texture
  7503. * @param forcedExtension defines the extension to use
  7504. */
  7505. delayLoad(forcedExtension?: string): void;
  7506. /**
  7507. * Returns the reflection texture matrix
  7508. * @returns the reflection texture matrix
  7509. */
  7510. getReflectionTextureMatrix(): Matrix;
  7511. /**
  7512. * Sets the reflection texture matrix
  7513. * @param value Reflection texture matrix
  7514. */
  7515. setReflectionTextureMatrix(value: Matrix): void;
  7516. /**
  7517. * Parses text to create a cube texture
  7518. * @param parsedTexture define the serialized text to read from
  7519. * @param scene defines the hosting scene
  7520. * @param rootUrl defines the root url of the cube texture
  7521. * @returns a cube texture
  7522. */
  7523. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7524. /**
  7525. * Makes a clone, or deep copy, of the cube texture
  7526. * @returns a new cube texture
  7527. */
  7528. clone(): CubeTexture;
  7529. }
  7530. }
  7531. declare module BABYLON {
  7532. /**
  7533. * Manages the defines for the Material
  7534. */
  7535. export class MaterialDefines {
  7536. /** @hidden */
  7537. protected _keys: string[];
  7538. private _isDirty;
  7539. /** @hidden */ private _renderId: number;
  7540. /** @hidden */ private _areLightsDirty: boolean;
  7541. /** @hidden */ private _areLightsDisposed: boolean;
  7542. /** @hidden */ private _areAttributesDirty: boolean;
  7543. /** @hidden */ private _areTexturesDirty: boolean;
  7544. /** @hidden */ private _areFresnelDirty: boolean;
  7545. /** @hidden */ private _areMiscDirty: boolean;
  7546. /** @hidden */ private _areImageProcessingDirty: boolean;
  7547. /** @hidden */ private _normals: boolean;
  7548. /** @hidden */ private _uvs: boolean;
  7549. /** @hidden */ private _needNormals: boolean;
  7550. /** @hidden */ private _needUVs: boolean;
  7551. [id: string]: any;
  7552. /**
  7553. * Specifies if the material needs to be re-calculated
  7554. */
  7555. readonly isDirty: boolean;
  7556. /**
  7557. * Marks the material to indicate that it has been re-calculated
  7558. */
  7559. markAsProcessed(): void;
  7560. /**
  7561. * Marks the material to indicate that it needs to be re-calculated
  7562. */
  7563. markAsUnprocessed(): void;
  7564. /**
  7565. * Marks the material to indicate all of its defines need to be re-calculated
  7566. */
  7567. markAllAsDirty(): void;
  7568. /**
  7569. * Marks the material to indicate that image processing needs to be re-calculated
  7570. */
  7571. markAsImageProcessingDirty(): void;
  7572. /**
  7573. * Marks the material to indicate the lights need to be re-calculated
  7574. * @param disposed Defines whether the light is dirty due to dispose or not
  7575. */
  7576. markAsLightDirty(disposed?: boolean): void;
  7577. /**
  7578. * Marks the attribute state as changed
  7579. */
  7580. markAsAttributesDirty(): void;
  7581. /**
  7582. * Marks the texture state as changed
  7583. */
  7584. markAsTexturesDirty(): void;
  7585. /**
  7586. * Marks the fresnel state as changed
  7587. */
  7588. markAsFresnelDirty(): void;
  7589. /**
  7590. * Marks the misc state as changed
  7591. */
  7592. markAsMiscDirty(): void;
  7593. /**
  7594. * Rebuilds the material defines
  7595. */
  7596. rebuild(): void;
  7597. /**
  7598. * Specifies if two material defines are equal
  7599. * @param other - A material define instance to compare to
  7600. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7601. */
  7602. isEqual(other: MaterialDefines): boolean;
  7603. /**
  7604. * Clones this instance's defines to another instance
  7605. * @param other - material defines to clone values to
  7606. */
  7607. cloneTo(other: MaterialDefines): void;
  7608. /**
  7609. * Resets the material define values
  7610. */
  7611. reset(): void;
  7612. /**
  7613. * Converts the material define values to a string
  7614. * @returns - String of material define information
  7615. */
  7616. toString(): string;
  7617. }
  7618. }
  7619. declare module BABYLON {
  7620. /**
  7621. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7622. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7623. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7624. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7625. */
  7626. export class ColorCurves {
  7627. private _dirty;
  7628. private _tempColor;
  7629. private _globalCurve;
  7630. private _highlightsCurve;
  7631. private _midtonesCurve;
  7632. private _shadowsCurve;
  7633. private _positiveCurve;
  7634. private _negativeCurve;
  7635. private _globalHue;
  7636. private _globalDensity;
  7637. private _globalSaturation;
  7638. private _globalExposure;
  7639. /**
  7640. * Gets the global Hue value.
  7641. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7642. */
  7643. /**
  7644. * Sets the global Hue value.
  7645. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7646. */
  7647. globalHue: number;
  7648. /**
  7649. * Gets the global Density value.
  7650. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7651. * Values less than zero provide a filter of opposite hue.
  7652. */
  7653. /**
  7654. * Sets the global Density value.
  7655. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7656. * Values less than zero provide a filter of opposite hue.
  7657. */
  7658. globalDensity: number;
  7659. /**
  7660. * Gets the global Saturation value.
  7661. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7662. */
  7663. /**
  7664. * Sets the global Saturation value.
  7665. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7666. */
  7667. globalSaturation: number;
  7668. /**
  7669. * Gets the global Exposure value.
  7670. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7671. */
  7672. /**
  7673. * Sets the global Exposure value.
  7674. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7675. */
  7676. globalExposure: number;
  7677. private _highlightsHue;
  7678. private _highlightsDensity;
  7679. private _highlightsSaturation;
  7680. private _highlightsExposure;
  7681. /**
  7682. * Gets the highlights Hue value.
  7683. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7684. */
  7685. /**
  7686. * Sets the highlights Hue value.
  7687. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7688. */
  7689. highlightsHue: number;
  7690. /**
  7691. * Gets the highlights Density value.
  7692. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7693. * Values less than zero provide a filter of opposite hue.
  7694. */
  7695. /**
  7696. * Sets the highlights Density value.
  7697. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7698. * Values less than zero provide a filter of opposite hue.
  7699. */
  7700. highlightsDensity: number;
  7701. /**
  7702. * Gets the highlights Saturation value.
  7703. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7704. */
  7705. /**
  7706. * Sets the highlights Saturation value.
  7707. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7708. */
  7709. highlightsSaturation: number;
  7710. /**
  7711. * Gets the highlights Exposure value.
  7712. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7713. */
  7714. /**
  7715. * Sets the highlights Exposure value.
  7716. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7717. */
  7718. highlightsExposure: number;
  7719. private _midtonesHue;
  7720. private _midtonesDensity;
  7721. private _midtonesSaturation;
  7722. private _midtonesExposure;
  7723. /**
  7724. * Gets the midtones Hue value.
  7725. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7726. */
  7727. /**
  7728. * Sets the midtones Hue value.
  7729. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7730. */
  7731. midtonesHue: number;
  7732. /**
  7733. * Gets the midtones Density value.
  7734. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7735. * Values less than zero provide a filter of opposite hue.
  7736. */
  7737. /**
  7738. * Sets the midtones Density value.
  7739. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7740. * Values less than zero provide a filter of opposite hue.
  7741. */
  7742. midtonesDensity: number;
  7743. /**
  7744. * Gets the midtones Saturation value.
  7745. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7746. */
  7747. /**
  7748. * Sets the midtones Saturation value.
  7749. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7750. */
  7751. midtonesSaturation: number;
  7752. /**
  7753. * Gets the midtones Exposure value.
  7754. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7755. */
  7756. /**
  7757. * Sets the midtones Exposure value.
  7758. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7759. */
  7760. midtonesExposure: number;
  7761. private _shadowsHue;
  7762. private _shadowsDensity;
  7763. private _shadowsSaturation;
  7764. private _shadowsExposure;
  7765. /**
  7766. * Gets the shadows Hue value.
  7767. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7768. */
  7769. /**
  7770. * Sets the shadows Hue value.
  7771. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7772. */
  7773. shadowsHue: number;
  7774. /**
  7775. * Gets the shadows Density value.
  7776. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7777. * Values less than zero provide a filter of opposite hue.
  7778. */
  7779. /**
  7780. * Sets the shadows Density value.
  7781. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7782. * Values less than zero provide a filter of opposite hue.
  7783. */
  7784. shadowsDensity: number;
  7785. /**
  7786. * Gets the shadows Saturation value.
  7787. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7788. */
  7789. /**
  7790. * Sets the shadows Saturation value.
  7791. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7792. */
  7793. shadowsSaturation: number;
  7794. /**
  7795. * Gets the shadows Exposure value.
  7796. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7797. */
  7798. /**
  7799. * Sets the shadows Exposure value.
  7800. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7801. */
  7802. shadowsExposure: number;
  7803. /**
  7804. * Returns the class name
  7805. * @returns The class name
  7806. */
  7807. getClassName(): string;
  7808. /**
  7809. * Binds the color curves to the shader.
  7810. * @param colorCurves The color curve to bind
  7811. * @param effect The effect to bind to
  7812. * @param positiveUniform The positive uniform shader parameter
  7813. * @param neutralUniform The neutral uniform shader parameter
  7814. * @param negativeUniform The negative uniform shader parameter
  7815. */
  7816. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7817. /**
  7818. * Prepare the list of uniforms associated with the ColorCurves effects.
  7819. * @param uniformsList The list of uniforms used in the effect
  7820. */
  7821. static PrepareUniforms(uniformsList: string[]): void;
  7822. /**
  7823. * Returns color grading data based on a hue, density, saturation and exposure value.
  7824. * @param filterHue The hue of the color filter.
  7825. * @param filterDensity The density of the color filter.
  7826. * @param saturation The saturation.
  7827. * @param exposure The exposure.
  7828. * @param result The result data container.
  7829. */
  7830. private getColorGradingDataToRef;
  7831. /**
  7832. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7833. * @param value The input slider value in range [-100,100].
  7834. * @returns Adjusted value.
  7835. */
  7836. private static applyColorGradingSliderNonlinear;
  7837. /**
  7838. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7839. * @param hue The hue (H) input.
  7840. * @param saturation The saturation (S) input.
  7841. * @param brightness The brightness (B) input.
  7842. * @result An RGBA color represented as Vector4.
  7843. */
  7844. private static fromHSBToRef;
  7845. /**
  7846. * Returns a value clamped between min and max
  7847. * @param value The value to clamp
  7848. * @param min The minimum of value
  7849. * @param max The maximum of value
  7850. * @returns The clamped value.
  7851. */
  7852. private static clamp;
  7853. /**
  7854. * Clones the current color curve instance.
  7855. * @return The cloned curves
  7856. */
  7857. clone(): ColorCurves;
  7858. /**
  7859. * Serializes the current color curve instance to a json representation.
  7860. * @return a JSON representation
  7861. */
  7862. serialize(): any;
  7863. /**
  7864. * Parses the color curve from a json representation.
  7865. * @param source the JSON source to parse
  7866. * @return The parsed curves
  7867. */
  7868. static Parse(source: any): ColorCurves;
  7869. }
  7870. }
  7871. declare module BABYLON {
  7872. /**
  7873. * Interface to follow in your material defines to integrate easily the
  7874. * Image proccessing functions.
  7875. * @hidden
  7876. */
  7877. export interface IImageProcessingConfigurationDefines {
  7878. IMAGEPROCESSING: boolean;
  7879. VIGNETTE: boolean;
  7880. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7881. VIGNETTEBLENDMODEOPAQUE: boolean;
  7882. TONEMAPPING: boolean;
  7883. TONEMAPPING_ACES: boolean;
  7884. CONTRAST: boolean;
  7885. EXPOSURE: boolean;
  7886. COLORCURVES: boolean;
  7887. COLORGRADING: boolean;
  7888. COLORGRADING3D: boolean;
  7889. SAMPLER3DGREENDEPTH: boolean;
  7890. SAMPLER3DBGRMAP: boolean;
  7891. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7892. }
  7893. /**
  7894. * @hidden
  7895. */
  7896. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7897. IMAGEPROCESSING: boolean;
  7898. VIGNETTE: boolean;
  7899. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7900. VIGNETTEBLENDMODEOPAQUE: boolean;
  7901. TONEMAPPING: boolean;
  7902. TONEMAPPING_ACES: boolean;
  7903. CONTRAST: boolean;
  7904. COLORCURVES: boolean;
  7905. COLORGRADING: boolean;
  7906. COLORGRADING3D: boolean;
  7907. SAMPLER3DGREENDEPTH: boolean;
  7908. SAMPLER3DBGRMAP: boolean;
  7909. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7910. EXPOSURE: boolean;
  7911. constructor();
  7912. }
  7913. /**
  7914. * This groups together the common properties used for image processing either in direct forward pass
  7915. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7916. * or not.
  7917. */
  7918. export class ImageProcessingConfiguration {
  7919. /**
  7920. * Default tone mapping applied in BabylonJS.
  7921. */
  7922. static readonly TONEMAPPING_STANDARD: number;
  7923. /**
  7924. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7925. * to other engines rendering to increase portability.
  7926. */
  7927. static readonly TONEMAPPING_ACES: number;
  7928. /**
  7929. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7930. */
  7931. colorCurves: Nullable<ColorCurves>;
  7932. private _colorCurvesEnabled;
  7933. /**
  7934. * Gets wether the color curves effect is enabled.
  7935. */
  7936. /**
  7937. * Sets wether the color curves effect is enabled.
  7938. */
  7939. colorCurvesEnabled: boolean;
  7940. private _colorGradingTexture;
  7941. /**
  7942. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7943. */
  7944. /**
  7945. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7946. */
  7947. colorGradingTexture: Nullable<BaseTexture>;
  7948. private _colorGradingEnabled;
  7949. /**
  7950. * Gets wether the color grading effect is enabled.
  7951. */
  7952. /**
  7953. * Sets wether the color grading effect is enabled.
  7954. */
  7955. colorGradingEnabled: boolean;
  7956. private _colorGradingWithGreenDepth;
  7957. /**
  7958. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  7959. */
  7960. /**
  7961. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  7962. */
  7963. colorGradingWithGreenDepth: boolean;
  7964. private _colorGradingBGR;
  7965. /**
  7966. * Gets wether the color grading texture contains BGR values.
  7967. */
  7968. /**
  7969. * Sets wether the color grading texture contains BGR values.
  7970. */
  7971. colorGradingBGR: boolean;
  7972. /** @hidden */ private _exposure: number;
  7973. /**
  7974. * Gets the Exposure used in the effect.
  7975. */
  7976. /**
  7977. * Sets the Exposure used in the effect.
  7978. */
  7979. exposure: number;
  7980. private _toneMappingEnabled;
  7981. /**
  7982. * Gets wether the tone mapping effect is enabled.
  7983. */
  7984. /**
  7985. * Sets wether the tone mapping effect is enabled.
  7986. */
  7987. toneMappingEnabled: boolean;
  7988. private _toneMappingType;
  7989. /**
  7990. * Gets the type of tone mapping effect.
  7991. */
  7992. /**
  7993. * Sets the type of tone mapping effect used in BabylonJS.
  7994. */
  7995. toneMappingType: number;
  7996. protected _contrast: number;
  7997. /**
  7998. * Gets the contrast used in the effect.
  7999. */
  8000. /**
  8001. * Sets the contrast used in the effect.
  8002. */
  8003. contrast: number;
  8004. /**
  8005. * Vignette stretch size.
  8006. */
  8007. vignetteStretch: number;
  8008. /**
  8009. * Vignette centre X Offset.
  8010. */
  8011. vignetteCentreX: number;
  8012. /**
  8013. * Vignette centre Y Offset.
  8014. */
  8015. vignetteCentreY: number;
  8016. /**
  8017. * Vignette weight or intensity of the vignette effect.
  8018. */
  8019. vignetteWeight: number;
  8020. /**
  8021. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8022. * if vignetteEnabled is set to true.
  8023. */
  8024. vignetteColor: Color4;
  8025. /**
  8026. * Camera field of view used by the Vignette effect.
  8027. */
  8028. vignetteCameraFov: number;
  8029. private _vignetteBlendMode;
  8030. /**
  8031. * Gets the vignette blend mode allowing different kind of effect.
  8032. */
  8033. /**
  8034. * Sets the vignette blend mode allowing different kind of effect.
  8035. */
  8036. vignetteBlendMode: number;
  8037. private _vignetteEnabled;
  8038. /**
  8039. * Gets wether the vignette effect is enabled.
  8040. */
  8041. /**
  8042. * Sets wether the vignette effect is enabled.
  8043. */
  8044. vignetteEnabled: boolean;
  8045. private _applyByPostProcess;
  8046. /**
  8047. * Gets wether the image processing is applied through a post process or not.
  8048. */
  8049. /**
  8050. * Sets wether the image processing is applied through a post process or not.
  8051. */
  8052. applyByPostProcess: boolean;
  8053. private _isEnabled;
  8054. /**
  8055. * Gets wether the image processing is enabled or not.
  8056. */
  8057. /**
  8058. * Sets wether the image processing is enabled or not.
  8059. */
  8060. isEnabled: boolean;
  8061. /**
  8062. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8063. */
  8064. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8065. /**
  8066. * Method called each time the image processing information changes requires to recompile the effect.
  8067. */
  8068. protected _updateParameters(): void;
  8069. /**
  8070. * Gets the current class name.
  8071. * @return "ImageProcessingConfiguration"
  8072. */
  8073. getClassName(): string;
  8074. /**
  8075. * Prepare the list of uniforms associated with the Image Processing effects.
  8076. * @param uniforms The list of uniforms used in the effect
  8077. * @param defines the list of defines currently in use
  8078. */
  8079. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8080. /**
  8081. * Prepare the list of samplers associated with the Image Processing effects.
  8082. * @param samplersList The list of uniforms used in the effect
  8083. * @param defines the list of defines currently in use
  8084. */
  8085. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8086. /**
  8087. * Prepare the list of defines associated to the shader.
  8088. * @param defines the list of defines to complete
  8089. * @param forPostProcess Define if we are currently in post process mode or not
  8090. */
  8091. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8092. /**
  8093. * Returns true if all the image processing information are ready.
  8094. * @returns True if ready, otherwise, false
  8095. */
  8096. isReady(): boolean;
  8097. /**
  8098. * Binds the image processing to the shader.
  8099. * @param effect The effect to bind to
  8100. * @param aspectRatio Define the current aspect ratio of the effect
  8101. */
  8102. bind(effect: Effect, aspectRatio?: number): void;
  8103. /**
  8104. * Clones the current image processing instance.
  8105. * @return The cloned image processing
  8106. */
  8107. clone(): ImageProcessingConfiguration;
  8108. /**
  8109. * Serializes the current image processing instance to a json representation.
  8110. * @return a JSON representation
  8111. */
  8112. serialize(): any;
  8113. /**
  8114. * Parses the image processing from a json representation.
  8115. * @param source the JSON source to parse
  8116. * @return The parsed image processing
  8117. */
  8118. static Parse(source: any): ImageProcessingConfiguration;
  8119. private static _VIGNETTEMODE_MULTIPLY;
  8120. private static _VIGNETTEMODE_OPAQUE;
  8121. /**
  8122. * Used to apply the vignette as a mix with the pixel color.
  8123. */
  8124. static readonly VIGNETTEMODE_MULTIPLY: number;
  8125. /**
  8126. * Used to apply the vignette as a replacement of the pixel color.
  8127. */
  8128. static readonly VIGNETTEMODE_OPAQUE: number;
  8129. }
  8130. }
  8131. declare module BABYLON {
  8132. /** @hidden */
  8133. export var postprocessVertexShader: {
  8134. name: string;
  8135. shader: string;
  8136. };
  8137. }
  8138. declare module BABYLON {
  8139. interface ThinEngine {
  8140. /**
  8141. * Creates a new render target texture
  8142. * @param size defines the size of the texture
  8143. * @param options defines the options used to create the texture
  8144. * @returns a new render target texture stored in an InternalTexture
  8145. */
  8146. createRenderTargetTexture(size: number | {
  8147. width: number;
  8148. height: number;
  8149. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8150. }
  8151. }
  8152. declare module BABYLON {
  8153. /** Defines supported spaces */
  8154. export enum Space {
  8155. /** Local (object) space */
  8156. LOCAL = 0,
  8157. /** World space */
  8158. WORLD = 1,
  8159. /** Bone space */
  8160. BONE = 2
  8161. }
  8162. /** Defines the 3 main axes */
  8163. export class Axis {
  8164. /** X axis */
  8165. static X: Vector3;
  8166. /** Y axis */
  8167. static Y: Vector3;
  8168. /** Z axis */
  8169. static Z: Vector3;
  8170. }
  8171. }
  8172. declare module BABYLON {
  8173. /**
  8174. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8175. * This is the base of the follow, arc rotate cameras and Free camera
  8176. * @see http://doc.babylonjs.com/features/cameras
  8177. */
  8178. export class TargetCamera extends Camera {
  8179. private static _RigCamTransformMatrix;
  8180. private static _TargetTransformMatrix;
  8181. private static _TargetFocalPoint;
  8182. /**
  8183. * Define the current direction the camera is moving to
  8184. */
  8185. cameraDirection: Vector3;
  8186. /**
  8187. * Define the current rotation the camera is rotating to
  8188. */
  8189. cameraRotation: Vector2;
  8190. /**
  8191. * When set, the up vector of the camera will be updated by the rotation of the camera
  8192. */
  8193. updateUpVectorFromRotation: boolean;
  8194. private _tmpQuaternion;
  8195. /**
  8196. * Define the current rotation of the camera
  8197. */
  8198. rotation: Vector3;
  8199. /**
  8200. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8201. */
  8202. rotationQuaternion: Quaternion;
  8203. /**
  8204. * Define the current speed of the camera
  8205. */
  8206. speed: number;
  8207. /**
  8208. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8209. * around all axis.
  8210. */
  8211. noRotationConstraint: boolean;
  8212. /**
  8213. * Define the current target of the camera as an object or a position.
  8214. */
  8215. lockedTarget: any;
  8216. /** @hidden */ private _currentTarget: Vector3;
  8217. /** @hidden */ private _initialFocalDistance: number;
  8218. /** @hidden */ private _viewMatrix: Matrix;
  8219. /** @hidden */ private _camMatrix: Matrix;
  8220. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8221. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8222. /** @hidden */ private _referencePoint: Vector3;
  8223. /** @hidden */ private _transformedReferencePoint: Vector3;
  8224. protected _globalCurrentTarget: Vector3;
  8225. protected _globalCurrentUpVector: Vector3;
  8226. /** @hidden */ private _reset: () => void;
  8227. private _defaultUp;
  8228. /**
  8229. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8230. * This is the base of the follow, arc rotate cameras and Free camera
  8231. * @see http://doc.babylonjs.com/features/cameras
  8232. * @param name Defines the name of the camera in the scene
  8233. * @param position Defines the start position of the camera in the scene
  8234. * @param scene Defines the scene the camera belongs to
  8235. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8236. */
  8237. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8238. /**
  8239. * Gets the position in front of the camera at a given distance.
  8240. * @param distance The distance from the camera we want the position to be
  8241. * @returns the position
  8242. */
  8243. getFrontPosition(distance: number): Vector3;
  8244. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8245. private _storedPosition;
  8246. private _storedRotation;
  8247. private _storedRotationQuaternion;
  8248. /**
  8249. * Store current camera state of the camera (fov, position, rotation, etc..)
  8250. * @returns the camera
  8251. */
  8252. storeState(): Camera;
  8253. /**
  8254. * Restored camera state. You must call storeState() first
  8255. * @returns whether it was successful or not
  8256. * @hidden
  8257. */ private _restoreStateValues(): boolean;
  8258. /** @hidden */ private _initCache(): void;
  8259. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8260. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8261. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8262. /**
  8263. * Defines the target the camera should look at.
  8264. * @param target Defines the new target as a Vector or a mesh
  8265. */
  8266. setTarget(target: Vector3): void;
  8267. /**
  8268. * Return the current target position of the camera. This value is expressed in local space.
  8269. * @returns the target position
  8270. */
  8271. getTarget(): Vector3;
  8272. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8273. /** @hidden */ private _updatePosition(): void;
  8274. /** @hidden */ private _checkInputs(): void;
  8275. protected _updateCameraRotationMatrix(): void;
  8276. /**
  8277. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8278. * @returns the current camera
  8279. */
  8280. private _rotateUpVectorWithCameraRotationMatrix;
  8281. private _cachedRotationZ;
  8282. private _cachedQuaternionRotationZ;
  8283. /** @hidden */ private _getViewMatrix(): Matrix;
  8284. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8285. /**
  8286. * @hidden
  8287. */
  8288. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8289. /**
  8290. * @hidden
  8291. */ private _updateRigCameras(): void;
  8292. private _getRigCamPositionAndTarget;
  8293. /**
  8294. * Gets the current object class name.
  8295. * @return the class name
  8296. */
  8297. getClassName(): string;
  8298. }
  8299. }
  8300. declare module BABYLON {
  8301. /**
  8302. * Gather the list of keyboard event types as constants.
  8303. */
  8304. export class KeyboardEventTypes {
  8305. /**
  8306. * The keydown event is fired when a key becomes active (pressed).
  8307. */
  8308. static readonly KEYDOWN: number;
  8309. /**
  8310. * The keyup event is fired when a key has been released.
  8311. */
  8312. static readonly KEYUP: number;
  8313. }
  8314. /**
  8315. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8316. */
  8317. export class KeyboardInfo {
  8318. /**
  8319. * Defines the type of event (KeyboardEventTypes)
  8320. */
  8321. type: number;
  8322. /**
  8323. * Defines the related dom event
  8324. */
  8325. event: KeyboardEvent;
  8326. /**
  8327. * Instantiates a new keyboard info.
  8328. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8329. * @param type Defines the type of event (KeyboardEventTypes)
  8330. * @param event Defines the related dom event
  8331. */
  8332. constructor(
  8333. /**
  8334. * Defines the type of event (KeyboardEventTypes)
  8335. */
  8336. type: number,
  8337. /**
  8338. * Defines the related dom event
  8339. */
  8340. event: KeyboardEvent);
  8341. }
  8342. /**
  8343. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8344. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8345. */
  8346. export class KeyboardInfoPre extends KeyboardInfo {
  8347. /**
  8348. * Defines the type of event (KeyboardEventTypes)
  8349. */
  8350. type: number;
  8351. /**
  8352. * Defines the related dom event
  8353. */
  8354. event: KeyboardEvent;
  8355. /**
  8356. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8357. */
  8358. skipOnPointerObservable: boolean;
  8359. /**
  8360. * Instantiates a new keyboard pre info.
  8361. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8362. * @param type Defines the type of event (KeyboardEventTypes)
  8363. * @param event Defines the related dom event
  8364. */
  8365. constructor(
  8366. /**
  8367. * Defines the type of event (KeyboardEventTypes)
  8368. */
  8369. type: number,
  8370. /**
  8371. * Defines the related dom event
  8372. */
  8373. event: KeyboardEvent);
  8374. }
  8375. }
  8376. declare module BABYLON {
  8377. /**
  8378. * Manage the keyboard inputs to control the movement of a free camera.
  8379. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8380. */
  8381. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8382. /**
  8383. * Defines the camera the input is attached to.
  8384. */
  8385. camera: FreeCamera;
  8386. /**
  8387. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8388. */
  8389. keysUp: number[];
  8390. /**
  8391. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8392. */
  8393. keysDown: number[];
  8394. /**
  8395. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8396. */
  8397. keysLeft: number[];
  8398. /**
  8399. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8400. */
  8401. keysRight: number[];
  8402. private _keys;
  8403. private _onCanvasBlurObserver;
  8404. private _onKeyboardObserver;
  8405. private _engine;
  8406. private _scene;
  8407. /**
  8408. * Attach the input controls to a specific dom element to get the input from.
  8409. * @param element Defines the element the controls should be listened from
  8410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8411. */
  8412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8413. /**
  8414. * Detach the current controls from the specified dom element.
  8415. * @param element Defines the element to stop listening the inputs from
  8416. */
  8417. detachControl(element: Nullable<HTMLElement>): void;
  8418. /**
  8419. * Update the current camera state depending on the inputs that have been used this frame.
  8420. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8421. */
  8422. checkInputs(): void;
  8423. /**
  8424. * Gets the class name of the current intput.
  8425. * @returns the class name
  8426. */
  8427. getClassName(): string;
  8428. /** @hidden */ private _onLostFocus(): void;
  8429. /**
  8430. * Get the friendly name associated with the input class.
  8431. * @returns the input friendly name
  8432. */
  8433. getSimpleName(): string;
  8434. }
  8435. }
  8436. declare module BABYLON {
  8437. /**
  8438. * Interface describing all the common properties and methods a shadow light needs to implement.
  8439. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8440. * as well as binding the different shadow properties to the effects.
  8441. */
  8442. export interface IShadowLight extends Light {
  8443. /**
  8444. * The light id in the scene (used in scene.findLighById for instance)
  8445. */
  8446. id: string;
  8447. /**
  8448. * The position the shdow will be casted from.
  8449. */
  8450. position: Vector3;
  8451. /**
  8452. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8453. */
  8454. direction: Vector3;
  8455. /**
  8456. * The transformed position. Position of the light in world space taking parenting in account.
  8457. */
  8458. transformedPosition: Vector3;
  8459. /**
  8460. * The transformed direction. Direction of the light in world space taking parenting in account.
  8461. */
  8462. transformedDirection: Vector3;
  8463. /**
  8464. * The friendly name of the light in the scene.
  8465. */
  8466. name: string;
  8467. /**
  8468. * Defines the shadow projection clipping minimum z value.
  8469. */
  8470. shadowMinZ: number;
  8471. /**
  8472. * Defines the shadow projection clipping maximum z value.
  8473. */
  8474. shadowMaxZ: number;
  8475. /**
  8476. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8477. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8478. */
  8479. computeTransformedInformation(): boolean;
  8480. /**
  8481. * Gets the scene the light belongs to.
  8482. * @returns The scene
  8483. */
  8484. getScene(): Scene;
  8485. /**
  8486. * Callback defining a custom Projection Matrix Builder.
  8487. * This can be used to override the default projection matrix computation.
  8488. */
  8489. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8490. /**
  8491. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8492. * @param matrix The materix to updated with the projection information
  8493. * @param viewMatrix The transform matrix of the light
  8494. * @param renderList The list of mesh to render in the map
  8495. * @returns The current light
  8496. */
  8497. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8498. /**
  8499. * Gets the current depth scale used in ESM.
  8500. * @returns The scale
  8501. */
  8502. getDepthScale(): number;
  8503. /**
  8504. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8505. * @returns true if a cube texture needs to be use
  8506. */
  8507. needCube(): boolean;
  8508. /**
  8509. * Detects if the projection matrix requires to be recomputed this frame.
  8510. * @returns true if it requires to be recomputed otherwise, false.
  8511. */
  8512. needProjectionMatrixCompute(): boolean;
  8513. /**
  8514. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8515. */
  8516. forceProjectionMatrixCompute(): void;
  8517. /**
  8518. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8519. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8520. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8521. */
  8522. getShadowDirection(faceIndex?: number): Vector3;
  8523. /**
  8524. * Gets the minZ used for shadow according to both the scene and the light.
  8525. * @param activeCamera The camera we are returning the min for
  8526. * @returns the depth min z
  8527. */
  8528. getDepthMinZ(activeCamera: Camera): number;
  8529. /**
  8530. * Gets the maxZ used for shadow according to both the scene and the light.
  8531. * @param activeCamera The camera we are returning the max for
  8532. * @returns the depth max z
  8533. */
  8534. getDepthMaxZ(activeCamera: Camera): number;
  8535. }
  8536. /**
  8537. * Base implementation IShadowLight
  8538. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8539. */
  8540. export abstract class ShadowLight extends Light implements IShadowLight {
  8541. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8542. protected _position: Vector3;
  8543. protected _setPosition(value: Vector3): void;
  8544. /**
  8545. * Sets the position the shadow will be casted from. Also use as the light position for both
  8546. * point and spot lights.
  8547. */
  8548. /**
  8549. * Sets the position the shadow will be casted from. Also use as the light position for both
  8550. * point and spot lights.
  8551. */
  8552. position: Vector3;
  8553. protected _direction: Vector3;
  8554. protected _setDirection(value: Vector3): void;
  8555. /**
  8556. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8557. * Also use as the light direction on spot and directional lights.
  8558. */
  8559. /**
  8560. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8561. * Also use as the light direction on spot and directional lights.
  8562. */
  8563. direction: Vector3;
  8564. private _shadowMinZ;
  8565. /**
  8566. * Gets the shadow projection clipping minimum z value.
  8567. */
  8568. /**
  8569. * Sets the shadow projection clipping minimum z value.
  8570. */
  8571. shadowMinZ: number;
  8572. private _shadowMaxZ;
  8573. /**
  8574. * Sets the shadow projection clipping maximum z value.
  8575. */
  8576. /**
  8577. * Gets the shadow projection clipping maximum z value.
  8578. */
  8579. shadowMaxZ: number;
  8580. /**
  8581. * Callback defining a custom Projection Matrix Builder.
  8582. * This can be used to override the default projection matrix computation.
  8583. */
  8584. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8585. /**
  8586. * The transformed position. Position of the light in world space taking parenting in account.
  8587. */
  8588. transformedPosition: Vector3;
  8589. /**
  8590. * The transformed direction. Direction of the light in world space taking parenting in account.
  8591. */
  8592. transformedDirection: Vector3;
  8593. private _needProjectionMatrixCompute;
  8594. /**
  8595. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8596. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8597. */
  8598. computeTransformedInformation(): boolean;
  8599. /**
  8600. * Return the depth scale used for the shadow map.
  8601. * @returns the depth scale.
  8602. */
  8603. getDepthScale(): number;
  8604. /**
  8605. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8606. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8607. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8608. */
  8609. getShadowDirection(faceIndex?: number): Vector3;
  8610. /**
  8611. * Returns the ShadowLight absolute position in the World.
  8612. * @returns the position vector in world space
  8613. */
  8614. getAbsolutePosition(): Vector3;
  8615. /**
  8616. * Sets the ShadowLight direction toward the passed target.
  8617. * @param target The point to target in local space
  8618. * @returns the updated ShadowLight direction
  8619. */
  8620. setDirectionToTarget(target: Vector3): Vector3;
  8621. /**
  8622. * Returns the light rotation in euler definition.
  8623. * @returns the x y z rotation in local space.
  8624. */
  8625. getRotation(): Vector3;
  8626. /**
  8627. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8628. * @returns true if a cube texture needs to be use
  8629. */
  8630. needCube(): boolean;
  8631. /**
  8632. * Detects if the projection matrix requires to be recomputed this frame.
  8633. * @returns true if it requires to be recomputed otherwise, false.
  8634. */
  8635. needProjectionMatrixCompute(): boolean;
  8636. /**
  8637. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8638. */
  8639. forceProjectionMatrixCompute(): void;
  8640. /** @hidden */ private _initCache(): void;
  8641. /** @hidden */ private _isSynchronized(): boolean;
  8642. /**
  8643. * Computes the world matrix of the node
  8644. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8645. * @returns the world matrix
  8646. */
  8647. computeWorldMatrix(force?: boolean): Matrix;
  8648. /**
  8649. * Gets the minZ used for shadow according to both the scene and the light.
  8650. * @param activeCamera The camera we are returning the min for
  8651. * @returns the depth min z
  8652. */
  8653. getDepthMinZ(activeCamera: Camera): number;
  8654. /**
  8655. * Gets the maxZ used for shadow according to both the scene and the light.
  8656. * @param activeCamera The camera we are returning the max for
  8657. * @returns the depth max z
  8658. */
  8659. getDepthMaxZ(activeCamera: Camera): number;
  8660. /**
  8661. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8662. * @param matrix The materix to updated with the projection information
  8663. * @param viewMatrix The transform matrix of the light
  8664. * @param renderList The list of mesh to render in the map
  8665. * @returns The current light
  8666. */
  8667. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8668. }
  8669. }
  8670. declare module BABYLON {
  8671. /**
  8672. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8673. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8674. */
  8675. export class EffectFallbacks implements IEffectFallbacks {
  8676. private _defines;
  8677. private _currentRank;
  8678. private _maxRank;
  8679. private _mesh;
  8680. /**
  8681. * Removes the fallback from the bound mesh.
  8682. */
  8683. unBindMesh(): void;
  8684. /**
  8685. * Adds a fallback on the specified property.
  8686. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8687. * @param define The name of the define in the shader
  8688. */
  8689. addFallback(rank: number, define: string): void;
  8690. /**
  8691. * Sets the mesh to use CPU skinning when needing to fallback.
  8692. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8693. * @param mesh The mesh to use the fallbacks.
  8694. */
  8695. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8696. /**
  8697. * Checks to see if more fallbacks are still availible.
  8698. */
  8699. readonly hasMoreFallbacks: boolean;
  8700. /**
  8701. * Removes the defines that should be removed when falling back.
  8702. * @param currentDefines defines the current define statements for the shader.
  8703. * @param effect defines the current effect we try to compile
  8704. * @returns The resulting defines with defines of the current rank removed.
  8705. */
  8706. reduce(currentDefines: string, effect: Effect): string;
  8707. }
  8708. }
  8709. declare module BABYLON {
  8710. /**
  8711. * "Static Class" containing the most commonly used helper while dealing with material for
  8712. * rendering purpose.
  8713. *
  8714. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8715. *
  8716. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8717. */
  8718. export class MaterialHelper {
  8719. /**
  8720. * Bind the current view position to an effect.
  8721. * @param effect The effect to be bound
  8722. * @param scene The scene the eyes position is used from
  8723. */
  8724. static BindEyePosition(effect: Effect, scene: Scene): void;
  8725. /**
  8726. * Helps preparing the defines values about the UVs in used in the effect.
  8727. * UVs are shared as much as we can accross channels in the shaders.
  8728. * @param texture The texture we are preparing the UVs for
  8729. * @param defines The defines to update
  8730. * @param key The channel key "diffuse", "specular"... used in the shader
  8731. */
  8732. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8733. /**
  8734. * Binds a texture matrix value to its corrsponding uniform
  8735. * @param texture The texture to bind the matrix for
  8736. * @param uniformBuffer The uniform buffer receivin the data
  8737. * @param key The channel key "diffuse", "specular"... used in the shader
  8738. */
  8739. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8740. /**
  8741. * Gets the current status of the fog (should it be enabled?)
  8742. * @param mesh defines the mesh to evaluate for fog support
  8743. * @param scene defines the hosting scene
  8744. * @returns true if fog must be enabled
  8745. */
  8746. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8747. /**
  8748. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8749. * @param mesh defines the current mesh
  8750. * @param scene defines the current scene
  8751. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8752. * @param pointsCloud defines if point cloud rendering has to be turned on
  8753. * @param fogEnabled defines if fog has to be turned on
  8754. * @param alphaTest defines if alpha testing has to be turned on
  8755. * @param defines defines the current list of defines
  8756. */
  8757. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8758. /**
  8759. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8760. * @param scene defines the current scene
  8761. * @param engine defines the current engine
  8762. * @param defines specifies the list of active defines
  8763. * @param useInstances defines if instances have to be turned on
  8764. * @param useClipPlane defines if clip plane have to be turned on
  8765. */
  8766. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8767. /**
  8768. * Prepares the defines for bones
  8769. * @param mesh The mesh containing the geometry data we will draw
  8770. * @param defines The defines to update
  8771. */
  8772. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8773. /**
  8774. * Prepares the defines for morph targets
  8775. * @param mesh The mesh containing the geometry data we will draw
  8776. * @param defines The defines to update
  8777. */
  8778. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8779. /**
  8780. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8781. * @param mesh The mesh containing the geometry data we will draw
  8782. * @param defines The defines to update
  8783. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8784. * @param useBones Precise whether bones should be used or not (override mesh info)
  8785. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8786. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8787. * @returns false if defines are considered not dirty and have not been checked
  8788. */
  8789. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8790. /**
  8791. * Prepares the defines related to multiview
  8792. * @param scene The scene we are intending to draw
  8793. * @param defines The defines to update
  8794. */
  8795. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8796. /**
  8797. * Prepares the defines related to the light information passed in parameter
  8798. * @param scene The scene we are intending to draw
  8799. * @param mesh The mesh the effect is compiling for
  8800. * @param light The light the effect is compiling for
  8801. * @param lightIndex The index of the light
  8802. * @param defines The defines to update
  8803. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8804. * @param state Defines the current state regarding what is needed (normals, etc...)
  8805. */
  8806. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8807. needNormals: boolean;
  8808. needRebuild: boolean;
  8809. shadowEnabled: boolean;
  8810. specularEnabled: boolean;
  8811. lightmapMode: boolean;
  8812. }): void;
  8813. /**
  8814. * Prepares the defines related to the light information passed in parameter
  8815. * @param scene The scene we are intending to draw
  8816. * @param mesh The mesh the effect is compiling for
  8817. * @param defines The defines to update
  8818. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8819. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8820. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8821. * @returns true if normals will be required for the rest of the effect
  8822. */
  8823. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8824. /**
  8825. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8826. * @param lightIndex defines the light index
  8827. * @param uniformsList The uniform list
  8828. * @param samplersList The sampler list
  8829. * @param projectedLightTexture defines if projected texture must be used
  8830. * @param uniformBuffersList defines an optional list of uniform buffers
  8831. */
  8832. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8833. /**
  8834. * Prepares the uniforms and samplers list to be used in the effect
  8835. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8836. * @param samplersList The sampler list
  8837. * @param defines The defines helping in the list generation
  8838. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8839. */
  8840. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8841. /**
  8842. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8843. * @param defines The defines to update while falling back
  8844. * @param fallbacks The authorized effect fallbacks
  8845. * @param maxSimultaneousLights The maximum number of lights allowed
  8846. * @param rank the current rank of the Effect
  8847. * @returns The newly affected rank
  8848. */
  8849. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8850. private static _TmpMorphInfluencers;
  8851. /**
  8852. * Prepares the list of attributes required for morph targets according to the effect defines.
  8853. * @param attribs The current list of supported attribs
  8854. * @param mesh The mesh to prepare the morph targets attributes for
  8855. * @param influencers The number of influencers
  8856. */
  8857. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8858. /**
  8859. * Prepares the list of attributes required for morph targets according to the effect defines.
  8860. * @param attribs The current list of supported attribs
  8861. * @param mesh The mesh to prepare the morph targets attributes for
  8862. * @param defines The current Defines of the effect
  8863. */
  8864. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8865. /**
  8866. * Prepares the list of attributes required for bones according to the effect defines.
  8867. * @param attribs The current list of supported attribs
  8868. * @param mesh The mesh to prepare the bones attributes for
  8869. * @param defines The current Defines of the effect
  8870. * @param fallbacks The current efffect fallback strategy
  8871. */
  8872. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8873. /**
  8874. * Check and prepare the list of attributes required for instances according to the effect defines.
  8875. * @param attribs The current list of supported attribs
  8876. * @param defines The current MaterialDefines of the effect
  8877. */
  8878. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8879. /**
  8880. * Add the list of attributes required for instances to the attribs array.
  8881. * @param attribs The current list of supported attribs
  8882. */
  8883. static PushAttributesForInstances(attribs: string[]): void;
  8884. /**
  8885. * Binds the light shadow information to the effect for the given mesh.
  8886. * @param light The light containing the generator
  8887. * @param scene The scene the lights belongs to
  8888. * @param mesh The mesh we are binding the information to render
  8889. * @param lightIndex The light index in the effect used to render the mesh
  8890. * @param effect The effect we are binding the data to
  8891. */
  8892. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8893. /**
  8894. * Binds the light information to the effect.
  8895. * @param light The light containing the generator
  8896. * @param effect The effect we are binding the data to
  8897. * @param lightIndex The light index in the effect used to render
  8898. */
  8899. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8900. /**
  8901. * Binds the lights information from the scene to the effect for the given mesh.
  8902. * @param light Light to bind
  8903. * @param lightIndex Light index
  8904. * @param scene The scene where the light belongs to
  8905. * @param mesh The mesh we are binding the information to render
  8906. * @param effect The effect we are binding the data to
  8907. * @param useSpecular Defines if specular is supported
  8908. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8909. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8910. */
  8911. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8912. /**
  8913. * Binds the lights information from the scene to the effect for the given mesh.
  8914. * @param scene The scene the lights belongs to
  8915. * @param mesh The mesh we are binding the information to render
  8916. * @param effect The effect we are binding the data to
  8917. * @param defines The generated defines for the effect
  8918. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8919. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8920. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8921. */
  8922. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  8923. private static _tempFogColor;
  8924. /**
  8925. * Binds the fog information from the scene to the effect for the given mesh.
  8926. * @param scene The scene the lights belongs to
  8927. * @param mesh The mesh we are binding the information to render
  8928. * @param effect The effect we are binding the data to
  8929. * @param linearSpace Defines if the fog effect is applied in linear space
  8930. */
  8931. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8932. /**
  8933. * Binds the bones information from the mesh to the effect.
  8934. * @param mesh The mesh we are binding the information to render
  8935. * @param effect The effect we are binding the data to
  8936. */
  8937. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8938. /**
  8939. * Binds the morph targets information from the mesh to the effect.
  8940. * @param abstractMesh The mesh we are binding the information to render
  8941. * @param effect The effect we are binding the data to
  8942. */
  8943. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8944. /**
  8945. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8946. * @param defines The generated defines used in the effect
  8947. * @param effect The effect we are binding the data to
  8948. * @param scene The scene we are willing to render with logarithmic scale for
  8949. */
  8950. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8951. /**
  8952. * Binds the clip plane information from the scene to the effect.
  8953. * @param scene The scene the clip plane information are extracted from
  8954. * @param effect The effect we are binding the data to
  8955. */
  8956. static BindClipPlane(effect: Effect, scene: Scene): void;
  8957. }
  8958. }
  8959. declare module BABYLON {
  8960. /** @hidden */
  8961. export var packingFunctions: {
  8962. name: string;
  8963. shader: string;
  8964. };
  8965. }
  8966. declare module BABYLON {
  8967. /** @hidden */
  8968. export var shadowMapPixelShader: {
  8969. name: string;
  8970. shader: string;
  8971. };
  8972. }
  8973. declare module BABYLON {
  8974. /** @hidden */
  8975. export var bonesDeclaration: {
  8976. name: string;
  8977. shader: string;
  8978. };
  8979. }
  8980. declare module BABYLON {
  8981. /** @hidden */
  8982. export var morphTargetsVertexGlobalDeclaration: {
  8983. name: string;
  8984. shader: string;
  8985. };
  8986. }
  8987. declare module BABYLON {
  8988. /** @hidden */
  8989. export var morphTargetsVertexDeclaration: {
  8990. name: string;
  8991. shader: string;
  8992. };
  8993. }
  8994. declare module BABYLON {
  8995. /** @hidden */
  8996. export var instancesDeclaration: {
  8997. name: string;
  8998. shader: string;
  8999. };
  9000. }
  9001. declare module BABYLON {
  9002. /** @hidden */
  9003. export var helperFunctions: {
  9004. name: string;
  9005. shader: string;
  9006. };
  9007. }
  9008. declare module BABYLON {
  9009. /** @hidden */
  9010. export var morphTargetsVertex: {
  9011. name: string;
  9012. shader: string;
  9013. };
  9014. }
  9015. declare module BABYLON {
  9016. /** @hidden */
  9017. export var instancesVertex: {
  9018. name: string;
  9019. shader: string;
  9020. };
  9021. }
  9022. declare module BABYLON {
  9023. /** @hidden */
  9024. export var bonesVertex: {
  9025. name: string;
  9026. shader: string;
  9027. };
  9028. }
  9029. declare module BABYLON {
  9030. /** @hidden */
  9031. export var shadowMapVertexShader: {
  9032. name: string;
  9033. shader: string;
  9034. };
  9035. }
  9036. declare module BABYLON {
  9037. /** @hidden */
  9038. export var depthBoxBlurPixelShader: {
  9039. name: string;
  9040. shader: string;
  9041. };
  9042. }
  9043. declare module BABYLON {
  9044. /**
  9045. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9046. */
  9047. export interface ICustomShaderOptions {
  9048. /**
  9049. * Gets or sets the custom shader name to use
  9050. */
  9051. shaderName: string;
  9052. /**
  9053. * The list of attribute names used in the shader
  9054. */
  9055. attributes?: string[];
  9056. /**
  9057. * The list of unifrom names used in the shader
  9058. */
  9059. uniforms?: string[];
  9060. /**
  9061. * The list of sampler names used in the shader
  9062. */
  9063. samplers?: string[];
  9064. /**
  9065. * The list of defines used in the shader
  9066. */
  9067. defines?: string[];
  9068. }
  9069. /**
  9070. * Interface to implement to create a shadow generator compatible with BJS.
  9071. */
  9072. export interface IShadowGenerator {
  9073. /**
  9074. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9075. * @returns The render target texture if present otherwise, null
  9076. */
  9077. getShadowMap(): Nullable<RenderTargetTexture>;
  9078. /**
  9079. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9080. * @returns The render target texture if the shadow map is present otherwise, null
  9081. */
  9082. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9083. /**
  9084. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9085. * @param subMesh The submesh we want to render in the shadow map
  9086. * @param useInstances Defines wether will draw in the map using instances
  9087. * @returns true if ready otherwise, false
  9088. */
  9089. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9090. /**
  9091. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9092. * @param defines Defines of the material we want to update
  9093. * @param lightIndex Index of the light in the enabled light list of the material
  9094. */
  9095. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9096. /**
  9097. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9098. * defined in the generator but impacting the effect).
  9099. * It implies the unifroms available on the materials are the standard BJS ones.
  9100. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9101. * @param effect The effect we are binfing the information for
  9102. */
  9103. bindShadowLight(lightIndex: string, effect: Effect): void;
  9104. /**
  9105. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9106. * (eq to shadow prjection matrix * light transform matrix)
  9107. * @returns The transform matrix used to create the shadow map
  9108. */
  9109. getTransformMatrix(): Matrix;
  9110. /**
  9111. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9112. * Cube and 2D textures for instance.
  9113. */
  9114. recreateShadowMap(): void;
  9115. /**
  9116. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9117. * @param onCompiled Callback triggered at the and of the effects compilation
  9118. * @param options Sets of optional options forcing the compilation with different modes
  9119. */
  9120. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9121. useInstances: boolean;
  9122. }>): void;
  9123. /**
  9124. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9125. * @param options Sets of optional options forcing the compilation with different modes
  9126. * @returns A promise that resolves when the compilation completes
  9127. */
  9128. forceCompilationAsync(options?: Partial<{
  9129. useInstances: boolean;
  9130. }>): Promise<void>;
  9131. /**
  9132. * Serializes the shadow generator setup to a json object.
  9133. * @returns The serialized JSON object
  9134. */
  9135. serialize(): any;
  9136. /**
  9137. * Disposes the Shadow map and related Textures and effects.
  9138. */
  9139. dispose(): void;
  9140. }
  9141. /**
  9142. * Default implementation IShadowGenerator.
  9143. * This is the main object responsible of generating shadows in the framework.
  9144. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9145. */
  9146. export class ShadowGenerator implements IShadowGenerator {
  9147. /**
  9148. * Shadow generator mode None: no filtering applied.
  9149. */
  9150. static readonly FILTER_NONE: number;
  9151. /**
  9152. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9153. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9154. */
  9155. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9156. /**
  9157. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9158. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9159. */
  9160. static readonly FILTER_POISSONSAMPLING: number;
  9161. /**
  9162. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9163. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9164. */
  9165. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9166. /**
  9167. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9168. * edge artifacts on steep falloff.
  9169. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9170. */
  9171. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9172. /**
  9173. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9174. * edge artifacts on steep falloff.
  9175. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9176. */
  9177. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9178. /**
  9179. * Shadow generator mode PCF: Percentage Closer Filtering
  9180. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9181. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9182. */
  9183. static readonly FILTER_PCF: number;
  9184. /**
  9185. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9186. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9187. * Contact Hardening
  9188. */
  9189. static readonly FILTER_PCSS: number;
  9190. /**
  9191. * Reserved for PCF and PCSS
  9192. * Highest Quality.
  9193. *
  9194. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9195. *
  9196. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9197. */
  9198. static readonly QUALITY_HIGH: number;
  9199. /**
  9200. * Reserved for PCF and PCSS
  9201. * Good tradeoff for quality/perf cross devices
  9202. *
  9203. * Execute PCF on a 3*3 kernel.
  9204. *
  9205. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9206. */
  9207. static readonly QUALITY_MEDIUM: number;
  9208. /**
  9209. * Reserved for PCF and PCSS
  9210. * The lowest quality but the fastest.
  9211. *
  9212. * Execute PCF on a 1*1 kernel.
  9213. *
  9214. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9215. */
  9216. static readonly QUALITY_LOW: number;
  9217. /** Gets or sets the custom shader name to use */
  9218. customShaderOptions: ICustomShaderOptions;
  9219. /**
  9220. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9221. */
  9222. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9223. /**
  9224. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9225. */
  9226. onAfterShadowMapRenderObservable: Observable<Effect>;
  9227. /**
  9228. * Observable triggered before a mesh is rendered in the shadow map.
  9229. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9230. */
  9231. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9232. /**
  9233. * Observable triggered after a mesh is rendered in the shadow map.
  9234. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9235. */
  9236. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9237. private _bias;
  9238. /**
  9239. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9240. */
  9241. /**
  9242. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9243. */
  9244. bias: number;
  9245. private _normalBias;
  9246. /**
  9247. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9248. */
  9249. /**
  9250. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9251. */
  9252. normalBias: number;
  9253. private _blurBoxOffset;
  9254. /**
  9255. * Gets the blur box offset: offset applied during the blur pass.
  9256. * Only useful if useKernelBlur = false
  9257. */
  9258. /**
  9259. * Sets the blur box offset: offset applied during the blur pass.
  9260. * Only useful if useKernelBlur = false
  9261. */
  9262. blurBoxOffset: number;
  9263. private _blurScale;
  9264. /**
  9265. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9266. * 2 means half of the size.
  9267. */
  9268. /**
  9269. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9270. * 2 means half of the size.
  9271. */
  9272. blurScale: number;
  9273. private _blurKernel;
  9274. /**
  9275. * Gets the blur kernel: kernel size of the blur pass.
  9276. * Only useful if useKernelBlur = true
  9277. */
  9278. /**
  9279. * Sets the blur kernel: kernel size of the blur pass.
  9280. * Only useful if useKernelBlur = true
  9281. */
  9282. blurKernel: number;
  9283. private _useKernelBlur;
  9284. /**
  9285. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9286. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9287. */
  9288. /**
  9289. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9290. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9291. */
  9292. useKernelBlur: boolean;
  9293. private _depthScale;
  9294. /**
  9295. * Gets the depth scale used in ESM mode.
  9296. */
  9297. /**
  9298. * Sets the depth scale used in ESM mode.
  9299. * This can override the scale stored on the light.
  9300. */
  9301. depthScale: number;
  9302. private _filter;
  9303. /**
  9304. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9305. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9306. */
  9307. /**
  9308. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9309. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9310. */
  9311. filter: number;
  9312. /**
  9313. * Gets if the current filter is set to Poisson Sampling.
  9314. */
  9315. /**
  9316. * Sets the current filter to Poisson Sampling.
  9317. */
  9318. usePoissonSampling: boolean;
  9319. /**
  9320. * Gets if the current filter is set to ESM.
  9321. */
  9322. /**
  9323. * Sets the current filter is to ESM.
  9324. */
  9325. useExponentialShadowMap: boolean;
  9326. /**
  9327. * Gets if the current filter is set to filtered ESM.
  9328. */
  9329. /**
  9330. * Gets if the current filter is set to filtered ESM.
  9331. */
  9332. useBlurExponentialShadowMap: boolean;
  9333. /**
  9334. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9335. * exponential to prevent steep falloff artifacts).
  9336. */
  9337. /**
  9338. * Sets the current filter to "close ESM" (using the inverse of the
  9339. * exponential to prevent steep falloff artifacts).
  9340. */
  9341. useCloseExponentialShadowMap: boolean;
  9342. /**
  9343. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9344. * exponential to prevent steep falloff artifacts).
  9345. */
  9346. /**
  9347. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9348. * exponential to prevent steep falloff artifacts).
  9349. */
  9350. useBlurCloseExponentialShadowMap: boolean;
  9351. /**
  9352. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9353. */
  9354. /**
  9355. * Sets the current filter to "PCF" (percentage closer filtering).
  9356. */
  9357. usePercentageCloserFiltering: boolean;
  9358. private _filteringQuality;
  9359. /**
  9360. * Gets the PCF or PCSS Quality.
  9361. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9362. */
  9363. /**
  9364. * Sets the PCF or PCSS Quality.
  9365. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9366. */
  9367. filteringQuality: number;
  9368. /**
  9369. * Gets if the current filter is set to "PCSS" (contact hardening).
  9370. */
  9371. /**
  9372. * Sets the current filter to "PCSS" (contact hardening).
  9373. */
  9374. useContactHardeningShadow: boolean;
  9375. private _contactHardeningLightSizeUVRatio;
  9376. /**
  9377. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9378. * Using a ratio helps keeping shape stability independently of the map size.
  9379. *
  9380. * It does not account for the light projection as it was having too much
  9381. * instability during the light setup or during light position changes.
  9382. *
  9383. * Only valid if useContactHardeningShadow is true.
  9384. */
  9385. /**
  9386. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9387. * Using a ratio helps keeping shape stability independently of the map size.
  9388. *
  9389. * It does not account for the light projection as it was having too much
  9390. * instability during the light setup or during light position changes.
  9391. *
  9392. * Only valid if useContactHardeningShadow is true.
  9393. */
  9394. contactHardeningLightSizeUVRatio: number;
  9395. private _darkness;
  9396. /** Gets or sets the actual darkness of a shadow */
  9397. darkness: number;
  9398. /**
  9399. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9400. * 0 means strongest and 1 would means no shadow.
  9401. * @returns the darkness.
  9402. */
  9403. getDarkness(): number;
  9404. /**
  9405. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9406. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9407. * @returns the shadow generator allowing fluent coding.
  9408. */
  9409. setDarkness(darkness: number): ShadowGenerator;
  9410. private _transparencyShadow;
  9411. /** Gets or sets the ability to have transparent shadow */
  9412. transparencyShadow: boolean;
  9413. /**
  9414. * Sets the ability to have transparent shadow (boolean).
  9415. * @param transparent True if transparent else False
  9416. * @returns the shadow generator allowing fluent coding
  9417. */
  9418. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9419. private _shadowMap;
  9420. private _shadowMap2;
  9421. /**
  9422. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9423. * @returns The render target texture if present otherwise, null
  9424. */
  9425. getShadowMap(): Nullable<RenderTargetTexture>;
  9426. /**
  9427. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9428. * @returns The render target texture if the shadow map is present otherwise, null
  9429. */
  9430. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9431. /**
  9432. * Gets the class name of that object
  9433. * @returns "ShadowGenerator"
  9434. */
  9435. getClassName(): string;
  9436. /**
  9437. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9438. * @param mesh Mesh to add
  9439. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9440. * @returns the Shadow Generator itself
  9441. */
  9442. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9443. /**
  9444. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9445. * @param mesh Mesh to remove
  9446. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9447. * @returns the Shadow Generator itself
  9448. */
  9449. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9450. /**
  9451. * Controls the extent to which the shadows fade out at the edge of the frustum
  9452. * Used only by directionals and spots
  9453. */
  9454. frustumEdgeFalloff: number;
  9455. private _light;
  9456. /**
  9457. * Returns the associated light object.
  9458. * @returns the light generating the shadow
  9459. */
  9460. getLight(): IShadowLight;
  9461. /**
  9462. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9463. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9464. * It might on the other hand introduce peter panning.
  9465. */
  9466. forceBackFacesOnly: boolean;
  9467. private _scene;
  9468. private _lightDirection;
  9469. private _effect;
  9470. private _viewMatrix;
  9471. private _projectionMatrix;
  9472. private _transformMatrix;
  9473. private _cachedPosition;
  9474. private _cachedDirection;
  9475. private _cachedDefines;
  9476. private _currentRenderID;
  9477. private _boxBlurPostprocess;
  9478. private _kernelBlurXPostprocess;
  9479. private _kernelBlurYPostprocess;
  9480. private _blurPostProcesses;
  9481. private _mapSize;
  9482. private _currentFaceIndex;
  9483. private _currentFaceIndexCache;
  9484. private _textureType;
  9485. private _defaultTextureMatrix;
  9486. private _storedUniqueId;
  9487. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9488. /**
  9489. * Creates a ShadowGenerator object.
  9490. * A ShadowGenerator is the required tool to use the shadows.
  9491. * Each light casting shadows needs to use its own ShadowGenerator.
  9492. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9493. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9494. * @param light The light object generating the shadows.
  9495. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9496. */
  9497. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9498. private _initializeGenerator;
  9499. private _initializeShadowMap;
  9500. private _initializeBlurRTTAndPostProcesses;
  9501. private _renderForShadowMap;
  9502. private _renderSubMeshForShadowMap;
  9503. private _applyFilterValues;
  9504. /**
  9505. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9506. * @param onCompiled Callback triggered at the and of the effects compilation
  9507. * @param options Sets of optional options forcing the compilation with different modes
  9508. */
  9509. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9510. useInstances: boolean;
  9511. }>): void;
  9512. /**
  9513. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9514. * @param options Sets of optional options forcing the compilation with different modes
  9515. * @returns A promise that resolves when the compilation completes
  9516. */
  9517. forceCompilationAsync(options?: Partial<{
  9518. useInstances: boolean;
  9519. }>): Promise<void>;
  9520. /**
  9521. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9522. * @param subMesh The submesh we want to render in the shadow map
  9523. * @param useInstances Defines wether will draw in the map using instances
  9524. * @returns true if ready otherwise, false
  9525. */
  9526. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9527. /**
  9528. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9529. * @param defines Defines of the material we want to update
  9530. * @param lightIndex Index of the light in the enabled light list of the material
  9531. */
  9532. prepareDefines(defines: any, lightIndex: number): void;
  9533. /**
  9534. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9535. * defined in the generator but impacting the effect).
  9536. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9537. * @param effect The effect we are binfing the information for
  9538. */
  9539. bindShadowLight(lightIndex: string, effect: Effect): void;
  9540. /**
  9541. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9542. * (eq to shadow prjection matrix * light transform matrix)
  9543. * @returns The transform matrix used to create the shadow map
  9544. */
  9545. getTransformMatrix(): Matrix;
  9546. /**
  9547. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9548. * Cube and 2D textures for instance.
  9549. */
  9550. recreateShadowMap(): void;
  9551. private _disposeBlurPostProcesses;
  9552. private _disposeRTTandPostProcesses;
  9553. /**
  9554. * Disposes the ShadowGenerator.
  9555. * Returns nothing.
  9556. */
  9557. dispose(): void;
  9558. /**
  9559. * Serializes the shadow generator setup to a json object.
  9560. * @returns The serialized JSON object
  9561. */
  9562. serialize(): any;
  9563. /**
  9564. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9565. * @param parsedShadowGenerator The JSON object to parse
  9566. * @param scene The scene to create the shadow map for
  9567. * @returns The parsed shadow generator
  9568. */
  9569. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9570. }
  9571. }
  9572. declare module BABYLON {
  9573. /**
  9574. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9575. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9576. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9577. */
  9578. export abstract class Light extends Node {
  9579. /**
  9580. * Falloff Default: light is falling off following the material specification:
  9581. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9582. */
  9583. static readonly FALLOFF_DEFAULT: number;
  9584. /**
  9585. * Falloff Physical: light is falling off following the inverse squared distance law.
  9586. */
  9587. static readonly FALLOFF_PHYSICAL: number;
  9588. /**
  9589. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9590. * to enhance interoperability with other engines.
  9591. */
  9592. static readonly FALLOFF_GLTF: number;
  9593. /**
  9594. * Falloff Standard: light is falling off like in the standard material
  9595. * to enhance interoperability with other materials.
  9596. */
  9597. static readonly FALLOFF_STANDARD: number;
  9598. /**
  9599. * If every light affecting the material is in this lightmapMode,
  9600. * material.lightmapTexture adds or multiplies
  9601. * (depends on material.useLightmapAsShadowmap)
  9602. * after every other light calculations.
  9603. */
  9604. static readonly LIGHTMAP_DEFAULT: number;
  9605. /**
  9606. * material.lightmapTexture as only diffuse lighting from this light
  9607. * adds only specular lighting from this light
  9608. * adds dynamic shadows
  9609. */
  9610. static readonly LIGHTMAP_SPECULAR: number;
  9611. /**
  9612. * material.lightmapTexture as only lighting
  9613. * no light calculation from this light
  9614. * only adds dynamic shadows from this light
  9615. */
  9616. static readonly LIGHTMAP_SHADOWSONLY: number;
  9617. /**
  9618. * Each light type uses the default quantity according to its type:
  9619. * point/spot lights use luminous intensity
  9620. * directional lights use illuminance
  9621. */
  9622. static readonly INTENSITYMODE_AUTOMATIC: number;
  9623. /**
  9624. * lumen (lm)
  9625. */
  9626. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9627. /**
  9628. * candela (lm/sr)
  9629. */
  9630. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9631. /**
  9632. * lux (lm/m^2)
  9633. */
  9634. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9635. /**
  9636. * nit (cd/m^2)
  9637. */
  9638. static readonly INTENSITYMODE_LUMINANCE: number;
  9639. /**
  9640. * Light type const id of the point light.
  9641. */
  9642. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9643. /**
  9644. * Light type const id of the directional light.
  9645. */
  9646. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9647. /**
  9648. * Light type const id of the spot light.
  9649. */
  9650. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9651. /**
  9652. * Light type const id of the hemispheric light.
  9653. */
  9654. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9655. /**
  9656. * Diffuse gives the basic color to an object.
  9657. */
  9658. diffuse: Color3;
  9659. /**
  9660. * Specular produces a highlight color on an object.
  9661. * Note: This is note affecting PBR materials.
  9662. */
  9663. specular: Color3;
  9664. /**
  9665. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9666. * falling off base on range or angle.
  9667. * This can be set to any values in Light.FALLOFF_x.
  9668. *
  9669. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9670. * other types of materials.
  9671. */
  9672. falloffType: number;
  9673. /**
  9674. * Strength of the light.
  9675. * Note: By default it is define in the framework own unit.
  9676. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9677. */
  9678. intensity: number;
  9679. private _range;
  9680. protected _inverseSquaredRange: number;
  9681. /**
  9682. * Defines how far from the source the light is impacting in scene units.
  9683. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9684. */
  9685. /**
  9686. * Defines how far from the source the light is impacting in scene units.
  9687. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9688. */
  9689. range: number;
  9690. /**
  9691. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9692. * of light.
  9693. */
  9694. private _photometricScale;
  9695. private _intensityMode;
  9696. /**
  9697. * Gets the photometric scale used to interpret the intensity.
  9698. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9699. */
  9700. /**
  9701. * Sets the photometric scale used to interpret the intensity.
  9702. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9703. */
  9704. intensityMode: number;
  9705. private _radius;
  9706. /**
  9707. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9708. */
  9709. /**
  9710. * sets the light radius used by PBR Materials to simulate soft area lights.
  9711. */
  9712. radius: number;
  9713. private _renderPriority;
  9714. /**
  9715. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9716. * exceeding the number allowed of the materials.
  9717. */
  9718. renderPriority: number;
  9719. private _shadowEnabled;
  9720. /**
  9721. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9722. * the current shadow generator.
  9723. */
  9724. /**
  9725. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9726. * the current shadow generator.
  9727. */
  9728. shadowEnabled: boolean;
  9729. private _includedOnlyMeshes;
  9730. /**
  9731. * Gets the only meshes impacted by this light.
  9732. */
  9733. /**
  9734. * Sets the only meshes impacted by this light.
  9735. */
  9736. includedOnlyMeshes: AbstractMesh[];
  9737. private _excludedMeshes;
  9738. /**
  9739. * Gets the meshes not impacted by this light.
  9740. */
  9741. /**
  9742. * Sets the meshes not impacted by this light.
  9743. */
  9744. excludedMeshes: AbstractMesh[];
  9745. private _excludeWithLayerMask;
  9746. /**
  9747. * Gets the layer id use to find what meshes are not impacted by the light.
  9748. * Inactive if 0
  9749. */
  9750. /**
  9751. * Sets the layer id use to find what meshes are not impacted by the light.
  9752. * Inactive if 0
  9753. */
  9754. excludeWithLayerMask: number;
  9755. private _includeOnlyWithLayerMask;
  9756. /**
  9757. * Gets the layer id use to find what meshes are impacted by the light.
  9758. * Inactive if 0
  9759. */
  9760. /**
  9761. * Sets the layer id use to find what meshes are impacted by the light.
  9762. * Inactive if 0
  9763. */
  9764. includeOnlyWithLayerMask: number;
  9765. private _lightmapMode;
  9766. /**
  9767. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9768. */
  9769. /**
  9770. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9771. */
  9772. lightmapMode: number;
  9773. /**
  9774. * Shadow generator associted to the light.
  9775. * @hidden Internal use only.
  9776. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9777. /**
  9778. * @hidden Internal use only.
  9779. */ private _excludedMeshesIds: string[];
  9780. /**
  9781. * @hidden Internal use only.
  9782. */ private _includedOnlyMeshesIds: string[];
  9783. /**
  9784. * The current light unifom buffer.
  9785. * @hidden Internal use only.
  9786. */ private _uniformBuffer: UniformBuffer;
  9787. /**
  9788. * Creates a Light object in the scene.
  9789. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9790. * @param name The firendly name of the light
  9791. * @param scene The scene the light belongs too
  9792. */
  9793. constructor(name: string, scene: Scene);
  9794. protected abstract _buildUniformLayout(): void;
  9795. /**
  9796. * Sets the passed Effect "effect" with the Light information.
  9797. * @param effect The effect to update
  9798. * @param lightIndex The index of the light in the effect to update
  9799. * @returns The light
  9800. */
  9801. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9802. /**
  9803. * Sets the passed Effect "effect" with the Light information.
  9804. * @param effect The effect to update
  9805. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9806. * @returns The light
  9807. */
  9808. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9809. /**
  9810. * Returns the string "Light".
  9811. * @returns the class name
  9812. */
  9813. getClassName(): string;
  9814. /** @hidden */ protected readonly _isLight: boolean;
  9815. /**
  9816. * Converts the light information to a readable string for debug purpose.
  9817. * @param fullDetails Supports for multiple levels of logging within scene loading
  9818. * @returns the human readable light info
  9819. */
  9820. toString(fullDetails?: boolean): string;
  9821. /** @hidden */
  9822. protected _syncParentEnabledState(): void;
  9823. /**
  9824. * Set the enabled state of this node.
  9825. * @param value - the new enabled state
  9826. */
  9827. setEnabled(value: boolean): void;
  9828. /**
  9829. * Returns the Light associated shadow generator if any.
  9830. * @return the associated shadow generator.
  9831. */
  9832. getShadowGenerator(): Nullable<IShadowGenerator>;
  9833. /**
  9834. * Returns a Vector3, the absolute light position in the World.
  9835. * @returns the world space position of the light
  9836. */
  9837. getAbsolutePosition(): Vector3;
  9838. /**
  9839. * Specifies if the light will affect the passed mesh.
  9840. * @param mesh The mesh to test against the light
  9841. * @return true the mesh is affected otherwise, false.
  9842. */
  9843. canAffectMesh(mesh: AbstractMesh): boolean;
  9844. /**
  9845. * Sort function to order lights for rendering.
  9846. * @param a First Light object to compare to second.
  9847. * @param b Second Light object to compare first.
  9848. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9849. */
  9850. static CompareLightsPriority(a: Light, b: Light): number;
  9851. /**
  9852. * Releases resources associated with this node.
  9853. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9854. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9855. */
  9856. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9857. /**
  9858. * Returns the light type ID (integer).
  9859. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9860. */
  9861. getTypeID(): number;
  9862. /**
  9863. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9864. * @returns the scaled intensity in intensity mode unit
  9865. */
  9866. getScaledIntensity(): number;
  9867. /**
  9868. * Returns a new Light object, named "name", from the current one.
  9869. * @param name The name of the cloned light
  9870. * @returns the new created light
  9871. */
  9872. clone(name: string): Nullable<Light>;
  9873. /**
  9874. * Serializes the current light into a Serialization object.
  9875. * @returns the serialized object.
  9876. */
  9877. serialize(): any;
  9878. /**
  9879. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9880. * This new light is named "name" and added to the passed scene.
  9881. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9882. * @param name The friendly name of the light
  9883. * @param scene The scene the new light will belong to
  9884. * @returns the constructor function
  9885. */
  9886. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9887. /**
  9888. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9889. * @param parsedLight The JSON representation of the light
  9890. * @param scene The scene to create the parsed light in
  9891. * @returns the created light after parsing
  9892. */
  9893. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9894. private _hookArrayForExcluded;
  9895. private _hookArrayForIncludedOnly;
  9896. private _resyncMeshes;
  9897. /**
  9898. * Forces the meshes to update their light related information in their rendering used effects
  9899. * @hidden Internal Use Only
  9900. */ private _markMeshesAsLightDirty(): void;
  9901. /**
  9902. * Recomputes the cached photometric scale if needed.
  9903. */
  9904. private _computePhotometricScale;
  9905. /**
  9906. * Returns the Photometric Scale according to the light type and intensity mode.
  9907. */
  9908. private _getPhotometricScale;
  9909. /**
  9910. * Reorder the light in the scene according to their defined priority.
  9911. * @hidden Internal Use Only
  9912. */ private _reorderLightsInScene(): void;
  9913. /**
  9914. * Prepares the list of defines specific to the light type.
  9915. * @param defines the list of defines
  9916. * @param lightIndex defines the index of the light for the effect
  9917. */
  9918. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9919. }
  9920. }
  9921. declare module BABYLON {
  9922. /**
  9923. * Interface used to define Action
  9924. */
  9925. export interface IAction {
  9926. /**
  9927. * Trigger for the action
  9928. */
  9929. trigger: number;
  9930. /** Options of the trigger */
  9931. triggerOptions: any;
  9932. /**
  9933. * Gets the trigger parameters
  9934. * @returns the trigger parameters
  9935. */
  9936. getTriggerParameter(): any;
  9937. /**
  9938. * Internal only - executes current action event
  9939. * @hidden
  9940. */ private _executeCurrent(evt?: ActionEvent): void;
  9941. /**
  9942. * Serialize placeholder for child classes
  9943. * @param parent of child
  9944. * @returns the serialized object
  9945. */
  9946. serialize(parent: any): any;
  9947. /**
  9948. * Internal only
  9949. * @hidden
  9950. */ private _prepare(): void;
  9951. /**
  9952. * Internal only - manager for action
  9953. * @hidden
  9954. */ private _actionManager: AbstractActionManager;
  9955. /**
  9956. * Adds action to chain of actions, may be a DoNothingAction
  9957. * @param action defines the next action to execute
  9958. * @returns The action passed in
  9959. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9960. */
  9961. then(action: IAction): IAction;
  9962. }
  9963. /**
  9964. * The action to be carried out following a trigger
  9965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9966. */
  9967. export class Action implements IAction {
  9968. /** the trigger, with or without parameters, for the action */
  9969. triggerOptions: any;
  9970. /**
  9971. * Trigger for the action
  9972. */
  9973. trigger: number;
  9974. /**
  9975. * Internal only - manager for action
  9976. * @hidden
  9977. */ private _actionManager: ActionManager;
  9978. private _nextActiveAction;
  9979. private _child;
  9980. private _condition?;
  9981. private _triggerParameter;
  9982. /**
  9983. * An event triggered prior to action being executed.
  9984. */
  9985. onBeforeExecuteObservable: Observable<Action>;
  9986. /**
  9987. * Creates a new Action
  9988. * @param triggerOptions the trigger, with or without parameters, for the action
  9989. * @param condition an optional determinant of action
  9990. */
  9991. constructor(
  9992. /** the trigger, with or without parameters, for the action */
  9993. triggerOptions: any, condition?: Condition);
  9994. /**
  9995. * Internal only
  9996. * @hidden
  9997. */ private _prepare(): void;
  9998. /**
  9999. * Gets the trigger parameters
  10000. * @returns the trigger parameters
  10001. */
  10002. getTriggerParameter(): any;
  10003. /**
  10004. * Internal only - executes current action event
  10005. * @hidden
  10006. */ private _executeCurrent(evt?: ActionEvent): void;
  10007. /**
  10008. * Execute placeholder for child classes
  10009. * @param evt optional action event
  10010. */
  10011. execute(evt?: ActionEvent): void;
  10012. /**
  10013. * Skips to next active action
  10014. */
  10015. skipToNextActiveAction(): void;
  10016. /**
  10017. * Adds action to chain of actions, may be a DoNothingAction
  10018. * @param action defines the next action to execute
  10019. * @returns The action passed in
  10020. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10021. */
  10022. then(action: Action): Action;
  10023. /**
  10024. * Internal only
  10025. * @hidden
  10026. */ private _getProperty(propertyPath: string): string;
  10027. /**
  10028. * Internal only
  10029. * @hidden
  10030. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10031. /**
  10032. * Serialize placeholder for child classes
  10033. * @param parent of child
  10034. * @returns the serialized object
  10035. */
  10036. serialize(parent: any): any;
  10037. /**
  10038. * Internal only called by serialize
  10039. * @hidden
  10040. */
  10041. protected _serialize(serializedAction: any, parent?: any): any;
  10042. /**
  10043. * Internal only
  10044. * @hidden
  10045. */ private static _SerializeValueAsString: (value: any) => string;
  10046. /**
  10047. * Internal only
  10048. * @hidden
  10049. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10050. name: string;
  10051. targetType: string;
  10052. value: string;
  10053. };
  10054. }
  10055. }
  10056. declare module BABYLON {
  10057. /**
  10058. * A Condition applied to an Action
  10059. */
  10060. export class Condition {
  10061. /**
  10062. * Internal only - manager for action
  10063. * @hidden
  10064. */ private _actionManager: ActionManager;
  10065. /**
  10066. * Internal only
  10067. * @hidden
  10068. */ private _evaluationId: number;
  10069. /**
  10070. * Internal only
  10071. * @hidden
  10072. */ private _currentResult: boolean;
  10073. /**
  10074. * Creates a new Condition
  10075. * @param actionManager the manager of the action the condition is applied to
  10076. */
  10077. constructor(actionManager: ActionManager);
  10078. /**
  10079. * Check if the current condition is valid
  10080. * @returns a boolean
  10081. */
  10082. isValid(): boolean;
  10083. /**
  10084. * Internal only
  10085. * @hidden
  10086. */ private _getProperty(propertyPath: string): string;
  10087. /**
  10088. * Internal only
  10089. * @hidden
  10090. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10091. /**
  10092. * Serialize placeholder for child classes
  10093. * @returns the serialized object
  10094. */
  10095. serialize(): any;
  10096. /**
  10097. * Internal only
  10098. * @hidden
  10099. */
  10100. protected _serialize(serializedCondition: any): any;
  10101. }
  10102. /**
  10103. * Defines specific conditional operators as extensions of Condition
  10104. */
  10105. export class ValueCondition extends Condition {
  10106. /** path to specify the property of the target the conditional operator uses */
  10107. propertyPath: string;
  10108. /** the value compared by the conditional operator against the current value of the property */
  10109. value: any;
  10110. /** the conditional operator, default ValueCondition.IsEqual */
  10111. operator: number;
  10112. /**
  10113. * Internal only
  10114. * @hidden
  10115. */
  10116. private static _IsEqual;
  10117. /**
  10118. * Internal only
  10119. * @hidden
  10120. */
  10121. private static _IsDifferent;
  10122. /**
  10123. * Internal only
  10124. * @hidden
  10125. */
  10126. private static _IsGreater;
  10127. /**
  10128. * Internal only
  10129. * @hidden
  10130. */
  10131. private static _IsLesser;
  10132. /**
  10133. * returns the number for IsEqual
  10134. */
  10135. static readonly IsEqual: number;
  10136. /**
  10137. * Returns the number for IsDifferent
  10138. */
  10139. static readonly IsDifferent: number;
  10140. /**
  10141. * Returns the number for IsGreater
  10142. */
  10143. static readonly IsGreater: number;
  10144. /**
  10145. * Returns the number for IsLesser
  10146. */
  10147. static readonly IsLesser: number;
  10148. /**
  10149. * Internal only The action manager for the condition
  10150. * @hidden
  10151. */ private _actionManager: ActionManager;
  10152. /**
  10153. * Internal only
  10154. * @hidden
  10155. */
  10156. private _target;
  10157. /**
  10158. * Internal only
  10159. * @hidden
  10160. */
  10161. private _effectiveTarget;
  10162. /**
  10163. * Internal only
  10164. * @hidden
  10165. */
  10166. private _property;
  10167. /**
  10168. * Creates a new ValueCondition
  10169. * @param actionManager manager for the action the condition applies to
  10170. * @param target for the action
  10171. * @param propertyPath path to specify the property of the target the conditional operator uses
  10172. * @param value the value compared by the conditional operator against the current value of the property
  10173. * @param operator the conditional operator, default ValueCondition.IsEqual
  10174. */
  10175. constructor(actionManager: ActionManager, target: any,
  10176. /** path to specify the property of the target the conditional operator uses */
  10177. propertyPath: string,
  10178. /** the value compared by the conditional operator against the current value of the property */
  10179. value: any,
  10180. /** the conditional operator, default ValueCondition.IsEqual */
  10181. operator?: number);
  10182. /**
  10183. * Compares the given value with the property value for the specified conditional operator
  10184. * @returns the result of the comparison
  10185. */
  10186. isValid(): boolean;
  10187. /**
  10188. * Serialize the ValueCondition into a JSON compatible object
  10189. * @returns serialization object
  10190. */
  10191. serialize(): any;
  10192. /**
  10193. * Gets the name of the conditional operator for the ValueCondition
  10194. * @param operator the conditional operator
  10195. * @returns the name
  10196. */
  10197. static GetOperatorName(operator: number): string;
  10198. }
  10199. /**
  10200. * Defines a predicate condition as an extension of Condition
  10201. */
  10202. export class PredicateCondition extends Condition {
  10203. /** defines the predicate function used to validate the condition */
  10204. predicate: () => boolean;
  10205. /**
  10206. * Internal only - manager for action
  10207. * @hidden
  10208. */ private _actionManager: ActionManager;
  10209. /**
  10210. * Creates a new PredicateCondition
  10211. * @param actionManager manager for the action the condition applies to
  10212. * @param predicate defines the predicate function used to validate the condition
  10213. */
  10214. constructor(actionManager: ActionManager,
  10215. /** defines the predicate function used to validate the condition */
  10216. predicate: () => boolean);
  10217. /**
  10218. * @returns the validity of the predicate condition
  10219. */
  10220. isValid(): boolean;
  10221. }
  10222. /**
  10223. * Defines a state condition as an extension of Condition
  10224. */
  10225. export class StateCondition extends Condition {
  10226. /** Value to compare with target state */
  10227. value: string;
  10228. /**
  10229. * Internal only - manager for action
  10230. * @hidden
  10231. */ private _actionManager: ActionManager;
  10232. /**
  10233. * Internal only
  10234. * @hidden
  10235. */
  10236. private _target;
  10237. /**
  10238. * Creates a new StateCondition
  10239. * @param actionManager manager for the action the condition applies to
  10240. * @param target of the condition
  10241. * @param value to compare with target state
  10242. */
  10243. constructor(actionManager: ActionManager, target: any,
  10244. /** Value to compare with target state */
  10245. value: string);
  10246. /**
  10247. * Gets a boolean indicating if the current condition is met
  10248. * @returns the validity of the state
  10249. */
  10250. isValid(): boolean;
  10251. /**
  10252. * Serialize the StateCondition into a JSON compatible object
  10253. * @returns serialization object
  10254. */
  10255. serialize(): any;
  10256. }
  10257. }
  10258. declare module BABYLON {
  10259. /**
  10260. * This defines an action responsible to toggle a boolean once triggered.
  10261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10262. */
  10263. export class SwitchBooleanAction extends Action {
  10264. /**
  10265. * The path to the boolean property in the target object
  10266. */
  10267. propertyPath: string;
  10268. private _target;
  10269. private _effectiveTarget;
  10270. private _property;
  10271. /**
  10272. * Instantiate the action
  10273. * @param triggerOptions defines the trigger options
  10274. * @param target defines the object containing the boolean
  10275. * @param propertyPath defines the path to the boolean property in the target object
  10276. * @param condition defines the trigger related conditions
  10277. */
  10278. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10279. /** @hidden */ private _prepare(): void;
  10280. /**
  10281. * Execute the action toggle the boolean value.
  10282. */
  10283. execute(): void;
  10284. /**
  10285. * Serializes the actions and its related information.
  10286. * @param parent defines the object to serialize in
  10287. * @returns the serialized object
  10288. */
  10289. serialize(parent: any): any;
  10290. }
  10291. /**
  10292. * This defines an action responsible to set a the state field of the target
  10293. * to a desired value once triggered.
  10294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10295. */
  10296. export class SetStateAction extends Action {
  10297. /**
  10298. * The value to store in the state field.
  10299. */
  10300. value: string;
  10301. private _target;
  10302. /**
  10303. * Instantiate the action
  10304. * @param triggerOptions defines the trigger options
  10305. * @param target defines the object containing the state property
  10306. * @param value defines the value to store in the state field
  10307. * @param condition defines the trigger related conditions
  10308. */
  10309. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10310. /**
  10311. * Execute the action and store the value on the target state property.
  10312. */
  10313. execute(): void;
  10314. /**
  10315. * Serializes the actions and its related information.
  10316. * @param parent defines the object to serialize in
  10317. * @returns the serialized object
  10318. */
  10319. serialize(parent: any): any;
  10320. }
  10321. /**
  10322. * This defines an action responsible to set a property of the target
  10323. * to a desired value once triggered.
  10324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10325. */
  10326. export class SetValueAction extends Action {
  10327. /**
  10328. * The path of the property to set in the target.
  10329. */
  10330. propertyPath: string;
  10331. /**
  10332. * The value to set in the property
  10333. */
  10334. value: any;
  10335. private _target;
  10336. private _effectiveTarget;
  10337. private _property;
  10338. /**
  10339. * Instantiate the action
  10340. * @param triggerOptions defines the trigger options
  10341. * @param target defines the object containing the property
  10342. * @param propertyPath defines the path of the property to set in the target
  10343. * @param value defines the value to set in the property
  10344. * @param condition defines the trigger related conditions
  10345. */
  10346. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10347. /** @hidden */ private _prepare(): void;
  10348. /**
  10349. * Execute the action and set the targetted property to the desired value.
  10350. */
  10351. execute(): void;
  10352. /**
  10353. * Serializes the actions and its related information.
  10354. * @param parent defines the object to serialize in
  10355. * @returns the serialized object
  10356. */
  10357. serialize(parent: any): any;
  10358. }
  10359. /**
  10360. * This defines an action responsible to increment the target value
  10361. * to a desired value once triggered.
  10362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10363. */
  10364. export class IncrementValueAction extends Action {
  10365. /**
  10366. * The path of the property to increment in the target.
  10367. */
  10368. propertyPath: string;
  10369. /**
  10370. * The value we should increment the property by.
  10371. */
  10372. value: any;
  10373. private _target;
  10374. private _effectiveTarget;
  10375. private _property;
  10376. /**
  10377. * Instantiate the action
  10378. * @param triggerOptions defines the trigger options
  10379. * @param target defines the object containing the property
  10380. * @param propertyPath defines the path of the property to increment in the target
  10381. * @param value defines the value value we should increment the property by
  10382. * @param condition defines the trigger related conditions
  10383. */
  10384. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10385. /** @hidden */ private _prepare(): void;
  10386. /**
  10387. * Execute the action and increment the target of the value amount.
  10388. */
  10389. execute(): void;
  10390. /**
  10391. * Serializes the actions and its related information.
  10392. * @param parent defines the object to serialize in
  10393. * @returns the serialized object
  10394. */
  10395. serialize(parent: any): any;
  10396. }
  10397. /**
  10398. * This defines an action responsible to start an animation once triggered.
  10399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10400. */
  10401. export class PlayAnimationAction extends Action {
  10402. /**
  10403. * Where the animation should start (animation frame)
  10404. */
  10405. from: number;
  10406. /**
  10407. * Where the animation should stop (animation frame)
  10408. */
  10409. to: number;
  10410. /**
  10411. * Define if the animation should loop or stop after the first play.
  10412. */
  10413. loop?: boolean;
  10414. private _target;
  10415. /**
  10416. * Instantiate the action
  10417. * @param triggerOptions defines the trigger options
  10418. * @param target defines the target animation or animation name
  10419. * @param from defines from where the animation should start (animation frame)
  10420. * @param end defines where the animation should stop (animation frame)
  10421. * @param loop defines if the animation should loop or stop after the first play
  10422. * @param condition defines the trigger related conditions
  10423. */
  10424. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10425. /** @hidden */ private _prepare(): void;
  10426. /**
  10427. * Execute the action and play the animation.
  10428. */
  10429. execute(): void;
  10430. /**
  10431. * Serializes the actions and its related information.
  10432. * @param parent defines the object to serialize in
  10433. * @returns the serialized object
  10434. */
  10435. serialize(parent: any): any;
  10436. }
  10437. /**
  10438. * This defines an action responsible to stop an animation once triggered.
  10439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10440. */
  10441. export class StopAnimationAction extends Action {
  10442. private _target;
  10443. /**
  10444. * Instantiate the action
  10445. * @param triggerOptions defines the trigger options
  10446. * @param target defines the target animation or animation name
  10447. * @param condition defines the trigger related conditions
  10448. */
  10449. constructor(triggerOptions: any, target: any, condition?: Condition);
  10450. /** @hidden */ private _prepare(): void;
  10451. /**
  10452. * Execute the action and stop the animation.
  10453. */
  10454. execute(): void;
  10455. /**
  10456. * Serializes the actions and its related information.
  10457. * @param parent defines the object to serialize in
  10458. * @returns the serialized object
  10459. */
  10460. serialize(parent: any): any;
  10461. }
  10462. /**
  10463. * This defines an action responsible that does nothing once triggered.
  10464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10465. */
  10466. export class DoNothingAction extends Action {
  10467. /**
  10468. * Instantiate the action
  10469. * @param triggerOptions defines the trigger options
  10470. * @param condition defines the trigger related conditions
  10471. */
  10472. constructor(triggerOptions?: any, condition?: Condition);
  10473. /**
  10474. * Execute the action and do nothing.
  10475. */
  10476. execute(): void;
  10477. /**
  10478. * Serializes the actions and its related information.
  10479. * @param parent defines the object to serialize in
  10480. * @returns the serialized object
  10481. */
  10482. serialize(parent: any): any;
  10483. }
  10484. /**
  10485. * This defines an action responsible to trigger several actions once triggered.
  10486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10487. */
  10488. export class CombineAction extends Action {
  10489. /**
  10490. * The list of aggregated animations to run.
  10491. */
  10492. children: Action[];
  10493. /**
  10494. * Instantiate the action
  10495. * @param triggerOptions defines the trigger options
  10496. * @param children defines the list of aggregated animations to run
  10497. * @param condition defines the trigger related conditions
  10498. */
  10499. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10500. /** @hidden */ private _prepare(): void;
  10501. /**
  10502. * Execute the action and executes all the aggregated actions.
  10503. */
  10504. execute(evt: ActionEvent): void;
  10505. /**
  10506. * Serializes the actions and its related information.
  10507. * @param parent defines the object to serialize in
  10508. * @returns the serialized object
  10509. */
  10510. serialize(parent: any): any;
  10511. }
  10512. /**
  10513. * This defines an action responsible to run code (external event) once triggered.
  10514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10515. */
  10516. export class ExecuteCodeAction extends Action {
  10517. /**
  10518. * The callback function to run.
  10519. */
  10520. func: (evt: ActionEvent) => void;
  10521. /**
  10522. * Instantiate the action
  10523. * @param triggerOptions defines the trigger options
  10524. * @param func defines the callback function to run
  10525. * @param condition defines the trigger related conditions
  10526. */
  10527. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10528. /**
  10529. * Execute the action and run the attached code.
  10530. */
  10531. execute(evt: ActionEvent): void;
  10532. }
  10533. /**
  10534. * This defines an action responsible to set the parent property of the target once triggered.
  10535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10536. */
  10537. export class SetParentAction extends Action {
  10538. private _parent;
  10539. private _target;
  10540. /**
  10541. * Instantiate the action
  10542. * @param triggerOptions defines the trigger options
  10543. * @param target defines the target containing the parent property
  10544. * @param parent defines from where the animation should start (animation frame)
  10545. * @param condition defines the trigger related conditions
  10546. */
  10547. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10548. /** @hidden */ private _prepare(): void;
  10549. /**
  10550. * Execute the action and set the parent property.
  10551. */
  10552. execute(): void;
  10553. /**
  10554. * Serializes the actions and its related information.
  10555. * @param parent defines the object to serialize in
  10556. * @returns the serialized object
  10557. */
  10558. serialize(parent: any): any;
  10559. }
  10560. }
  10561. declare module BABYLON {
  10562. /**
  10563. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10564. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10565. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10566. */
  10567. export class ActionManager extends AbstractActionManager {
  10568. /**
  10569. * Nothing
  10570. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10571. */
  10572. static readonly NothingTrigger: number;
  10573. /**
  10574. * On pick
  10575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10576. */
  10577. static readonly OnPickTrigger: number;
  10578. /**
  10579. * On left pick
  10580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10581. */
  10582. static readonly OnLeftPickTrigger: number;
  10583. /**
  10584. * On right pick
  10585. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10586. */
  10587. static readonly OnRightPickTrigger: number;
  10588. /**
  10589. * On center pick
  10590. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10591. */
  10592. static readonly OnCenterPickTrigger: number;
  10593. /**
  10594. * On pick down
  10595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10596. */
  10597. static readonly OnPickDownTrigger: number;
  10598. /**
  10599. * On double pick
  10600. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10601. */
  10602. static readonly OnDoublePickTrigger: number;
  10603. /**
  10604. * On pick up
  10605. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10606. */
  10607. static readonly OnPickUpTrigger: number;
  10608. /**
  10609. * On pick out.
  10610. * This trigger will only be raised if you also declared a OnPickDown
  10611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10612. */
  10613. static readonly OnPickOutTrigger: number;
  10614. /**
  10615. * On long press
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10617. */
  10618. static readonly OnLongPressTrigger: number;
  10619. /**
  10620. * On pointer over
  10621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10622. */
  10623. static readonly OnPointerOverTrigger: number;
  10624. /**
  10625. * On pointer out
  10626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10627. */
  10628. static readonly OnPointerOutTrigger: number;
  10629. /**
  10630. * On every frame
  10631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10632. */
  10633. static readonly OnEveryFrameTrigger: number;
  10634. /**
  10635. * On intersection enter
  10636. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10637. */
  10638. static readonly OnIntersectionEnterTrigger: number;
  10639. /**
  10640. * On intersection exit
  10641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10642. */
  10643. static readonly OnIntersectionExitTrigger: number;
  10644. /**
  10645. * On key down
  10646. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10647. */
  10648. static readonly OnKeyDownTrigger: number;
  10649. /**
  10650. * On key up
  10651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10652. */
  10653. static readonly OnKeyUpTrigger: number;
  10654. private _scene;
  10655. /**
  10656. * Creates a new action manager
  10657. * @param scene defines the hosting scene
  10658. */
  10659. constructor(scene: Scene);
  10660. /**
  10661. * Releases all associated resources
  10662. */
  10663. dispose(): void;
  10664. /**
  10665. * Gets hosting scene
  10666. * @returns the hosting scene
  10667. */
  10668. getScene(): Scene;
  10669. /**
  10670. * Does this action manager handles actions of any of the given triggers
  10671. * @param triggers defines the triggers to be tested
  10672. * @return a boolean indicating whether one (or more) of the triggers is handled
  10673. */
  10674. hasSpecificTriggers(triggers: number[]): boolean;
  10675. /**
  10676. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10677. * speed.
  10678. * @param triggerA defines the trigger to be tested
  10679. * @param triggerB defines the trigger to be tested
  10680. * @return a boolean indicating whether one (or more) of the triggers is handled
  10681. */
  10682. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10683. /**
  10684. * Does this action manager handles actions of a given trigger
  10685. * @param trigger defines the trigger to be tested
  10686. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10687. * @return whether the trigger is handled
  10688. */
  10689. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10690. /**
  10691. * Does this action manager has pointer triggers
  10692. */
  10693. readonly hasPointerTriggers: boolean;
  10694. /**
  10695. * Does this action manager has pick triggers
  10696. */
  10697. readonly hasPickTriggers: boolean;
  10698. /**
  10699. * Registers an action to this action manager
  10700. * @param action defines the action to be registered
  10701. * @return the action amended (prepared) after registration
  10702. */
  10703. registerAction(action: IAction): Nullable<IAction>;
  10704. /**
  10705. * Unregisters an action to this action manager
  10706. * @param action defines the action to be unregistered
  10707. * @return a boolean indicating whether the action has been unregistered
  10708. */
  10709. unregisterAction(action: IAction): Boolean;
  10710. /**
  10711. * Process a specific trigger
  10712. * @param trigger defines the trigger to process
  10713. * @param evt defines the event details to be processed
  10714. */
  10715. processTrigger(trigger: number, evt?: IActionEvent): void;
  10716. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10717. /** @hidden */ private _getProperty(propertyPath: string): string;
  10718. /**
  10719. * Serialize this manager to a JSON object
  10720. * @param name defines the property name to store this manager
  10721. * @returns a JSON representation of this manager
  10722. */
  10723. serialize(name: string): any;
  10724. /**
  10725. * Creates a new ActionManager from a JSON data
  10726. * @param parsedActions defines the JSON data to read from
  10727. * @param object defines the hosting mesh
  10728. * @param scene defines the hosting scene
  10729. */
  10730. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10731. /**
  10732. * Get a trigger name by index
  10733. * @param trigger defines the trigger index
  10734. * @returns a trigger name
  10735. */
  10736. static GetTriggerName(trigger: number): string;
  10737. }
  10738. }
  10739. declare module BABYLON {
  10740. /**
  10741. * Class representing a ray with position and direction
  10742. */
  10743. export class Ray {
  10744. /** origin point */
  10745. origin: Vector3;
  10746. /** direction */
  10747. direction: Vector3;
  10748. /** length of the ray */
  10749. length: number;
  10750. private static readonly TmpVector3;
  10751. private _tmpRay;
  10752. /**
  10753. * Creates a new ray
  10754. * @param origin origin point
  10755. * @param direction direction
  10756. * @param length length of the ray
  10757. */
  10758. constructor(
  10759. /** origin point */
  10760. origin: Vector3,
  10761. /** direction */
  10762. direction: Vector3,
  10763. /** length of the ray */
  10764. length?: number);
  10765. /**
  10766. * Checks if the ray intersects a box
  10767. * @param minimum bound of the box
  10768. * @param maximum bound of the box
  10769. * @param intersectionTreshold extra extend to be added to the box in all direction
  10770. * @returns if the box was hit
  10771. */
  10772. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10773. /**
  10774. * Checks if the ray intersects a box
  10775. * @param box the bounding box to check
  10776. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10777. * @returns if the box was hit
  10778. */
  10779. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10780. /**
  10781. * If the ray hits a sphere
  10782. * @param sphere the bounding sphere to check
  10783. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10784. * @returns true if it hits the sphere
  10785. */
  10786. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10787. /**
  10788. * If the ray hits a triange
  10789. * @param vertex0 triangle vertex
  10790. * @param vertex1 triangle vertex
  10791. * @param vertex2 triangle vertex
  10792. * @returns intersection information if hit
  10793. */
  10794. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10795. /**
  10796. * Checks if ray intersects a plane
  10797. * @param plane the plane to check
  10798. * @returns the distance away it was hit
  10799. */
  10800. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10801. /**
  10802. * Calculate the intercept of a ray on a given axis
  10803. * @param axis to check 'x' | 'y' | 'z'
  10804. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10805. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10806. */
  10807. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10808. /**
  10809. * Checks if ray intersects a mesh
  10810. * @param mesh the mesh to check
  10811. * @param fastCheck if only the bounding box should checked
  10812. * @returns picking info of the intersecton
  10813. */
  10814. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10815. /**
  10816. * Checks if ray intersects a mesh
  10817. * @param meshes the meshes to check
  10818. * @param fastCheck if only the bounding box should checked
  10819. * @param results array to store result in
  10820. * @returns Array of picking infos
  10821. */
  10822. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10823. private _comparePickingInfo;
  10824. private static smallnum;
  10825. private static rayl;
  10826. /**
  10827. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10828. * @param sega the first point of the segment to test the intersection against
  10829. * @param segb the second point of the segment to test the intersection against
  10830. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10831. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10832. */
  10833. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10834. /**
  10835. * Update the ray from viewport position
  10836. * @param x position
  10837. * @param y y position
  10838. * @param viewportWidth viewport width
  10839. * @param viewportHeight viewport height
  10840. * @param world world matrix
  10841. * @param view view matrix
  10842. * @param projection projection matrix
  10843. * @returns this ray updated
  10844. */
  10845. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10846. /**
  10847. * Creates a ray with origin and direction of 0,0,0
  10848. * @returns the new ray
  10849. */
  10850. static Zero(): Ray;
  10851. /**
  10852. * Creates a new ray from screen space and viewport
  10853. * @param x position
  10854. * @param y y position
  10855. * @param viewportWidth viewport width
  10856. * @param viewportHeight viewport height
  10857. * @param world world matrix
  10858. * @param view view matrix
  10859. * @param projection projection matrix
  10860. * @returns new ray
  10861. */
  10862. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10863. /**
  10864. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10865. * transformed to the given world matrix.
  10866. * @param origin The origin point
  10867. * @param end The end point
  10868. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10869. * @returns the new ray
  10870. */
  10871. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10872. /**
  10873. * Transforms a ray by a matrix
  10874. * @param ray ray to transform
  10875. * @param matrix matrix to apply
  10876. * @returns the resulting new ray
  10877. */
  10878. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10879. /**
  10880. * Transforms a ray by a matrix
  10881. * @param ray ray to transform
  10882. * @param matrix matrix to apply
  10883. * @param result ray to store result in
  10884. */
  10885. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10886. /**
  10887. * Unproject a ray from screen space to object space
  10888. * @param sourceX defines the screen space x coordinate to use
  10889. * @param sourceY defines the screen space y coordinate to use
  10890. * @param viewportWidth defines the current width of the viewport
  10891. * @param viewportHeight defines the current height of the viewport
  10892. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10893. * @param view defines the view matrix to use
  10894. * @param projection defines the projection matrix to use
  10895. */
  10896. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10897. }
  10898. /**
  10899. * Type used to define predicate used to select faces when a mesh intersection is detected
  10900. */
  10901. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10902. interface Scene {
  10903. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  10904. /** @hidden */ private _cachedRayForTransform: Ray;
  10905. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  10906. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10907. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10908. }
  10909. }
  10910. declare module BABYLON {
  10911. /**
  10912. * Groups all the scene component constants in one place to ease maintenance.
  10913. * @hidden
  10914. */
  10915. export class SceneComponentConstants {
  10916. static readonly NAME_EFFECTLAYER: string;
  10917. static readonly NAME_LAYER: string;
  10918. static readonly NAME_LENSFLARESYSTEM: string;
  10919. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10920. static readonly NAME_PARTICLESYSTEM: string;
  10921. static readonly NAME_GAMEPAD: string;
  10922. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10923. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10924. static readonly NAME_DEPTHRENDERER: string;
  10925. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10926. static readonly NAME_SPRITE: string;
  10927. static readonly NAME_OUTLINERENDERER: string;
  10928. static readonly NAME_PROCEDURALTEXTURE: string;
  10929. static readonly NAME_SHADOWGENERATOR: string;
  10930. static readonly NAME_OCTREE: string;
  10931. static readonly NAME_PHYSICSENGINE: string;
  10932. static readonly NAME_AUDIO: string;
  10933. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10934. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10935. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10936. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10937. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10938. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10939. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10940. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10941. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10942. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10943. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10944. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10945. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10946. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10947. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10948. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10949. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10950. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10951. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10952. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10953. static readonly STEP_AFTERRENDER_AUDIO: number;
  10954. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10955. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10956. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10957. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10958. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10959. static readonly STEP_POINTERMOVE_SPRITE: number;
  10960. static readonly STEP_POINTERDOWN_SPRITE: number;
  10961. static readonly STEP_POINTERUP_SPRITE: number;
  10962. }
  10963. /**
  10964. * This represents a scene component.
  10965. *
  10966. * This is used to decouple the dependency the scene is having on the different workloads like
  10967. * layers, post processes...
  10968. */
  10969. export interface ISceneComponent {
  10970. /**
  10971. * The name of the component. Each component must have a unique name.
  10972. */
  10973. name: string;
  10974. /**
  10975. * The scene the component belongs to.
  10976. */
  10977. scene: Scene;
  10978. /**
  10979. * Register the component to one instance of a scene.
  10980. */
  10981. register(): void;
  10982. /**
  10983. * Rebuilds the elements related to this component in case of
  10984. * context lost for instance.
  10985. */
  10986. rebuild(): void;
  10987. /**
  10988. * Disposes the component and the associated ressources.
  10989. */
  10990. dispose(): void;
  10991. }
  10992. /**
  10993. * This represents a SERIALIZABLE scene component.
  10994. *
  10995. * This extends Scene Component to add Serialization methods on top.
  10996. */
  10997. export interface ISceneSerializableComponent extends ISceneComponent {
  10998. /**
  10999. * Adds all the elements from the container to the scene
  11000. * @param container the container holding the elements
  11001. */
  11002. addFromContainer(container: AbstractScene): void;
  11003. /**
  11004. * Removes all the elements in the container from the scene
  11005. * @param container contains the elements to remove
  11006. * @param dispose if the removed element should be disposed (default: false)
  11007. */
  11008. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11009. /**
  11010. * Serializes the component data to the specified json object
  11011. * @param serializationObject The object to serialize to
  11012. */
  11013. serialize(serializationObject: any): void;
  11014. }
  11015. /**
  11016. * Strong typing of a Mesh related stage step action
  11017. */
  11018. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11019. /**
  11020. * Strong typing of a Evaluate Sub Mesh related stage step action
  11021. */
  11022. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11023. /**
  11024. * Strong typing of a Active Mesh related stage step action
  11025. */
  11026. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11027. /**
  11028. * Strong typing of a Camera related stage step action
  11029. */
  11030. export type CameraStageAction = (camera: Camera) => void;
  11031. /**
  11032. * Strong typing of a Camera Frame buffer related stage step action
  11033. */
  11034. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11035. /**
  11036. * Strong typing of a Render Target related stage step action
  11037. */
  11038. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11039. /**
  11040. * Strong typing of a RenderingGroup related stage step action
  11041. */
  11042. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11043. /**
  11044. * Strong typing of a Mesh Render related stage step action
  11045. */
  11046. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11047. /**
  11048. * Strong typing of a simple stage step action
  11049. */
  11050. export type SimpleStageAction = () => void;
  11051. /**
  11052. * Strong typing of a render target action.
  11053. */
  11054. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11055. /**
  11056. * Strong typing of a pointer move action.
  11057. */
  11058. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11059. /**
  11060. * Strong typing of a pointer up/down action.
  11061. */
  11062. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11063. /**
  11064. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11065. * @hidden
  11066. */
  11067. export class Stage<T extends Function> extends Array<{
  11068. index: number;
  11069. component: ISceneComponent;
  11070. action: T;
  11071. }> {
  11072. /**
  11073. * Hide ctor from the rest of the world.
  11074. * @param items The items to add.
  11075. */
  11076. private constructor();
  11077. /**
  11078. * Creates a new Stage.
  11079. * @returns A new instance of a Stage
  11080. */
  11081. static Create<T extends Function>(): Stage<T>;
  11082. /**
  11083. * Registers a step in an ordered way in the targeted stage.
  11084. * @param index Defines the position to register the step in
  11085. * @param component Defines the component attached to the step
  11086. * @param action Defines the action to launch during the step
  11087. */
  11088. registerStep(index: number, component: ISceneComponent, action: T): void;
  11089. /**
  11090. * Clears all the steps from the stage.
  11091. */
  11092. clear(): void;
  11093. }
  11094. }
  11095. declare module BABYLON {
  11096. interface Scene {
  11097. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11098. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11099. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11100. /**
  11101. * All of the sprite managers added to this scene
  11102. * @see http://doc.babylonjs.com/babylon101/sprites
  11103. */
  11104. spriteManagers: Array<ISpriteManager>;
  11105. /**
  11106. * An event triggered when sprites rendering is about to start
  11107. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11108. */
  11109. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11110. /**
  11111. * An event triggered when sprites rendering is done
  11112. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11113. */
  11114. onAfterSpritesRenderingObservable: Observable<Scene>;
  11115. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11116. /** Launch a ray to try to pick a sprite in the scene
  11117. * @param x position on screen
  11118. * @param y position on screen
  11119. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11120. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11121. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11122. * @returns a PickingInfo
  11123. */
  11124. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11125. /** Use the given ray to pick a sprite in the scene
  11126. * @param ray The ray (in world space) to use to pick meshes
  11127. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11128. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11129. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11130. * @returns a PickingInfo
  11131. */
  11132. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11133. /** @hidden */ private _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11134. /** Launch a ray to try to pick sprites in the scene
  11135. * @param x position on screen
  11136. * @param y position on screen
  11137. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11138. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11139. * @returns a PickingInfo array
  11140. */
  11141. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11142. /** Use the given ray to pick sprites in the scene
  11143. * @param ray The ray (in world space) to use to pick meshes
  11144. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11145. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11146. * @returns a PickingInfo array
  11147. */
  11148. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11149. /**
  11150. * Force the sprite under the pointer
  11151. * @param sprite defines the sprite to use
  11152. */
  11153. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11154. /**
  11155. * Gets the sprite under the pointer
  11156. * @returns a Sprite or null if no sprite is under the pointer
  11157. */
  11158. getPointerOverSprite(): Nullable<Sprite>;
  11159. }
  11160. /**
  11161. * Defines the sprite scene component responsible to manage sprites
  11162. * in a given scene.
  11163. */
  11164. export class SpriteSceneComponent implements ISceneComponent {
  11165. /**
  11166. * The component name helpfull to identify the component in the list of scene components.
  11167. */
  11168. readonly name: string;
  11169. /**
  11170. * The scene the component belongs to.
  11171. */
  11172. scene: Scene;
  11173. /** @hidden */
  11174. private _spritePredicate;
  11175. /**
  11176. * Creates a new instance of the component for the given scene
  11177. * @param scene Defines the scene to register the component in
  11178. */
  11179. constructor(scene: Scene);
  11180. /**
  11181. * Registers the component in a given scene
  11182. */
  11183. register(): void;
  11184. /**
  11185. * Rebuilds the elements related to this component in case of
  11186. * context lost for instance.
  11187. */
  11188. rebuild(): void;
  11189. /**
  11190. * Disposes the component and the associated ressources.
  11191. */
  11192. dispose(): void;
  11193. private _pickSpriteButKeepRay;
  11194. private _pointerMove;
  11195. private _pointerDown;
  11196. private _pointerUp;
  11197. }
  11198. }
  11199. declare module BABYLON {
  11200. /** @hidden */
  11201. export var fogFragmentDeclaration: {
  11202. name: string;
  11203. shader: string;
  11204. };
  11205. }
  11206. declare module BABYLON {
  11207. /** @hidden */
  11208. export var fogFragment: {
  11209. name: string;
  11210. shader: string;
  11211. };
  11212. }
  11213. declare module BABYLON {
  11214. /** @hidden */
  11215. export var spritesPixelShader: {
  11216. name: string;
  11217. shader: string;
  11218. };
  11219. }
  11220. declare module BABYLON {
  11221. /** @hidden */
  11222. export var fogVertexDeclaration: {
  11223. name: string;
  11224. shader: string;
  11225. };
  11226. }
  11227. declare module BABYLON {
  11228. /** @hidden */
  11229. export var spritesVertexShader: {
  11230. name: string;
  11231. shader: string;
  11232. };
  11233. }
  11234. declare module BABYLON {
  11235. /**
  11236. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11237. */
  11238. export interface ISpriteManager extends IDisposable {
  11239. /**
  11240. * Restricts the camera to viewing objects with the same layerMask.
  11241. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11242. */
  11243. layerMask: number;
  11244. /**
  11245. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11246. */
  11247. isPickable: boolean;
  11248. /**
  11249. * Specifies the rendering group id for this mesh (0 by default)
  11250. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11251. */
  11252. renderingGroupId: number;
  11253. /**
  11254. * Defines the list of sprites managed by the manager.
  11255. */
  11256. sprites: Array<Sprite>;
  11257. /**
  11258. * Tests the intersection of a sprite with a specific ray.
  11259. * @param ray The ray we are sending to test the collision
  11260. * @param camera The camera space we are sending rays in
  11261. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11262. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11263. * @returns picking info or null.
  11264. */
  11265. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11266. /**
  11267. * Intersects the sprites with a ray
  11268. * @param ray defines the ray to intersect with
  11269. * @param camera defines the current active camera
  11270. * @param predicate defines a predicate used to select candidate sprites
  11271. * @returns null if no hit or a PickingInfo array
  11272. */
  11273. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11274. /**
  11275. * Renders the list of sprites on screen.
  11276. */
  11277. render(): void;
  11278. }
  11279. /**
  11280. * Class used to manage multiple sprites on the same spritesheet
  11281. * @see http://doc.babylonjs.com/babylon101/sprites
  11282. */
  11283. export class SpriteManager implements ISpriteManager {
  11284. /** defines the manager's name */
  11285. name: string;
  11286. /** Gets the list of sprites */
  11287. sprites: Sprite[];
  11288. /** Gets or sets the rendering group id (0 by default) */
  11289. renderingGroupId: number;
  11290. /** Gets or sets camera layer mask */
  11291. layerMask: number;
  11292. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11293. fogEnabled: boolean;
  11294. /** Gets or sets a boolean indicating if the sprites are pickable */
  11295. isPickable: boolean;
  11296. /** Defines the default width of a cell in the spritesheet */
  11297. cellWidth: number;
  11298. /** Defines the default height of a cell in the spritesheet */
  11299. cellHeight: number;
  11300. /** Associative array from JSON sprite data file */
  11301. private _cellData;
  11302. /** Array of sprite names from JSON sprite data file */
  11303. private _spriteMap;
  11304. /** True when packed cell data from JSON file is ready*/
  11305. private _packedAndReady;
  11306. /**
  11307. * An event triggered when the manager is disposed.
  11308. */
  11309. onDisposeObservable: Observable<SpriteManager>;
  11310. private _onDisposeObserver;
  11311. /**
  11312. * Callback called when the manager is disposed
  11313. */
  11314. onDispose: () => void;
  11315. private _capacity;
  11316. private _fromPacked;
  11317. private _spriteTexture;
  11318. private _epsilon;
  11319. private _scene;
  11320. private _vertexData;
  11321. private _buffer;
  11322. private _vertexBuffers;
  11323. private _indexBuffer;
  11324. private _effectBase;
  11325. private _effectFog;
  11326. /**
  11327. * Gets or sets the spritesheet texture
  11328. */
  11329. texture: Texture;
  11330. /**
  11331. * Creates a new sprite manager
  11332. * @param name defines the manager's name
  11333. * @param imgUrl defines the sprite sheet url
  11334. * @param capacity defines the maximum allowed number of sprites
  11335. * @param cellSize defines the size of a sprite cell
  11336. * @param scene defines the hosting scene
  11337. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11338. * @param samplingMode defines the smapling mode to use with spritesheet
  11339. * @param fromPacked set to false; do not alter
  11340. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11341. */
  11342. constructor(
  11343. /** defines the manager's name */
  11344. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11345. private _makePacked;
  11346. private _appendSpriteVertex;
  11347. /**
  11348. * Intersects the sprites with a ray
  11349. * @param ray defines the ray to intersect with
  11350. * @param camera defines the current active camera
  11351. * @param predicate defines a predicate used to select candidate sprites
  11352. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11353. * @returns null if no hit or a PickingInfo
  11354. */
  11355. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11356. /**
  11357. * Intersects the sprites with a ray
  11358. * @param ray defines the ray to intersect with
  11359. * @param camera defines the current active camera
  11360. * @param predicate defines a predicate used to select candidate sprites
  11361. * @returns null if no hit or a PickingInfo array
  11362. */
  11363. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11364. /**
  11365. * Render all child sprites
  11366. */
  11367. render(): void;
  11368. /**
  11369. * Release associated resources
  11370. */
  11371. dispose(): void;
  11372. }
  11373. }
  11374. declare module BABYLON {
  11375. /**
  11376. * Class used to represent a sprite
  11377. * @see http://doc.babylonjs.com/babylon101/sprites
  11378. */
  11379. export class Sprite {
  11380. /** defines the name */
  11381. name: string;
  11382. /** Gets or sets the current world position */
  11383. position: Vector3;
  11384. /** Gets or sets the main color */
  11385. color: Color4;
  11386. /** Gets or sets the width */
  11387. width: number;
  11388. /** Gets or sets the height */
  11389. height: number;
  11390. /** Gets or sets rotation angle */
  11391. angle: number;
  11392. /** Gets or sets the cell index in the sprite sheet */
  11393. cellIndex: number;
  11394. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11395. cellRef: string;
  11396. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11397. invertU: number;
  11398. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11399. invertV: number;
  11400. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11401. disposeWhenFinishedAnimating: boolean;
  11402. /** Gets the list of attached animations */
  11403. animations: Animation[];
  11404. /** Gets or sets a boolean indicating if the sprite can be picked */
  11405. isPickable: boolean;
  11406. /**
  11407. * Gets or sets the associated action manager
  11408. */
  11409. actionManager: Nullable<ActionManager>;
  11410. private _animationStarted;
  11411. private _loopAnimation;
  11412. private _fromIndex;
  11413. private _toIndex;
  11414. private _delay;
  11415. private _direction;
  11416. private _manager;
  11417. private _time;
  11418. private _onAnimationEnd;
  11419. /**
  11420. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11421. */
  11422. isVisible: boolean;
  11423. /**
  11424. * Gets or sets the sprite size
  11425. */
  11426. size: number;
  11427. /**
  11428. * Creates a new Sprite
  11429. * @param name defines the name
  11430. * @param manager defines the manager
  11431. */
  11432. constructor(
  11433. /** defines the name */
  11434. name: string, manager: ISpriteManager);
  11435. /**
  11436. * Starts an animation
  11437. * @param from defines the initial key
  11438. * @param to defines the end key
  11439. * @param loop defines if the animation must loop
  11440. * @param delay defines the start delay (in ms)
  11441. * @param onAnimationEnd defines a callback to call when animation ends
  11442. */
  11443. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11444. /** Stops current animation (if any) */
  11445. stopAnimation(): void;
  11446. /** @hidden */ private _animate(deltaTime: number): void;
  11447. /** Release associated resources */
  11448. dispose(): void;
  11449. }
  11450. }
  11451. declare module BABYLON {
  11452. /**
  11453. * Information about the result of picking within a scene
  11454. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11455. */
  11456. export class PickingInfo {
  11457. /** @hidden */ private _pickingUnavailable: boolean;
  11458. /**
  11459. * If the pick collided with an object
  11460. */
  11461. hit: boolean;
  11462. /**
  11463. * Distance away where the pick collided
  11464. */
  11465. distance: number;
  11466. /**
  11467. * The location of pick collision
  11468. */
  11469. pickedPoint: Nullable<Vector3>;
  11470. /**
  11471. * The mesh corresponding the the pick collision
  11472. */
  11473. pickedMesh: Nullable<AbstractMesh>;
  11474. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11475. bu: number;
  11476. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11477. bv: number;
  11478. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11479. faceId: number;
  11480. /** Id of the the submesh that was picked */
  11481. subMeshId: number;
  11482. /** If a sprite was picked, this will be the sprite the pick collided with */
  11483. pickedSprite: Nullable<Sprite>;
  11484. /**
  11485. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11486. */
  11487. originMesh: Nullable<AbstractMesh>;
  11488. /**
  11489. * The ray that was used to perform the picking.
  11490. */
  11491. ray: Nullable<Ray>;
  11492. /**
  11493. * Gets the normal correspodning to the face the pick collided with
  11494. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11495. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11496. * @returns The normal correspodning to the face the pick collided with
  11497. */
  11498. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11499. /**
  11500. * Gets the texture coordinates of where the pick occured
  11501. * @returns the vector containing the coordnates of the texture
  11502. */
  11503. getTextureCoordinates(): Nullable<Vector2>;
  11504. }
  11505. }
  11506. declare module BABYLON {
  11507. /**
  11508. * Gather the list of pointer event types as constants.
  11509. */
  11510. export class PointerEventTypes {
  11511. /**
  11512. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11513. */
  11514. static readonly POINTERDOWN: number;
  11515. /**
  11516. * The pointerup event is fired when a pointer is no longer active.
  11517. */
  11518. static readonly POINTERUP: number;
  11519. /**
  11520. * The pointermove event is fired when a pointer changes coordinates.
  11521. */
  11522. static readonly POINTERMOVE: number;
  11523. /**
  11524. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11525. */
  11526. static readonly POINTERWHEEL: number;
  11527. /**
  11528. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11529. */
  11530. static readonly POINTERPICK: number;
  11531. /**
  11532. * The pointertap event is fired when a the object has been touched and released without drag.
  11533. */
  11534. static readonly POINTERTAP: number;
  11535. /**
  11536. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11537. */
  11538. static readonly POINTERDOUBLETAP: number;
  11539. }
  11540. /**
  11541. * Base class of pointer info types.
  11542. */
  11543. export class PointerInfoBase {
  11544. /**
  11545. * Defines the type of event (PointerEventTypes)
  11546. */
  11547. type: number;
  11548. /**
  11549. * Defines the related dom event
  11550. */
  11551. event: PointerEvent | MouseWheelEvent;
  11552. /**
  11553. * Instantiates the base class of pointers info.
  11554. * @param type Defines the type of event (PointerEventTypes)
  11555. * @param event Defines the related dom event
  11556. */
  11557. constructor(
  11558. /**
  11559. * Defines the type of event (PointerEventTypes)
  11560. */
  11561. type: number,
  11562. /**
  11563. * Defines the related dom event
  11564. */
  11565. event: PointerEvent | MouseWheelEvent);
  11566. }
  11567. /**
  11568. * This class is used to store pointer related info for the onPrePointerObservable event.
  11569. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11570. */
  11571. export class PointerInfoPre extends PointerInfoBase {
  11572. /**
  11573. * Ray from a pointer if availible (eg. 6dof controller)
  11574. */
  11575. ray: Nullable<Ray>;
  11576. /**
  11577. * Defines the local position of the pointer on the canvas.
  11578. */
  11579. localPosition: Vector2;
  11580. /**
  11581. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11582. */
  11583. skipOnPointerObservable: boolean;
  11584. /**
  11585. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11586. * @param type Defines the type of event (PointerEventTypes)
  11587. * @param event Defines the related dom event
  11588. * @param localX Defines the local x coordinates of the pointer when the event occured
  11589. * @param localY Defines the local y coordinates of the pointer when the event occured
  11590. */
  11591. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11592. }
  11593. /**
  11594. * This type contains all the data related to a pointer event in Babylon.js.
  11595. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11596. */
  11597. export class PointerInfo extends PointerInfoBase {
  11598. /**
  11599. * Defines the picking info associated to the info (if any)\
  11600. */
  11601. pickInfo: Nullable<PickingInfo>;
  11602. /**
  11603. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11604. * @param type Defines the type of event (PointerEventTypes)
  11605. * @param event Defines the related dom event
  11606. * @param pickInfo Defines the picking info associated to the info (if any)\
  11607. */
  11608. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11609. /**
  11610. * Defines the picking info associated to the info (if any)\
  11611. */
  11612. pickInfo: Nullable<PickingInfo>);
  11613. }
  11614. /**
  11615. * Data relating to a touch event on the screen.
  11616. */
  11617. export interface PointerTouch {
  11618. /**
  11619. * X coordinate of touch.
  11620. */
  11621. x: number;
  11622. /**
  11623. * Y coordinate of touch.
  11624. */
  11625. y: number;
  11626. /**
  11627. * Id of touch. Unique for each finger.
  11628. */
  11629. pointerId: number;
  11630. /**
  11631. * Event type passed from DOM.
  11632. */
  11633. type: any;
  11634. }
  11635. }
  11636. declare module BABYLON {
  11637. /**
  11638. * Manage the mouse inputs to control the movement of a free camera.
  11639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11640. */
  11641. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11642. /**
  11643. * Define if touch is enabled in the mouse input
  11644. */
  11645. touchEnabled: boolean;
  11646. /**
  11647. * Defines the camera the input is attached to.
  11648. */
  11649. camera: FreeCamera;
  11650. /**
  11651. * Defines the buttons associated with the input to handle camera move.
  11652. */
  11653. buttons: number[];
  11654. /**
  11655. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11656. */
  11657. angularSensibility: number;
  11658. private _pointerInput;
  11659. private _onMouseMove;
  11660. private _observer;
  11661. private previousPosition;
  11662. /**
  11663. * Observable for when a pointer move event occurs containing the move offset
  11664. */
  11665. onPointerMovedObservable: Observable<{
  11666. offsetX: number;
  11667. offsetY: number;
  11668. }>;
  11669. /**
  11670. * @hidden
  11671. * If the camera should be rotated automatically based on pointer movement
  11672. */ private _allowCameraRotation: boolean;
  11673. /**
  11674. * Manage the mouse inputs to control the movement of a free camera.
  11675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11676. * @param touchEnabled Defines if touch is enabled or not
  11677. */
  11678. constructor(
  11679. /**
  11680. * Define if touch is enabled in the mouse input
  11681. */
  11682. touchEnabled?: boolean);
  11683. /**
  11684. * Attach the input controls to a specific dom element to get the input from.
  11685. * @param element Defines the element the controls should be listened from
  11686. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11687. */
  11688. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11689. /**
  11690. * Called on JS contextmenu event.
  11691. * Override this method to provide functionality.
  11692. */
  11693. protected onContextMenu(evt: PointerEvent): void;
  11694. /**
  11695. * Detach the current controls from the specified dom element.
  11696. * @param element Defines the element to stop listening the inputs from
  11697. */
  11698. detachControl(element: Nullable<HTMLElement>): void;
  11699. /**
  11700. * Gets the class name of the current intput.
  11701. * @returns the class name
  11702. */
  11703. getClassName(): string;
  11704. /**
  11705. * Get the friendly name associated with the input class.
  11706. * @returns the input friendly name
  11707. */
  11708. getSimpleName(): string;
  11709. }
  11710. }
  11711. declare module BABYLON {
  11712. /**
  11713. * Manage the touch inputs to control the movement of a free camera.
  11714. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11715. */
  11716. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11717. /**
  11718. * Defines the camera the input is attached to.
  11719. */
  11720. camera: FreeCamera;
  11721. /**
  11722. * Defines the touch sensibility for rotation.
  11723. * The higher the faster.
  11724. */
  11725. touchAngularSensibility: number;
  11726. /**
  11727. * Defines the touch sensibility for move.
  11728. * The higher the faster.
  11729. */
  11730. touchMoveSensibility: number;
  11731. private _offsetX;
  11732. private _offsetY;
  11733. private _pointerPressed;
  11734. private _pointerInput;
  11735. private _observer;
  11736. private _onLostFocus;
  11737. /**
  11738. * Attach the input controls to a specific dom element to get the input from.
  11739. * @param element Defines the element the controls should be listened from
  11740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11741. */
  11742. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11743. /**
  11744. * Detach the current controls from the specified dom element.
  11745. * @param element Defines the element to stop listening the inputs from
  11746. */
  11747. detachControl(element: Nullable<HTMLElement>): void;
  11748. /**
  11749. * Update the current camera state depending on the inputs that have been used this frame.
  11750. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11751. */
  11752. checkInputs(): void;
  11753. /**
  11754. * Gets the class name of the current intput.
  11755. * @returns the class name
  11756. */
  11757. getClassName(): string;
  11758. /**
  11759. * Get the friendly name associated with the input class.
  11760. * @returns the input friendly name
  11761. */
  11762. getSimpleName(): string;
  11763. }
  11764. }
  11765. declare module BABYLON {
  11766. /**
  11767. * Default Inputs manager for the FreeCamera.
  11768. * It groups all the default supported inputs for ease of use.
  11769. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11770. */
  11771. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11772. /**
  11773. * @hidden
  11774. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11775. /**
  11776. * Instantiates a new FreeCameraInputsManager.
  11777. * @param camera Defines the camera the inputs belong to
  11778. */
  11779. constructor(camera: FreeCamera);
  11780. /**
  11781. * Add keyboard input support to the input manager.
  11782. * @returns the current input manager
  11783. */
  11784. addKeyboard(): FreeCameraInputsManager;
  11785. /**
  11786. * Add mouse input support to the input manager.
  11787. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11788. * @returns the current input manager
  11789. */
  11790. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11791. /**
  11792. * Removes the mouse input support from the manager
  11793. * @returns the current input manager
  11794. */
  11795. removeMouse(): FreeCameraInputsManager;
  11796. /**
  11797. * Add touch input support to the input manager.
  11798. * @returns the current input manager
  11799. */
  11800. addTouch(): FreeCameraInputsManager;
  11801. /**
  11802. * Remove all attached input methods from a camera
  11803. */
  11804. clear(): void;
  11805. }
  11806. }
  11807. declare module BABYLON {
  11808. /**
  11809. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11810. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11811. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11812. */
  11813. export class FreeCamera extends TargetCamera {
  11814. /**
  11815. * Define the collision ellipsoid of the camera.
  11816. * This is helpful to simulate a camera body like the player body around the camera
  11817. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11818. */
  11819. ellipsoid: Vector3;
  11820. /**
  11821. * Define an offset for the position of the ellipsoid around the camera.
  11822. * This can be helpful to determine the center of the body near the gravity center of the body
  11823. * instead of its head.
  11824. */
  11825. ellipsoidOffset: Vector3;
  11826. /**
  11827. * Enable or disable collisions of the camera with the rest of the scene objects.
  11828. */
  11829. checkCollisions: boolean;
  11830. /**
  11831. * Enable or disable gravity on the camera.
  11832. */
  11833. applyGravity: boolean;
  11834. /**
  11835. * Define the input manager associated to the camera.
  11836. */
  11837. inputs: FreeCameraInputsManager;
  11838. /**
  11839. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11840. * Higher values reduce sensitivity.
  11841. */
  11842. /**
  11843. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11844. * Higher values reduce sensitivity.
  11845. */
  11846. angularSensibility: number;
  11847. /**
  11848. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11849. */
  11850. keysUp: number[];
  11851. /**
  11852. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11853. */
  11854. keysDown: number[];
  11855. /**
  11856. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11857. */
  11858. keysLeft: number[];
  11859. /**
  11860. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11861. */
  11862. keysRight: number[];
  11863. /**
  11864. * Event raised when the camera collide with a mesh in the scene.
  11865. */
  11866. onCollide: (collidedMesh: AbstractMesh) => void;
  11867. private _collider;
  11868. private _needMoveForGravity;
  11869. private _oldPosition;
  11870. private _diffPosition;
  11871. private _newPosition;
  11872. /** @hidden */ private _localDirection: Vector3;
  11873. /** @hidden */ private _transformedDirection: Vector3;
  11874. /**
  11875. * Instantiates a Free Camera.
  11876. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11877. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11878. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11879. * @param name Define the name of the camera in the scene
  11880. * @param position Define the start position of the camera in the scene
  11881. * @param scene Define the scene the camera belongs to
  11882. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11883. */
  11884. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11885. /**
  11886. * Attached controls to the current camera.
  11887. * @param element Defines the element the controls should be listened from
  11888. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11889. */
  11890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11891. /**
  11892. * Detach the current controls from the camera.
  11893. * The camera will stop reacting to inputs.
  11894. * @param element Defines the element to stop listening the inputs from
  11895. */
  11896. detachControl(element: HTMLElement): void;
  11897. private _collisionMask;
  11898. /**
  11899. * Define a collision mask to limit the list of object the camera can collide with
  11900. */
  11901. collisionMask: number;
  11902. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  11903. private _onCollisionPositionChange;
  11904. /** @hidden */ private _checkInputs(): void;
  11905. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  11906. /** @hidden */ private _updatePosition(): void;
  11907. /**
  11908. * Destroy the camera and release the current resources hold by it.
  11909. */
  11910. dispose(): void;
  11911. /**
  11912. * Gets the current object class name.
  11913. * @return the class name
  11914. */
  11915. getClassName(): string;
  11916. }
  11917. }
  11918. declare module BABYLON {
  11919. /**
  11920. * Represents a gamepad control stick position
  11921. */
  11922. export class StickValues {
  11923. /**
  11924. * The x component of the control stick
  11925. */
  11926. x: number;
  11927. /**
  11928. * The y component of the control stick
  11929. */
  11930. y: number;
  11931. /**
  11932. * Initializes the gamepad x and y control stick values
  11933. * @param x The x component of the gamepad control stick value
  11934. * @param y The y component of the gamepad control stick value
  11935. */
  11936. constructor(
  11937. /**
  11938. * The x component of the control stick
  11939. */
  11940. x: number,
  11941. /**
  11942. * The y component of the control stick
  11943. */
  11944. y: number);
  11945. }
  11946. /**
  11947. * An interface which manages callbacks for gamepad button changes
  11948. */
  11949. export interface GamepadButtonChanges {
  11950. /**
  11951. * Called when a gamepad has been changed
  11952. */
  11953. changed: boolean;
  11954. /**
  11955. * Called when a gamepad press event has been triggered
  11956. */
  11957. pressChanged: boolean;
  11958. /**
  11959. * Called when a touch event has been triggered
  11960. */
  11961. touchChanged: boolean;
  11962. /**
  11963. * Called when a value has changed
  11964. */
  11965. valueChanged: boolean;
  11966. }
  11967. /**
  11968. * Represents a gamepad
  11969. */
  11970. export class Gamepad {
  11971. /**
  11972. * The id of the gamepad
  11973. */
  11974. id: string;
  11975. /**
  11976. * The index of the gamepad
  11977. */
  11978. index: number;
  11979. /**
  11980. * The browser gamepad
  11981. */
  11982. browserGamepad: any;
  11983. /**
  11984. * Specifies what type of gamepad this represents
  11985. */
  11986. type: number;
  11987. private _leftStick;
  11988. private _rightStick;
  11989. /** @hidden */ private _isConnected: boolean;
  11990. private _leftStickAxisX;
  11991. private _leftStickAxisY;
  11992. private _rightStickAxisX;
  11993. private _rightStickAxisY;
  11994. /**
  11995. * Triggered when the left control stick has been changed
  11996. */
  11997. private _onleftstickchanged;
  11998. /**
  11999. * Triggered when the right control stick has been changed
  12000. */
  12001. private _onrightstickchanged;
  12002. /**
  12003. * Represents a gamepad controller
  12004. */
  12005. static GAMEPAD: number;
  12006. /**
  12007. * Represents a generic controller
  12008. */
  12009. static GENERIC: number;
  12010. /**
  12011. * Represents an XBox controller
  12012. */
  12013. static XBOX: number;
  12014. /**
  12015. * Represents a pose-enabled controller
  12016. */
  12017. static POSE_ENABLED: number;
  12018. /**
  12019. * Represents an Dual Shock controller
  12020. */
  12021. static DUALSHOCK: number;
  12022. /**
  12023. * Specifies whether the left control stick should be Y-inverted
  12024. */
  12025. protected _invertLeftStickY: boolean;
  12026. /**
  12027. * Specifies if the gamepad has been connected
  12028. */
  12029. readonly isConnected: boolean;
  12030. /**
  12031. * Initializes the gamepad
  12032. * @param id The id of the gamepad
  12033. * @param index The index of the gamepad
  12034. * @param browserGamepad The browser gamepad
  12035. * @param leftStickX The x component of the left joystick
  12036. * @param leftStickY The y component of the left joystick
  12037. * @param rightStickX The x component of the right joystick
  12038. * @param rightStickY The y component of the right joystick
  12039. */
  12040. constructor(
  12041. /**
  12042. * The id of the gamepad
  12043. */
  12044. id: string,
  12045. /**
  12046. * The index of the gamepad
  12047. */
  12048. index: number,
  12049. /**
  12050. * The browser gamepad
  12051. */
  12052. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12053. /**
  12054. * Callback triggered when the left joystick has changed
  12055. * @param callback
  12056. */
  12057. onleftstickchanged(callback: (values: StickValues) => void): void;
  12058. /**
  12059. * Callback triggered when the right joystick has changed
  12060. * @param callback
  12061. */
  12062. onrightstickchanged(callback: (values: StickValues) => void): void;
  12063. /**
  12064. * Gets the left joystick
  12065. */
  12066. /**
  12067. * Sets the left joystick values
  12068. */
  12069. leftStick: StickValues;
  12070. /**
  12071. * Gets the right joystick
  12072. */
  12073. /**
  12074. * Sets the right joystick value
  12075. */
  12076. rightStick: StickValues;
  12077. /**
  12078. * Updates the gamepad joystick positions
  12079. */
  12080. update(): void;
  12081. /**
  12082. * Disposes the gamepad
  12083. */
  12084. dispose(): void;
  12085. }
  12086. /**
  12087. * Represents a generic gamepad
  12088. */
  12089. export class GenericPad extends Gamepad {
  12090. private _buttons;
  12091. private _onbuttondown;
  12092. private _onbuttonup;
  12093. /**
  12094. * Observable triggered when a button has been pressed
  12095. */
  12096. onButtonDownObservable: Observable<number>;
  12097. /**
  12098. * Observable triggered when a button has been released
  12099. */
  12100. onButtonUpObservable: Observable<number>;
  12101. /**
  12102. * Callback triggered when a button has been pressed
  12103. * @param callback Called when a button has been pressed
  12104. */
  12105. onbuttondown(callback: (buttonPressed: number) => void): void;
  12106. /**
  12107. * Callback triggered when a button has been released
  12108. * @param callback Called when a button has been released
  12109. */
  12110. onbuttonup(callback: (buttonReleased: number) => void): void;
  12111. /**
  12112. * Initializes the generic gamepad
  12113. * @param id The id of the generic gamepad
  12114. * @param index The index of the generic gamepad
  12115. * @param browserGamepad The browser gamepad
  12116. */
  12117. constructor(id: string, index: number, browserGamepad: any);
  12118. private _setButtonValue;
  12119. /**
  12120. * Updates the generic gamepad
  12121. */
  12122. update(): void;
  12123. /**
  12124. * Disposes the generic gamepad
  12125. */
  12126. dispose(): void;
  12127. }
  12128. }
  12129. declare module BABYLON {
  12130. interface Engine {
  12131. /**
  12132. * Creates a raw texture
  12133. * @param data defines the data to store in the texture
  12134. * @param width defines the width of the texture
  12135. * @param height defines the height of the texture
  12136. * @param format defines the format of the data
  12137. * @param generateMipMaps defines if the engine should generate the mip levels
  12138. * @param invertY defines if data must be stored with Y axis inverted
  12139. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12140. * @param compression defines the compression used (null by default)
  12141. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12142. * @returns the raw texture inside an InternalTexture
  12143. */
  12144. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12145. /**
  12146. * Update a raw texture
  12147. * @param texture defines the texture to update
  12148. * @param data defines the data to store in the texture
  12149. * @param format defines the format of the data
  12150. * @param invertY defines if data must be stored with Y axis inverted
  12151. */
  12152. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12153. /**
  12154. * Update a raw texture
  12155. * @param texture defines the texture to update
  12156. * @param data defines the data to store in the texture
  12157. * @param format defines the format of the data
  12158. * @param invertY defines if data must be stored with Y axis inverted
  12159. * @param compression defines the compression used (null by default)
  12160. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12161. */
  12162. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12163. /**
  12164. * Creates a new raw cube texture
  12165. * @param data defines the array of data to use to create each face
  12166. * @param size defines the size of the textures
  12167. * @param format defines the format of the data
  12168. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12169. * @param generateMipMaps defines if the engine should generate the mip levels
  12170. * @param invertY defines if data must be stored with Y axis inverted
  12171. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12172. * @param compression defines the compression used (null by default)
  12173. * @returns the cube texture as an InternalTexture
  12174. */
  12175. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12176. /**
  12177. * Update a raw cube texture
  12178. * @param texture defines the texture to udpdate
  12179. * @param data defines the data to store
  12180. * @param format defines the data format
  12181. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12182. * @param invertY defines if data must be stored with Y axis inverted
  12183. */
  12184. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12185. /**
  12186. * Update a raw cube texture
  12187. * @param texture defines the texture to udpdate
  12188. * @param data defines the data to store
  12189. * @param format defines the data format
  12190. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12191. * @param invertY defines if data must be stored with Y axis inverted
  12192. * @param compression defines the compression used (null by default)
  12193. */
  12194. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12195. /**
  12196. * Update a raw cube texture
  12197. * @param texture defines the texture to udpdate
  12198. * @param data defines the data to store
  12199. * @param format defines the data format
  12200. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12201. * @param invertY defines if data must be stored with Y axis inverted
  12202. * @param compression defines the compression used (null by default)
  12203. * @param level defines which level of the texture to update
  12204. */
  12205. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12206. /**
  12207. * Creates a new raw cube texture from a specified url
  12208. * @param url defines the url where the data is located
  12209. * @param scene defines the current scene
  12210. * @param size defines the size of the textures
  12211. * @param format defines the format of the data
  12212. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12213. * @param noMipmap defines if the engine should avoid generating the mip levels
  12214. * @param callback defines a callback used to extract texture data from loaded data
  12215. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12216. * @param onLoad defines a callback called when texture is loaded
  12217. * @param onError defines a callback called if there is an error
  12218. * @returns the cube texture as an InternalTexture
  12219. */
  12220. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12221. /**
  12222. * Creates a new raw cube texture from a specified url
  12223. * @param url defines the url where the data is located
  12224. * @param scene defines the current scene
  12225. * @param size defines the size of the textures
  12226. * @param format defines the format of the data
  12227. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12228. * @param noMipmap defines if the engine should avoid generating the mip levels
  12229. * @param callback defines a callback used to extract texture data from loaded data
  12230. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12231. * @param onLoad defines a callback called when texture is loaded
  12232. * @param onError defines a callback called if there is an error
  12233. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12234. * @param invertY defines if data must be stored with Y axis inverted
  12235. * @returns the cube texture as an InternalTexture
  12236. */
  12237. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12238. /**
  12239. * Creates a new raw 3D texture
  12240. * @param data defines the data used to create the texture
  12241. * @param width defines the width of the texture
  12242. * @param height defines the height of the texture
  12243. * @param depth defines the depth of the texture
  12244. * @param format defines the format of the texture
  12245. * @param generateMipMaps defines if the engine must generate mip levels
  12246. * @param invertY defines if data must be stored with Y axis inverted
  12247. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12248. * @param compression defines the compressed used (can be null)
  12249. * @param textureType defines the compressed used (can be null)
  12250. * @returns a new raw 3D texture (stored in an InternalTexture)
  12251. */
  12252. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12253. /**
  12254. * Update a raw 3D texture
  12255. * @param texture defines the texture to update
  12256. * @param data defines the data to store
  12257. * @param format defines the data format
  12258. * @param invertY defines if data must be stored with Y axis inverted
  12259. */
  12260. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12261. /**
  12262. * Update a raw 3D texture
  12263. * @param texture defines the texture to update
  12264. * @param data defines the data to store
  12265. * @param format defines the data format
  12266. * @param invertY defines if data must be stored with Y axis inverted
  12267. * @param compression defines the used compression (can be null)
  12268. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12269. */
  12270. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12271. }
  12272. }
  12273. declare module BABYLON {
  12274. /**
  12275. * Raw texture can help creating a texture directly from an array of data.
  12276. * This can be super useful if you either get the data from an uncompressed source or
  12277. * if you wish to create your texture pixel by pixel.
  12278. */
  12279. export class RawTexture extends Texture {
  12280. /**
  12281. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12282. */
  12283. format: number;
  12284. private _engine;
  12285. /**
  12286. * Instantiates a new RawTexture.
  12287. * Raw texture can help creating a texture directly from an array of data.
  12288. * This can be super useful if you either get the data from an uncompressed source or
  12289. * if you wish to create your texture pixel by pixel.
  12290. * @param data define the array of data to use to create the texture
  12291. * @param width define the width of the texture
  12292. * @param height define the height of the texture
  12293. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12294. * @param scene define the scene the texture belongs to
  12295. * @param generateMipMaps define whether mip maps should be generated or not
  12296. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12297. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12298. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12299. */
  12300. constructor(data: ArrayBufferView, width: number, height: number,
  12301. /**
  12302. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12303. */
  12304. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12305. /**
  12306. * Updates the texture underlying data.
  12307. * @param data Define the new data of the texture
  12308. */
  12309. update(data: ArrayBufferView): void;
  12310. /**
  12311. * Creates a luminance texture from some data.
  12312. * @param data Define the texture data
  12313. * @param width Define the width of the texture
  12314. * @param height Define the height of the texture
  12315. * @param scene Define the scene the texture belongs to
  12316. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12317. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12318. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12319. * @returns the luminance texture
  12320. */
  12321. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12322. /**
  12323. * Creates a luminance alpha texture from some data.
  12324. * @param data Define the texture data
  12325. * @param width Define the width of the texture
  12326. * @param height Define the height of the texture
  12327. * @param scene Define the scene the texture belongs to
  12328. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12329. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12330. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12331. * @returns the luminance alpha texture
  12332. */
  12333. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12334. /**
  12335. * Creates an alpha texture from some data.
  12336. * @param data Define the texture data
  12337. * @param width Define the width of the texture
  12338. * @param height Define the height of the texture
  12339. * @param scene Define the scene the texture belongs to
  12340. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12341. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12342. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12343. * @returns the alpha texture
  12344. */
  12345. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12346. /**
  12347. * Creates a RGB texture from some data.
  12348. * @param data Define the texture data
  12349. * @param width Define the width of the texture
  12350. * @param height Define the height of the texture
  12351. * @param scene Define the scene the texture belongs to
  12352. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12353. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12354. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12355. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12356. * @returns the RGB alpha texture
  12357. */
  12358. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12359. /**
  12360. * Creates a RGBA texture from some data.
  12361. * @param data Define the texture data
  12362. * @param width Define the width of the texture
  12363. * @param height Define the height of the texture
  12364. * @param scene Define the scene the texture belongs to
  12365. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12366. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12367. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12368. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12369. * @returns the RGBA texture
  12370. */
  12371. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12372. /**
  12373. * Creates a R texture from some data.
  12374. * @param data Define the texture data
  12375. * @param width Define the width of the texture
  12376. * @param height Define the height of the texture
  12377. * @param scene Define the scene the texture belongs to
  12378. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12379. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12380. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12381. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12382. * @returns the R texture
  12383. */
  12384. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12385. }
  12386. }
  12387. declare module BABYLON {
  12388. /**
  12389. * Interface for the size containing width and height
  12390. */
  12391. export interface ISize {
  12392. /**
  12393. * Width
  12394. */
  12395. width: number;
  12396. /**
  12397. * Heighht
  12398. */
  12399. height: number;
  12400. }
  12401. /**
  12402. * Size containing widht and height
  12403. */
  12404. export class Size implements ISize {
  12405. /**
  12406. * Width
  12407. */
  12408. width: number;
  12409. /**
  12410. * Height
  12411. */
  12412. height: number;
  12413. /**
  12414. * Creates a Size object from the given width and height (floats).
  12415. * @param width width of the new size
  12416. * @param height height of the new size
  12417. */
  12418. constructor(width: number, height: number);
  12419. /**
  12420. * Returns a string with the Size width and height
  12421. * @returns a string with the Size width and height
  12422. */
  12423. toString(): string;
  12424. /**
  12425. * "Size"
  12426. * @returns the string "Size"
  12427. */
  12428. getClassName(): string;
  12429. /**
  12430. * Returns the Size hash code.
  12431. * @returns a hash code for a unique width and height
  12432. */
  12433. getHashCode(): number;
  12434. /**
  12435. * Updates the current size from the given one.
  12436. * @param src the given size
  12437. */
  12438. copyFrom(src: Size): void;
  12439. /**
  12440. * Updates in place the current Size from the given floats.
  12441. * @param width width of the new size
  12442. * @param height height of the new size
  12443. * @returns the updated Size.
  12444. */
  12445. copyFromFloats(width: number, height: number): Size;
  12446. /**
  12447. * Updates in place the current Size from the given floats.
  12448. * @param width width to set
  12449. * @param height height to set
  12450. * @returns the updated Size.
  12451. */
  12452. set(width: number, height: number): Size;
  12453. /**
  12454. * Multiplies the width and height by numbers
  12455. * @param w factor to multiple the width by
  12456. * @param h factor to multiple the height by
  12457. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12458. */
  12459. multiplyByFloats(w: number, h: number): Size;
  12460. /**
  12461. * Clones the size
  12462. * @returns a new Size copied from the given one.
  12463. */
  12464. clone(): Size;
  12465. /**
  12466. * True if the current Size and the given one width and height are strictly equal.
  12467. * @param other the other size to compare against
  12468. * @returns True if the current Size and the given one width and height are strictly equal.
  12469. */
  12470. equals(other: Size): boolean;
  12471. /**
  12472. * The surface of the Size : width * height (float).
  12473. */
  12474. readonly surface: number;
  12475. /**
  12476. * Create a new size of zero
  12477. * @returns a new Size set to (0.0, 0.0)
  12478. */
  12479. static Zero(): Size;
  12480. /**
  12481. * Sums the width and height of two sizes
  12482. * @param otherSize size to add to this size
  12483. * @returns a new Size set as the addition result of the current Size and the given one.
  12484. */
  12485. add(otherSize: Size): Size;
  12486. /**
  12487. * Subtracts the width and height of two
  12488. * @param otherSize size to subtract to this size
  12489. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12490. */
  12491. subtract(otherSize: Size): Size;
  12492. /**
  12493. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12494. * @param start starting size to lerp between
  12495. * @param end end size to lerp between
  12496. * @param amount amount to lerp between the start and end values
  12497. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12498. */
  12499. static Lerp(start: Size, end: Size, amount: number): Size;
  12500. }
  12501. }
  12502. declare module BABYLON {
  12503. /**
  12504. * Defines a runtime animation
  12505. */
  12506. export class RuntimeAnimation {
  12507. private _events;
  12508. /**
  12509. * The current frame of the runtime animation
  12510. */
  12511. private _currentFrame;
  12512. /**
  12513. * The animation used by the runtime animation
  12514. */
  12515. private _animation;
  12516. /**
  12517. * The target of the runtime animation
  12518. */
  12519. private _target;
  12520. /**
  12521. * The initiating animatable
  12522. */
  12523. private _host;
  12524. /**
  12525. * The original value of the runtime animation
  12526. */
  12527. private _originalValue;
  12528. /**
  12529. * The original blend value of the runtime animation
  12530. */
  12531. private _originalBlendValue;
  12532. /**
  12533. * The offsets cache of the runtime animation
  12534. */
  12535. private _offsetsCache;
  12536. /**
  12537. * The high limits cache of the runtime animation
  12538. */
  12539. private _highLimitsCache;
  12540. /**
  12541. * Specifies if the runtime animation has been stopped
  12542. */
  12543. private _stopped;
  12544. /**
  12545. * The blending factor of the runtime animation
  12546. */
  12547. private _blendingFactor;
  12548. /**
  12549. * The BabylonJS scene
  12550. */
  12551. private _scene;
  12552. /**
  12553. * The current value of the runtime animation
  12554. */
  12555. private _currentValue;
  12556. /** @hidden */ private _animationState: _IAnimationState;
  12557. /**
  12558. * The active target of the runtime animation
  12559. */
  12560. private _activeTargets;
  12561. private _currentActiveTarget;
  12562. private _directTarget;
  12563. /**
  12564. * The target path of the runtime animation
  12565. */
  12566. private _targetPath;
  12567. /**
  12568. * The weight of the runtime animation
  12569. */
  12570. private _weight;
  12571. /**
  12572. * The ratio offset of the runtime animation
  12573. */
  12574. private _ratioOffset;
  12575. /**
  12576. * The previous delay of the runtime animation
  12577. */
  12578. private _previousDelay;
  12579. /**
  12580. * The previous ratio of the runtime animation
  12581. */
  12582. private _previousRatio;
  12583. private _enableBlending;
  12584. private _keys;
  12585. private _minFrame;
  12586. private _maxFrame;
  12587. private _minValue;
  12588. private _maxValue;
  12589. private _targetIsArray;
  12590. /**
  12591. * Gets the current frame of the runtime animation
  12592. */
  12593. readonly currentFrame: number;
  12594. /**
  12595. * Gets the weight of the runtime animation
  12596. */
  12597. readonly weight: number;
  12598. /**
  12599. * Gets the current value of the runtime animation
  12600. */
  12601. readonly currentValue: any;
  12602. /**
  12603. * Gets the target path of the runtime animation
  12604. */
  12605. readonly targetPath: string;
  12606. /**
  12607. * Gets the actual target of the runtime animation
  12608. */
  12609. readonly target: any;
  12610. /** @hidden */ private _onLoop: () => void;
  12611. /**
  12612. * Create a new RuntimeAnimation object
  12613. * @param target defines the target of the animation
  12614. * @param animation defines the source animation object
  12615. * @param scene defines the hosting scene
  12616. * @param host defines the initiating Animatable
  12617. */
  12618. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12619. private _preparePath;
  12620. /**
  12621. * Gets the animation from the runtime animation
  12622. */
  12623. readonly animation: Animation;
  12624. /**
  12625. * Resets the runtime animation to the beginning
  12626. * @param restoreOriginal defines whether to restore the target property to the original value
  12627. */
  12628. reset(restoreOriginal?: boolean): void;
  12629. /**
  12630. * Specifies if the runtime animation is stopped
  12631. * @returns Boolean specifying if the runtime animation is stopped
  12632. */
  12633. isStopped(): boolean;
  12634. /**
  12635. * Disposes of the runtime animation
  12636. */
  12637. dispose(): void;
  12638. /**
  12639. * Apply the interpolated value to the target
  12640. * @param currentValue defines the value computed by the animation
  12641. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12642. */
  12643. setValue(currentValue: any, weight: number): void;
  12644. private _getOriginalValues;
  12645. private _setValue;
  12646. /**
  12647. * Gets the loop pmode of the runtime animation
  12648. * @returns Loop Mode
  12649. */
  12650. private _getCorrectLoopMode;
  12651. /**
  12652. * Move the current animation to a given frame
  12653. * @param frame defines the frame to move to
  12654. */
  12655. goToFrame(frame: number): void;
  12656. /**
  12657. * @hidden Internal use only
  12658. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12659. /**
  12660. * Execute the current animation
  12661. * @param delay defines the delay to add to the current frame
  12662. * @param from defines the lower bound of the animation range
  12663. * @param to defines the upper bound of the animation range
  12664. * @param loop defines if the current animation must loop
  12665. * @param speedRatio defines the current speed ratio
  12666. * @param weight defines the weight of the animation (default is -1 so no weight)
  12667. * @param onLoop optional callback called when animation loops
  12668. * @returns a boolean indicating if the animation is running
  12669. */
  12670. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12671. }
  12672. }
  12673. declare module BABYLON {
  12674. /**
  12675. * Class used to store an actual running animation
  12676. */
  12677. export class Animatable {
  12678. /** defines the target object */
  12679. target: any;
  12680. /** defines the starting frame number (default is 0) */
  12681. fromFrame: number;
  12682. /** defines the ending frame number (default is 100) */
  12683. toFrame: number;
  12684. /** defines if the animation must loop (default is false) */
  12685. loopAnimation: boolean;
  12686. /** defines a callback to call when animation ends if it is not looping */
  12687. onAnimationEnd?: (() => void) | null | undefined;
  12688. /** defines a callback to call when animation loops */
  12689. onAnimationLoop?: (() => void) | null | undefined;
  12690. private _localDelayOffset;
  12691. private _pausedDelay;
  12692. private _runtimeAnimations;
  12693. private _paused;
  12694. private _scene;
  12695. private _speedRatio;
  12696. private _weight;
  12697. private _syncRoot;
  12698. /**
  12699. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12700. * This will only apply for non looping animation (default is true)
  12701. */
  12702. disposeOnEnd: boolean;
  12703. /**
  12704. * Gets a boolean indicating if the animation has started
  12705. */
  12706. animationStarted: boolean;
  12707. /**
  12708. * Observer raised when the animation ends
  12709. */
  12710. onAnimationEndObservable: Observable<Animatable>;
  12711. /**
  12712. * Observer raised when the animation loops
  12713. */
  12714. onAnimationLoopObservable: Observable<Animatable>;
  12715. /**
  12716. * Gets the root Animatable used to synchronize and normalize animations
  12717. */
  12718. readonly syncRoot: Nullable<Animatable>;
  12719. /**
  12720. * Gets the current frame of the first RuntimeAnimation
  12721. * Used to synchronize Animatables
  12722. */
  12723. readonly masterFrame: number;
  12724. /**
  12725. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12726. */
  12727. weight: number;
  12728. /**
  12729. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12730. */
  12731. speedRatio: number;
  12732. /**
  12733. * Creates a new Animatable
  12734. * @param scene defines the hosting scene
  12735. * @param target defines the target object
  12736. * @param fromFrame defines the starting frame number (default is 0)
  12737. * @param toFrame defines the ending frame number (default is 100)
  12738. * @param loopAnimation defines if the animation must loop (default is false)
  12739. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12740. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12741. * @param animations defines a group of animation to add to the new Animatable
  12742. * @param onAnimationLoop defines a callback to call when animation loops
  12743. */
  12744. constructor(scene: Scene,
  12745. /** defines the target object */
  12746. target: any,
  12747. /** defines the starting frame number (default is 0) */
  12748. fromFrame?: number,
  12749. /** defines the ending frame number (default is 100) */
  12750. toFrame?: number,
  12751. /** defines if the animation must loop (default is false) */
  12752. loopAnimation?: boolean, speedRatio?: number,
  12753. /** defines a callback to call when animation ends if it is not looping */
  12754. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12755. /** defines a callback to call when animation loops */
  12756. onAnimationLoop?: (() => void) | null | undefined);
  12757. /**
  12758. * Synchronize and normalize current Animatable with a source Animatable
  12759. * This is useful when using animation weights and when animations are not of the same length
  12760. * @param root defines the root Animatable to synchronize with
  12761. * @returns the current Animatable
  12762. */
  12763. syncWith(root: Animatable): Animatable;
  12764. /**
  12765. * Gets the list of runtime animations
  12766. * @returns an array of RuntimeAnimation
  12767. */
  12768. getAnimations(): RuntimeAnimation[];
  12769. /**
  12770. * Adds more animations to the current animatable
  12771. * @param target defines the target of the animations
  12772. * @param animations defines the new animations to add
  12773. */
  12774. appendAnimations(target: any, animations: Animation[]): void;
  12775. /**
  12776. * Gets the source animation for a specific property
  12777. * @param property defines the propertyu to look for
  12778. * @returns null or the source animation for the given property
  12779. */
  12780. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12781. /**
  12782. * Gets the runtime animation for a specific property
  12783. * @param property defines the propertyu to look for
  12784. * @returns null or the runtime animation for the given property
  12785. */
  12786. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12787. /**
  12788. * Resets the animatable to its original state
  12789. */
  12790. reset(): void;
  12791. /**
  12792. * Allows the animatable to blend with current running animations
  12793. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12794. * @param blendingSpeed defines the blending speed to use
  12795. */
  12796. enableBlending(blendingSpeed: number): void;
  12797. /**
  12798. * Disable animation blending
  12799. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12800. */
  12801. disableBlending(): void;
  12802. /**
  12803. * Jump directly to a given frame
  12804. * @param frame defines the frame to jump to
  12805. */
  12806. goToFrame(frame: number): void;
  12807. /**
  12808. * Pause the animation
  12809. */
  12810. pause(): void;
  12811. /**
  12812. * Restart the animation
  12813. */
  12814. restart(): void;
  12815. private _raiseOnAnimationEnd;
  12816. /**
  12817. * Stop and delete the current animation
  12818. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12819. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  12820. */
  12821. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12822. /**
  12823. * Wait asynchronously for the animation to end
  12824. * @returns a promise which will be fullfilled when the animation ends
  12825. */
  12826. waitAsync(): Promise<Animatable>;
  12827. /** @hidden */ private _animate(delay: number): boolean;
  12828. }
  12829. interface Scene {
  12830. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12831. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  12832. totalWeight: number;
  12833. animations: RuntimeAnimation[];
  12834. originalValue: Matrix;
  12835. }): any;
  12836. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  12837. totalWeight: number;
  12838. animations: RuntimeAnimation[];
  12839. originalValue: Quaternion;
  12840. }, refQuaternion: Quaternion): Quaternion;
  12841. /** @hidden */ private _processLateAnimationBindings(): void;
  12842. /**
  12843. * Will start the animation sequence of a given target
  12844. * @param target defines the target
  12845. * @param from defines from which frame should animation start
  12846. * @param to defines until which frame should animation run.
  12847. * @param weight defines the weight to apply to the animation (1.0 by default)
  12848. * @param loop defines if the animation loops
  12849. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12850. * @param onAnimationEnd defines the function to be executed when the animation ends
  12851. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12852. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12853. * @param onAnimationLoop defines the callback to call when an animation loops
  12854. * @returns the animatable object created for this animation
  12855. */
  12856. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12857. /**
  12858. * Will start the animation sequence of a given target
  12859. * @param target defines the target
  12860. * @param from defines from which frame should animation start
  12861. * @param to defines until which frame should animation run.
  12862. * @param loop defines if the animation loops
  12863. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12864. * @param onAnimationEnd defines the function to be executed when the animation ends
  12865. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12866. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12867. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12868. * @param onAnimationLoop defines the callback to call when an animation loops
  12869. * @returns the animatable object created for this animation
  12870. */
  12871. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12872. /**
  12873. * Will start the animation sequence of a given target and its hierarchy
  12874. * @param target defines the target
  12875. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  12876. * @param from defines from which frame should animation start
  12877. * @param to defines until which frame should animation run.
  12878. * @param loop defines if the animation loops
  12879. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12880. * @param onAnimationEnd defines the function to be executed when the animation ends
  12881. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12882. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12883. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12884. * @param onAnimationLoop defines the callback to call when an animation loops
  12885. * @returns the list of created animatables
  12886. */
  12887. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  12888. /**
  12889. * Begin a new animation on a given node
  12890. * @param target defines the target where the animation will take place
  12891. * @param animations defines the list of animations to start
  12892. * @param from defines the initial value
  12893. * @param to defines the final value
  12894. * @param loop defines if you want animation to loop (off by default)
  12895. * @param speedRatio defines the speed ratio to apply to all animations
  12896. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12897. * @param onAnimationLoop defines the callback to call when an animation loops
  12898. * @returns the list of created animatables
  12899. */
  12900. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12901. /**
  12902. * Begin a new animation on a given node and its hierarchy
  12903. * @param target defines the root node where the animation will take place
  12904. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  12905. * @param animations defines the list of animations to start
  12906. * @param from defines the initial value
  12907. * @param to defines the final value
  12908. * @param loop defines if you want animation to loop (off by default)
  12909. * @param speedRatio defines the speed ratio to apply to all animations
  12910. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12911. * @param onAnimationLoop defines the callback to call when an animation loops
  12912. * @returns the list of animatables created for all nodes
  12913. */
  12914. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12915. /**
  12916. * Gets the animatable associated with a specific target
  12917. * @param target defines the target of the animatable
  12918. * @returns the required animatable if found
  12919. */
  12920. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12921. /**
  12922. * Gets all animatables associated with a given target
  12923. * @param target defines the target to look animatables for
  12924. * @returns an array of Animatables
  12925. */
  12926. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12927. /**
  12928. * Stops and removes all animations that have been applied to the scene
  12929. */
  12930. stopAllAnimations(): void;
  12931. /**
  12932. * Gets the current delta time used by animation engine
  12933. */
  12934. deltaTime: number;
  12935. }
  12936. interface Bone {
  12937. /**
  12938. * Copy an animation range from another bone
  12939. * @param source defines the source bone
  12940. * @param rangeName defines the range name to copy
  12941. * @param frameOffset defines the frame offset
  12942. * @param rescaleAsRequired defines if rescaling must be applied if required
  12943. * @param skelDimensionsRatio defines the scaling ratio
  12944. * @returns true if operation was successful
  12945. */
  12946. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12947. }
  12948. }
  12949. declare module BABYLON {
  12950. /**
  12951. * Class used to override all child animations of a given target
  12952. */
  12953. export class AnimationPropertiesOverride {
  12954. /**
  12955. * Gets or sets a value indicating if animation blending must be used
  12956. */
  12957. enableBlending: boolean;
  12958. /**
  12959. * Gets or sets the blending speed to use when enableBlending is true
  12960. */
  12961. blendingSpeed: number;
  12962. /**
  12963. * Gets or sets the default loop mode to use
  12964. */
  12965. loopMode: number;
  12966. }
  12967. }
  12968. declare module BABYLON {
  12969. /**
  12970. * Class used to handle skinning animations
  12971. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  12972. */
  12973. export class Skeleton implements IAnimatable {
  12974. /** defines the skeleton name */
  12975. name: string;
  12976. /** defines the skeleton Id */
  12977. id: string;
  12978. /**
  12979. * Defines the list of child bones
  12980. */
  12981. bones: Bone[];
  12982. /**
  12983. * Defines an estimate of the dimension of the skeleton at rest
  12984. */
  12985. dimensionsAtRest: Vector3;
  12986. /**
  12987. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  12988. */
  12989. needInitialSkinMatrix: boolean;
  12990. /**
  12991. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  12992. */
  12993. overrideMesh: Nullable<AbstractMesh>;
  12994. /**
  12995. * Gets the list of animations attached to this skeleton
  12996. */
  12997. animations: Array<Animation>;
  12998. private _scene;
  12999. private _isDirty;
  13000. private _transformMatrices;
  13001. private _transformMatrixTexture;
  13002. private _meshesWithPoseMatrix;
  13003. private _animatables;
  13004. private _identity;
  13005. private _synchronizedWithMesh;
  13006. private _ranges;
  13007. private _lastAbsoluteTransformsUpdateId;
  13008. private _canUseTextureForBones;
  13009. private _uniqueId;
  13010. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  13011. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  13012. /**
  13013. * Specifies if the skeleton should be serialized
  13014. */
  13015. doNotSerialize: boolean;
  13016. private _useTextureToStoreBoneMatrices;
  13017. /**
  13018. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13019. * Please note that this option is not available if the hardware does not support it
  13020. */
  13021. useTextureToStoreBoneMatrices: boolean;
  13022. private _animationPropertiesOverride;
  13023. /**
  13024. * Gets or sets the animation properties override
  13025. */
  13026. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13027. /**
  13028. * List of inspectable custom properties (used by the Inspector)
  13029. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13030. */
  13031. inspectableCustomProperties: IInspectable[];
  13032. /**
  13033. * An observable triggered before computing the skeleton's matrices
  13034. */
  13035. onBeforeComputeObservable: Observable<Skeleton>;
  13036. /**
  13037. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13038. */
  13039. readonly isUsingTextureForMatrices: boolean;
  13040. /**
  13041. * Gets the unique ID of this skeleton
  13042. */
  13043. readonly uniqueId: number;
  13044. /**
  13045. * Creates a new skeleton
  13046. * @param name defines the skeleton name
  13047. * @param id defines the skeleton Id
  13048. * @param scene defines the hosting scene
  13049. */
  13050. constructor(
  13051. /** defines the skeleton name */
  13052. name: string,
  13053. /** defines the skeleton Id */
  13054. id: string, scene: Scene);
  13055. /**
  13056. * Gets the current object class name.
  13057. * @return the class name
  13058. */
  13059. getClassName(): string;
  13060. /**
  13061. * Returns an array containing the root bones
  13062. * @returns an array containing the root bones
  13063. */
  13064. getChildren(): Array<Bone>;
  13065. /**
  13066. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13067. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13068. * @returns a Float32Array containing matrices data
  13069. */
  13070. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13071. /**
  13072. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13073. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13074. * @returns a raw texture containing the data
  13075. */
  13076. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13077. /**
  13078. * Gets the current hosting scene
  13079. * @returns a scene object
  13080. */
  13081. getScene(): Scene;
  13082. /**
  13083. * Gets a string representing the current skeleton data
  13084. * @param fullDetails defines a boolean indicating if we want a verbose version
  13085. * @returns a string representing the current skeleton data
  13086. */
  13087. toString(fullDetails?: boolean): string;
  13088. /**
  13089. * Get bone's index searching by name
  13090. * @param name defines bone's name to search for
  13091. * @return the indice of the bone. Returns -1 if not found
  13092. */
  13093. getBoneIndexByName(name: string): number;
  13094. /**
  13095. * Creater a new animation range
  13096. * @param name defines the name of the range
  13097. * @param from defines the start key
  13098. * @param to defines the end key
  13099. */
  13100. createAnimationRange(name: string, from: number, to: number): void;
  13101. /**
  13102. * Delete a specific animation range
  13103. * @param name defines the name of the range
  13104. * @param deleteFrames defines if frames must be removed as well
  13105. */
  13106. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13107. /**
  13108. * Gets a specific animation range
  13109. * @param name defines the name of the range to look for
  13110. * @returns the requested animation range or null if not found
  13111. */
  13112. getAnimationRange(name: string): Nullable<AnimationRange>;
  13113. /**
  13114. * Gets the list of all animation ranges defined on this skeleton
  13115. * @returns an array
  13116. */
  13117. getAnimationRanges(): Nullable<AnimationRange>[];
  13118. /**
  13119. * Copy animation range from a source skeleton.
  13120. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13121. * @param source defines the source skeleton
  13122. * @param name defines the name of the range to copy
  13123. * @param rescaleAsRequired defines if rescaling must be applied if required
  13124. * @returns true if operation was successful
  13125. */
  13126. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13127. /**
  13128. * Forces the skeleton to go to rest pose
  13129. */
  13130. returnToRest(): void;
  13131. private _getHighestAnimationFrame;
  13132. /**
  13133. * Begin a specific animation range
  13134. * @param name defines the name of the range to start
  13135. * @param loop defines if looping must be turned on (false by default)
  13136. * @param speedRatio defines the speed ratio to apply (1 by default)
  13137. * @param onAnimationEnd defines a callback which will be called when animation will end
  13138. * @returns a new animatable
  13139. */
  13140. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13141. /** @hidden */ private _markAsDirty(): void;
  13142. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13143. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13144. private _computeTransformMatrices;
  13145. /**
  13146. * Build all resources required to render a skeleton
  13147. */
  13148. prepare(): void;
  13149. /**
  13150. * Gets the list of animatables currently running for this skeleton
  13151. * @returns an array of animatables
  13152. */
  13153. getAnimatables(): IAnimatable[];
  13154. /**
  13155. * Clone the current skeleton
  13156. * @param name defines the name of the new skeleton
  13157. * @param id defines the id of the new skeleton
  13158. * @returns the new skeleton
  13159. */
  13160. clone(name: string, id: string): Skeleton;
  13161. /**
  13162. * Enable animation blending for this skeleton
  13163. * @param blendingSpeed defines the blending speed to apply
  13164. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13165. */
  13166. enableBlending(blendingSpeed?: number): void;
  13167. /**
  13168. * Releases all resources associated with the current skeleton
  13169. */
  13170. dispose(): void;
  13171. /**
  13172. * Serialize the skeleton in a JSON object
  13173. * @returns a JSON object
  13174. */
  13175. serialize(): any;
  13176. /**
  13177. * Creates a new skeleton from serialized data
  13178. * @param parsedSkeleton defines the serialized data
  13179. * @param scene defines the hosting scene
  13180. * @returns a new skeleton
  13181. */
  13182. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13183. /**
  13184. * Compute all node absolute transforms
  13185. * @param forceUpdate defines if computation must be done even if cache is up to date
  13186. */
  13187. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13188. /**
  13189. * Gets the root pose matrix
  13190. * @returns a matrix
  13191. */
  13192. getPoseMatrix(): Nullable<Matrix>;
  13193. /**
  13194. * Sorts bones per internal index
  13195. */
  13196. sortBones(): void;
  13197. private _sortBones;
  13198. }
  13199. }
  13200. declare module BABYLON {
  13201. /**
  13202. * Class used to store bone information
  13203. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13204. */
  13205. export class Bone extends Node {
  13206. /**
  13207. * defines the bone name
  13208. */
  13209. name: string;
  13210. private static _tmpVecs;
  13211. private static _tmpQuat;
  13212. private static _tmpMats;
  13213. /**
  13214. * Gets the list of child bones
  13215. */
  13216. children: Bone[];
  13217. /** Gets the animations associated with this bone */
  13218. animations: Animation[];
  13219. /**
  13220. * Gets or sets bone length
  13221. */
  13222. length: number;
  13223. /**
  13224. * @hidden Internal only
  13225. * Set this value to map this bone to a different index in the transform matrices
  13226. * Set this value to -1 to exclude the bone from the transform matrices
  13227. */ private _index: Nullable<number>;
  13228. private _skeleton;
  13229. private _localMatrix;
  13230. private _restPose;
  13231. private _baseMatrix;
  13232. private _absoluteTransform;
  13233. private _invertedAbsoluteTransform;
  13234. private _parent;
  13235. private _scalingDeterminant;
  13236. private _worldTransform;
  13237. private _localScaling;
  13238. private _localRotation;
  13239. private _localPosition;
  13240. private _needToDecompose;
  13241. private _needToCompose;
  13242. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13243. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13244. /** @hidden */
  13245. /** @hidden */ private _matrix: Matrix;
  13246. /**
  13247. * Create a new bone
  13248. * @param name defines the bone name
  13249. * @param skeleton defines the parent skeleton
  13250. * @param parentBone defines the parent (can be null if the bone is the root)
  13251. * @param localMatrix defines the local matrix
  13252. * @param restPose defines the rest pose matrix
  13253. * @param baseMatrix defines the base matrix
  13254. * @param index defines index of the bone in the hiearchy
  13255. */
  13256. constructor(
  13257. /**
  13258. * defines the bone name
  13259. */
  13260. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13261. /**
  13262. * Gets the current object class name.
  13263. * @return the class name
  13264. */
  13265. getClassName(): string;
  13266. /**
  13267. * Gets the parent skeleton
  13268. * @returns a skeleton
  13269. */
  13270. getSkeleton(): Skeleton;
  13271. /**
  13272. * Gets parent bone
  13273. * @returns a bone or null if the bone is the root of the bone hierarchy
  13274. */
  13275. getParent(): Nullable<Bone>;
  13276. /**
  13277. * Returns an array containing the root bones
  13278. * @returns an array containing the root bones
  13279. */
  13280. getChildren(): Array<Bone>;
  13281. /**
  13282. * Sets the parent bone
  13283. * @param parent defines the parent (can be null if the bone is the root)
  13284. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13285. */
  13286. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13287. /**
  13288. * Gets the local matrix
  13289. * @returns a matrix
  13290. */
  13291. getLocalMatrix(): Matrix;
  13292. /**
  13293. * Gets the base matrix (initial matrix which remains unchanged)
  13294. * @returns a matrix
  13295. */
  13296. getBaseMatrix(): Matrix;
  13297. /**
  13298. * Gets the rest pose matrix
  13299. * @returns a matrix
  13300. */
  13301. getRestPose(): Matrix;
  13302. /**
  13303. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13304. */
  13305. getWorldMatrix(): Matrix;
  13306. /**
  13307. * Sets the local matrix to rest pose matrix
  13308. */
  13309. returnToRest(): void;
  13310. /**
  13311. * Gets the inverse of the absolute transform matrix.
  13312. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13313. * @returns a matrix
  13314. */
  13315. getInvertedAbsoluteTransform(): Matrix;
  13316. /**
  13317. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13318. * @returns a matrix
  13319. */
  13320. getAbsoluteTransform(): Matrix;
  13321. /**
  13322. * Links with the given transform node.
  13323. * The local matrix of this bone is copied from the transform node every frame.
  13324. * @param transformNode defines the transform node to link to
  13325. */
  13326. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13327. /**
  13328. * Gets the node used to drive the bone's transformation
  13329. * @returns a transform node or null
  13330. */
  13331. getTransformNode(): Nullable<TransformNode>;
  13332. /** Gets or sets current position (in local space) */
  13333. position: Vector3;
  13334. /** Gets or sets current rotation (in local space) */
  13335. rotation: Vector3;
  13336. /** Gets or sets current rotation quaternion (in local space) */
  13337. rotationQuaternion: Quaternion;
  13338. /** Gets or sets current scaling (in local space) */
  13339. scaling: Vector3;
  13340. /**
  13341. * Gets the animation properties override
  13342. */
  13343. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13344. private _decompose;
  13345. private _compose;
  13346. /**
  13347. * Update the base and local matrices
  13348. * @param matrix defines the new base or local matrix
  13349. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13350. * @param updateLocalMatrix defines if the local matrix should be updated
  13351. */
  13352. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13353. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13354. /**
  13355. * Flag the bone as dirty (Forcing it to update everything)
  13356. */
  13357. markAsDirty(): void;
  13358. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13359. private _markAsDirtyAndDecompose;
  13360. /**
  13361. * Translate the bone in local or world space
  13362. * @param vec The amount to translate the bone
  13363. * @param space The space that the translation is in
  13364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13365. */
  13366. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13367. /**
  13368. * Set the postion of the bone in local or world space
  13369. * @param position The position to set the bone
  13370. * @param space The space that the position is in
  13371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13372. */
  13373. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13374. /**
  13375. * Set the absolute position of the bone (world space)
  13376. * @param position The position to set the bone
  13377. * @param mesh The mesh that this bone is attached to
  13378. */
  13379. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13380. /**
  13381. * Scale the bone on the x, y and z axes (in local space)
  13382. * @param x The amount to scale the bone on the x axis
  13383. * @param y The amount to scale the bone on the y axis
  13384. * @param z The amount to scale the bone on the z axis
  13385. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13386. */
  13387. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13388. /**
  13389. * Set the bone scaling in local space
  13390. * @param scale defines the scaling vector
  13391. */
  13392. setScale(scale: Vector3): void;
  13393. /**
  13394. * Gets the current scaling in local space
  13395. * @returns the current scaling vector
  13396. */
  13397. getScale(): Vector3;
  13398. /**
  13399. * Gets the current scaling in local space and stores it in a target vector
  13400. * @param result defines the target vector
  13401. */
  13402. getScaleToRef(result: Vector3): void;
  13403. /**
  13404. * Set the yaw, pitch, and roll of the bone in local or world space
  13405. * @param yaw The rotation of the bone on the y axis
  13406. * @param pitch The rotation of the bone on the x axis
  13407. * @param roll The rotation of the bone on the z axis
  13408. * @param space The space that the axes of rotation are in
  13409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13410. */
  13411. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13412. /**
  13413. * Add a rotation to the bone on an axis in local or world space
  13414. * @param axis The axis to rotate the bone on
  13415. * @param amount The amount to rotate the bone
  13416. * @param space The space that the axis is in
  13417. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13418. */
  13419. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13420. /**
  13421. * Set the rotation of the bone to a particular axis angle in local or world space
  13422. * @param axis The axis to rotate the bone on
  13423. * @param angle The angle that the bone should be rotated to
  13424. * @param space The space that the axis is in
  13425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13426. */
  13427. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13428. /**
  13429. * Set the euler rotation of the bone in local of world space
  13430. * @param rotation The euler rotation that the bone should be set to
  13431. * @param space The space that the rotation is in
  13432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13433. */
  13434. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13435. /**
  13436. * Set the quaternion rotation of the bone in local of world space
  13437. * @param quat The quaternion rotation that the bone should be set to
  13438. * @param space The space that the rotation is in
  13439. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13440. */
  13441. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13442. /**
  13443. * Set the rotation matrix of the bone in local of world space
  13444. * @param rotMat The rotation matrix that the bone should be set to
  13445. * @param space The space that the rotation is in
  13446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13447. */
  13448. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13449. private _rotateWithMatrix;
  13450. private _getNegativeRotationToRef;
  13451. /**
  13452. * Get the position of the bone in local or world space
  13453. * @param space The space that the returned position is in
  13454. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13455. * @returns The position of the bone
  13456. */
  13457. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13458. /**
  13459. * Copy the position of the bone to a vector3 in local or world space
  13460. * @param space The space that the returned position is in
  13461. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13462. * @param result The vector3 to copy the position to
  13463. */
  13464. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13465. /**
  13466. * Get the absolute position of the bone (world space)
  13467. * @param mesh The mesh that this bone is attached to
  13468. * @returns The absolute position of the bone
  13469. */
  13470. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13471. /**
  13472. * Copy the absolute position of the bone (world space) to the result param
  13473. * @param mesh The mesh that this bone is attached to
  13474. * @param result The vector3 to copy the absolute position to
  13475. */
  13476. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13477. /**
  13478. * Compute the absolute transforms of this bone and its children
  13479. */
  13480. computeAbsoluteTransforms(): void;
  13481. /**
  13482. * Get the world direction from an axis that is in the local space of the bone
  13483. * @param localAxis The local direction that is used to compute the world direction
  13484. * @param mesh The mesh that this bone is attached to
  13485. * @returns The world direction
  13486. */
  13487. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13488. /**
  13489. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13490. * @param localAxis The local direction that is used to compute the world direction
  13491. * @param mesh The mesh that this bone is attached to
  13492. * @param result The vector3 that the world direction will be copied to
  13493. */
  13494. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13495. /**
  13496. * Get the euler rotation of the bone in local or world space
  13497. * @param space The space that the rotation should be in
  13498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13499. * @returns The euler rotation
  13500. */
  13501. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13502. /**
  13503. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13504. * @param space The space that the rotation should be in
  13505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13506. * @param result The vector3 that the rotation should be copied to
  13507. */
  13508. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13509. /**
  13510. * Get the quaternion rotation of the bone in either local or world space
  13511. * @param space The space that the rotation should be in
  13512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13513. * @returns The quaternion rotation
  13514. */
  13515. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13516. /**
  13517. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13518. * @param space The space that the rotation should be in
  13519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13520. * @param result The quaternion that the rotation should be copied to
  13521. */
  13522. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13523. /**
  13524. * Get the rotation matrix of the bone in local or world space
  13525. * @param space The space that the rotation should be in
  13526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13527. * @returns The rotation matrix
  13528. */
  13529. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13530. /**
  13531. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13532. * @param space The space that the rotation should be in
  13533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13534. * @param result The quaternion that the rotation should be copied to
  13535. */
  13536. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13537. /**
  13538. * Get the world position of a point that is in the local space of the bone
  13539. * @param position The local position
  13540. * @param mesh The mesh that this bone is attached to
  13541. * @returns The world position
  13542. */
  13543. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13544. /**
  13545. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13546. * @param position The local position
  13547. * @param mesh The mesh that this bone is attached to
  13548. * @param result The vector3 that the world position should be copied to
  13549. */
  13550. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13551. /**
  13552. * Get the local position of a point that is in world space
  13553. * @param position The world position
  13554. * @param mesh The mesh that this bone is attached to
  13555. * @returns The local position
  13556. */
  13557. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13558. /**
  13559. * Get the local position of a point that is in world space and copy it to the result param
  13560. * @param position The world position
  13561. * @param mesh The mesh that this bone is attached to
  13562. * @param result The vector3 that the local position should be copied to
  13563. */
  13564. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13565. }
  13566. }
  13567. declare module BABYLON {
  13568. /**
  13569. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13570. * @see https://doc.babylonjs.com/how_to/transformnode
  13571. */
  13572. export class TransformNode extends Node {
  13573. /**
  13574. * Object will not rotate to face the camera
  13575. */
  13576. static BILLBOARDMODE_NONE: number;
  13577. /**
  13578. * Object will rotate to face the camera but only on the x axis
  13579. */
  13580. static BILLBOARDMODE_X: number;
  13581. /**
  13582. * Object will rotate to face the camera but only on the y axis
  13583. */
  13584. static BILLBOARDMODE_Y: number;
  13585. /**
  13586. * Object will rotate to face the camera but only on the z axis
  13587. */
  13588. static BILLBOARDMODE_Z: number;
  13589. /**
  13590. * Object will rotate to face the camera
  13591. */
  13592. static BILLBOARDMODE_ALL: number;
  13593. /**
  13594. * Object will rotate to face the camera's position instead of orientation
  13595. */
  13596. static BILLBOARDMODE_USE_POSITION: number;
  13597. private _forward;
  13598. private _forwardInverted;
  13599. private _up;
  13600. private _right;
  13601. private _rightInverted;
  13602. private _position;
  13603. private _rotation;
  13604. private _rotationQuaternion;
  13605. protected _scaling: Vector3;
  13606. protected _isDirty: boolean;
  13607. private _transformToBoneReferal;
  13608. private _isAbsoluteSynced;
  13609. private _billboardMode;
  13610. /**
  13611. * Gets or sets the billboard mode. Default is 0.
  13612. *
  13613. * | Value | Type | Description |
  13614. * | --- | --- | --- |
  13615. * | 0 | BILLBOARDMODE_NONE | |
  13616. * | 1 | BILLBOARDMODE_X | |
  13617. * | 2 | BILLBOARDMODE_Y | |
  13618. * | 4 | BILLBOARDMODE_Z | |
  13619. * | 7 | BILLBOARDMODE_ALL | |
  13620. *
  13621. */
  13622. billboardMode: number;
  13623. private _preserveParentRotationForBillboard;
  13624. /**
  13625. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13626. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13627. */
  13628. preserveParentRotationForBillboard: boolean;
  13629. /**
  13630. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  13631. */
  13632. scalingDeterminant: number;
  13633. private _infiniteDistance;
  13634. /**
  13635. * Gets or sets the distance of the object to max, often used by skybox
  13636. */
  13637. infiniteDistance: boolean;
  13638. /**
  13639. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13640. * By default the system will update normals to compensate
  13641. */
  13642. ignoreNonUniformScaling: boolean;
  13643. /**
  13644. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13645. */
  13646. reIntegrateRotationIntoRotationQuaternion: boolean;
  13647. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13648. /** @hidden */ private _localMatrix: Matrix;
  13649. private _usePivotMatrix;
  13650. private _absolutePosition;
  13651. private _absoluteScaling;
  13652. private _absoluteRotationQuaternion;
  13653. private _pivotMatrix;
  13654. private _pivotMatrixInverse;
  13655. protected _postMultiplyPivotMatrix: boolean;
  13656. protected _isWorldMatrixFrozen: boolean;
  13657. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13658. /**
  13659. * An event triggered after the world matrix is updated
  13660. */
  13661. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13662. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13663. /**
  13664. * Gets a string identifying the name of the class
  13665. * @returns "TransformNode" string
  13666. */
  13667. getClassName(): string;
  13668. /**
  13669. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13670. */
  13671. position: Vector3;
  13672. /**
  13673. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13674. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13675. */
  13676. rotation: Vector3;
  13677. /**
  13678. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13679. */
  13680. scaling: Vector3;
  13681. /**
  13682. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  13683. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13684. */
  13685. rotationQuaternion: Nullable<Quaternion>;
  13686. /**
  13687. * The forward direction of that transform in world space.
  13688. */
  13689. readonly forward: Vector3;
  13690. /**
  13691. * The up direction of that transform in world space.
  13692. */
  13693. readonly up: Vector3;
  13694. /**
  13695. * The right direction of that transform in world space.
  13696. */
  13697. readonly right: Vector3;
  13698. /**
  13699. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13700. * @param matrix the matrix to copy the pose from
  13701. * @returns this TransformNode.
  13702. */
  13703. updatePoseMatrix(matrix: Matrix): TransformNode;
  13704. /**
  13705. * Returns the mesh Pose matrix.
  13706. * @returns the pose matrix
  13707. */
  13708. getPoseMatrix(): Matrix;
  13709. /** @hidden */ private _isSynchronized(): boolean;
  13710. /** @hidden */ private _initCache(): void;
  13711. /**
  13712. * Flag the transform node as dirty (Forcing it to update everything)
  13713. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13714. * @returns this transform node
  13715. */
  13716. markAsDirty(property: string): TransformNode;
  13717. /**
  13718. * Returns the current mesh absolute position.
  13719. * Returns a Vector3.
  13720. */
  13721. readonly absolutePosition: Vector3;
  13722. /**
  13723. * Returns the current mesh absolute scaling.
  13724. * Returns a Vector3.
  13725. */
  13726. readonly absoluteScaling: Vector3;
  13727. /**
  13728. * Returns the current mesh absolute rotation.
  13729. * Returns a Quaternion.
  13730. */
  13731. readonly absoluteRotationQuaternion: Quaternion;
  13732. /**
  13733. * Sets a new matrix to apply before all other transformation
  13734. * @param matrix defines the transform matrix
  13735. * @returns the current TransformNode
  13736. */
  13737. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13738. /**
  13739. * Sets a new pivot matrix to the current node
  13740. * @param matrix defines the new pivot matrix to use
  13741. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  13742. * @returns the current TransformNode
  13743. */
  13744. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13745. /**
  13746. * Returns the mesh pivot matrix.
  13747. * Default : Identity.
  13748. * @returns the matrix
  13749. */
  13750. getPivotMatrix(): Matrix;
  13751. /**
  13752. * Instantiate (when possible) or clone that node with its hierarchy
  13753. * @param newParent defines the new parent to use for the instance (or clone)
  13754. * @returns an instance (or a clone) of the current node with its hiearchy
  13755. */
  13756. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  13757. /**
  13758. * Prevents the World matrix to be computed any longer
  13759. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13760. * @returns the TransformNode.
  13761. */
  13762. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13763. /**
  13764. * Allows back the World matrix computation.
  13765. * @returns the TransformNode.
  13766. */
  13767. unfreezeWorldMatrix(): this;
  13768. /**
  13769. * True if the World matrix has been frozen.
  13770. */
  13771. readonly isWorldMatrixFrozen: boolean;
  13772. /**
  13773. * Retuns the mesh absolute position in the World.
  13774. * @returns a Vector3.
  13775. */
  13776. getAbsolutePosition(): Vector3;
  13777. /**
  13778. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13779. * @param absolutePosition the absolute position to set
  13780. * @returns the TransformNode.
  13781. */
  13782. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13783. /**
  13784. * Sets the mesh position in its local space.
  13785. * @param vector3 the position to set in localspace
  13786. * @returns the TransformNode.
  13787. */
  13788. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13789. /**
  13790. * Returns the mesh position in the local space from the current World matrix values.
  13791. * @returns a new Vector3.
  13792. */
  13793. getPositionExpressedInLocalSpace(): Vector3;
  13794. /**
  13795. * Translates the mesh along the passed Vector3 in its local space.
  13796. * @param vector3 the distance to translate in localspace
  13797. * @returns the TransformNode.
  13798. */
  13799. locallyTranslate(vector3: Vector3): TransformNode;
  13800. private static _lookAtVectorCache;
  13801. /**
  13802. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13803. * @param targetPoint the position (must be in same space as current mesh) to look at
  13804. * @param yawCor optional yaw (y-axis) correction in radians
  13805. * @param pitchCor optional pitch (x-axis) correction in radians
  13806. * @param rollCor optional roll (z-axis) correction in radians
  13807. * @param space the choosen space of the target
  13808. * @returns the TransformNode.
  13809. */
  13810. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13811. /**
  13812. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13813. * This Vector3 is expressed in the World space.
  13814. * @param localAxis axis to rotate
  13815. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13816. */
  13817. getDirection(localAxis: Vector3): Vector3;
  13818. /**
  13819. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13820. * localAxis is expressed in the mesh local space.
  13821. * result is computed in the Wordl space from the mesh World matrix.
  13822. * @param localAxis axis to rotate
  13823. * @param result the resulting transformnode
  13824. * @returns this TransformNode.
  13825. */
  13826. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13827. /**
  13828. * Sets this transform node rotation to the given local axis.
  13829. * @param localAxis the axis in local space
  13830. * @param yawCor optional yaw (y-axis) correction in radians
  13831. * @param pitchCor optional pitch (x-axis) correction in radians
  13832. * @param rollCor optional roll (z-axis) correction in radians
  13833. * @returns this TransformNode
  13834. */
  13835. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13836. /**
  13837. * Sets a new pivot point to the current node
  13838. * @param point defines the new pivot point to use
  13839. * @param space defines if the point is in world or local space (local by default)
  13840. * @returns the current TransformNode
  13841. */
  13842. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13843. /**
  13844. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13845. * @returns the pivot point
  13846. */
  13847. getPivotPoint(): Vector3;
  13848. /**
  13849. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13850. * @param result the vector3 to store the result
  13851. * @returns this TransformNode.
  13852. */
  13853. getPivotPointToRef(result: Vector3): TransformNode;
  13854. /**
  13855. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13856. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13857. */
  13858. getAbsolutePivotPoint(): Vector3;
  13859. /**
  13860. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13861. * @param result vector3 to store the result
  13862. * @returns this TransformNode.
  13863. */
  13864. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13865. /**
  13866. * Defines the passed node as the parent of the current node.
  13867. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13868. * @see https://doc.babylonjs.com/how_to/parenting
  13869. * @param node the node ot set as the parent
  13870. * @returns this TransformNode.
  13871. */
  13872. setParent(node: Nullable<Node>): TransformNode;
  13873. private _nonUniformScaling;
  13874. /**
  13875. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13876. */
  13877. readonly nonUniformScaling: boolean;
  13878. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  13879. /**
  13880. * Attach the current TransformNode to another TransformNode associated with a bone
  13881. * @param bone Bone affecting the TransformNode
  13882. * @param affectedTransformNode TransformNode associated with the bone
  13883. * @returns this object
  13884. */
  13885. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13886. /**
  13887. * Detach the transform node if its associated with a bone
  13888. * @returns this object
  13889. */
  13890. detachFromBone(): TransformNode;
  13891. private static _rotationAxisCache;
  13892. /**
  13893. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13894. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13895. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13896. * The passed axis is also normalized.
  13897. * @param axis the axis to rotate around
  13898. * @param amount the amount to rotate in radians
  13899. * @param space Space to rotate in (Default: local)
  13900. * @returns the TransformNode.
  13901. */
  13902. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13903. /**
  13904. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13905. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13906. * The passed axis is also normalized. .
  13907. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13908. * @param point the point to rotate around
  13909. * @param axis the axis to rotate around
  13910. * @param amount the amount to rotate in radians
  13911. * @returns the TransformNode
  13912. */
  13913. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13914. /**
  13915. * Translates the mesh along the axis vector for the passed distance in the given space.
  13916. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13917. * @param axis the axis to translate in
  13918. * @param distance the distance to translate
  13919. * @param space Space to rotate in (Default: local)
  13920. * @returns the TransformNode.
  13921. */
  13922. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13923. /**
  13924. * Adds a rotation step to the mesh current rotation.
  13925. * x, y, z are Euler angles expressed in radians.
  13926. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13927. * This means this rotation is made in the mesh local space only.
  13928. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13929. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13930. * ```javascript
  13931. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13932. * ```
  13933. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13934. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  13935. * @param x Rotation to add
  13936. * @param y Rotation to add
  13937. * @param z Rotation to add
  13938. * @returns the TransformNode.
  13939. */
  13940. addRotation(x: number, y: number, z: number): TransformNode;
  13941. /**
  13942. * @hidden
  13943. */
  13944. protected _getEffectiveParent(): Nullable<Node>;
  13945. /**
  13946. * Computes the world matrix of the node
  13947. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13948. * @returns the world matrix
  13949. */
  13950. computeWorldMatrix(force?: boolean): Matrix;
  13951. protected _afterComputeWorldMatrix(): void;
  13952. /**
  13953. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13954. * @param func callback function to add
  13955. *
  13956. * @returns the TransformNode.
  13957. */
  13958. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13959. /**
  13960. * Removes a registered callback function.
  13961. * @param func callback function to remove
  13962. * @returns the TransformNode.
  13963. */
  13964. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13965. /**
  13966. * Gets the position of the current mesh in camera space
  13967. * @param camera defines the camera to use
  13968. * @returns a position
  13969. */
  13970. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13971. /**
  13972. * Returns the distance from the mesh to the active camera
  13973. * @param camera defines the camera to use
  13974. * @returns the distance
  13975. */
  13976. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13977. /**
  13978. * Clone the current transform node
  13979. * @param name Name of the new clone
  13980. * @param newParent New parent for the clone
  13981. * @param doNotCloneChildren Do not clone children hierarchy
  13982. * @returns the new transform node
  13983. */
  13984. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13985. /**
  13986. * Serializes the objects information.
  13987. * @param currentSerializationObject defines the object to serialize in
  13988. * @returns the serialized object
  13989. */
  13990. serialize(currentSerializationObject?: any): any;
  13991. /**
  13992. * Returns a new TransformNode object parsed from the source provided.
  13993. * @param parsedTransformNode is the source.
  13994. * @param scene the scne the object belongs to
  13995. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13996. * @returns a new TransformNode object parsed from the source provided.
  13997. */
  13998. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13999. /**
  14000. * Get all child-transformNodes of this node
  14001. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14002. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14003. * @returns an array of TransformNode
  14004. */
  14005. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14006. /**
  14007. * Releases resources associated with this transform node.
  14008. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14009. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14010. */
  14011. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14012. /**
  14013. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14014. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14015. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14016. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14017. * @returns the current mesh
  14018. */
  14019. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14020. private _syncAbsoluteScalingAndRotation;
  14021. }
  14022. }
  14023. declare module BABYLON {
  14024. /**
  14025. * Defines the types of pose enabled controllers that are supported
  14026. */
  14027. export enum PoseEnabledControllerType {
  14028. /**
  14029. * HTC Vive
  14030. */
  14031. VIVE = 0,
  14032. /**
  14033. * Oculus Rift
  14034. */
  14035. OCULUS = 1,
  14036. /**
  14037. * Windows mixed reality
  14038. */
  14039. WINDOWS = 2,
  14040. /**
  14041. * Samsung gear VR
  14042. */
  14043. GEAR_VR = 3,
  14044. /**
  14045. * Google Daydream
  14046. */
  14047. DAYDREAM = 4,
  14048. /**
  14049. * Generic
  14050. */
  14051. GENERIC = 5
  14052. }
  14053. /**
  14054. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14055. */
  14056. export interface MutableGamepadButton {
  14057. /**
  14058. * Value of the button/trigger
  14059. */
  14060. value: number;
  14061. /**
  14062. * If the button/trigger is currently touched
  14063. */
  14064. touched: boolean;
  14065. /**
  14066. * If the button/trigger is currently pressed
  14067. */
  14068. pressed: boolean;
  14069. }
  14070. /**
  14071. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14072. * @hidden
  14073. */
  14074. export interface ExtendedGamepadButton extends GamepadButton {
  14075. /**
  14076. * If the button/trigger is currently pressed
  14077. */
  14078. readonly pressed: boolean;
  14079. /**
  14080. * If the button/trigger is currently touched
  14081. */
  14082. readonly touched: boolean;
  14083. /**
  14084. * Value of the button/trigger
  14085. */
  14086. readonly value: number;
  14087. }
  14088. /** @hidden */
  14089. export interface _GamePadFactory {
  14090. /**
  14091. * Returns wether or not the current gamepad can be created for this type of controller.
  14092. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14093. * @returns true if it can be created, otherwise false
  14094. */
  14095. canCreate(gamepadInfo: any): boolean;
  14096. /**
  14097. * Creates a new instance of the Gamepad.
  14098. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14099. * @returns the new gamepad instance
  14100. */
  14101. create(gamepadInfo: any): Gamepad;
  14102. }
  14103. /**
  14104. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14105. */
  14106. export class PoseEnabledControllerHelper {
  14107. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14108. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14109. /**
  14110. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14111. * @param vrGamepad the gamepad to initialized
  14112. * @returns a vr controller of the type the gamepad identified as
  14113. */
  14114. static InitiateController(vrGamepad: any): Gamepad;
  14115. }
  14116. /**
  14117. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14118. */
  14119. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14120. /**
  14121. * If the controller is used in a webXR session
  14122. */
  14123. isXR: boolean;
  14124. private _deviceRoomPosition;
  14125. private _deviceRoomRotationQuaternion;
  14126. /**
  14127. * The device position in babylon space
  14128. */
  14129. devicePosition: Vector3;
  14130. /**
  14131. * The device rotation in babylon space
  14132. */
  14133. deviceRotationQuaternion: Quaternion;
  14134. /**
  14135. * The scale factor of the device in babylon space
  14136. */
  14137. deviceScaleFactor: number;
  14138. /**
  14139. * (Likely devicePosition should be used instead) The device position in its room space
  14140. */
  14141. position: Vector3;
  14142. /**
  14143. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14144. */
  14145. rotationQuaternion: Quaternion;
  14146. /**
  14147. * The type of controller (Eg. Windows mixed reality)
  14148. */
  14149. controllerType: PoseEnabledControllerType;
  14150. protected _calculatedPosition: Vector3;
  14151. private _calculatedRotation;
  14152. /**
  14153. * The raw pose from the device
  14154. */
  14155. rawPose: DevicePose;
  14156. private _trackPosition;
  14157. private _maxRotationDistFromHeadset;
  14158. private _draggedRoomRotation;
  14159. /**
  14160. * @hidden
  14161. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14162. /**
  14163. * Internal, the mesh attached to the controller
  14164. * @hidden
  14165. */ private _mesh: Nullable<AbstractMesh>;
  14166. private _poseControlledCamera;
  14167. private _leftHandSystemQuaternion;
  14168. /**
  14169. * Internal, matrix used to convert room space to babylon space
  14170. * @hidden
  14171. */ private _deviceToWorld: Matrix;
  14172. /**
  14173. * Node to be used when casting a ray from the controller
  14174. * @hidden
  14175. */ private _pointingPoseNode: Nullable<TransformNode>;
  14176. /**
  14177. * Name of the child mesh that can be used to cast a ray from the controller
  14178. */
  14179. static readonly POINTING_POSE: string;
  14180. /**
  14181. * Creates a new PoseEnabledController from a gamepad
  14182. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14183. */
  14184. constructor(browserGamepad: any);
  14185. private _workingMatrix;
  14186. /**
  14187. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14188. */
  14189. update(): void;
  14190. /**
  14191. * Updates only the pose device and mesh without doing any button event checking
  14192. */
  14193. protected _updatePoseAndMesh(): void;
  14194. /**
  14195. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14196. * @param poseData raw pose fromthe device
  14197. */
  14198. updateFromDevice(poseData: DevicePose): void;
  14199. /**
  14200. * @hidden
  14201. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14202. /**
  14203. * Attaches a mesh to the controller
  14204. * @param mesh the mesh to be attached
  14205. */
  14206. attachToMesh(mesh: AbstractMesh): void;
  14207. /**
  14208. * Attaches the controllers mesh to a camera
  14209. * @param camera the camera the mesh should be attached to
  14210. */
  14211. attachToPoseControlledCamera(camera: TargetCamera): void;
  14212. /**
  14213. * Disposes of the controller
  14214. */
  14215. dispose(): void;
  14216. /**
  14217. * The mesh that is attached to the controller
  14218. */
  14219. readonly mesh: Nullable<AbstractMesh>;
  14220. /**
  14221. * Gets the ray of the controller in the direction the controller is pointing
  14222. * @param length the length the resulting ray should be
  14223. * @returns a ray in the direction the controller is pointing
  14224. */
  14225. getForwardRay(length?: number): Ray;
  14226. }
  14227. }
  14228. declare module BABYLON {
  14229. /**
  14230. * Defines the WebVRController object that represents controllers tracked in 3D space
  14231. */
  14232. export abstract class WebVRController extends PoseEnabledController {
  14233. /**
  14234. * Internal, the default controller model for the controller
  14235. */
  14236. protected _defaultModel: Nullable<AbstractMesh>;
  14237. /**
  14238. * Fired when the trigger state has changed
  14239. */
  14240. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14241. /**
  14242. * Fired when the main button state has changed
  14243. */
  14244. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14245. /**
  14246. * Fired when the secondary button state has changed
  14247. */
  14248. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14249. /**
  14250. * Fired when the pad state has changed
  14251. */
  14252. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14253. /**
  14254. * Fired when controllers stick values have changed
  14255. */
  14256. onPadValuesChangedObservable: Observable<StickValues>;
  14257. /**
  14258. * Array of button availible on the controller
  14259. */
  14260. protected _buttons: Array<MutableGamepadButton>;
  14261. private _onButtonStateChange;
  14262. /**
  14263. * Fired when a controller button's state has changed
  14264. * @param callback the callback containing the button that was modified
  14265. */
  14266. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14267. /**
  14268. * X and Y axis corresponding to the controllers joystick
  14269. */
  14270. pad: StickValues;
  14271. /**
  14272. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14273. */
  14274. hand: string;
  14275. /**
  14276. * The default controller model for the controller
  14277. */
  14278. readonly defaultModel: Nullable<AbstractMesh>;
  14279. /**
  14280. * Creates a new WebVRController from a gamepad
  14281. * @param vrGamepad the gamepad that the WebVRController should be created from
  14282. */
  14283. constructor(vrGamepad: any);
  14284. /**
  14285. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14286. */
  14287. update(): void;
  14288. /**
  14289. * Function to be called when a button is modified
  14290. */
  14291. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14292. /**
  14293. * Loads a mesh and attaches it to the controller
  14294. * @param scene the scene the mesh should be added to
  14295. * @param meshLoaded callback for when the mesh has been loaded
  14296. */
  14297. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14298. private _setButtonValue;
  14299. private _changes;
  14300. private _checkChanges;
  14301. /**
  14302. * Disposes of th webVRCOntroller
  14303. */
  14304. dispose(): void;
  14305. }
  14306. }
  14307. declare module BABYLON {
  14308. /**
  14309. * The HemisphericLight simulates the ambient environment light,
  14310. * so the passed direction is the light reflection direction, not the incoming direction.
  14311. */
  14312. export class HemisphericLight extends Light {
  14313. /**
  14314. * The groundColor is the light in the opposite direction to the one specified during creation.
  14315. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  14316. */
  14317. groundColor: Color3;
  14318. /**
  14319. * The light reflection direction, not the incoming direction.
  14320. */
  14321. direction: Vector3;
  14322. /**
  14323. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14324. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14325. * The HemisphericLight can't cast shadows.
  14326. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14327. * @param name The friendly name of the light
  14328. * @param direction The direction of the light reflection
  14329. * @param scene The scene the light belongs to
  14330. */
  14331. constructor(name: string, direction: Vector3, scene: Scene);
  14332. protected _buildUniformLayout(): void;
  14333. /**
  14334. * Returns the string "HemisphericLight".
  14335. * @return The class name
  14336. */
  14337. getClassName(): string;
  14338. /**
  14339. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14340. * Returns the updated direction.
  14341. * @param target The target the direction should point to
  14342. * @return The computed direction
  14343. */
  14344. setDirectionToTarget(target: Vector3): Vector3;
  14345. /**
  14346. * Returns the shadow generator associated to the light.
  14347. * @returns Always null for hemispheric lights because it does not support shadows.
  14348. */
  14349. getShadowGenerator(): Nullable<IShadowGenerator>;
  14350. /**
  14351. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14352. * @param effect The effect to update
  14353. * @param lightIndex The index of the light in the effect to update
  14354. * @returns The hemispheric light
  14355. */
  14356. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14357. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14358. /**
  14359. * Computes the world matrix of the node
  14360. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14361. * @param useWasUpdatedFlag defines a reserved property
  14362. * @returns the world matrix
  14363. */
  14364. computeWorldMatrix(): Matrix;
  14365. /**
  14366. * Returns the integer 3.
  14367. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14368. */
  14369. getTypeID(): number;
  14370. /**
  14371. * Prepares the list of defines specific to the light type.
  14372. * @param defines the list of defines
  14373. * @param lightIndex defines the index of the light for the effect
  14374. */
  14375. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14376. }
  14377. }
  14378. declare module BABYLON {
  14379. /** @hidden */
  14380. export var vrMultiviewToSingleviewPixelShader: {
  14381. name: string;
  14382. shader: string;
  14383. };
  14384. }
  14385. declare module BABYLON {
  14386. /**
  14387. * Renders to multiple views with a single draw call
  14388. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14389. */
  14390. export class MultiviewRenderTarget extends RenderTargetTexture {
  14391. /**
  14392. * Creates a multiview render target
  14393. * @param scene scene used with the render target
  14394. * @param size the size of the render target (used for each view)
  14395. */
  14396. constructor(scene: Scene, size?: number | {
  14397. width: number;
  14398. height: number;
  14399. } | {
  14400. ratio: number;
  14401. });
  14402. /**
  14403. * @hidden
  14404. * @param faceIndex the face index, if its a cube texture
  14405. */ private _bindFrameBuffer(faceIndex?: number): void;
  14406. /**
  14407. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14408. * @returns the view count
  14409. */
  14410. getViewCount(): number;
  14411. }
  14412. }
  14413. declare module BABYLON {
  14414. /**
  14415. * Represents a camera frustum
  14416. */
  14417. export class Frustum {
  14418. /**
  14419. * Gets the planes representing the frustum
  14420. * @param transform matrix to be applied to the returned planes
  14421. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14422. */
  14423. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14424. /**
  14425. * Gets the near frustum plane transformed by the transform matrix
  14426. * @param transform transformation matrix to be applied to the resulting frustum plane
  14427. * @param frustumPlane the resuling frustum plane
  14428. */
  14429. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14430. /**
  14431. * Gets the far frustum plane transformed by the transform matrix
  14432. * @param transform transformation matrix to be applied to the resulting frustum plane
  14433. * @param frustumPlane the resuling frustum plane
  14434. */
  14435. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14436. /**
  14437. * Gets the left frustum plane transformed by the transform matrix
  14438. * @param transform transformation matrix to be applied to the resulting frustum plane
  14439. * @param frustumPlane the resuling frustum plane
  14440. */
  14441. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14442. /**
  14443. * Gets the right frustum plane transformed by the transform matrix
  14444. * @param transform transformation matrix to be applied to the resulting frustum plane
  14445. * @param frustumPlane the resuling frustum plane
  14446. */
  14447. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14448. /**
  14449. * Gets the top frustum plane transformed by the transform matrix
  14450. * @param transform transformation matrix to be applied to the resulting frustum plane
  14451. * @param frustumPlane the resuling frustum plane
  14452. */
  14453. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14454. /**
  14455. * Gets the bottom frustum plane transformed by the transform matrix
  14456. * @param transform transformation matrix to be applied to the resulting frustum plane
  14457. * @param frustumPlane the resuling frustum plane
  14458. */
  14459. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14460. /**
  14461. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14462. * @param transform transformation matrix to be applied to the resulting frustum planes
  14463. * @param frustumPlanes the resuling frustum planes
  14464. */
  14465. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14466. }
  14467. }
  14468. declare module BABYLON {
  14469. interface Engine {
  14470. /**
  14471. * Creates a new multiview render target
  14472. * @param width defines the width of the texture
  14473. * @param height defines the height of the texture
  14474. * @returns the created multiview texture
  14475. */
  14476. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14477. /**
  14478. * Binds a multiview framebuffer to be drawn to
  14479. * @param multiviewTexture texture to bind
  14480. */
  14481. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14482. }
  14483. interface Camera {
  14484. /**
  14485. * @hidden
  14486. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14487. */ private _useMultiviewToSingleView: boolean;
  14488. /**
  14489. * @hidden
  14490. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14491. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14492. /**
  14493. * @hidden
  14494. * ensures the multiview texture of the camera exists and has the specified width/height
  14495. * @param width height to set on the multiview texture
  14496. * @param height width to set on the multiview texture
  14497. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14498. }
  14499. interface Scene {
  14500. /** @hidden */ private _transformMatrixR: Matrix;
  14501. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14502. /** @hidden */ private _createMultiviewUbo(): void;
  14503. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14504. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14505. }
  14506. }
  14507. declare module BABYLON {
  14508. /**
  14509. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14510. * This will not be used for webXR as it supports displaying texture arrays directly
  14511. */
  14512. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14513. /**
  14514. * Initializes a VRMultiviewToSingleview
  14515. * @param name name of the post process
  14516. * @param camera camera to be applied to
  14517. * @param scaleFactor scaling factor to the size of the output texture
  14518. */
  14519. constructor(name: string, camera: Camera, scaleFactor: number);
  14520. }
  14521. }
  14522. declare module BABYLON {
  14523. interface Engine {
  14524. /** @hidden */ private _vrDisplay: any;
  14525. /** @hidden */ private _vrSupported: boolean;
  14526. /** @hidden */ private _oldSize: Size;
  14527. /** @hidden */ private _oldHardwareScaleFactor: number;
  14528. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14529. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14530. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14531. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14532. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14533. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14534. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14535. /**
  14536. * Observable signaled when VR display mode changes
  14537. */
  14538. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14539. /**
  14540. * Observable signaled when VR request present is complete
  14541. */
  14542. onVRRequestPresentComplete: Observable<boolean>;
  14543. /**
  14544. * Observable signaled when VR request present starts
  14545. */
  14546. onVRRequestPresentStart: Observable<Engine>;
  14547. /**
  14548. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14549. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14550. */
  14551. isInVRExclusivePointerMode: boolean;
  14552. /**
  14553. * Gets a boolean indicating if a webVR device was detected
  14554. * @returns true if a webVR device was detected
  14555. */
  14556. isVRDevicePresent(): boolean;
  14557. /**
  14558. * Gets the current webVR device
  14559. * @returns the current webVR device (or null)
  14560. */
  14561. getVRDevice(): any;
  14562. /**
  14563. * Initializes a webVR display and starts listening to display change events
  14564. * The onVRDisplayChangedObservable will be notified upon these changes
  14565. * @returns A promise containing a VRDisplay and if vr is supported
  14566. */
  14567. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14568. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14569. /**
  14570. * Call this function to switch to webVR mode
  14571. * Will do nothing if webVR is not supported or if there is no webVR device
  14572. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14573. */
  14574. enableVR(): void;
  14575. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14576. }
  14577. }
  14578. declare module BABYLON {
  14579. /**
  14580. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14581. * IMPORTANT!! The data is right-hand data.
  14582. * @export
  14583. * @interface DevicePose
  14584. */
  14585. export interface DevicePose {
  14586. /**
  14587. * The position of the device, values in array are [x,y,z].
  14588. */
  14589. readonly position: Nullable<Float32Array>;
  14590. /**
  14591. * The linearVelocity of the device, values in array are [x,y,z].
  14592. */
  14593. readonly linearVelocity: Nullable<Float32Array>;
  14594. /**
  14595. * The linearAcceleration of the device, values in array are [x,y,z].
  14596. */
  14597. readonly linearAcceleration: Nullable<Float32Array>;
  14598. /**
  14599. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14600. */
  14601. readonly orientation: Nullable<Float32Array>;
  14602. /**
  14603. * The angularVelocity of the device, values in array are [x,y,z].
  14604. */
  14605. readonly angularVelocity: Nullable<Float32Array>;
  14606. /**
  14607. * The angularAcceleration of the device, values in array are [x,y,z].
  14608. */
  14609. readonly angularAcceleration: Nullable<Float32Array>;
  14610. }
  14611. /**
  14612. * Interface representing a pose controlled object in Babylon.
  14613. * A pose controlled object has both regular pose values as well as pose values
  14614. * from an external device such as a VR head mounted display
  14615. */
  14616. export interface PoseControlled {
  14617. /**
  14618. * The position of the object in babylon space.
  14619. */
  14620. position: Vector3;
  14621. /**
  14622. * The rotation quaternion of the object in babylon space.
  14623. */
  14624. rotationQuaternion: Quaternion;
  14625. /**
  14626. * The position of the device in babylon space.
  14627. */
  14628. devicePosition?: Vector3;
  14629. /**
  14630. * The rotation quaternion of the device in babylon space.
  14631. */
  14632. deviceRotationQuaternion: Quaternion;
  14633. /**
  14634. * The raw pose coming from the device.
  14635. */
  14636. rawPose: Nullable<DevicePose>;
  14637. /**
  14638. * The scale of the device to be used when translating from device space to babylon space.
  14639. */
  14640. deviceScaleFactor: number;
  14641. /**
  14642. * Updates the poseControlled values based on the input device pose.
  14643. * @param poseData the pose data to update the object with
  14644. */
  14645. updateFromDevice(poseData: DevicePose): void;
  14646. }
  14647. /**
  14648. * Set of options to customize the webVRCamera
  14649. */
  14650. export interface WebVROptions {
  14651. /**
  14652. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14653. */
  14654. trackPosition?: boolean;
  14655. /**
  14656. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14657. */
  14658. positionScale?: number;
  14659. /**
  14660. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14661. */
  14662. displayName?: string;
  14663. /**
  14664. * Should the native controller meshes be initialized. (default: true)
  14665. */
  14666. controllerMeshes?: boolean;
  14667. /**
  14668. * Creating a default HemiLight only on controllers. (default: true)
  14669. */
  14670. defaultLightingOnControllers?: boolean;
  14671. /**
  14672. * If you don't want to use the default VR button of the helper. (default: false)
  14673. */
  14674. useCustomVRButton?: boolean;
  14675. /**
  14676. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14677. */
  14678. customVRButton?: HTMLButtonElement;
  14679. /**
  14680. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14681. */
  14682. rayLength?: number;
  14683. /**
  14684. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14685. */
  14686. defaultHeight?: number;
  14687. /**
  14688. * If multiview should be used if availible (default: false)
  14689. */
  14690. useMultiview?: boolean;
  14691. }
  14692. /**
  14693. * This represents a WebVR camera.
  14694. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14695. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14696. */
  14697. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14698. private webVROptions;
  14699. /**
  14700. * @hidden
  14701. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14702. */ private _vrDevice: any;
  14703. /**
  14704. * The rawPose of the vrDevice.
  14705. */
  14706. rawPose: Nullable<DevicePose>;
  14707. private _onVREnabled;
  14708. private _specsVersion;
  14709. private _attached;
  14710. private _frameData;
  14711. protected _descendants: Array<Node>;
  14712. private _deviceRoomPosition;
  14713. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14714. private _standingMatrix;
  14715. /**
  14716. * Represents device position in babylon space.
  14717. */
  14718. devicePosition: Vector3;
  14719. /**
  14720. * Represents device rotation in babylon space.
  14721. */
  14722. deviceRotationQuaternion: Quaternion;
  14723. /**
  14724. * The scale of the device to be used when translating from device space to babylon space.
  14725. */
  14726. deviceScaleFactor: number;
  14727. private _deviceToWorld;
  14728. private _worldToDevice;
  14729. /**
  14730. * References to the webVR controllers for the vrDevice.
  14731. */
  14732. controllers: Array<WebVRController>;
  14733. /**
  14734. * Emits an event when a controller is attached.
  14735. */
  14736. onControllersAttachedObservable: Observable<WebVRController[]>;
  14737. /**
  14738. * Emits an event when a controller's mesh has been loaded;
  14739. */
  14740. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14741. /**
  14742. * Emits an event when the HMD's pose has been updated.
  14743. */
  14744. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14745. private _poseSet;
  14746. /**
  14747. * If the rig cameras be used as parent instead of this camera.
  14748. */
  14749. rigParenting: boolean;
  14750. private _lightOnControllers;
  14751. private _defaultHeight?;
  14752. /**
  14753. * Instantiates a WebVRFreeCamera.
  14754. * @param name The name of the WebVRFreeCamera
  14755. * @param position The starting anchor position for the camera
  14756. * @param scene The scene the camera belongs to
  14757. * @param webVROptions a set of customizable options for the webVRCamera
  14758. */
  14759. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14760. /**
  14761. * Gets the device distance from the ground in meters.
  14762. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  14763. */
  14764. deviceDistanceToRoomGround(): number;
  14765. /**
  14766. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14767. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14768. */
  14769. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14770. /**
  14771. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14772. * @returns A promise with a boolean set to if the standing matrix is supported.
  14773. */
  14774. useStandingMatrixAsync(): Promise<boolean>;
  14775. /**
  14776. * Disposes the camera
  14777. */
  14778. dispose(): void;
  14779. /**
  14780. * Gets a vrController by name.
  14781. * @param name The name of the controller to retreive
  14782. * @returns the controller matching the name specified or null if not found
  14783. */
  14784. getControllerByName(name: string): Nullable<WebVRController>;
  14785. private _leftController;
  14786. /**
  14787. * The controller corresponding to the users left hand.
  14788. */
  14789. readonly leftController: Nullable<WebVRController>;
  14790. private _rightController;
  14791. /**
  14792. * The controller corresponding to the users right hand.
  14793. */
  14794. readonly rightController: Nullable<WebVRController>;
  14795. /**
  14796. * Casts a ray forward from the vrCamera's gaze.
  14797. * @param length Length of the ray (default: 100)
  14798. * @returns the ray corresponding to the gaze
  14799. */
  14800. getForwardRay(length?: number): Ray;
  14801. /**
  14802. * @hidden
  14803. * Updates the camera based on device's frame data
  14804. */ private _checkInputs(): void;
  14805. /**
  14806. * Updates the poseControlled values based on the input device pose.
  14807. * @param poseData Pose coming from the device
  14808. */
  14809. updateFromDevice(poseData: DevicePose): void;
  14810. private _htmlElementAttached;
  14811. private _detachIfAttached;
  14812. /**
  14813. * WebVR's attach control will start broadcasting frames to the device.
  14814. * Note that in certain browsers (chrome for example) this function must be called
  14815. * within a user-interaction callback. Example:
  14816. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14817. *
  14818. * @param element html element to attach the vrDevice to
  14819. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14820. */
  14821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14822. /**
  14823. * Detaches the camera from the html element and disables VR
  14824. *
  14825. * @param element html element to detach from
  14826. */
  14827. detachControl(element: HTMLElement): void;
  14828. /**
  14829. * @returns the name of this class
  14830. */
  14831. getClassName(): string;
  14832. /**
  14833. * Calls resetPose on the vrDisplay
  14834. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14835. */
  14836. resetToCurrentRotation(): void;
  14837. /**
  14838. * @hidden
  14839. * Updates the rig cameras (left and right eye)
  14840. */ private _updateRigCameras(): void;
  14841. private _workingVector;
  14842. private _oneVector;
  14843. private _workingMatrix;
  14844. private updateCacheCalled;
  14845. private _correctPositionIfNotTrackPosition;
  14846. /**
  14847. * @hidden
  14848. * Updates the cached values of the camera
  14849. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14850. */ private _updateCache(ignoreParentClass?: boolean): void;
  14851. /**
  14852. * @hidden
  14853. * Get current device position in babylon world
  14854. */ private _computeDevicePosition(): void;
  14855. /**
  14856. * Updates the current device position and rotation in the babylon world
  14857. */
  14858. update(): void;
  14859. /**
  14860. * @hidden
  14861. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14862. * @returns an identity matrix
  14863. */ private _getViewMatrix(): Matrix;
  14864. private _tmpMatrix;
  14865. /**
  14866. * This function is called by the two RIG cameras.
  14867. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14868. * @hidden
  14869. */ private _getWebVRViewMatrix(): Matrix;
  14870. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  14871. private _onGamepadConnectedObserver;
  14872. private _onGamepadDisconnectedObserver;
  14873. private _updateCacheWhenTrackingDisabledObserver;
  14874. /**
  14875. * Initializes the controllers and their meshes
  14876. */
  14877. initControllers(): void;
  14878. }
  14879. }
  14880. declare module BABYLON {
  14881. /**
  14882. * Size options for a post process
  14883. */
  14884. export type PostProcessOptions = {
  14885. width: number;
  14886. height: number;
  14887. };
  14888. /**
  14889. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14890. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14891. */
  14892. export class PostProcess {
  14893. /** Name of the PostProcess. */
  14894. name: string;
  14895. /**
  14896. * Gets or sets the unique id of the post process
  14897. */
  14898. uniqueId: number;
  14899. /**
  14900. * Width of the texture to apply the post process on
  14901. */
  14902. width: number;
  14903. /**
  14904. * Height of the texture to apply the post process on
  14905. */
  14906. height: number;
  14907. /**
  14908. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14909. * @hidden
  14910. */ private _outputTexture: Nullable<InternalTexture>;
  14911. /**
  14912. * Sampling mode used by the shader
  14913. * See https://doc.babylonjs.com/classes/3.1/texture
  14914. */
  14915. renderTargetSamplingMode: number;
  14916. /**
  14917. * Clear color to use when screen clearing
  14918. */
  14919. clearColor: Color4;
  14920. /**
  14921. * If the buffer needs to be cleared before applying the post process. (default: true)
  14922. * Should be set to false if shader will overwrite all previous pixels.
  14923. */
  14924. autoClear: boolean;
  14925. /**
  14926. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14927. */
  14928. alphaMode: number;
  14929. /**
  14930. * Sets the setAlphaBlendConstants of the babylon engine
  14931. */
  14932. alphaConstants: Color4;
  14933. /**
  14934. * Animations to be used for the post processing
  14935. */
  14936. animations: Animation[];
  14937. /**
  14938. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14939. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14940. */
  14941. enablePixelPerfectMode: boolean;
  14942. /**
  14943. * Force the postprocess to be applied without taking in account viewport
  14944. */
  14945. forceFullscreenViewport: boolean;
  14946. /**
  14947. * List of inspectable custom properties (used by the Inspector)
  14948. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14949. */
  14950. inspectableCustomProperties: IInspectable[];
  14951. /**
  14952. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14953. *
  14954. * | Value | Type | Description |
  14955. * | ----- | ----------------------------------- | ----------- |
  14956. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14957. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14958. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14959. *
  14960. */
  14961. scaleMode: number;
  14962. /**
  14963. * Force textures to be a power of two (default: false)
  14964. */
  14965. alwaysForcePOT: boolean;
  14966. private _samples;
  14967. /**
  14968. * Number of sample textures (default: 1)
  14969. */
  14970. samples: number;
  14971. /**
  14972. * Modify the scale of the post process to be the same as the viewport (default: false)
  14973. */
  14974. adaptScaleToCurrentViewport: boolean;
  14975. private _camera;
  14976. private _scene;
  14977. private _engine;
  14978. private _options;
  14979. private _reusable;
  14980. private _textureType;
  14981. /**
  14982. * Smart array of input and output textures for the post process.
  14983. * @hidden
  14984. */ private _textures: SmartArray<InternalTexture>;
  14985. /**
  14986. * The index in _textures that corresponds to the output texture.
  14987. * @hidden
  14988. */ private _currentRenderTextureInd: number;
  14989. private _effect;
  14990. private _samplers;
  14991. private _fragmentUrl;
  14992. private _vertexUrl;
  14993. private _parameters;
  14994. private _scaleRatio;
  14995. protected _indexParameters: any;
  14996. private _shareOutputWithPostProcess;
  14997. private _texelSize;
  14998. private _forcedOutputTexture;
  14999. /**
  15000. * Returns the fragment url or shader name used in the post process.
  15001. * @returns the fragment url or name in the shader store.
  15002. */
  15003. getEffectName(): string;
  15004. /**
  15005. * An event triggered when the postprocess is activated.
  15006. */
  15007. onActivateObservable: Observable<Camera>;
  15008. private _onActivateObserver;
  15009. /**
  15010. * A function that is added to the onActivateObservable
  15011. */
  15012. onActivate: Nullable<(camera: Camera) => void>;
  15013. /**
  15014. * An event triggered when the postprocess changes its size.
  15015. */
  15016. onSizeChangedObservable: Observable<PostProcess>;
  15017. private _onSizeChangedObserver;
  15018. /**
  15019. * A function that is added to the onSizeChangedObservable
  15020. */
  15021. onSizeChanged: (postProcess: PostProcess) => void;
  15022. /**
  15023. * An event triggered when the postprocess applies its effect.
  15024. */
  15025. onApplyObservable: Observable<Effect>;
  15026. private _onApplyObserver;
  15027. /**
  15028. * A function that is added to the onApplyObservable
  15029. */
  15030. onApply: (effect: Effect) => void;
  15031. /**
  15032. * An event triggered before rendering the postprocess
  15033. */
  15034. onBeforeRenderObservable: Observable<Effect>;
  15035. private _onBeforeRenderObserver;
  15036. /**
  15037. * A function that is added to the onBeforeRenderObservable
  15038. */
  15039. onBeforeRender: (effect: Effect) => void;
  15040. /**
  15041. * An event triggered after rendering the postprocess
  15042. */
  15043. onAfterRenderObservable: Observable<Effect>;
  15044. private _onAfterRenderObserver;
  15045. /**
  15046. * A function that is added to the onAfterRenderObservable
  15047. */
  15048. onAfterRender: (efect: Effect) => void;
  15049. /**
  15050. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15051. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15052. */
  15053. inputTexture: InternalTexture;
  15054. /**
  15055. * Gets the camera which post process is applied to.
  15056. * @returns The camera the post process is applied to.
  15057. */
  15058. getCamera(): Camera;
  15059. /**
  15060. * Gets the texel size of the postprocess.
  15061. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15062. */
  15063. readonly texelSize: Vector2;
  15064. /**
  15065. * Creates a new instance PostProcess
  15066. * @param name The name of the PostProcess.
  15067. * @param fragmentUrl The url of the fragment shader to be used.
  15068. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15069. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15070. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15071. * @param camera The camera to apply the render pass to.
  15072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15073. * @param engine The engine which the post process will be applied. (default: current engine)
  15074. * @param reusable If the post process can be reused on the same frame. (default: false)
  15075. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15076. * @param textureType Type of textures used when performing the post process. (default: 0)
  15077. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15078. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15079. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15080. */
  15081. constructor(
  15082. /** Name of the PostProcess. */
  15083. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15084. /**
  15085. * Gets a string idenfifying the name of the class
  15086. * @returns "PostProcess" string
  15087. */
  15088. getClassName(): string;
  15089. /**
  15090. * Gets the engine which this post process belongs to.
  15091. * @returns The engine the post process was enabled with.
  15092. */
  15093. getEngine(): Engine;
  15094. /**
  15095. * The effect that is created when initializing the post process.
  15096. * @returns The created effect corresponding the the postprocess.
  15097. */
  15098. getEffect(): Effect;
  15099. /**
  15100. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15101. * @param postProcess The post process to share the output with.
  15102. * @returns This post process.
  15103. */
  15104. shareOutputWith(postProcess: PostProcess): PostProcess;
  15105. /**
  15106. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15107. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15108. */
  15109. useOwnOutput(): void;
  15110. /**
  15111. * Updates the effect with the current post process compile time values and recompiles the shader.
  15112. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15113. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15114. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15115. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15116. * @param onCompiled Called when the shader has been compiled.
  15117. * @param onError Called if there is an error when compiling a shader.
  15118. */
  15119. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15120. /**
  15121. * The post process is reusable if it can be used multiple times within one frame.
  15122. * @returns If the post process is reusable
  15123. */
  15124. isReusable(): boolean;
  15125. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15126. markTextureDirty(): void;
  15127. /**
  15128. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15129. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15130. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15131. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15132. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15133. * @returns The target texture that was bound to be written to.
  15134. */
  15135. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15136. /**
  15137. * If the post process is supported.
  15138. */
  15139. readonly isSupported: boolean;
  15140. /**
  15141. * The aspect ratio of the output texture.
  15142. */
  15143. readonly aspectRatio: number;
  15144. /**
  15145. * Get a value indicating if the post-process is ready to be used
  15146. * @returns true if the post-process is ready (shader is compiled)
  15147. */
  15148. isReady(): boolean;
  15149. /**
  15150. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15151. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15152. */
  15153. apply(): Nullable<Effect>;
  15154. private _disposeTextures;
  15155. /**
  15156. * Disposes the post process.
  15157. * @param camera The camera to dispose the post process on.
  15158. */
  15159. dispose(camera?: Camera): void;
  15160. }
  15161. }
  15162. declare module BABYLON {
  15163. /** @hidden */
  15164. export var kernelBlurVaryingDeclaration: {
  15165. name: string;
  15166. shader: string;
  15167. };
  15168. }
  15169. declare module BABYLON {
  15170. /** @hidden */
  15171. export var kernelBlurFragment: {
  15172. name: string;
  15173. shader: string;
  15174. };
  15175. }
  15176. declare module BABYLON {
  15177. /** @hidden */
  15178. export var kernelBlurFragment2: {
  15179. name: string;
  15180. shader: string;
  15181. };
  15182. }
  15183. declare module BABYLON {
  15184. /** @hidden */
  15185. export var kernelBlurPixelShader: {
  15186. name: string;
  15187. shader: string;
  15188. };
  15189. }
  15190. declare module BABYLON {
  15191. /** @hidden */
  15192. export var kernelBlurVertex: {
  15193. name: string;
  15194. shader: string;
  15195. };
  15196. }
  15197. declare module BABYLON {
  15198. /** @hidden */
  15199. export var kernelBlurVertexShader: {
  15200. name: string;
  15201. shader: string;
  15202. };
  15203. }
  15204. declare module BABYLON {
  15205. /**
  15206. * The Blur Post Process which blurs an image based on a kernel and direction.
  15207. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15208. */
  15209. export class BlurPostProcess extends PostProcess {
  15210. /** The direction in which to blur the image. */
  15211. direction: Vector2;
  15212. private blockCompilation;
  15213. protected _kernel: number;
  15214. protected _idealKernel: number;
  15215. protected _packedFloat: boolean;
  15216. private _staticDefines;
  15217. /**
  15218. * Sets the length in pixels of the blur sample region
  15219. */
  15220. /**
  15221. * Gets the length in pixels of the blur sample region
  15222. */
  15223. kernel: number;
  15224. /**
  15225. * Sets wether or not the blur needs to unpack/repack floats
  15226. */
  15227. /**
  15228. * Gets wether or not the blur is unpacking/repacking floats
  15229. */
  15230. packedFloat: boolean;
  15231. /**
  15232. * Creates a new instance BlurPostProcess
  15233. * @param name The name of the effect.
  15234. * @param direction The direction in which to blur the image.
  15235. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  15236. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15237. * @param camera The camera to apply the render pass to.
  15238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15239. * @param engine The engine which the post process will be applied. (default: current engine)
  15240. * @param reusable If the post process can be reused on the same frame. (default: false)
  15241. * @param textureType Type of textures used when performing the post process. (default: 0)
  15242. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  15243. */
  15244. constructor(name: string,
  15245. /** The direction in which to blur the image. */
  15246. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15247. /**
  15248. * Updates the effect with the current post process compile time values and recompiles the shader.
  15249. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15250. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15251. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15252. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15253. * @param onCompiled Called when the shader has been compiled.
  15254. * @param onError Called if there is an error when compiling a shader.
  15255. */
  15256. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15257. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15258. /**
  15259. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15260. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15261. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15262. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15263. * The gaps between physical kernels are compensated for in the weighting of the samples
  15264. * @param idealKernel Ideal blur kernel.
  15265. * @return Nearest best kernel.
  15266. */
  15267. protected _nearestBestKernel(idealKernel: number): number;
  15268. /**
  15269. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15270. * @param x The point on the Gaussian distribution to sample.
  15271. * @return the value of the Gaussian function at x.
  15272. */
  15273. protected _gaussianWeight(x: number): number;
  15274. /**
  15275. * Generates a string that can be used as a floating point number in GLSL.
  15276. * @param x Value to print.
  15277. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15278. * @return GLSL float string.
  15279. */
  15280. protected _glslFloat(x: number, decimalFigures?: number): string;
  15281. }
  15282. }
  15283. declare module BABYLON {
  15284. /**
  15285. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15286. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15287. * You can then easily use it as a reflectionTexture on a flat surface.
  15288. * In case the surface is not a plane, please consider relying on reflection probes.
  15289. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15290. */
  15291. export class MirrorTexture extends RenderTargetTexture {
  15292. private scene;
  15293. /**
  15294. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15295. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  15296. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15297. */
  15298. mirrorPlane: Plane;
  15299. /**
  15300. * Define the blur ratio used to blur the reflection if needed.
  15301. */
  15302. blurRatio: number;
  15303. /**
  15304. * Define the adaptive blur kernel used to blur the reflection if needed.
  15305. * This will autocompute the closest best match for the `blurKernel`
  15306. */
  15307. adaptiveBlurKernel: number;
  15308. /**
  15309. * Define the blur kernel used to blur the reflection if needed.
  15310. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15311. */
  15312. blurKernel: number;
  15313. /**
  15314. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15315. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15316. */
  15317. blurKernelX: number;
  15318. /**
  15319. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15320. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15321. */
  15322. blurKernelY: number;
  15323. private _autoComputeBlurKernel;
  15324. protected _onRatioRescale(): void;
  15325. private _updateGammaSpace;
  15326. private _imageProcessingConfigChangeObserver;
  15327. private _transformMatrix;
  15328. private _mirrorMatrix;
  15329. private _savedViewMatrix;
  15330. private _blurX;
  15331. private _blurY;
  15332. private _adaptiveBlurKernel;
  15333. private _blurKernelX;
  15334. private _blurKernelY;
  15335. private _blurRatio;
  15336. /**
  15337. * Instantiates a Mirror Texture.
  15338. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15339. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15340. * You can then easily use it as a reflectionTexture on a flat surface.
  15341. * In case the surface is not a plane, please consider relying on reflection probes.
  15342. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15343. * @param name
  15344. * @param size
  15345. * @param scene
  15346. * @param generateMipMaps
  15347. * @param type
  15348. * @param samplingMode
  15349. * @param generateDepthBuffer
  15350. */
  15351. constructor(name: string, size: number | {
  15352. width: number;
  15353. height: number;
  15354. } | {
  15355. ratio: number;
  15356. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15357. private _preparePostProcesses;
  15358. /**
  15359. * Clone the mirror texture.
  15360. * @returns the cloned texture
  15361. */
  15362. clone(): MirrorTexture;
  15363. /**
  15364. * Serialize the texture to a JSON representation you could use in Parse later on
  15365. * @returns the serialized JSON representation
  15366. */
  15367. serialize(): any;
  15368. /**
  15369. * Dispose the texture and release its associated resources.
  15370. */
  15371. dispose(): void;
  15372. }
  15373. }
  15374. declare module BABYLON {
  15375. /**
  15376. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15377. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15378. */
  15379. export class Texture extends BaseTexture {
  15380. /**
  15381. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15382. */
  15383. static SerializeBuffers: boolean;
  15384. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15385. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15386. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15387. /** nearest is mag = nearest and min = nearest and mip = linear */
  15388. static readonly NEAREST_SAMPLINGMODE: number;
  15389. /** nearest is mag = nearest and min = nearest and mip = linear */
  15390. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15391. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15392. static readonly BILINEAR_SAMPLINGMODE: number;
  15393. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15394. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15395. /** Trilinear is mag = linear and min = linear and mip = linear */
  15396. static readonly TRILINEAR_SAMPLINGMODE: number;
  15397. /** Trilinear is mag = linear and min = linear and mip = linear */
  15398. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15399. /** mag = nearest and min = nearest and mip = nearest */
  15400. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15401. /** mag = nearest and min = linear and mip = nearest */
  15402. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15403. /** mag = nearest and min = linear and mip = linear */
  15404. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15405. /** mag = nearest and min = linear and mip = none */
  15406. static readonly NEAREST_LINEAR: number;
  15407. /** mag = nearest and min = nearest and mip = none */
  15408. static readonly NEAREST_NEAREST: number;
  15409. /** mag = linear and min = nearest and mip = nearest */
  15410. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15411. /** mag = linear and min = nearest and mip = linear */
  15412. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15413. /** mag = linear and min = linear and mip = none */
  15414. static readonly LINEAR_LINEAR: number;
  15415. /** mag = linear and min = nearest and mip = none */
  15416. static readonly LINEAR_NEAREST: number;
  15417. /** Explicit coordinates mode */
  15418. static readonly EXPLICIT_MODE: number;
  15419. /** Spherical coordinates mode */
  15420. static readonly SPHERICAL_MODE: number;
  15421. /** Planar coordinates mode */
  15422. static readonly PLANAR_MODE: number;
  15423. /** Cubic coordinates mode */
  15424. static readonly CUBIC_MODE: number;
  15425. /** Projection coordinates mode */
  15426. static readonly PROJECTION_MODE: number;
  15427. /** Inverse Cubic coordinates mode */
  15428. static readonly SKYBOX_MODE: number;
  15429. /** Inverse Cubic coordinates mode */
  15430. static readonly INVCUBIC_MODE: number;
  15431. /** Equirectangular coordinates mode */
  15432. static readonly EQUIRECTANGULAR_MODE: number;
  15433. /** Equirectangular Fixed coordinates mode */
  15434. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15435. /** Equirectangular Fixed Mirrored coordinates mode */
  15436. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15437. /** Texture is not repeating outside of 0..1 UVs */
  15438. static readonly CLAMP_ADDRESSMODE: number;
  15439. /** Texture is repeating outside of 0..1 UVs */
  15440. static readonly WRAP_ADDRESSMODE: number;
  15441. /** Texture is repeating and mirrored */
  15442. static readonly MIRROR_ADDRESSMODE: number;
  15443. /**
  15444. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  15445. */
  15446. static UseSerializedUrlIfAny: boolean;
  15447. /**
  15448. * Define the url of the texture.
  15449. */
  15450. url: Nullable<string>;
  15451. /**
  15452. * Define an offset on the texture to offset the u coordinates of the UVs
  15453. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15454. */
  15455. uOffset: number;
  15456. /**
  15457. * Define an offset on the texture to offset the v coordinates of the UVs
  15458. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15459. */
  15460. vOffset: number;
  15461. /**
  15462. * Define an offset on the texture to scale the u coordinates of the UVs
  15463. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15464. */
  15465. uScale: number;
  15466. /**
  15467. * Define an offset on the texture to scale the v coordinates of the UVs
  15468. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15469. */
  15470. vScale: number;
  15471. /**
  15472. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15473. * @see http://doc.babylonjs.com/how_to/more_materials
  15474. */
  15475. uAng: number;
  15476. /**
  15477. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15478. * @see http://doc.babylonjs.com/how_to/more_materials
  15479. */
  15480. vAng: number;
  15481. /**
  15482. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15483. * @see http://doc.babylonjs.com/how_to/more_materials
  15484. */
  15485. wAng: number;
  15486. /**
  15487. * Defines the center of rotation (U)
  15488. */
  15489. uRotationCenter: number;
  15490. /**
  15491. * Defines the center of rotation (V)
  15492. */
  15493. vRotationCenter: number;
  15494. /**
  15495. * Defines the center of rotation (W)
  15496. */
  15497. wRotationCenter: number;
  15498. /**
  15499. * Are mip maps generated for this texture or not.
  15500. */
  15501. readonly noMipmap: boolean;
  15502. /**
  15503. * List of inspectable custom properties (used by the Inspector)
  15504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15505. */
  15506. inspectableCustomProperties: Nullable<IInspectable[]>;
  15507. private _noMipmap;
  15508. /** @hidden */ private _invertY: boolean;
  15509. private _rowGenerationMatrix;
  15510. private _cachedTextureMatrix;
  15511. private _projectionModeMatrix;
  15512. private _t0;
  15513. private _t1;
  15514. private _t2;
  15515. private _cachedUOffset;
  15516. private _cachedVOffset;
  15517. private _cachedUScale;
  15518. private _cachedVScale;
  15519. private _cachedUAng;
  15520. private _cachedVAng;
  15521. private _cachedWAng;
  15522. private _cachedProjectionMatrixId;
  15523. private _cachedCoordinatesMode;
  15524. /** @hidden */
  15525. protected _initialSamplingMode: number;
  15526. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  15527. private _deleteBuffer;
  15528. protected _format: Nullable<number>;
  15529. private _delayedOnLoad;
  15530. private _delayedOnError;
  15531. /**
  15532. * Observable triggered once the texture has been loaded.
  15533. */
  15534. onLoadObservable: Observable<Texture>;
  15535. protected _isBlocking: boolean;
  15536. /**
  15537. * Is the texture preventing material to render while loading.
  15538. * If false, a default texture will be used instead of the loading one during the preparation step.
  15539. */
  15540. isBlocking: boolean;
  15541. /**
  15542. * Get the current sampling mode associated with the texture.
  15543. */
  15544. readonly samplingMode: number;
  15545. /**
  15546. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15547. */
  15548. readonly invertY: boolean;
  15549. /**
  15550. * Instantiates a new texture.
  15551. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15552. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15553. * @param url define the url of the picture to load as a texture
  15554. * @param scene define the scene or engine the texture will belong to
  15555. * @param noMipmap define if the texture will require mip maps or not
  15556. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15557. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15558. * @param onLoad define a callback triggered when the texture has been loaded
  15559. * @param onError define a callback triggered when an error occurred during the loading session
  15560. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15561. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15562. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15563. */
  15564. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15565. /**
  15566. * Update the url (and optional buffer) of this texture if url was null during construction.
  15567. * @param url the url of the texture
  15568. * @param buffer the buffer of the texture (defaults to null)
  15569. * @param onLoad callback called when the texture is loaded (defaults to null)
  15570. */
  15571. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15572. /**
  15573. * Finish the loading sequence of a texture flagged as delayed load.
  15574. * @hidden
  15575. */
  15576. delayLoad(): void;
  15577. private _prepareRowForTextureGeneration;
  15578. /**
  15579. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15580. * @returns the transform matrix of the texture.
  15581. */
  15582. getTextureMatrix(): Matrix;
  15583. /**
  15584. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15585. * @returns The reflection texture transform
  15586. */
  15587. getReflectionTextureMatrix(): Matrix;
  15588. /**
  15589. * Clones the texture.
  15590. * @returns the cloned texture
  15591. */
  15592. clone(): Texture;
  15593. /**
  15594. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15595. * @returns The JSON representation of the texture
  15596. */
  15597. serialize(): any;
  15598. /**
  15599. * Get the current class name of the texture useful for serialization or dynamic coding.
  15600. * @returns "Texture"
  15601. */
  15602. getClassName(): string;
  15603. /**
  15604. * Dispose the texture and release its associated resources.
  15605. */
  15606. dispose(): void;
  15607. /**
  15608. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15609. * @param parsedTexture Define the JSON representation of the texture
  15610. * @param scene Define the scene the parsed texture should be instantiated in
  15611. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15612. * @returns The parsed texture if successful
  15613. */
  15614. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15615. /**
  15616. * Creates a texture from its base 64 representation.
  15617. * @param data Define the base64 payload without the data: prefix
  15618. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15619. * @param scene Define the scene the texture should belong to
  15620. * @param noMipmap Forces the texture to not create mip map information if true
  15621. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15622. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15623. * @param onLoad define a callback triggered when the texture has been loaded
  15624. * @param onError define a callback triggered when an error occurred during the loading session
  15625. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15626. * @returns the created texture
  15627. */
  15628. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15629. /**
  15630. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15631. * @param data Define the base64 payload without the data: prefix
  15632. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15633. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15634. * @param scene Define the scene the texture should belong to
  15635. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15636. * @param noMipmap Forces the texture to not create mip map information if true
  15637. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15638. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15639. * @param onLoad define a callback triggered when the texture has been loaded
  15640. * @param onError define a callback triggered when an error occurred during the loading session
  15641. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15642. * @returns the created texture
  15643. */
  15644. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  15645. }
  15646. }
  15647. declare module BABYLON {
  15648. /**
  15649. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15650. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15651. */
  15652. export class PostProcessManager {
  15653. private _scene;
  15654. private _indexBuffer;
  15655. private _vertexBuffers;
  15656. /**
  15657. * Creates a new instance PostProcess
  15658. * @param scene The scene that the post process is associated with.
  15659. */
  15660. constructor(scene: Scene);
  15661. private _prepareBuffers;
  15662. private _buildIndexBuffer;
  15663. /**
  15664. * Rebuilds the vertex buffers of the manager.
  15665. * @hidden
  15666. */ private _rebuild(): void;
  15667. /**
  15668. * Prepares a frame to be run through a post process.
  15669. * @param sourceTexture The input texture to the post procesess. (default: null)
  15670. * @param postProcesses An array of post processes to be run. (default: null)
  15671. * @returns True if the post processes were able to be run.
  15672. * @hidden
  15673. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15674. /**
  15675. * Manually render a set of post processes to a texture.
  15676. * @param postProcesses An array of post processes to be run.
  15677. * @param targetTexture The target texture to render to.
  15678. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15679. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15680. * @param lodLevel defines which lod of the texture to render to
  15681. */
  15682. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15683. /**
  15684. * Finalize the result of the output of the postprocesses.
  15685. * @param doNotPresent If true the result will not be displayed to the screen.
  15686. * @param targetTexture The target texture to render to.
  15687. * @param faceIndex The index of the face to bind the target texture to.
  15688. * @param postProcesses The array of post processes to render.
  15689. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15690. * @hidden
  15691. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15692. /**
  15693. * Disposes of the post process manager.
  15694. */
  15695. dispose(): void;
  15696. }
  15697. }
  15698. declare module BABYLON {
  15699. /** Interface used by value gradients (color, factor, ...) */
  15700. export interface IValueGradient {
  15701. /**
  15702. * Gets or sets the gradient value (between 0 and 1)
  15703. */
  15704. gradient: number;
  15705. }
  15706. /** Class used to store color4 gradient */
  15707. export class ColorGradient implements IValueGradient {
  15708. /**
  15709. * Gets or sets the gradient value (between 0 and 1)
  15710. */
  15711. gradient: number;
  15712. /**
  15713. * Gets or sets first associated color
  15714. */
  15715. color1: Color4;
  15716. /**
  15717. * Gets or sets second associated color
  15718. */
  15719. color2?: Color4;
  15720. /**
  15721. * Will get a color picked randomly between color1 and color2.
  15722. * If color2 is undefined then color1 will be used
  15723. * @param result defines the target Color4 to store the result in
  15724. */
  15725. getColorToRef(result: Color4): void;
  15726. }
  15727. /** Class used to store color 3 gradient */
  15728. export class Color3Gradient implements IValueGradient {
  15729. /**
  15730. * Gets or sets the gradient value (between 0 and 1)
  15731. */
  15732. gradient: number;
  15733. /**
  15734. * Gets or sets the associated color
  15735. */
  15736. color: Color3;
  15737. }
  15738. /** Class used to store factor gradient */
  15739. export class FactorGradient implements IValueGradient {
  15740. /**
  15741. * Gets or sets the gradient value (between 0 and 1)
  15742. */
  15743. gradient: number;
  15744. /**
  15745. * Gets or sets first associated factor
  15746. */
  15747. factor1: number;
  15748. /**
  15749. * Gets or sets second associated factor
  15750. */
  15751. factor2?: number;
  15752. /**
  15753. * Will get a number picked randomly between factor1 and factor2.
  15754. * If factor2 is undefined then factor1 will be used
  15755. * @returns the picked number
  15756. */
  15757. getFactor(): number;
  15758. }
  15759. /**
  15760. * Helper used to simplify some generic gradient tasks
  15761. */
  15762. export class GradientHelper {
  15763. /**
  15764. * Gets the current gradient from an array of IValueGradient
  15765. * @param ratio defines the current ratio to get
  15766. * @param gradients defines the array of IValueGradient
  15767. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15768. */
  15769. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15770. }
  15771. }
  15772. declare module BABYLON {
  15773. interface ThinEngine {
  15774. /**
  15775. * Creates a dynamic texture
  15776. * @param width defines the width of the texture
  15777. * @param height defines the height of the texture
  15778. * @param generateMipMaps defines if the engine should generate the mip levels
  15779. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  15780. * @returns the dynamic texture inside an InternalTexture
  15781. */
  15782. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  15783. /**
  15784. * Update the content of a dynamic texture
  15785. * @param texture defines the texture to update
  15786. * @param canvas defines the canvas containing the source
  15787. * @param invertY defines if data must be stored with Y axis inverted
  15788. * @param premulAlpha defines if alpha is stored as premultiplied
  15789. * @param format defines the format of the data
  15790. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  15791. */
  15792. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  15793. }
  15794. }
  15795. declare module BABYLON {
  15796. /**
  15797. * A class extending Texture allowing drawing on a texture
  15798. * @see http://doc.babylonjs.com/how_to/dynamictexture
  15799. */
  15800. export class DynamicTexture extends Texture {
  15801. private _generateMipMaps;
  15802. private _canvas;
  15803. private _context;
  15804. private _engine;
  15805. /**
  15806. * Creates a DynamicTexture
  15807. * @param name defines the name of the texture
  15808. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  15809. * @param scene defines the scene where you want the texture
  15810. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  15811. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  15812. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  15813. */
  15814. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  15815. /**
  15816. * Get the current class name of the texture useful for serialization or dynamic coding.
  15817. * @returns "DynamicTexture"
  15818. */
  15819. getClassName(): string;
  15820. /**
  15821. * Gets the current state of canRescale
  15822. */
  15823. readonly canRescale: boolean;
  15824. private _recreate;
  15825. /**
  15826. * Scales the texture
  15827. * @param ratio the scale factor to apply to both width and height
  15828. */
  15829. scale(ratio: number): void;
  15830. /**
  15831. * Resizes the texture
  15832. * @param width the new width
  15833. * @param height the new height
  15834. */
  15835. scaleTo(width: number, height: number): void;
  15836. /**
  15837. * Gets the context of the canvas used by the texture
  15838. * @returns the canvas context of the dynamic texture
  15839. */
  15840. getContext(): CanvasRenderingContext2D;
  15841. /**
  15842. * Clears the texture
  15843. */
  15844. clear(): void;
  15845. /**
  15846. * Updates the texture
  15847. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15848. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  15849. */
  15850. update(invertY?: boolean, premulAlpha?: boolean): void;
  15851. /**
  15852. * Draws text onto the texture
  15853. * @param text defines the text to be drawn
  15854. * @param x defines the placement of the text from the left
  15855. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  15856. * @param font defines the font to be used with font-style, font-size, font-name
  15857. * @param color defines the color used for the text
  15858. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  15859. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  15860. * @param update defines whether texture is immediately update (default is true)
  15861. */
  15862. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  15863. /**
  15864. * Clones the texture
  15865. * @returns the clone of the texture.
  15866. */
  15867. clone(): DynamicTexture;
  15868. /**
  15869. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  15870. * @returns a serialized dynamic texture object
  15871. */
  15872. serialize(): any;
  15873. /** @hidden */ private _rebuild(): void;
  15874. }
  15875. }
  15876. declare module BABYLON {
  15877. interface AbstractScene {
  15878. /**
  15879. * The list of procedural textures added to the scene
  15880. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15881. */
  15882. proceduralTextures: Array<ProceduralTexture>;
  15883. }
  15884. /**
  15885. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15886. * in a given scene.
  15887. */
  15888. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15889. /**
  15890. * The component name helpfull to identify the component in the list of scene components.
  15891. */
  15892. readonly name: string;
  15893. /**
  15894. * The scene the component belongs to.
  15895. */
  15896. scene: Scene;
  15897. /**
  15898. * Creates a new instance of the component for the given scene
  15899. * @param scene Defines the scene to register the component in
  15900. */
  15901. constructor(scene: Scene);
  15902. /**
  15903. * Registers the component in a given scene
  15904. */
  15905. register(): void;
  15906. /**
  15907. * Rebuilds the elements related to this component in case of
  15908. * context lost for instance.
  15909. */
  15910. rebuild(): void;
  15911. /**
  15912. * Disposes the component and the associated ressources.
  15913. */
  15914. dispose(): void;
  15915. private _beforeClear;
  15916. }
  15917. }
  15918. declare module BABYLON {
  15919. interface ThinEngine {
  15920. /**
  15921. * Creates a new render target cube texture
  15922. * @param size defines the size of the texture
  15923. * @param options defines the options used to create the texture
  15924. * @returns a new render target cube texture stored in an InternalTexture
  15925. */
  15926. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15927. }
  15928. }
  15929. declare module BABYLON {
  15930. /** @hidden */
  15931. export var proceduralVertexShader: {
  15932. name: string;
  15933. shader: string;
  15934. };
  15935. }
  15936. declare module BABYLON {
  15937. /**
  15938. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  15939. * This is the base class of any Procedural texture and contains most of the shareable code.
  15940. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15941. */
  15942. export class ProceduralTexture extends Texture {
  15943. isCube: boolean;
  15944. /**
  15945. * Define if the texture is enabled or not (disabled texture will not render)
  15946. */
  15947. isEnabled: boolean;
  15948. /**
  15949. * Define if the texture must be cleared before rendering (default is true)
  15950. */
  15951. autoClear: boolean;
  15952. /**
  15953. * Callback called when the texture is generated
  15954. */
  15955. onGenerated: () => void;
  15956. /**
  15957. * Event raised when the texture is generated
  15958. */
  15959. onGeneratedObservable: Observable<ProceduralTexture>;
  15960. /** @hidden */ private _generateMipMaps: boolean;
  15961. /** @hidden **/ private _effect: Effect;
  15962. /** @hidden */ private _textures: {
  15963. [key: string]: Texture;
  15964. };
  15965. private _size;
  15966. private _currentRefreshId;
  15967. private _refreshRate;
  15968. private _vertexBuffers;
  15969. private _indexBuffer;
  15970. private _uniforms;
  15971. private _samplers;
  15972. private _fragment;
  15973. private _floats;
  15974. private _ints;
  15975. private _floatsArrays;
  15976. private _colors3;
  15977. private _colors4;
  15978. private _vectors2;
  15979. private _vectors3;
  15980. private _matrices;
  15981. private _fallbackTexture;
  15982. private _fallbackTextureUsed;
  15983. private _engine;
  15984. private _cachedDefines;
  15985. private _contentUpdateId;
  15986. private _contentData;
  15987. /**
  15988. * Instantiates a new procedural texture.
  15989. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  15990. * This is the base class of any Procedural texture and contains most of the shareable code.
  15991. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15992. * @param name Define the name of the texture
  15993. * @param size Define the size of the texture to create
  15994. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15995. * @param scene Define the scene the texture belongs to
  15996. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15997. * @param generateMipMaps Define if the texture should creates mip maps or not
  15998. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15999. */
  16000. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16001. /**
  16002. * The effect that is created when initializing the post process.
  16003. * @returns The created effect corresponding the the postprocess.
  16004. */
  16005. getEffect(): Effect;
  16006. /**
  16007. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16008. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16009. */
  16010. getContent(): Nullable<ArrayBufferView>;
  16011. private _createIndexBuffer;
  16012. /** @hidden */ private _rebuild(): void;
  16013. /**
  16014. * Resets the texture in order to recreate its associated resources.
  16015. * This can be called in case of context loss
  16016. */
  16017. reset(): void;
  16018. protected _getDefines(): string;
  16019. /**
  16020. * Is the texture ready to be used ? (rendered at least once)
  16021. * @returns true if ready, otherwise, false.
  16022. */
  16023. isReady(): boolean;
  16024. /**
  16025. * Resets the refresh counter of the texture and start bak from scratch.
  16026. * Could be useful to regenerate the texture if it is setup to render only once.
  16027. */
  16028. resetRefreshCounter(): void;
  16029. /**
  16030. * Set the fragment shader to use in order to render the texture.
  16031. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16032. */
  16033. setFragment(fragment: any): void;
  16034. /**
  16035. * Define the refresh rate of the texture or the rendering frequency.
  16036. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16037. */
  16038. refreshRate: number;
  16039. /** @hidden */ private _shouldRender(): boolean;
  16040. /**
  16041. * Get the size the texture is rendering at.
  16042. * @returns the size (texture is always squared)
  16043. */
  16044. getRenderSize(): number;
  16045. /**
  16046. * Resize the texture to new value.
  16047. * @param size Define the new size the texture should have
  16048. * @param generateMipMaps Define whether the new texture should create mip maps
  16049. */
  16050. resize(size: number, generateMipMaps: boolean): void;
  16051. private _checkUniform;
  16052. /**
  16053. * Set a texture in the shader program used to render.
  16054. * @param name Define the name of the uniform samplers as defined in the shader
  16055. * @param texture Define the texture to bind to this sampler
  16056. * @return the texture itself allowing "fluent" like uniform updates
  16057. */
  16058. setTexture(name: string, texture: Texture): ProceduralTexture;
  16059. /**
  16060. * Set a float in the shader.
  16061. * @param name Define the name of the uniform as defined in the shader
  16062. * @param value Define the value to give to the uniform
  16063. * @return the texture itself allowing "fluent" like uniform updates
  16064. */
  16065. setFloat(name: string, value: number): ProceduralTexture;
  16066. /**
  16067. * Set a int in the shader.
  16068. * @param name Define the name of the uniform as defined in the shader
  16069. * @param value Define the value to give to the uniform
  16070. * @return the texture itself allowing "fluent" like uniform updates
  16071. */
  16072. setInt(name: string, value: number): ProceduralTexture;
  16073. /**
  16074. * Set an array of floats in the shader.
  16075. * @param name Define the name of the uniform as defined in the shader
  16076. * @param value Define the value to give to the uniform
  16077. * @return the texture itself allowing "fluent" like uniform updates
  16078. */
  16079. setFloats(name: string, value: number[]): ProceduralTexture;
  16080. /**
  16081. * Set a vec3 in the shader from a Color3.
  16082. * @param name Define the name of the uniform as defined in the shader
  16083. * @param value Define the value to give to the uniform
  16084. * @return the texture itself allowing "fluent" like uniform updates
  16085. */
  16086. setColor3(name: string, value: Color3): ProceduralTexture;
  16087. /**
  16088. * Set a vec4 in the shader from a Color4.
  16089. * @param name Define the name of the uniform as defined in the shader
  16090. * @param value Define the value to give to the uniform
  16091. * @return the texture itself allowing "fluent" like uniform updates
  16092. */
  16093. setColor4(name: string, value: Color4): ProceduralTexture;
  16094. /**
  16095. * Set a vec2 in the shader from a Vector2.
  16096. * @param name Define the name of the uniform as defined in the shader
  16097. * @param value Define the value to give to the uniform
  16098. * @return the texture itself allowing "fluent" like uniform updates
  16099. */
  16100. setVector2(name: string, value: Vector2): ProceduralTexture;
  16101. /**
  16102. * Set a vec3 in the shader from a Vector3.
  16103. * @param name Define the name of the uniform as defined in the shader
  16104. * @param value Define the value to give to the uniform
  16105. * @return the texture itself allowing "fluent" like uniform updates
  16106. */
  16107. setVector3(name: string, value: Vector3): ProceduralTexture;
  16108. /**
  16109. * Set a mat4 in the shader from a MAtrix.
  16110. * @param name Define the name of the uniform as defined in the shader
  16111. * @param value Define the value to give to the uniform
  16112. * @return the texture itself allowing "fluent" like uniform updates
  16113. */
  16114. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16115. /**
  16116. * Render the texture to its associated render target.
  16117. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16118. */
  16119. render(useCameraPostProcess?: boolean): void;
  16120. /**
  16121. * Clone the texture.
  16122. * @returns the cloned texture
  16123. */
  16124. clone(): ProceduralTexture;
  16125. /**
  16126. * Dispose the texture and release its asoociated resources.
  16127. */
  16128. dispose(): void;
  16129. }
  16130. }
  16131. declare module BABYLON {
  16132. /**
  16133. * This represents the base class for particle system in Babylon.
  16134. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16135. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16136. * @example https://doc.babylonjs.com/babylon101/particles
  16137. */
  16138. export class BaseParticleSystem {
  16139. /**
  16140. * Source color is added to the destination color without alpha affecting the result
  16141. */
  16142. static BLENDMODE_ONEONE: number;
  16143. /**
  16144. * Blend current color and particle color using particle’s alpha
  16145. */
  16146. static BLENDMODE_STANDARD: number;
  16147. /**
  16148. * Add current color and particle color multiplied by particle’s alpha
  16149. */
  16150. static BLENDMODE_ADD: number;
  16151. /**
  16152. * Multiply current color with particle color
  16153. */
  16154. static BLENDMODE_MULTIPLY: number;
  16155. /**
  16156. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16157. */
  16158. static BLENDMODE_MULTIPLYADD: number;
  16159. /**
  16160. * List of animations used by the particle system.
  16161. */
  16162. animations: Animation[];
  16163. /**
  16164. * The id of the Particle system.
  16165. */
  16166. id: string;
  16167. /**
  16168. * The friendly name of the Particle system.
  16169. */
  16170. name: string;
  16171. /**
  16172. * The rendering group used by the Particle system to chose when to render.
  16173. */
  16174. renderingGroupId: number;
  16175. /**
  16176. * The emitter represents the Mesh or position we are attaching the particle system to.
  16177. */
  16178. emitter: Nullable<AbstractMesh | Vector3>;
  16179. /**
  16180. * The maximum number of particles to emit per frame
  16181. */
  16182. emitRate: number;
  16183. /**
  16184. * If you want to launch only a few particles at once, that can be done, as well.
  16185. */
  16186. manualEmitCount: number;
  16187. /**
  16188. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16189. */
  16190. updateSpeed: number;
  16191. /**
  16192. * The amount of time the particle system is running (depends of the overall update speed).
  16193. */
  16194. targetStopDuration: number;
  16195. /**
  16196. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16197. */
  16198. disposeOnStop: boolean;
  16199. /**
  16200. * Minimum power of emitting particles.
  16201. */
  16202. minEmitPower: number;
  16203. /**
  16204. * Maximum power of emitting particles.
  16205. */
  16206. maxEmitPower: number;
  16207. /**
  16208. * Minimum life time of emitting particles.
  16209. */
  16210. minLifeTime: number;
  16211. /**
  16212. * Maximum life time of emitting particles.
  16213. */
  16214. maxLifeTime: number;
  16215. /**
  16216. * Minimum Size of emitting particles.
  16217. */
  16218. minSize: number;
  16219. /**
  16220. * Maximum Size of emitting particles.
  16221. */
  16222. maxSize: number;
  16223. /**
  16224. * Minimum scale of emitting particles on X axis.
  16225. */
  16226. minScaleX: number;
  16227. /**
  16228. * Maximum scale of emitting particles on X axis.
  16229. */
  16230. maxScaleX: number;
  16231. /**
  16232. * Minimum scale of emitting particles on Y axis.
  16233. */
  16234. minScaleY: number;
  16235. /**
  16236. * Maximum scale of emitting particles on Y axis.
  16237. */
  16238. maxScaleY: number;
  16239. /**
  16240. * Gets or sets the minimal initial rotation in radians.
  16241. */
  16242. minInitialRotation: number;
  16243. /**
  16244. * Gets or sets the maximal initial rotation in radians.
  16245. */
  16246. maxInitialRotation: number;
  16247. /**
  16248. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16249. */
  16250. minAngularSpeed: number;
  16251. /**
  16252. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16253. */
  16254. maxAngularSpeed: number;
  16255. /**
  16256. * The texture used to render each particle. (this can be a spritesheet)
  16257. */
  16258. particleTexture: Nullable<Texture>;
  16259. /**
  16260. * The layer mask we are rendering the particles through.
  16261. */
  16262. layerMask: number;
  16263. /**
  16264. * This can help using your own shader to render the particle system.
  16265. * The according effect will be created
  16266. */
  16267. customShader: any;
  16268. /**
  16269. * By default particle system starts as soon as they are created. This prevents the
  16270. * automatic start to happen and let you decide when to start emitting particles.
  16271. */
  16272. preventAutoStart: boolean;
  16273. private _noiseTexture;
  16274. /**
  16275. * Gets or sets a texture used to add random noise to particle positions
  16276. */
  16277. noiseTexture: Nullable<ProceduralTexture>;
  16278. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16279. noiseStrength: Vector3;
  16280. /**
  16281. * Callback triggered when the particle animation is ending.
  16282. */
  16283. onAnimationEnd: Nullable<() => void>;
  16284. /**
  16285. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16286. */
  16287. blendMode: number;
  16288. /**
  16289. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16290. * to override the particles.
  16291. */
  16292. forceDepthWrite: boolean;
  16293. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  16294. preWarmCycles: number;
  16295. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16296. preWarmStepOffset: number;
  16297. /**
  16298. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16299. */
  16300. spriteCellChangeSpeed: number;
  16301. /**
  16302. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16303. */
  16304. startSpriteCellID: number;
  16305. /**
  16306. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16307. */
  16308. endSpriteCellID: number;
  16309. /**
  16310. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16311. */
  16312. spriteCellWidth: number;
  16313. /**
  16314. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16315. */
  16316. spriteCellHeight: number;
  16317. /**
  16318. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16319. */
  16320. spriteRandomStartCell: boolean;
  16321. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16322. translationPivot: Vector2;
  16323. /** @hidden */
  16324. protected _isAnimationSheetEnabled: boolean;
  16325. /**
  16326. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16327. */
  16328. beginAnimationOnStart: boolean;
  16329. /**
  16330. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16331. */
  16332. beginAnimationFrom: number;
  16333. /**
  16334. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16335. */
  16336. beginAnimationTo: number;
  16337. /**
  16338. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16339. */
  16340. beginAnimationLoop: boolean;
  16341. /**
  16342. * Gets or sets a world offset applied to all particles
  16343. */
  16344. worldOffset: Vector3;
  16345. /**
  16346. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16347. */
  16348. isAnimationSheetEnabled: boolean;
  16349. /**
  16350. * Get hosting scene
  16351. * @returns the scene
  16352. */
  16353. getScene(): Scene;
  16354. /**
  16355. * You can use gravity if you want to give an orientation to your particles.
  16356. */
  16357. gravity: Vector3;
  16358. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16359. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16360. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16361. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16362. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16363. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16364. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16365. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16366. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16367. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16368. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16369. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16370. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16371. /**
  16372. * Defines the delay in milliseconds before starting the system (0 by default)
  16373. */
  16374. startDelay: number;
  16375. /**
  16376. * Gets the current list of drag gradients.
  16377. * You must use addDragGradient and removeDragGradient to udpate this list
  16378. * @returns the list of drag gradients
  16379. */
  16380. getDragGradients(): Nullable<Array<FactorGradient>>;
  16381. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16382. limitVelocityDamping: number;
  16383. /**
  16384. * Gets the current list of limit velocity gradients.
  16385. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16386. * @returns the list of limit velocity gradients
  16387. */
  16388. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16389. /**
  16390. * Gets the current list of color gradients.
  16391. * You must use addColorGradient and removeColorGradient to udpate this list
  16392. * @returns the list of color gradients
  16393. */
  16394. getColorGradients(): Nullable<Array<ColorGradient>>;
  16395. /**
  16396. * Gets the current list of size gradients.
  16397. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16398. * @returns the list of size gradients
  16399. */
  16400. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16401. /**
  16402. * Gets the current list of color remap gradients.
  16403. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16404. * @returns the list of color remap gradients
  16405. */
  16406. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16407. /**
  16408. * Gets the current list of alpha remap gradients.
  16409. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16410. * @returns the list of alpha remap gradients
  16411. */
  16412. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16413. /**
  16414. * Gets the current list of life time gradients.
  16415. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16416. * @returns the list of life time gradients
  16417. */
  16418. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16419. /**
  16420. * Gets the current list of angular speed gradients.
  16421. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16422. * @returns the list of angular speed gradients
  16423. */
  16424. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16425. /**
  16426. * Gets the current list of velocity gradients.
  16427. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16428. * @returns the list of velocity gradients
  16429. */
  16430. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16431. /**
  16432. * Gets the current list of start size gradients.
  16433. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16434. * @returns the list of start size gradients
  16435. */
  16436. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16437. /**
  16438. * Gets the current list of emit rate gradients.
  16439. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16440. * @returns the list of emit rate gradients
  16441. */
  16442. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16443. /**
  16444. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16445. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16446. */
  16447. direction1: Vector3;
  16448. /**
  16449. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16450. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16451. */
  16452. direction2: Vector3;
  16453. /**
  16454. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16455. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16456. */
  16457. minEmitBox: Vector3;
  16458. /**
  16459. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16460. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16461. */
  16462. maxEmitBox: Vector3;
  16463. /**
  16464. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16465. */
  16466. color1: Color4;
  16467. /**
  16468. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16469. */
  16470. color2: Color4;
  16471. /**
  16472. * Color the particle will have at the end of its lifetime
  16473. */
  16474. colorDead: Color4;
  16475. /**
  16476. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16477. */
  16478. textureMask: Color4;
  16479. /**
  16480. * The particle emitter type defines the emitter used by the particle system.
  16481. * It can be for example box, sphere, or cone...
  16482. */
  16483. particleEmitterType: IParticleEmitterType;
  16484. /** @hidden */ private _isSubEmitter: boolean;
  16485. /**
  16486. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16487. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16488. */
  16489. billboardMode: number;
  16490. protected _isBillboardBased: boolean;
  16491. /**
  16492. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16493. */
  16494. isBillboardBased: boolean;
  16495. /**
  16496. * The scene the particle system belongs to.
  16497. */
  16498. protected _scene: Scene;
  16499. /**
  16500. * Local cache of defines for image processing.
  16501. */
  16502. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16503. /**
  16504. * Default configuration related to image processing available in the standard Material.
  16505. */
  16506. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16507. /**
  16508. * Gets the image processing configuration used either in this material.
  16509. */
  16510. /**
  16511. * Sets the Default image processing configuration used either in the this material.
  16512. *
  16513. * If sets to null, the scene one is in use.
  16514. */
  16515. imageProcessingConfiguration: ImageProcessingConfiguration;
  16516. /**
  16517. * Attaches a new image processing configuration to the Standard Material.
  16518. * @param configuration
  16519. */
  16520. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16521. /** @hidden */
  16522. protected _reset(): void;
  16523. /** @hidden */
  16524. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16525. /**
  16526. * Instantiates a particle system.
  16527. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16528. * @param name The name of the particle system
  16529. */
  16530. constructor(name: string);
  16531. /**
  16532. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16533. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16534. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16535. * @returns the emitter
  16536. */
  16537. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16538. /**
  16539. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16540. * @param radius The radius of the hemisphere to emit from
  16541. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16542. * @returns the emitter
  16543. */
  16544. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16545. /**
  16546. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16547. * @param radius The radius of the sphere to emit from
  16548. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16549. * @returns the emitter
  16550. */
  16551. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16552. /**
  16553. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16554. * @param radius The radius of the sphere to emit from
  16555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16557. * @returns the emitter
  16558. */
  16559. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16560. /**
  16561. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16562. * @param radius The radius of the emission cylinder
  16563. * @param height The height of the emission cylinder
  16564. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16565. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16566. * @returns the emitter
  16567. */
  16568. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16569. /**
  16570. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16571. * @param radius The radius of the cylinder to emit from
  16572. * @param height The height of the emission cylinder
  16573. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16574. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16575. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16576. * @returns the emitter
  16577. */
  16578. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16579. /**
  16580. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16581. * @param radius The radius of the cone to emit from
  16582. * @param angle The base angle of the cone
  16583. * @returns the emitter
  16584. */
  16585. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16586. /**
  16587. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16588. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16589. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16590. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16591. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16592. * @returns the emitter
  16593. */
  16594. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16595. }
  16596. }
  16597. declare module BABYLON {
  16598. /**
  16599. * Type of sub emitter
  16600. */
  16601. export enum SubEmitterType {
  16602. /**
  16603. * Attached to the particle over it's lifetime
  16604. */
  16605. ATTACHED = 0,
  16606. /**
  16607. * Created when the particle dies
  16608. */
  16609. END = 1
  16610. }
  16611. /**
  16612. * Sub emitter class used to emit particles from an existing particle
  16613. */
  16614. export class SubEmitter {
  16615. /**
  16616. * the particle system to be used by the sub emitter
  16617. */
  16618. particleSystem: ParticleSystem;
  16619. /**
  16620. * Type of the submitter (Default: END)
  16621. */
  16622. type: SubEmitterType;
  16623. /**
  16624. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  16625. * Note: This only is supported when using an emitter of type Mesh
  16626. */
  16627. inheritDirection: boolean;
  16628. /**
  16629. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16630. */
  16631. inheritedVelocityAmount: number;
  16632. /**
  16633. * Creates a sub emitter
  16634. * @param particleSystem the particle system to be used by the sub emitter
  16635. */
  16636. constructor(
  16637. /**
  16638. * the particle system to be used by the sub emitter
  16639. */
  16640. particleSystem: ParticleSystem);
  16641. /**
  16642. * Clones the sub emitter
  16643. * @returns the cloned sub emitter
  16644. */
  16645. clone(): SubEmitter;
  16646. /**
  16647. * Serialize current object to a JSON object
  16648. * @returns the serialized object
  16649. */
  16650. serialize(): any;
  16651. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16652. /**
  16653. * Creates a new SubEmitter from a serialized JSON version
  16654. * @param serializationObject defines the JSON object to read from
  16655. * @param scene defines the hosting scene
  16656. * @param rootUrl defines the rootUrl for data loading
  16657. * @returns a new SubEmitter
  16658. */
  16659. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16660. /** Release associated resources */
  16661. dispose(): void;
  16662. }
  16663. }
  16664. declare module BABYLON {
  16665. /** @hidden */
  16666. export var clipPlaneFragmentDeclaration: {
  16667. name: string;
  16668. shader: string;
  16669. };
  16670. }
  16671. declare module BABYLON {
  16672. /** @hidden */
  16673. export var imageProcessingDeclaration: {
  16674. name: string;
  16675. shader: string;
  16676. };
  16677. }
  16678. declare module BABYLON {
  16679. /** @hidden */
  16680. export var imageProcessingFunctions: {
  16681. name: string;
  16682. shader: string;
  16683. };
  16684. }
  16685. declare module BABYLON {
  16686. /** @hidden */
  16687. export var clipPlaneFragment: {
  16688. name: string;
  16689. shader: string;
  16690. };
  16691. }
  16692. declare module BABYLON {
  16693. /** @hidden */
  16694. export var particlesPixelShader: {
  16695. name: string;
  16696. shader: string;
  16697. };
  16698. }
  16699. declare module BABYLON {
  16700. /** @hidden */
  16701. export var clipPlaneVertexDeclaration: {
  16702. name: string;
  16703. shader: string;
  16704. };
  16705. }
  16706. declare module BABYLON {
  16707. /** @hidden */
  16708. export var clipPlaneVertex: {
  16709. name: string;
  16710. shader: string;
  16711. };
  16712. }
  16713. declare module BABYLON {
  16714. /** @hidden */
  16715. export var particlesVertexShader: {
  16716. name: string;
  16717. shader: string;
  16718. };
  16719. }
  16720. declare module BABYLON {
  16721. /**
  16722. * This represents a particle system in Babylon.
  16723. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16724. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16725. * @example https://doc.babylonjs.com/babylon101/particles
  16726. */
  16727. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16728. /**
  16729. * Billboard mode will only apply to Y axis
  16730. */
  16731. static readonly BILLBOARDMODE_Y: number;
  16732. /**
  16733. * Billboard mode will apply to all axes
  16734. */
  16735. static readonly BILLBOARDMODE_ALL: number;
  16736. /**
  16737. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16738. */
  16739. static readonly BILLBOARDMODE_STRETCHED: number;
  16740. /**
  16741. * This function can be defined to provide custom update for active particles.
  16742. * This function will be called instead of regular update (age, position, color, etc.).
  16743. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16744. */
  16745. updateFunction: (particles: Particle[]) => void;
  16746. private _emitterWorldMatrix;
  16747. /**
  16748. * This function can be defined to specify initial direction for every new particle.
  16749. * It by default use the emitterType defined function
  16750. */
  16751. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16752. /**
  16753. * This function can be defined to specify initial position for every new particle.
  16754. * It by default use the emitterType defined function
  16755. */
  16756. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16757. /**
  16758. * @hidden
  16759. */ private _inheritedVelocityOffset: Vector3;
  16760. /**
  16761. * An event triggered when the system is disposed
  16762. */
  16763. onDisposeObservable: Observable<ParticleSystem>;
  16764. private _onDisposeObserver;
  16765. /**
  16766. * Sets a callback that will be triggered when the system is disposed
  16767. */
  16768. onDispose: () => void;
  16769. private _particles;
  16770. private _epsilon;
  16771. private _capacity;
  16772. private _stockParticles;
  16773. private _newPartsExcess;
  16774. private _vertexData;
  16775. private _vertexBuffer;
  16776. private _vertexBuffers;
  16777. private _spriteBuffer;
  16778. private _indexBuffer;
  16779. private _effect;
  16780. private _customEffect;
  16781. private _cachedDefines;
  16782. private _scaledColorStep;
  16783. private _colorDiff;
  16784. private _scaledDirection;
  16785. private _scaledGravity;
  16786. private _currentRenderId;
  16787. private _alive;
  16788. private _useInstancing;
  16789. private _started;
  16790. private _stopped;
  16791. private _actualFrame;
  16792. private _scaledUpdateSpeed;
  16793. private _vertexBufferSize;
  16794. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16795. /** @hidden */ private _currentEmitRate1: number;
  16796. /** @hidden */ private _currentEmitRate2: number;
  16797. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16798. /** @hidden */ private _currentStartSize1: number;
  16799. /** @hidden */ private _currentStartSize2: number;
  16800. private readonly _rawTextureWidth;
  16801. private _rampGradientsTexture;
  16802. private _useRampGradients;
  16803. /** Gets or sets a boolean indicating that ramp gradients must be used
  16804. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16805. */
  16806. useRampGradients: boolean;
  16807. /**
  16808. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  16809. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  16810. */
  16811. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16812. private _subEmitters;
  16813. /**
  16814. * @hidden
  16815. * If the particle systems emitter should be disposed when the particle system is disposed
  16816. */ private _disposeEmitterOnDispose: boolean;
  16817. /**
  16818. * The current active Sub-systems, this property is used by the root particle system only.
  16819. */
  16820. activeSubSystems: Array<ParticleSystem>;
  16821. private _rootParticleSystem;
  16822. /**
  16823. * Gets the current list of active particles
  16824. */
  16825. readonly particles: Particle[];
  16826. /**
  16827. * Returns the string "ParticleSystem"
  16828. * @returns a string containing the class name
  16829. */
  16830. getClassName(): string;
  16831. /**
  16832. * Instantiates a particle system.
  16833. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16834. * @param name The name of the particle system
  16835. * @param capacity The max number of particles alive at the same time
  16836. * @param scene The scene the particle system belongs to
  16837. * @param customEffect a custom effect used to change the way particles are rendered by default
  16838. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16839. * @param epsilon Offset used to render the particles
  16840. */
  16841. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16842. private _addFactorGradient;
  16843. private _removeFactorGradient;
  16844. /**
  16845. * Adds a new life time gradient
  16846. * @param gradient defines the gradient to use (between 0 and 1)
  16847. * @param factor defines the life time factor to affect to the specified gradient
  16848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16849. * @returns the current particle system
  16850. */
  16851. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16852. /**
  16853. * Remove a specific life time gradient
  16854. * @param gradient defines the gradient to remove
  16855. * @returns the current particle system
  16856. */
  16857. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16858. /**
  16859. * Adds a new size gradient
  16860. * @param gradient defines the gradient to use (between 0 and 1)
  16861. * @param factor defines the size factor to affect to the specified gradient
  16862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16863. * @returns the current particle system
  16864. */
  16865. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16866. /**
  16867. * Remove a specific size gradient
  16868. * @param gradient defines the gradient to remove
  16869. * @returns the current particle system
  16870. */
  16871. removeSizeGradient(gradient: number): IParticleSystem;
  16872. /**
  16873. * Adds a new color remap gradient
  16874. * @param gradient defines the gradient to use (between 0 and 1)
  16875. * @param min defines the color remap minimal range
  16876. * @param max defines the color remap maximal range
  16877. * @returns the current particle system
  16878. */
  16879. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16880. /**
  16881. * Remove a specific color remap gradient
  16882. * @param gradient defines the gradient to remove
  16883. * @returns the current particle system
  16884. */
  16885. removeColorRemapGradient(gradient: number): IParticleSystem;
  16886. /**
  16887. * Adds a new alpha remap gradient
  16888. * @param gradient defines the gradient to use (between 0 and 1)
  16889. * @param min defines the alpha remap minimal range
  16890. * @param max defines the alpha remap maximal range
  16891. * @returns the current particle system
  16892. */
  16893. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16894. /**
  16895. * Remove a specific alpha remap gradient
  16896. * @param gradient defines the gradient to remove
  16897. * @returns the current particle system
  16898. */
  16899. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16900. /**
  16901. * Adds a new angular speed gradient
  16902. * @param gradient defines the gradient to use (between 0 and 1)
  16903. * @param factor defines the angular speed to affect to the specified gradient
  16904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16905. * @returns the current particle system
  16906. */
  16907. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16908. /**
  16909. * Remove a specific angular speed gradient
  16910. * @param gradient defines the gradient to remove
  16911. * @returns the current particle system
  16912. */
  16913. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16914. /**
  16915. * Adds a new velocity gradient
  16916. * @param gradient defines the gradient to use (between 0 and 1)
  16917. * @param factor defines the velocity to affect to the specified gradient
  16918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16919. * @returns the current particle system
  16920. */
  16921. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16922. /**
  16923. * Remove a specific velocity gradient
  16924. * @param gradient defines the gradient to remove
  16925. * @returns the current particle system
  16926. */
  16927. removeVelocityGradient(gradient: number): IParticleSystem;
  16928. /**
  16929. * Adds a new limit velocity gradient
  16930. * @param gradient defines the gradient to use (between 0 and 1)
  16931. * @param factor defines the limit velocity value to affect to the specified gradient
  16932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16933. * @returns the current particle system
  16934. */
  16935. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16936. /**
  16937. * Remove a specific limit velocity gradient
  16938. * @param gradient defines the gradient to remove
  16939. * @returns the current particle system
  16940. */
  16941. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16942. /**
  16943. * Adds a new drag gradient
  16944. * @param gradient defines the gradient to use (between 0 and 1)
  16945. * @param factor defines the drag value to affect to the specified gradient
  16946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16947. * @returns the current particle system
  16948. */
  16949. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16950. /**
  16951. * Remove a specific drag gradient
  16952. * @param gradient defines the gradient to remove
  16953. * @returns the current particle system
  16954. */
  16955. removeDragGradient(gradient: number): IParticleSystem;
  16956. /**
  16957. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16958. * @param gradient defines the gradient to use (between 0 and 1)
  16959. * @param factor defines the emit rate value to affect to the specified gradient
  16960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16961. * @returns the current particle system
  16962. */
  16963. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16964. /**
  16965. * Remove a specific emit rate gradient
  16966. * @param gradient defines the gradient to remove
  16967. * @returns the current particle system
  16968. */
  16969. removeEmitRateGradient(gradient: number): IParticleSystem;
  16970. /**
  16971. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16972. * @param gradient defines the gradient to use (between 0 and 1)
  16973. * @param factor defines the start size value to affect to the specified gradient
  16974. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16975. * @returns the current particle system
  16976. */
  16977. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16978. /**
  16979. * Remove a specific start size gradient
  16980. * @param gradient defines the gradient to remove
  16981. * @returns the current particle system
  16982. */
  16983. removeStartSizeGradient(gradient: number): IParticleSystem;
  16984. private _createRampGradientTexture;
  16985. /**
  16986. * Gets the current list of ramp gradients.
  16987. * You must use addRampGradient and removeRampGradient to udpate this list
  16988. * @returns the list of ramp gradients
  16989. */
  16990. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16991. /**
  16992. * Adds a new ramp gradient used to remap particle colors
  16993. * @param gradient defines the gradient to use (between 0 and 1)
  16994. * @param color defines the color to affect to the specified gradient
  16995. * @returns the current particle system
  16996. */
  16997. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16998. /**
  16999. * Remove a specific ramp gradient
  17000. * @param gradient defines the gradient to remove
  17001. * @returns the current particle system
  17002. */
  17003. removeRampGradient(gradient: number): ParticleSystem;
  17004. /**
  17005. * Adds a new color gradient
  17006. * @param gradient defines the gradient to use (between 0 and 1)
  17007. * @param color1 defines the color to affect to the specified gradient
  17008. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17009. * @returns this particle system
  17010. */
  17011. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17012. /**
  17013. * Remove a specific color gradient
  17014. * @param gradient defines the gradient to remove
  17015. * @returns this particle system
  17016. */
  17017. removeColorGradient(gradient: number): IParticleSystem;
  17018. private _fetchR;
  17019. protected _reset(): void;
  17020. private _resetEffect;
  17021. private _createVertexBuffers;
  17022. private _createIndexBuffer;
  17023. /**
  17024. * Gets the maximum number of particles active at the same time.
  17025. * @returns The max number of active particles.
  17026. */
  17027. getCapacity(): number;
  17028. /**
  17029. * Gets whether there are still active particles in the system.
  17030. * @returns True if it is alive, otherwise false.
  17031. */
  17032. isAlive(): boolean;
  17033. /**
  17034. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17035. * @returns True if it has been started, otherwise false.
  17036. */
  17037. isStarted(): boolean;
  17038. private _prepareSubEmitterInternalArray;
  17039. /**
  17040. * Starts the particle system and begins to emit
  17041. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17042. */
  17043. start(delay?: number): void;
  17044. /**
  17045. * Stops the particle system.
  17046. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  17047. */
  17048. stop(stopSubEmitters?: boolean): void;
  17049. /**
  17050. * Remove all active particles
  17051. */
  17052. reset(): void;
  17053. /**
  17054. * @hidden (for internal use only)
  17055. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17056. /**
  17057. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17058. * Its lifetime will start back at 0.
  17059. */
  17060. recycleParticle: (particle: Particle) => void;
  17061. private _stopSubEmitters;
  17062. private _createParticle;
  17063. private _removeFromRoot;
  17064. private _emitFromParticle;
  17065. private _update;
  17066. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17067. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17068. /** @hidden */
  17069. private _getEffect;
  17070. /**
  17071. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17072. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17073. */
  17074. animate(preWarmOnly?: boolean): void;
  17075. private _appendParticleVertices;
  17076. /**
  17077. * Rebuilds the particle system.
  17078. */
  17079. rebuild(): void;
  17080. /**
  17081. * Is this system ready to be used/rendered
  17082. * @return true if the system is ready
  17083. */
  17084. isReady(): boolean;
  17085. private _render;
  17086. /**
  17087. * Renders the particle system in its current state.
  17088. * @returns the current number of particles
  17089. */
  17090. render(): number;
  17091. /**
  17092. * Disposes the particle system and free the associated resources
  17093. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17094. */
  17095. dispose(disposeTexture?: boolean): void;
  17096. /**
  17097. * Clones the particle system.
  17098. * @param name The name of the cloned object
  17099. * @param newEmitter The new emitter to use
  17100. * @returns the cloned particle system
  17101. */
  17102. clone(name: string, newEmitter: any): ParticleSystem;
  17103. /**
  17104. * Serializes the particle system to a JSON object.
  17105. * @returns the JSON object
  17106. */
  17107. serialize(): any;
  17108. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17109. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17110. /**
  17111. * Parses a JSON object to create a particle system.
  17112. * @param parsedParticleSystem The JSON object to parse
  17113. * @param scene The scene to create the particle system in
  17114. * @param rootUrl The root url to use to load external dependencies like texture
  17115. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17116. * @returns the Parsed particle system
  17117. */
  17118. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17119. }
  17120. }
  17121. declare module BABYLON {
  17122. /**
  17123. * A particle represents one of the element emitted by a particle system.
  17124. * This is mainly define by its coordinates, direction, velocity and age.
  17125. */
  17126. export class Particle {
  17127. /**
  17128. * The particle system the particle belongs to.
  17129. */
  17130. particleSystem: ParticleSystem;
  17131. private static _Count;
  17132. /**
  17133. * Unique ID of the particle
  17134. */
  17135. id: number;
  17136. /**
  17137. * The world position of the particle in the scene.
  17138. */
  17139. position: Vector3;
  17140. /**
  17141. * The world direction of the particle in the scene.
  17142. */
  17143. direction: Vector3;
  17144. /**
  17145. * The color of the particle.
  17146. */
  17147. color: Color4;
  17148. /**
  17149. * The color change of the particle per step.
  17150. */
  17151. colorStep: Color4;
  17152. /**
  17153. * Defines how long will the life of the particle be.
  17154. */
  17155. lifeTime: number;
  17156. /**
  17157. * The current age of the particle.
  17158. */
  17159. age: number;
  17160. /**
  17161. * The current size of the particle.
  17162. */
  17163. size: number;
  17164. /**
  17165. * The current scale of the particle.
  17166. */
  17167. scale: Vector2;
  17168. /**
  17169. * The current angle of the particle.
  17170. */
  17171. angle: number;
  17172. /**
  17173. * Defines how fast is the angle changing.
  17174. */
  17175. angularSpeed: number;
  17176. /**
  17177. * Defines the cell index used by the particle to be rendered from a sprite.
  17178. */
  17179. cellIndex: number;
  17180. /**
  17181. * The information required to support color remapping
  17182. */
  17183. remapData: Vector4;
  17184. /** @hidden */ private _randomCellOffset?: number;
  17185. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17186. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17187. /** @hidden */ private _initialStartSpriteCellID: number;
  17188. /** @hidden */ private _initialEndSpriteCellID: number;
  17189. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17190. /** @hidden */ private _currentColor1: Color4;
  17191. /** @hidden */ private _currentColor2: Color4;
  17192. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17193. /** @hidden */ private _currentSize1: number;
  17194. /** @hidden */ private _currentSize2: number;
  17195. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17196. /** @hidden */ private _currentAngularSpeed1: number;
  17197. /** @hidden */ private _currentAngularSpeed2: number;
  17198. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17199. /** @hidden */ private _currentVelocity1: number;
  17200. /** @hidden */ private _currentVelocity2: number;
  17201. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17202. /** @hidden */ private _currentLimitVelocity1: number;
  17203. /** @hidden */ private _currentLimitVelocity2: number;
  17204. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17205. /** @hidden */ private _currentDrag1: number;
  17206. /** @hidden */ private _currentDrag2: number;
  17207. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17208. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17209. /**
  17210. * Creates a new instance Particle
  17211. * @param particleSystem the particle system the particle belongs to
  17212. */
  17213. constructor(
  17214. /**
  17215. * The particle system the particle belongs to.
  17216. */
  17217. particleSystem: ParticleSystem);
  17218. private updateCellInfoFromSystem;
  17219. /**
  17220. * Defines how the sprite cell index is updated for the particle
  17221. */
  17222. updateCellIndex(): void;
  17223. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17224. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17225. /** @hidden */ private _reset(): void;
  17226. /**
  17227. * Copy the properties of particle to another one.
  17228. * @param other the particle to copy the information to.
  17229. */
  17230. copyTo(other: Particle): void;
  17231. }
  17232. }
  17233. declare module BABYLON {
  17234. /**
  17235. * Particle emitter represents a volume emitting particles.
  17236. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17237. */
  17238. export interface IParticleEmitterType {
  17239. /**
  17240. * Called by the particle System when the direction is computed for the created particle.
  17241. * @param worldMatrix is the world matrix of the particle system
  17242. * @param directionToUpdate is the direction vector to update with the result
  17243. * @param particle is the particle we are computed the direction for
  17244. */
  17245. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17246. /**
  17247. * Called by the particle System when the position is computed for the created particle.
  17248. * @param worldMatrix is the world matrix of the particle system
  17249. * @param positionToUpdate is the position vector to update with the result
  17250. * @param particle is the particle we are computed the position for
  17251. */
  17252. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17253. /**
  17254. * Clones the current emitter and returns a copy of it
  17255. * @returns the new emitter
  17256. */
  17257. clone(): IParticleEmitterType;
  17258. /**
  17259. * Called by the GPUParticleSystem to setup the update shader
  17260. * @param effect defines the update shader
  17261. */
  17262. applyToShader(effect: Effect): void;
  17263. /**
  17264. * Returns a string to use to update the GPU particles update shader
  17265. * @returns the effect defines string
  17266. */
  17267. getEffectDefines(): string;
  17268. /**
  17269. * Returns a string representing the class name
  17270. * @returns a string containing the class name
  17271. */
  17272. getClassName(): string;
  17273. /**
  17274. * Serializes the particle system to a JSON object.
  17275. * @returns the JSON object
  17276. */
  17277. serialize(): any;
  17278. /**
  17279. * Parse properties from a JSON object
  17280. * @param serializationObject defines the JSON object
  17281. */
  17282. parse(serializationObject: any): void;
  17283. }
  17284. }
  17285. declare module BABYLON {
  17286. /**
  17287. * Particle emitter emitting particles from the inside of a box.
  17288. * It emits the particles randomly between 2 given directions.
  17289. */
  17290. export class BoxParticleEmitter implements IParticleEmitterType {
  17291. /**
  17292. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17293. */
  17294. direction1: Vector3;
  17295. /**
  17296. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17297. */
  17298. direction2: Vector3;
  17299. /**
  17300. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17301. */
  17302. minEmitBox: Vector3;
  17303. /**
  17304. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17305. */
  17306. maxEmitBox: Vector3;
  17307. /**
  17308. * Creates a new instance BoxParticleEmitter
  17309. */
  17310. constructor();
  17311. /**
  17312. * Called by the particle System when the direction is computed for the created particle.
  17313. * @param worldMatrix is the world matrix of the particle system
  17314. * @param directionToUpdate is the direction vector to update with the result
  17315. * @param particle is the particle we are computed the direction for
  17316. */
  17317. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17318. /**
  17319. * Called by the particle System when the position is computed for the created particle.
  17320. * @param worldMatrix is the world matrix of the particle system
  17321. * @param positionToUpdate is the position vector to update with the result
  17322. * @param particle is the particle we are computed the position for
  17323. */
  17324. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17325. /**
  17326. * Clones the current emitter and returns a copy of it
  17327. * @returns the new emitter
  17328. */
  17329. clone(): BoxParticleEmitter;
  17330. /**
  17331. * Called by the GPUParticleSystem to setup the update shader
  17332. * @param effect defines the update shader
  17333. */
  17334. applyToShader(effect: Effect): void;
  17335. /**
  17336. * Returns a string to use to update the GPU particles update shader
  17337. * @returns a string containng the defines string
  17338. */
  17339. getEffectDefines(): string;
  17340. /**
  17341. * Returns the string "BoxParticleEmitter"
  17342. * @returns a string containing the class name
  17343. */
  17344. getClassName(): string;
  17345. /**
  17346. * Serializes the particle system to a JSON object.
  17347. * @returns the JSON object
  17348. */
  17349. serialize(): any;
  17350. /**
  17351. * Parse properties from a JSON object
  17352. * @param serializationObject defines the JSON object
  17353. */
  17354. parse(serializationObject: any): void;
  17355. }
  17356. }
  17357. declare module BABYLON {
  17358. /**
  17359. * Particle emitter emitting particles from the inside of a cone.
  17360. * It emits the particles alongside the cone volume from the base to the particle.
  17361. * The emission direction might be randomized.
  17362. */
  17363. export class ConeParticleEmitter implements IParticleEmitterType {
  17364. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17365. directionRandomizer: number;
  17366. private _radius;
  17367. private _angle;
  17368. private _height;
  17369. /**
  17370. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17371. */
  17372. radiusRange: number;
  17373. /**
  17374. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17375. */
  17376. heightRange: number;
  17377. /**
  17378. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17379. */
  17380. emitFromSpawnPointOnly: boolean;
  17381. /**
  17382. * Gets or sets the radius of the emission cone
  17383. */
  17384. radius: number;
  17385. /**
  17386. * Gets or sets the angle of the emission cone
  17387. */
  17388. angle: number;
  17389. private _buildHeight;
  17390. /**
  17391. * Creates a new instance ConeParticleEmitter
  17392. * @param radius the radius of the emission cone (1 by default)
  17393. * @param angle the cone base angle (PI by default)
  17394. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17395. */
  17396. constructor(radius?: number, angle?: number,
  17397. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17398. directionRandomizer?: number);
  17399. /**
  17400. * Called by the particle System when the direction is computed for the created particle.
  17401. * @param worldMatrix is the world matrix of the particle system
  17402. * @param directionToUpdate is the direction vector to update with the result
  17403. * @param particle is the particle we are computed the direction for
  17404. */
  17405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17406. /**
  17407. * Called by the particle System when the position is computed for the created particle.
  17408. * @param worldMatrix is the world matrix of the particle system
  17409. * @param positionToUpdate is the position vector to update with the result
  17410. * @param particle is the particle we are computed the position for
  17411. */
  17412. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17413. /**
  17414. * Clones the current emitter and returns a copy of it
  17415. * @returns the new emitter
  17416. */
  17417. clone(): ConeParticleEmitter;
  17418. /**
  17419. * Called by the GPUParticleSystem to setup the update shader
  17420. * @param effect defines the update shader
  17421. */
  17422. applyToShader(effect: Effect): void;
  17423. /**
  17424. * Returns a string to use to update the GPU particles update shader
  17425. * @returns a string containng the defines string
  17426. */
  17427. getEffectDefines(): string;
  17428. /**
  17429. * Returns the string "ConeParticleEmitter"
  17430. * @returns a string containing the class name
  17431. */
  17432. getClassName(): string;
  17433. /**
  17434. * Serializes the particle system to a JSON object.
  17435. * @returns the JSON object
  17436. */
  17437. serialize(): any;
  17438. /**
  17439. * Parse properties from a JSON object
  17440. * @param serializationObject defines the JSON object
  17441. */
  17442. parse(serializationObject: any): void;
  17443. }
  17444. }
  17445. declare module BABYLON {
  17446. /**
  17447. * Particle emitter emitting particles from the inside of a cylinder.
  17448. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17449. */
  17450. export class CylinderParticleEmitter implements IParticleEmitterType {
  17451. /**
  17452. * The radius of the emission cylinder.
  17453. */
  17454. radius: number;
  17455. /**
  17456. * The height of the emission cylinder.
  17457. */
  17458. height: number;
  17459. /**
  17460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17461. */
  17462. radiusRange: number;
  17463. /**
  17464. * How much to randomize the particle direction [0-1].
  17465. */
  17466. directionRandomizer: number;
  17467. /**
  17468. * Creates a new instance CylinderParticleEmitter
  17469. * @param radius the radius of the emission cylinder (1 by default)
  17470. * @param height the height of the emission cylinder (1 by default)
  17471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17472. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17473. */
  17474. constructor(
  17475. /**
  17476. * The radius of the emission cylinder.
  17477. */
  17478. radius?: number,
  17479. /**
  17480. * The height of the emission cylinder.
  17481. */
  17482. height?: number,
  17483. /**
  17484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17485. */
  17486. radiusRange?: number,
  17487. /**
  17488. * How much to randomize the particle direction [0-1].
  17489. */
  17490. directionRandomizer?: number);
  17491. /**
  17492. * Called by the particle System when the direction is computed for the created particle.
  17493. * @param worldMatrix is the world matrix of the particle system
  17494. * @param directionToUpdate is the direction vector to update with the result
  17495. * @param particle is the particle we are computed the direction for
  17496. */
  17497. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17498. /**
  17499. * Called by the particle System when the position is computed for the created particle.
  17500. * @param worldMatrix is the world matrix of the particle system
  17501. * @param positionToUpdate is the position vector to update with the result
  17502. * @param particle is the particle we are computed the position for
  17503. */
  17504. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17505. /**
  17506. * Clones the current emitter and returns a copy of it
  17507. * @returns the new emitter
  17508. */
  17509. clone(): CylinderParticleEmitter;
  17510. /**
  17511. * Called by the GPUParticleSystem to setup the update shader
  17512. * @param effect defines the update shader
  17513. */
  17514. applyToShader(effect: Effect): void;
  17515. /**
  17516. * Returns a string to use to update the GPU particles update shader
  17517. * @returns a string containng the defines string
  17518. */
  17519. getEffectDefines(): string;
  17520. /**
  17521. * Returns the string "CylinderParticleEmitter"
  17522. * @returns a string containing the class name
  17523. */
  17524. getClassName(): string;
  17525. /**
  17526. * Serializes the particle system to a JSON object.
  17527. * @returns the JSON object
  17528. */
  17529. serialize(): any;
  17530. /**
  17531. * Parse properties from a JSON object
  17532. * @param serializationObject defines the JSON object
  17533. */
  17534. parse(serializationObject: any): void;
  17535. }
  17536. /**
  17537. * Particle emitter emitting particles from the inside of a cylinder.
  17538. * It emits the particles randomly between two vectors.
  17539. */
  17540. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17541. /**
  17542. * The min limit of the emission direction.
  17543. */
  17544. direction1: Vector3;
  17545. /**
  17546. * The max limit of the emission direction.
  17547. */
  17548. direction2: Vector3;
  17549. /**
  17550. * Creates a new instance CylinderDirectedParticleEmitter
  17551. * @param radius the radius of the emission cylinder (1 by default)
  17552. * @param height the height of the emission cylinder (1 by default)
  17553. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17554. * @param direction1 the min limit of the emission direction (up vector by default)
  17555. * @param direction2 the max limit of the emission direction (up vector by default)
  17556. */
  17557. constructor(radius?: number, height?: number, radiusRange?: number,
  17558. /**
  17559. * The min limit of the emission direction.
  17560. */
  17561. direction1?: Vector3,
  17562. /**
  17563. * The max limit of the emission direction.
  17564. */
  17565. direction2?: Vector3);
  17566. /**
  17567. * Called by the particle System when the direction is computed for the created particle.
  17568. * @param worldMatrix is the world matrix of the particle system
  17569. * @param directionToUpdate is the direction vector to update with the result
  17570. * @param particle is the particle we are computed the direction for
  17571. */
  17572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17573. /**
  17574. * Clones the current emitter and returns a copy of it
  17575. * @returns the new emitter
  17576. */
  17577. clone(): CylinderDirectedParticleEmitter;
  17578. /**
  17579. * Called by the GPUParticleSystem to setup the update shader
  17580. * @param effect defines the update shader
  17581. */
  17582. applyToShader(effect: Effect): void;
  17583. /**
  17584. * Returns a string to use to update the GPU particles update shader
  17585. * @returns a string containng the defines string
  17586. */
  17587. getEffectDefines(): string;
  17588. /**
  17589. * Returns the string "CylinderDirectedParticleEmitter"
  17590. * @returns a string containing the class name
  17591. */
  17592. getClassName(): string;
  17593. /**
  17594. * Serializes the particle system to a JSON object.
  17595. * @returns the JSON object
  17596. */
  17597. serialize(): any;
  17598. /**
  17599. * Parse properties from a JSON object
  17600. * @param serializationObject defines the JSON object
  17601. */
  17602. parse(serializationObject: any): void;
  17603. }
  17604. }
  17605. declare module BABYLON {
  17606. /**
  17607. * Particle emitter emitting particles from the inside of a hemisphere.
  17608. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17609. */
  17610. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17611. /**
  17612. * The radius of the emission hemisphere.
  17613. */
  17614. radius: number;
  17615. /**
  17616. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17617. */
  17618. radiusRange: number;
  17619. /**
  17620. * How much to randomize the particle direction [0-1].
  17621. */
  17622. directionRandomizer: number;
  17623. /**
  17624. * Creates a new instance HemisphericParticleEmitter
  17625. * @param radius the radius of the emission hemisphere (1 by default)
  17626. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17627. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17628. */
  17629. constructor(
  17630. /**
  17631. * The radius of the emission hemisphere.
  17632. */
  17633. radius?: number,
  17634. /**
  17635. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17636. */
  17637. radiusRange?: number,
  17638. /**
  17639. * How much to randomize the particle direction [0-1].
  17640. */
  17641. directionRandomizer?: number);
  17642. /**
  17643. * Called by the particle System when the direction is computed for the created particle.
  17644. * @param worldMatrix is the world matrix of the particle system
  17645. * @param directionToUpdate is the direction vector to update with the result
  17646. * @param particle is the particle we are computed the direction for
  17647. */
  17648. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17649. /**
  17650. * Called by the particle System when the position is computed for the created particle.
  17651. * @param worldMatrix is the world matrix of the particle system
  17652. * @param positionToUpdate is the position vector to update with the result
  17653. * @param particle is the particle we are computed the position for
  17654. */
  17655. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17656. /**
  17657. * Clones the current emitter and returns a copy of it
  17658. * @returns the new emitter
  17659. */
  17660. clone(): HemisphericParticleEmitter;
  17661. /**
  17662. * Called by the GPUParticleSystem to setup the update shader
  17663. * @param effect defines the update shader
  17664. */
  17665. applyToShader(effect: Effect): void;
  17666. /**
  17667. * Returns a string to use to update the GPU particles update shader
  17668. * @returns a string containng the defines string
  17669. */
  17670. getEffectDefines(): string;
  17671. /**
  17672. * Returns the string "HemisphericParticleEmitter"
  17673. * @returns a string containing the class name
  17674. */
  17675. getClassName(): string;
  17676. /**
  17677. * Serializes the particle system to a JSON object.
  17678. * @returns the JSON object
  17679. */
  17680. serialize(): any;
  17681. /**
  17682. * Parse properties from a JSON object
  17683. * @param serializationObject defines the JSON object
  17684. */
  17685. parse(serializationObject: any): void;
  17686. }
  17687. }
  17688. declare module BABYLON {
  17689. /**
  17690. * Particle emitter emitting particles from a point.
  17691. * It emits the particles randomly between 2 given directions.
  17692. */
  17693. export class PointParticleEmitter implements IParticleEmitterType {
  17694. /**
  17695. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17696. */
  17697. direction1: Vector3;
  17698. /**
  17699. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17700. */
  17701. direction2: Vector3;
  17702. /**
  17703. * Creates a new instance PointParticleEmitter
  17704. */
  17705. constructor();
  17706. /**
  17707. * Called by the particle System when the direction is computed for the created particle.
  17708. * @param worldMatrix is the world matrix of the particle system
  17709. * @param directionToUpdate is the direction vector to update with the result
  17710. * @param particle is the particle we are computed the direction for
  17711. */
  17712. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17713. /**
  17714. * Called by the particle System when the position is computed for the created particle.
  17715. * @param worldMatrix is the world matrix of the particle system
  17716. * @param positionToUpdate is the position vector to update with the result
  17717. * @param particle is the particle we are computed the position for
  17718. */
  17719. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17720. /**
  17721. * Clones the current emitter and returns a copy of it
  17722. * @returns the new emitter
  17723. */
  17724. clone(): PointParticleEmitter;
  17725. /**
  17726. * Called by the GPUParticleSystem to setup the update shader
  17727. * @param effect defines the update shader
  17728. */
  17729. applyToShader(effect: Effect): void;
  17730. /**
  17731. * Returns a string to use to update the GPU particles update shader
  17732. * @returns a string containng the defines string
  17733. */
  17734. getEffectDefines(): string;
  17735. /**
  17736. * Returns the string "PointParticleEmitter"
  17737. * @returns a string containing the class name
  17738. */
  17739. getClassName(): string;
  17740. /**
  17741. * Serializes the particle system to a JSON object.
  17742. * @returns the JSON object
  17743. */
  17744. serialize(): any;
  17745. /**
  17746. * Parse properties from a JSON object
  17747. * @param serializationObject defines the JSON object
  17748. */
  17749. parse(serializationObject: any): void;
  17750. }
  17751. }
  17752. declare module BABYLON {
  17753. /**
  17754. * Particle emitter emitting particles from the inside of a sphere.
  17755. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17756. */
  17757. export class SphereParticleEmitter implements IParticleEmitterType {
  17758. /**
  17759. * The radius of the emission sphere.
  17760. */
  17761. radius: number;
  17762. /**
  17763. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17764. */
  17765. radiusRange: number;
  17766. /**
  17767. * How much to randomize the particle direction [0-1].
  17768. */
  17769. directionRandomizer: number;
  17770. /**
  17771. * Creates a new instance SphereParticleEmitter
  17772. * @param radius the radius of the emission sphere (1 by default)
  17773. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17774. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17775. */
  17776. constructor(
  17777. /**
  17778. * The radius of the emission sphere.
  17779. */
  17780. radius?: number,
  17781. /**
  17782. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17783. */
  17784. radiusRange?: number,
  17785. /**
  17786. * How much to randomize the particle direction [0-1].
  17787. */
  17788. directionRandomizer?: number);
  17789. /**
  17790. * Called by the particle System when the direction is computed for the created particle.
  17791. * @param worldMatrix is the world matrix of the particle system
  17792. * @param directionToUpdate is the direction vector to update with the result
  17793. * @param particle is the particle we are computed the direction for
  17794. */
  17795. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17796. /**
  17797. * Called by the particle System when the position is computed for the created particle.
  17798. * @param worldMatrix is the world matrix of the particle system
  17799. * @param positionToUpdate is the position vector to update with the result
  17800. * @param particle is the particle we are computed the position for
  17801. */
  17802. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17803. /**
  17804. * Clones the current emitter and returns a copy of it
  17805. * @returns the new emitter
  17806. */
  17807. clone(): SphereParticleEmitter;
  17808. /**
  17809. * Called by the GPUParticleSystem to setup the update shader
  17810. * @param effect defines the update shader
  17811. */
  17812. applyToShader(effect: Effect): void;
  17813. /**
  17814. * Returns a string to use to update the GPU particles update shader
  17815. * @returns a string containng the defines string
  17816. */
  17817. getEffectDefines(): string;
  17818. /**
  17819. * Returns the string "SphereParticleEmitter"
  17820. * @returns a string containing the class name
  17821. */
  17822. getClassName(): string;
  17823. /**
  17824. * Serializes the particle system to a JSON object.
  17825. * @returns the JSON object
  17826. */
  17827. serialize(): any;
  17828. /**
  17829. * Parse properties from a JSON object
  17830. * @param serializationObject defines the JSON object
  17831. */
  17832. parse(serializationObject: any): void;
  17833. }
  17834. /**
  17835. * Particle emitter emitting particles from the inside of a sphere.
  17836. * It emits the particles randomly between two vectors.
  17837. */
  17838. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17839. /**
  17840. * The min limit of the emission direction.
  17841. */
  17842. direction1: Vector3;
  17843. /**
  17844. * The max limit of the emission direction.
  17845. */
  17846. direction2: Vector3;
  17847. /**
  17848. * Creates a new instance SphereDirectedParticleEmitter
  17849. * @param radius the radius of the emission sphere (1 by default)
  17850. * @param direction1 the min limit of the emission direction (up vector by default)
  17851. * @param direction2 the max limit of the emission direction (up vector by default)
  17852. */
  17853. constructor(radius?: number,
  17854. /**
  17855. * The min limit of the emission direction.
  17856. */
  17857. direction1?: Vector3,
  17858. /**
  17859. * The max limit of the emission direction.
  17860. */
  17861. direction2?: Vector3);
  17862. /**
  17863. * Called by the particle System when the direction is computed for the created particle.
  17864. * @param worldMatrix is the world matrix of the particle system
  17865. * @param directionToUpdate is the direction vector to update with the result
  17866. * @param particle is the particle we are computed the direction for
  17867. */
  17868. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17869. /**
  17870. * Clones the current emitter and returns a copy of it
  17871. * @returns the new emitter
  17872. */
  17873. clone(): SphereDirectedParticleEmitter;
  17874. /**
  17875. * Called by the GPUParticleSystem to setup the update shader
  17876. * @param effect defines the update shader
  17877. */
  17878. applyToShader(effect: Effect): void;
  17879. /**
  17880. * Returns a string to use to update the GPU particles update shader
  17881. * @returns a string containng the defines string
  17882. */
  17883. getEffectDefines(): string;
  17884. /**
  17885. * Returns the string "SphereDirectedParticleEmitter"
  17886. * @returns a string containing the class name
  17887. */
  17888. getClassName(): string;
  17889. /**
  17890. * Serializes the particle system to a JSON object.
  17891. * @returns the JSON object
  17892. */
  17893. serialize(): any;
  17894. /**
  17895. * Parse properties from a JSON object
  17896. * @param serializationObject defines the JSON object
  17897. */
  17898. parse(serializationObject: any): void;
  17899. }
  17900. }
  17901. declare module BABYLON {
  17902. /**
  17903. * Interface representing a particle system in Babylon.js.
  17904. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17905. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17906. */
  17907. export interface IParticleSystem {
  17908. /**
  17909. * List of animations used by the particle system.
  17910. */
  17911. animations: Animation[];
  17912. /**
  17913. * The id of the Particle system.
  17914. */
  17915. id: string;
  17916. /**
  17917. * The name of the Particle system.
  17918. */
  17919. name: string;
  17920. /**
  17921. * The emitter represents the Mesh or position we are attaching the particle system to.
  17922. */
  17923. emitter: Nullable<AbstractMesh | Vector3>;
  17924. /**
  17925. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17926. */
  17927. isBillboardBased: boolean;
  17928. /**
  17929. * The rendering group used by the Particle system to chose when to render.
  17930. */
  17931. renderingGroupId: number;
  17932. /**
  17933. * The layer mask we are rendering the particles through.
  17934. */
  17935. layerMask: number;
  17936. /**
  17937. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17938. */
  17939. updateSpeed: number;
  17940. /**
  17941. * The amount of time the particle system is running (depends of the overall update speed).
  17942. */
  17943. targetStopDuration: number;
  17944. /**
  17945. * The texture used to render each particle. (this can be a spritesheet)
  17946. */
  17947. particleTexture: Nullable<Texture>;
  17948. /**
  17949. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17950. */
  17951. blendMode: number;
  17952. /**
  17953. * Minimum life time of emitting particles.
  17954. */
  17955. minLifeTime: number;
  17956. /**
  17957. * Maximum life time of emitting particles.
  17958. */
  17959. maxLifeTime: number;
  17960. /**
  17961. * Minimum Size of emitting particles.
  17962. */
  17963. minSize: number;
  17964. /**
  17965. * Maximum Size of emitting particles.
  17966. */
  17967. maxSize: number;
  17968. /**
  17969. * Minimum scale of emitting particles on X axis.
  17970. */
  17971. minScaleX: number;
  17972. /**
  17973. * Maximum scale of emitting particles on X axis.
  17974. */
  17975. maxScaleX: number;
  17976. /**
  17977. * Minimum scale of emitting particles on Y axis.
  17978. */
  17979. minScaleY: number;
  17980. /**
  17981. * Maximum scale of emitting particles on Y axis.
  17982. */
  17983. maxScaleY: number;
  17984. /**
  17985. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17986. */
  17987. color1: Color4;
  17988. /**
  17989. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17990. */
  17991. color2: Color4;
  17992. /**
  17993. * Color the particle will have at the end of its lifetime.
  17994. */
  17995. colorDead: Color4;
  17996. /**
  17997. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17998. */
  17999. emitRate: number;
  18000. /**
  18001. * You can use gravity if you want to give an orientation to your particles.
  18002. */
  18003. gravity: Vector3;
  18004. /**
  18005. * Minimum power of emitting particles.
  18006. */
  18007. minEmitPower: number;
  18008. /**
  18009. * Maximum power of emitting particles.
  18010. */
  18011. maxEmitPower: number;
  18012. /**
  18013. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18014. */
  18015. minAngularSpeed: number;
  18016. /**
  18017. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18018. */
  18019. maxAngularSpeed: number;
  18020. /**
  18021. * Gets or sets the minimal initial rotation in radians.
  18022. */
  18023. minInitialRotation: number;
  18024. /**
  18025. * Gets or sets the maximal initial rotation in radians.
  18026. */
  18027. maxInitialRotation: number;
  18028. /**
  18029. * The particle emitter type defines the emitter used by the particle system.
  18030. * It can be for example box, sphere, or cone...
  18031. */
  18032. particleEmitterType: Nullable<IParticleEmitterType>;
  18033. /**
  18034. * Defines the delay in milliseconds before starting the system (0 by default)
  18035. */
  18036. startDelay: number;
  18037. /**
  18038. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  18039. */
  18040. preWarmCycles: number;
  18041. /**
  18042. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18043. */
  18044. preWarmStepOffset: number;
  18045. /**
  18046. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  18047. */
  18048. spriteCellChangeSpeed: number;
  18049. /**
  18050. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18051. */
  18052. startSpriteCellID: number;
  18053. /**
  18054. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18055. */
  18056. endSpriteCellID: number;
  18057. /**
  18058. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18059. */
  18060. spriteCellWidth: number;
  18061. /**
  18062. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18063. */
  18064. spriteCellHeight: number;
  18065. /**
  18066. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18067. */
  18068. spriteRandomStartCell: boolean;
  18069. /**
  18070. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18071. */
  18072. isAnimationSheetEnabled: boolean;
  18073. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18074. translationPivot: Vector2;
  18075. /**
  18076. * Gets or sets a texture used to add random noise to particle positions
  18077. */
  18078. noiseTexture: Nullable<BaseTexture>;
  18079. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18080. noiseStrength: Vector3;
  18081. /**
  18082. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18083. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18084. */
  18085. billboardMode: number;
  18086. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18087. limitVelocityDamping: number;
  18088. /**
  18089. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18090. */
  18091. beginAnimationOnStart: boolean;
  18092. /**
  18093. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18094. */
  18095. beginAnimationFrom: number;
  18096. /**
  18097. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18098. */
  18099. beginAnimationTo: number;
  18100. /**
  18101. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18102. */
  18103. beginAnimationLoop: boolean;
  18104. /**
  18105. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18106. */
  18107. disposeOnStop: boolean;
  18108. /**
  18109. * Gets the maximum number of particles active at the same time.
  18110. * @returns The max number of active particles.
  18111. */
  18112. getCapacity(): number;
  18113. /**
  18114. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18115. * @returns True if it has been started, otherwise false.
  18116. */
  18117. isStarted(): boolean;
  18118. /**
  18119. * Animates the particle system for this frame.
  18120. */
  18121. animate(): void;
  18122. /**
  18123. * Renders the particle system in its current state.
  18124. * @returns the current number of particles
  18125. */
  18126. render(): number;
  18127. /**
  18128. * Dispose the particle system and frees its associated resources.
  18129. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18130. */
  18131. dispose(disposeTexture?: boolean): void;
  18132. /**
  18133. * Clones the particle system.
  18134. * @param name The name of the cloned object
  18135. * @param newEmitter The new emitter to use
  18136. * @returns the cloned particle system
  18137. */
  18138. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18139. /**
  18140. * Serializes the particle system to a JSON object.
  18141. * @returns the JSON object
  18142. */
  18143. serialize(): any;
  18144. /**
  18145. * Rebuild the particle system
  18146. */
  18147. rebuild(): void;
  18148. /**
  18149. * Starts the particle system and begins to emit
  18150. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18151. */
  18152. start(delay?: number): void;
  18153. /**
  18154. * Stops the particle system.
  18155. */
  18156. stop(): void;
  18157. /**
  18158. * Remove all active particles
  18159. */
  18160. reset(): void;
  18161. /**
  18162. * Is this system ready to be used/rendered
  18163. * @return true if the system is ready
  18164. */
  18165. isReady(): boolean;
  18166. /**
  18167. * Adds a new color gradient
  18168. * @param gradient defines the gradient to use (between 0 and 1)
  18169. * @param color1 defines the color to affect to the specified gradient
  18170. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18171. * @returns the current particle system
  18172. */
  18173. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18174. /**
  18175. * Remove a specific color gradient
  18176. * @param gradient defines the gradient to remove
  18177. * @returns the current particle system
  18178. */
  18179. removeColorGradient(gradient: number): IParticleSystem;
  18180. /**
  18181. * Adds a new size gradient
  18182. * @param gradient defines the gradient to use (between 0 and 1)
  18183. * @param factor defines the size factor to affect to the specified gradient
  18184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18185. * @returns the current particle system
  18186. */
  18187. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18188. /**
  18189. * Remove a specific size gradient
  18190. * @param gradient defines the gradient to remove
  18191. * @returns the current particle system
  18192. */
  18193. removeSizeGradient(gradient: number): IParticleSystem;
  18194. /**
  18195. * Gets the current list of color gradients.
  18196. * You must use addColorGradient and removeColorGradient to udpate this list
  18197. * @returns the list of color gradients
  18198. */
  18199. getColorGradients(): Nullable<Array<ColorGradient>>;
  18200. /**
  18201. * Gets the current list of size gradients.
  18202. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18203. * @returns the list of size gradients
  18204. */
  18205. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18206. /**
  18207. * Gets the current list of angular speed gradients.
  18208. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18209. * @returns the list of angular speed gradients
  18210. */
  18211. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18212. /**
  18213. * Adds a new angular speed gradient
  18214. * @param gradient defines the gradient to use (between 0 and 1)
  18215. * @param factor defines the angular speed to affect to the specified gradient
  18216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18217. * @returns the current particle system
  18218. */
  18219. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18220. /**
  18221. * Remove a specific angular speed gradient
  18222. * @param gradient defines the gradient to remove
  18223. * @returns the current particle system
  18224. */
  18225. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18226. /**
  18227. * Gets the current list of velocity gradients.
  18228. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18229. * @returns the list of velocity gradients
  18230. */
  18231. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18232. /**
  18233. * Adds a new velocity gradient
  18234. * @param gradient defines the gradient to use (between 0 and 1)
  18235. * @param factor defines the velocity to affect to the specified gradient
  18236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18237. * @returns the current particle system
  18238. */
  18239. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18240. /**
  18241. * Remove a specific velocity gradient
  18242. * @param gradient defines the gradient to remove
  18243. * @returns the current particle system
  18244. */
  18245. removeVelocityGradient(gradient: number): IParticleSystem;
  18246. /**
  18247. * Gets the current list of limit velocity gradients.
  18248. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18249. * @returns the list of limit velocity gradients
  18250. */
  18251. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18252. /**
  18253. * Adds a new limit velocity gradient
  18254. * @param gradient defines the gradient to use (between 0 and 1)
  18255. * @param factor defines the limit velocity to affect to the specified gradient
  18256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18257. * @returns the current particle system
  18258. */
  18259. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18260. /**
  18261. * Remove a specific limit velocity gradient
  18262. * @param gradient defines the gradient to remove
  18263. * @returns the current particle system
  18264. */
  18265. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18266. /**
  18267. * Adds a new drag gradient
  18268. * @param gradient defines the gradient to use (between 0 and 1)
  18269. * @param factor defines the drag to affect to the specified gradient
  18270. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18271. * @returns the current particle system
  18272. */
  18273. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18274. /**
  18275. * Remove a specific drag gradient
  18276. * @param gradient defines the gradient to remove
  18277. * @returns the current particle system
  18278. */
  18279. removeDragGradient(gradient: number): IParticleSystem;
  18280. /**
  18281. * Gets the current list of drag gradients.
  18282. * You must use addDragGradient and removeDragGradient to udpate this list
  18283. * @returns the list of drag gradients
  18284. */
  18285. getDragGradients(): Nullable<Array<FactorGradient>>;
  18286. /**
  18287. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18288. * @param gradient defines the gradient to use (between 0 and 1)
  18289. * @param factor defines the emit rate to affect to the specified gradient
  18290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18291. * @returns the current particle system
  18292. */
  18293. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18294. /**
  18295. * Remove a specific emit rate gradient
  18296. * @param gradient defines the gradient to remove
  18297. * @returns the current particle system
  18298. */
  18299. removeEmitRateGradient(gradient: number): IParticleSystem;
  18300. /**
  18301. * Gets the current list of emit rate gradients.
  18302. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18303. * @returns the list of emit rate gradients
  18304. */
  18305. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18306. /**
  18307. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18308. * @param gradient defines the gradient to use (between 0 and 1)
  18309. * @param factor defines the start size to affect to the specified gradient
  18310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18311. * @returns the current particle system
  18312. */
  18313. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18314. /**
  18315. * Remove a specific start size gradient
  18316. * @param gradient defines the gradient to remove
  18317. * @returns the current particle system
  18318. */
  18319. removeStartSizeGradient(gradient: number): IParticleSystem;
  18320. /**
  18321. * Gets the current list of start size gradients.
  18322. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18323. * @returns the list of start size gradients
  18324. */
  18325. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18326. /**
  18327. * Adds a new life time gradient
  18328. * @param gradient defines the gradient to use (between 0 and 1)
  18329. * @param factor defines the life time factor to affect to the specified gradient
  18330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18331. * @returns the current particle system
  18332. */
  18333. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18334. /**
  18335. * Remove a specific life time gradient
  18336. * @param gradient defines the gradient to remove
  18337. * @returns the current particle system
  18338. */
  18339. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18340. /**
  18341. * Gets the current list of life time gradients.
  18342. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18343. * @returns the list of life time gradients
  18344. */
  18345. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18346. /**
  18347. * Gets the current list of color gradients.
  18348. * You must use addColorGradient and removeColorGradient to udpate this list
  18349. * @returns the list of color gradients
  18350. */
  18351. getColorGradients(): Nullable<Array<ColorGradient>>;
  18352. /**
  18353. * Adds a new ramp gradient used to remap particle colors
  18354. * @param gradient defines the gradient to use (between 0 and 1)
  18355. * @param color defines the color to affect to the specified gradient
  18356. * @returns the current particle system
  18357. */
  18358. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18359. /**
  18360. * Gets the current list of ramp gradients.
  18361. * You must use addRampGradient and removeRampGradient to udpate this list
  18362. * @returns the list of ramp gradients
  18363. */
  18364. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18365. /** Gets or sets a boolean indicating that ramp gradients must be used
  18366. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18367. */
  18368. useRampGradients: boolean;
  18369. /**
  18370. * Adds a new color remap gradient
  18371. * @param gradient defines the gradient to use (between 0 and 1)
  18372. * @param min defines the color remap minimal range
  18373. * @param max defines the color remap maximal range
  18374. * @returns the current particle system
  18375. */
  18376. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18377. /**
  18378. * Gets the current list of color remap gradients.
  18379. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18380. * @returns the list of color remap gradients
  18381. */
  18382. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18383. /**
  18384. * Adds a new alpha remap gradient
  18385. * @param gradient defines the gradient to use (between 0 and 1)
  18386. * @param min defines the alpha remap minimal range
  18387. * @param max defines the alpha remap maximal range
  18388. * @returns the current particle system
  18389. */
  18390. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18391. /**
  18392. * Gets the current list of alpha remap gradients.
  18393. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18394. * @returns the list of alpha remap gradients
  18395. */
  18396. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18397. /**
  18398. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18399. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18400. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18401. * @returns the emitter
  18402. */
  18403. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18404. /**
  18405. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18406. * @param radius The radius of the hemisphere to emit from
  18407. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18408. * @returns the emitter
  18409. */
  18410. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18411. /**
  18412. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18413. * @param radius The radius of the sphere to emit from
  18414. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18415. * @returns the emitter
  18416. */
  18417. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18418. /**
  18419. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18420. * @param radius The radius of the sphere to emit from
  18421. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18422. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18423. * @returns the emitter
  18424. */
  18425. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18426. /**
  18427. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18428. * @param radius The radius of the emission cylinder
  18429. * @param height The height of the emission cylinder
  18430. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18431. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18432. * @returns the emitter
  18433. */
  18434. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18435. /**
  18436. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18437. * @param radius The radius of the cylinder to emit from
  18438. * @param height The height of the emission cylinder
  18439. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18440. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18441. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18442. * @returns the emitter
  18443. */
  18444. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18445. /**
  18446. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18447. * @param radius The radius of the cone to emit from
  18448. * @param angle The base angle of the cone
  18449. * @returns the emitter
  18450. */
  18451. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18452. /**
  18453. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18454. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18455. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18456. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18457. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18458. * @returns the emitter
  18459. */
  18460. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18461. /**
  18462. * Get hosting scene
  18463. * @returns the scene
  18464. */
  18465. getScene(): Scene;
  18466. }
  18467. }
  18468. declare module BABYLON {
  18469. /**
  18470. * Creates an instance based on a source mesh.
  18471. */
  18472. export class InstancedMesh extends AbstractMesh {
  18473. private _sourceMesh;
  18474. private _currentLOD;
  18475. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18476. constructor(name: string, source: Mesh);
  18477. /**
  18478. * Returns the string "InstancedMesh".
  18479. */
  18480. getClassName(): string;
  18481. /** Gets the list of lights affecting that mesh */
  18482. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light, dispose: boolean): void;
  18483. /**
  18484. * If the source mesh receives shadows
  18485. */
  18486. readonly receiveShadows: boolean;
  18487. /**
  18488. * The material of the source mesh
  18489. */
  18490. readonly material: Nullable<Material>;
  18491. /**
  18492. * Visibility of the source mesh
  18493. */
  18494. readonly visibility: number;
  18495. /**
  18496. * Skeleton of the source mesh
  18497. */
  18498. readonly skeleton: Nullable<Skeleton>;
  18499. /**
  18500. * Rendering ground id of the source mesh
  18501. */
  18502. renderingGroupId: number;
  18503. /**
  18504. * Returns the total number of vertices (integer).
  18505. */
  18506. getTotalVertices(): number;
  18507. /**
  18508. * Returns a positive integer : the total number of indices in this mesh geometry.
  18509. * @returns the numner of indices or zero if the mesh has no geometry.
  18510. */
  18511. getTotalIndices(): number;
  18512. /**
  18513. * The source mesh of the instance
  18514. */
  18515. readonly sourceMesh: Mesh;
  18516. /**
  18517. * Is this node ready to be used/rendered
  18518. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18519. * @return {boolean} is it ready
  18520. */
  18521. isReady(completeCheck?: boolean): boolean;
  18522. /**
  18523. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18524. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18525. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  18526. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18527. */
  18528. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18529. /**
  18530. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18531. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18532. * The `data` are either a numeric array either a Float32Array.
  18533. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18534. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  18535. * Note that a new underlying VertexBuffer object is created each call.
  18536. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18537. *
  18538. * Possible `kind` values :
  18539. * - VertexBuffer.PositionKind
  18540. * - VertexBuffer.UVKind
  18541. * - VertexBuffer.UV2Kind
  18542. * - VertexBuffer.UV3Kind
  18543. * - VertexBuffer.UV4Kind
  18544. * - VertexBuffer.UV5Kind
  18545. * - VertexBuffer.UV6Kind
  18546. * - VertexBuffer.ColorKind
  18547. * - VertexBuffer.MatricesIndicesKind
  18548. * - VertexBuffer.MatricesIndicesExtraKind
  18549. * - VertexBuffer.MatricesWeightsKind
  18550. * - VertexBuffer.MatricesWeightsExtraKind
  18551. *
  18552. * Returns the Mesh.
  18553. */
  18554. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  18555. /**
  18556. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18557. * If the mesh has no geometry, it is simply returned as it is.
  18558. * The `data` are either a numeric array either a Float32Array.
  18559. * No new underlying VertexBuffer object is created.
  18560. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18561. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18562. *
  18563. * Possible `kind` values :
  18564. * - VertexBuffer.PositionKind
  18565. * - VertexBuffer.UVKind
  18566. * - VertexBuffer.UV2Kind
  18567. * - VertexBuffer.UV3Kind
  18568. * - VertexBuffer.UV4Kind
  18569. * - VertexBuffer.UV5Kind
  18570. * - VertexBuffer.UV6Kind
  18571. * - VertexBuffer.ColorKind
  18572. * - VertexBuffer.MatricesIndicesKind
  18573. * - VertexBuffer.MatricesIndicesExtraKind
  18574. * - VertexBuffer.MatricesWeightsKind
  18575. * - VertexBuffer.MatricesWeightsExtraKind
  18576. *
  18577. * Returns the Mesh.
  18578. */
  18579. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18580. /**
  18581. * Sets the mesh indices.
  18582. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18583. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18584. * This method creates a new index buffer each call.
  18585. * Returns the Mesh.
  18586. */
  18587. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18588. /**
  18589. * Boolean : True if the mesh owns the requested kind of data.
  18590. */
  18591. isVerticesDataPresent(kind: string): boolean;
  18592. /**
  18593. * Returns an array of indices (IndicesArray).
  18594. */
  18595. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18596. /**
  18597. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18598. * This means the mesh underlying bounding box and sphere are recomputed.
  18599. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18600. * @returns the current mesh
  18601. */
  18602. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18603. /** @hidden */ private _preActivate(): InstancedMesh;
  18604. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18605. /** @hidden */ private _postActivate(): void;
  18606. getWorldMatrix(): Matrix;
  18607. readonly isAnInstance: boolean;
  18608. /**
  18609. * Returns the current associated LOD AbstractMesh.
  18610. */
  18611. getLOD(camera: Camera): AbstractMesh;
  18612. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18613. /** @hidden */ private _generatePointsArray(): boolean;
  18614. /**
  18615. * Creates a new InstancedMesh from the current mesh.
  18616. * - name (string) : the cloned mesh name
  18617. * - newParent (optional Node) : the optional Node to parent the clone to.
  18618. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18619. *
  18620. * Returns the clone.
  18621. */
  18622. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  18623. /**
  18624. * Disposes the InstancedMesh.
  18625. * Returns nothing.
  18626. */
  18627. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18628. }
  18629. }
  18630. declare module BABYLON {
  18631. /**
  18632. * Defines the options associated with the creation of a shader material.
  18633. */
  18634. export interface IShaderMaterialOptions {
  18635. /**
  18636. * Does the material work in alpha blend mode
  18637. */
  18638. needAlphaBlending: boolean;
  18639. /**
  18640. * Does the material work in alpha test mode
  18641. */
  18642. needAlphaTesting: boolean;
  18643. /**
  18644. * The list of attribute names used in the shader
  18645. */
  18646. attributes: string[];
  18647. /**
  18648. * The list of unifrom names used in the shader
  18649. */
  18650. uniforms: string[];
  18651. /**
  18652. * The list of UBO names used in the shader
  18653. */
  18654. uniformBuffers: string[];
  18655. /**
  18656. * The list of sampler names used in the shader
  18657. */
  18658. samplers: string[];
  18659. /**
  18660. * The list of defines used in the shader
  18661. */
  18662. defines: string[];
  18663. }
  18664. /**
  18665. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  18666. *
  18667. * This returned material effects how the mesh will look based on the code in the shaders.
  18668. *
  18669. * @see http://doc.babylonjs.com/how_to/shader_material
  18670. */
  18671. export class ShaderMaterial extends Material {
  18672. private _shaderPath;
  18673. private _options;
  18674. private _textures;
  18675. private _textureArrays;
  18676. private _floats;
  18677. private _ints;
  18678. private _floatsArrays;
  18679. private _colors3;
  18680. private _colors3Arrays;
  18681. private _colors4;
  18682. private _colors4Arrays;
  18683. private _vectors2;
  18684. private _vectors3;
  18685. private _vectors4;
  18686. private _matrices;
  18687. private _matrices3x3;
  18688. private _matrices2x2;
  18689. private _vectors2Arrays;
  18690. private _vectors3Arrays;
  18691. private _vectors4Arrays;
  18692. private _cachedWorldViewMatrix;
  18693. private _cachedWorldViewProjectionMatrix;
  18694. private _renderId;
  18695. /**
  18696. * Instantiate a new shader material.
  18697. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  18698. * This returned material effects how the mesh will look based on the code in the shaders.
  18699. * @see http://doc.babylonjs.com/how_to/shader_material
  18700. * @param name Define the name of the material in the scene
  18701. * @param scene Define the scene the material belongs to
  18702. * @param shaderPath Defines the route to the shader code in one of three ways:
  18703. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18704. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  18705. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  18706. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18707. * @param options Define the options used to create the shader
  18708. */
  18709. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18710. /**
  18711. * Gets the options used to compile the shader.
  18712. * They can be modified to trigger a new compilation
  18713. */
  18714. readonly options: IShaderMaterialOptions;
  18715. /**
  18716. * Gets the current class name of the material e.g. "ShaderMaterial"
  18717. * Mainly use in serialization.
  18718. * @returns the class name
  18719. */
  18720. getClassName(): string;
  18721. /**
  18722. * Specifies if the material will require alpha blending
  18723. * @returns a boolean specifying if alpha blending is needed
  18724. */
  18725. needAlphaBlending(): boolean;
  18726. /**
  18727. * Specifies if this material should be rendered in alpha test mode
  18728. * @returns a boolean specifying if an alpha test is needed.
  18729. */
  18730. needAlphaTesting(): boolean;
  18731. private _checkUniform;
  18732. /**
  18733. * Set a texture in the shader.
  18734. * @param name Define the name of the uniform samplers as defined in the shader
  18735. * @param texture Define the texture to bind to this sampler
  18736. * @return the material itself allowing "fluent" like uniform updates
  18737. */
  18738. setTexture(name: string, texture: Texture): ShaderMaterial;
  18739. /**
  18740. * Set a texture array in the shader.
  18741. * @param name Define the name of the uniform sampler array as defined in the shader
  18742. * @param textures Define the list of textures to bind to this sampler
  18743. * @return the material itself allowing "fluent" like uniform updates
  18744. */
  18745. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18746. /**
  18747. * Set a float in the shader.
  18748. * @param name Define the name of the uniform as defined in the shader
  18749. * @param value Define the value to give to the uniform
  18750. * @return the material itself allowing "fluent" like uniform updates
  18751. */
  18752. setFloat(name: string, value: number): ShaderMaterial;
  18753. /**
  18754. * Set a int in the shader.
  18755. * @param name Define the name of the uniform as defined in the shader
  18756. * @param value Define the value to give to the uniform
  18757. * @return the material itself allowing "fluent" like uniform updates
  18758. */
  18759. setInt(name: string, value: number): ShaderMaterial;
  18760. /**
  18761. * Set an array of floats in the shader.
  18762. * @param name Define the name of the uniform as defined in the shader
  18763. * @param value Define the value to give to the uniform
  18764. * @return the material itself allowing "fluent" like uniform updates
  18765. */
  18766. setFloats(name: string, value: number[]): ShaderMaterial;
  18767. /**
  18768. * Set a vec3 in the shader from a Color3.
  18769. * @param name Define the name of the uniform as defined in the shader
  18770. * @param value Define the value to give to the uniform
  18771. * @return the material itself allowing "fluent" like uniform updates
  18772. */
  18773. setColor3(name: string, value: Color3): ShaderMaterial;
  18774. /**
  18775. * Set a vec3 array in the shader from a Color3 array.
  18776. * @param name Define the name of the uniform as defined in the shader
  18777. * @param value Define the value to give to the uniform
  18778. * @return the material itself allowing "fluent" like uniform updates
  18779. */
  18780. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18781. /**
  18782. * Set a vec4 in the shader from a Color4.
  18783. * @param name Define the name of the uniform as defined in the shader
  18784. * @param value Define the value to give to the uniform
  18785. * @return the material itself allowing "fluent" like uniform updates
  18786. */
  18787. setColor4(name: string, value: Color4): ShaderMaterial;
  18788. /**
  18789. * Set a vec4 array in the shader from a Color4 array.
  18790. * @param name Define the name of the uniform as defined in the shader
  18791. * @param value Define the value to give to the uniform
  18792. * @return the material itself allowing "fluent" like uniform updates
  18793. */
  18794. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18795. /**
  18796. * Set a vec2 in the shader from a Vector2.
  18797. * @param name Define the name of the uniform as defined in the shader
  18798. * @param value Define the value to give to the uniform
  18799. * @return the material itself allowing "fluent" like uniform updates
  18800. */
  18801. setVector2(name: string, value: Vector2): ShaderMaterial;
  18802. /**
  18803. * Set a vec3 in the shader from a Vector3.
  18804. * @param name Define the name of the uniform as defined in the shader
  18805. * @param value Define the value to give to the uniform
  18806. * @return the material itself allowing "fluent" like uniform updates
  18807. */
  18808. setVector3(name: string, value: Vector3): ShaderMaterial;
  18809. /**
  18810. * Set a vec4 in the shader from a Vector4.
  18811. * @param name Define the name of the uniform as defined in the shader
  18812. * @param value Define the value to give to the uniform
  18813. * @return the material itself allowing "fluent" like uniform updates
  18814. */
  18815. setVector4(name: string, value: Vector4): ShaderMaterial;
  18816. /**
  18817. * Set a mat4 in the shader from a Matrix.
  18818. * @param name Define the name of the uniform as defined in the shader
  18819. * @param value Define the value to give to the uniform
  18820. * @return the material itself allowing "fluent" like uniform updates
  18821. */
  18822. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18823. /**
  18824. * Set a mat3 in the shader from a Float32Array.
  18825. * @param name Define the name of the uniform as defined in the shader
  18826. * @param value Define the value to give to the uniform
  18827. * @return the material itself allowing "fluent" like uniform updates
  18828. */
  18829. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18830. /**
  18831. * Set a mat2 in the shader from a Float32Array.
  18832. * @param name Define the name of the uniform as defined in the shader
  18833. * @param value Define the value to give to the uniform
  18834. * @return the material itself allowing "fluent" like uniform updates
  18835. */
  18836. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18837. /**
  18838. * Set a vec2 array in the shader from a number array.
  18839. * @param name Define the name of the uniform as defined in the shader
  18840. * @param value Define the value to give to the uniform
  18841. * @return the material itself allowing "fluent" like uniform updates
  18842. */
  18843. setArray2(name: string, value: number[]): ShaderMaterial;
  18844. /**
  18845. * Set a vec3 array in the shader from a number array.
  18846. * @param name Define the name of the uniform as defined in the shader
  18847. * @param value Define the value to give to the uniform
  18848. * @return the material itself allowing "fluent" like uniform updates
  18849. */
  18850. setArray3(name: string, value: number[]): ShaderMaterial;
  18851. /**
  18852. * Set a vec4 array in the shader from a number array.
  18853. * @param name Define the name of the uniform as defined in the shader
  18854. * @param value Define the value to give to the uniform
  18855. * @return the material itself allowing "fluent" like uniform updates
  18856. */
  18857. setArray4(name: string, value: number[]): ShaderMaterial;
  18858. private _checkCache;
  18859. /**
  18860. * Specifies that the submesh is ready to be used
  18861. * @param mesh defines the mesh to check
  18862. * @param subMesh defines which submesh to check
  18863. * @param useInstances specifies that instances should be used
  18864. * @returns a boolean indicating that the submesh is ready or not
  18865. */
  18866. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18867. /**
  18868. * Checks if the material is ready to render the requested mesh
  18869. * @param mesh Define the mesh to render
  18870. * @param useInstances Define whether or not the material is used with instances
  18871. * @returns true if ready, otherwise false
  18872. */
  18873. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18874. /**
  18875. * Binds the world matrix to the material
  18876. * @param world defines the world transformation matrix
  18877. */
  18878. bindOnlyWorldMatrix(world: Matrix): void;
  18879. /**
  18880. * Binds the material to the mesh
  18881. * @param world defines the world transformation matrix
  18882. * @param mesh defines the mesh to bind the material to
  18883. */
  18884. bind(world: Matrix, mesh?: Mesh): void;
  18885. /**
  18886. * Gets the active textures from the material
  18887. * @returns an array of textures
  18888. */
  18889. getActiveTextures(): BaseTexture[];
  18890. /**
  18891. * Specifies if the material uses a texture
  18892. * @param texture defines the texture to check against the material
  18893. * @returns a boolean specifying if the material uses the texture
  18894. */
  18895. hasTexture(texture: BaseTexture): boolean;
  18896. /**
  18897. * Makes a duplicate of the material, and gives it a new name
  18898. * @param name defines the new name for the duplicated material
  18899. * @returns the cloned material
  18900. */
  18901. clone(name: string): ShaderMaterial;
  18902. /**
  18903. * Disposes the material
  18904. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18905. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18906. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18907. */
  18908. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18909. /**
  18910. * Serializes this material in a JSON representation
  18911. * @returns the serialized material object
  18912. */
  18913. serialize(): any;
  18914. /**
  18915. * Creates a shader material from parsed shader material data
  18916. * @param source defines the JSON represnetation of the material
  18917. * @param scene defines the hosting scene
  18918. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18919. * @returns a new material
  18920. */
  18921. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18922. }
  18923. }
  18924. declare module BABYLON {
  18925. /** @hidden */
  18926. export var colorPixelShader: {
  18927. name: string;
  18928. shader: string;
  18929. };
  18930. }
  18931. declare module BABYLON {
  18932. /** @hidden */
  18933. export var colorVertexShader: {
  18934. name: string;
  18935. shader: string;
  18936. };
  18937. }
  18938. declare module BABYLON {
  18939. /**
  18940. * Line mesh
  18941. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18942. */
  18943. export class LinesMesh extends Mesh {
  18944. /**
  18945. * If vertex color should be applied to the mesh
  18946. */
  18947. readonly useVertexColor?: boolean | undefined;
  18948. /**
  18949. * If vertex alpha should be applied to the mesh
  18950. */
  18951. readonly useVertexAlpha?: boolean | undefined;
  18952. /**
  18953. * Color of the line (Default: White)
  18954. */
  18955. color: Color3;
  18956. /**
  18957. * Alpha of the line (Default: 1)
  18958. */
  18959. alpha: number;
  18960. /**
  18961. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18962. * This margin is expressed in world space coordinates, so its value may vary.
  18963. * Default value is 0.1
  18964. */
  18965. intersectionThreshold: number;
  18966. private _colorShader;
  18967. private color4;
  18968. /**
  18969. * Creates a new LinesMesh
  18970. * @param name defines the name
  18971. * @param scene defines the hosting scene
  18972. * @param parent defines the parent mesh if any
  18973. * @param source defines the optional source LinesMesh used to clone data from
  18974. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18975. * When false, achieved by calling a clone(), also passing False.
  18976. * This will make creation of children, recursive.
  18977. * @param useVertexColor defines if this LinesMesh supports vertex color
  18978. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18979. */
  18980. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  18981. /**
  18982. * If vertex color should be applied to the mesh
  18983. */
  18984. useVertexColor?: boolean | undefined,
  18985. /**
  18986. * If vertex alpha should be applied to the mesh
  18987. */
  18988. useVertexAlpha?: boolean | undefined);
  18989. private _addClipPlaneDefine;
  18990. private _removeClipPlaneDefine;
  18991. isReady(): boolean;
  18992. /**
  18993. * Returns the string "LineMesh"
  18994. */
  18995. getClassName(): string;
  18996. /**
  18997. * @hidden
  18998. */
  18999. /**
  19000. * @hidden
  19001. */
  19002. material: Material;
  19003. /**
  19004. * @hidden
  19005. */
  19006. readonly checkCollisions: boolean;
  19007. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19008. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19009. /**
  19010. * Disposes of the line mesh
  19011. * @param doNotRecurse If children should be disposed
  19012. */
  19013. dispose(doNotRecurse?: boolean): void;
  19014. /**
  19015. * Returns a new LineMesh object cloned from the current one.
  19016. */
  19017. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19018. /**
  19019. * Creates a new InstancedLinesMesh object from the mesh model.
  19020. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19021. * @param name defines the name of the new instance
  19022. * @returns a new InstancedLinesMesh
  19023. */
  19024. createInstance(name: string): InstancedLinesMesh;
  19025. }
  19026. /**
  19027. * Creates an instance based on a source LinesMesh
  19028. */
  19029. export class InstancedLinesMesh extends InstancedMesh {
  19030. /**
  19031. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19032. * This margin is expressed in world space coordinates, so its value may vary.
  19033. * Initilized with the intersectionThreshold value of the source LinesMesh
  19034. */
  19035. intersectionThreshold: number;
  19036. constructor(name: string, source: LinesMesh);
  19037. /**
  19038. * Returns the string "InstancedLinesMesh".
  19039. */
  19040. getClassName(): string;
  19041. }
  19042. }
  19043. declare module BABYLON {
  19044. /** @hidden */
  19045. export var linePixelShader: {
  19046. name: string;
  19047. shader: string;
  19048. };
  19049. }
  19050. declare module BABYLON {
  19051. /** @hidden */
  19052. export var lineVertexShader: {
  19053. name: string;
  19054. shader: string;
  19055. };
  19056. }
  19057. declare module BABYLON {
  19058. interface AbstractMesh {
  19059. /**
  19060. * Gets the edgesRenderer associated with the mesh
  19061. */
  19062. edgesRenderer: Nullable<EdgesRenderer>;
  19063. }
  19064. interface LinesMesh {
  19065. /**
  19066. * Enables the edge rendering mode on the mesh.
  19067. * This mode makes the mesh edges visible
  19068. * @param epsilon defines the maximal distance between two angles to detect a face
  19069. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19070. * @returns the currentAbstractMesh
  19071. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19072. */
  19073. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19074. }
  19075. interface InstancedLinesMesh {
  19076. /**
  19077. * Enables the edge rendering mode on the mesh.
  19078. * This mode makes the mesh edges visible
  19079. * @param epsilon defines the maximal distance between two angles to detect a face
  19080. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19081. * @returns the current InstancedLinesMesh
  19082. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19083. */
  19084. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19085. }
  19086. /**
  19087. * Defines the minimum contract an Edges renderer should follow.
  19088. */
  19089. export interface IEdgesRenderer extends IDisposable {
  19090. /**
  19091. * Gets or sets a boolean indicating if the edgesRenderer is active
  19092. */
  19093. isEnabled: boolean;
  19094. /**
  19095. * Renders the edges of the attached mesh,
  19096. */
  19097. render(): void;
  19098. /**
  19099. * Checks wether or not the edges renderer is ready to render.
  19100. * @return true if ready, otherwise false.
  19101. */
  19102. isReady(): boolean;
  19103. }
  19104. /**
  19105. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19106. */
  19107. export class EdgesRenderer implements IEdgesRenderer {
  19108. /**
  19109. * Define the size of the edges with an orthographic camera
  19110. */
  19111. edgesWidthScalerForOrthographic: number;
  19112. /**
  19113. * Define the size of the edges with a perspective camera
  19114. */
  19115. edgesWidthScalerForPerspective: number;
  19116. protected _source: AbstractMesh;
  19117. protected _linesPositions: number[];
  19118. protected _linesNormals: number[];
  19119. protected _linesIndices: number[];
  19120. protected _epsilon: number;
  19121. protected _indicesCount: number;
  19122. protected _lineShader: ShaderMaterial;
  19123. protected _ib: DataBuffer;
  19124. protected _buffers: {
  19125. [key: string]: Nullable<VertexBuffer>;
  19126. };
  19127. protected _checkVerticesInsteadOfIndices: boolean;
  19128. private _meshRebuildObserver;
  19129. private _meshDisposeObserver;
  19130. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19131. isEnabled: boolean;
  19132. /**
  19133. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19134. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19135. * @param source Mesh used to create edges
  19136. * @param epsilon sum of angles in adjacency to check for edge
  19137. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19138. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19139. */
  19140. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19141. protected _prepareRessources(): void;
  19142. /** @hidden */ private _rebuild(): void;
  19143. /**
  19144. * Releases the required resources for the edges renderer
  19145. */
  19146. dispose(): void;
  19147. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19148. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19149. /**
  19150. * Checks if the pair of p0 and p1 is en edge
  19151. * @param faceIndex
  19152. * @param edge
  19153. * @param faceNormals
  19154. * @param p0
  19155. * @param p1
  19156. * @private
  19157. */
  19158. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19159. /**
  19160. * push line into the position, normal and index buffer
  19161. * @protected
  19162. */
  19163. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19164. /**
  19165. * Generates lines edges from adjacencjes
  19166. * @private
  19167. */ private _generateEdgesLines(): void;
  19168. /**
  19169. * Checks wether or not the edges renderer is ready to render.
  19170. * @return true if ready, otherwise false.
  19171. */
  19172. isReady(): boolean;
  19173. /**
  19174. * Renders the edges of the attached mesh,
  19175. */
  19176. render(): void;
  19177. }
  19178. /**
  19179. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19180. */
  19181. export class LineEdgesRenderer extends EdgesRenderer {
  19182. /**
  19183. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19184. * @param source LineMesh used to generate edges
  19185. * @param epsilon not important (specified angle for edge detection)
  19186. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19187. */
  19188. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19189. /**
  19190. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19191. */ private _generateEdgesLines(): void;
  19192. }
  19193. }
  19194. declare module BABYLON {
  19195. /**
  19196. * This represents the object necessary to create a rendering group.
  19197. * This is exclusively used and created by the rendering manager.
  19198. * To modify the behavior, you use the available helpers in your scene or meshes.
  19199. * @hidden
  19200. */
  19201. export class RenderingGroup {
  19202. index: number;
  19203. private static _zeroVector;
  19204. private _scene;
  19205. private _opaqueSubMeshes;
  19206. private _transparentSubMeshes;
  19207. private _alphaTestSubMeshes;
  19208. private _depthOnlySubMeshes;
  19209. private _particleSystems;
  19210. private _spriteManagers;
  19211. private _opaqueSortCompareFn;
  19212. private _alphaTestSortCompareFn;
  19213. private _transparentSortCompareFn;
  19214. private _renderOpaque;
  19215. private _renderAlphaTest;
  19216. private _renderTransparent;
  19217. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19218. onBeforeTransparentRendering: () => void;
  19219. /**
  19220. * Set the opaque sort comparison function.
  19221. * If null the sub meshes will be render in the order they were created
  19222. */
  19223. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19224. /**
  19225. * Set the alpha test sort comparison function.
  19226. * If null the sub meshes will be render in the order they were created
  19227. */
  19228. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19229. /**
  19230. * Set the transparent sort comparison function.
  19231. * If null the sub meshes will be render in the order they were created
  19232. */
  19233. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19234. /**
  19235. * Creates a new rendering group.
  19236. * @param index The rendering group index
  19237. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19238. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19239. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19240. */
  19241. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  19242. /**
  19243. * Render all the sub meshes contained in the group.
  19244. * @param customRenderFunction Used to override the default render behaviour of the group.
  19245. * @returns true if rendered some submeshes.
  19246. */
  19247. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19248. /**
  19249. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19250. * @param subMeshes The submeshes to render
  19251. */
  19252. private renderOpaqueSorted;
  19253. /**
  19254. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19255. * @param subMeshes The submeshes to render
  19256. */
  19257. private renderAlphaTestSorted;
  19258. /**
  19259. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19260. * @param subMeshes The submeshes to render
  19261. */
  19262. private renderTransparentSorted;
  19263. /**
  19264. * Renders the submeshes in a specified order.
  19265. * @param subMeshes The submeshes to sort before render
  19266. * @param sortCompareFn The comparison function use to sort
  19267. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19268. * @param transparent Specifies to activate blending if true
  19269. */
  19270. private static renderSorted;
  19271. /**
  19272. * Renders the submeshes in the order they were dispatched (no sort applied).
  19273. * @param subMeshes The submeshes to render
  19274. */
  19275. private static renderUnsorted;
  19276. /**
  19277. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19278. * are rendered back to front if in the same alpha index.
  19279. *
  19280. * @param a The first submesh
  19281. * @param b The second submesh
  19282. * @returns The result of the comparison
  19283. */
  19284. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19285. /**
  19286. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19287. * are rendered back to front.
  19288. *
  19289. * @param a The first submesh
  19290. * @param b The second submesh
  19291. * @returns The result of the comparison
  19292. */
  19293. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19294. /**
  19295. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19296. * are rendered front to back (prevent overdraw).
  19297. *
  19298. * @param a The first submesh
  19299. * @param b The second submesh
  19300. * @returns The result of the comparison
  19301. */
  19302. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19303. /**
  19304. * Resets the different lists of submeshes to prepare a new frame.
  19305. */
  19306. prepare(): void;
  19307. dispose(): void;
  19308. /**
  19309. * Inserts the submesh in its correct queue depending on its material.
  19310. * @param subMesh The submesh to dispatch
  19311. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19312. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19313. */
  19314. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19315. dispatchSprites(spriteManager: ISpriteManager): void;
  19316. dispatchParticles(particleSystem: IParticleSystem): void;
  19317. private _renderParticles;
  19318. private _renderSprites;
  19319. }
  19320. }
  19321. declare module BABYLON {
  19322. /**
  19323. * Interface describing the different options available in the rendering manager
  19324. * regarding Auto Clear between groups.
  19325. */
  19326. export interface IRenderingManagerAutoClearSetup {
  19327. /**
  19328. * Defines whether or not autoclear is enable.
  19329. */
  19330. autoClear: boolean;
  19331. /**
  19332. * Defines whether or not to autoclear the depth buffer.
  19333. */
  19334. depth: boolean;
  19335. /**
  19336. * Defines whether or not to autoclear the stencil buffer.
  19337. */
  19338. stencil: boolean;
  19339. }
  19340. /**
  19341. * This class is used by the onRenderingGroupObservable
  19342. */
  19343. export class RenderingGroupInfo {
  19344. /**
  19345. * The Scene that being rendered
  19346. */
  19347. scene: Scene;
  19348. /**
  19349. * The camera currently used for the rendering pass
  19350. */
  19351. camera: Nullable<Camera>;
  19352. /**
  19353. * The ID of the renderingGroup being processed
  19354. */
  19355. renderingGroupId: number;
  19356. }
  19357. /**
  19358. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19359. * It is enable to manage the different groups as well as the different necessary sort functions.
  19360. * This should not be used directly aside of the few static configurations
  19361. */
  19362. export class RenderingManager {
  19363. /**
  19364. * The max id used for rendering groups (not included)
  19365. */
  19366. static MAX_RENDERINGGROUPS: number;
  19367. /**
  19368. * The min id used for rendering groups (included)
  19369. */
  19370. static MIN_RENDERINGGROUPS: number;
  19371. /**
  19372. * Used to globally prevent autoclearing scenes.
  19373. */
  19374. static AUTOCLEAR: boolean;
  19375. /**
  19376. * @hidden
  19377. */ private _useSceneAutoClearSetup: boolean;
  19378. private _scene;
  19379. private _renderingGroups;
  19380. private _depthStencilBufferAlreadyCleaned;
  19381. private _autoClearDepthStencil;
  19382. private _customOpaqueSortCompareFn;
  19383. private _customAlphaTestSortCompareFn;
  19384. private _customTransparentSortCompareFn;
  19385. private _renderingGroupInfo;
  19386. /**
  19387. * Instantiates a new rendering group for a particular scene
  19388. * @param scene Defines the scene the groups belongs to
  19389. */
  19390. constructor(scene: Scene);
  19391. private _clearDepthStencilBuffer;
  19392. /**
  19393. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19394. * @hidden
  19395. */
  19396. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19397. /**
  19398. * Resets the different information of the group to prepare a new frame
  19399. * @hidden
  19400. */
  19401. reset(): void;
  19402. /**
  19403. * Dispose and release the group and its associated resources.
  19404. * @hidden
  19405. */
  19406. dispose(): void;
  19407. /**
  19408. * Clear the info related to rendering groups preventing retention points during dispose.
  19409. */
  19410. freeRenderingGroups(): void;
  19411. private _prepareRenderingGroup;
  19412. /**
  19413. * Add a sprite manager to the rendering manager in order to render it this frame.
  19414. * @param spriteManager Define the sprite manager to render
  19415. */
  19416. dispatchSprites(spriteManager: ISpriteManager): void;
  19417. /**
  19418. * Add a particle system to the rendering manager in order to render it this frame.
  19419. * @param particleSystem Define the particle system to render
  19420. */
  19421. dispatchParticles(particleSystem: IParticleSystem): void;
  19422. /**
  19423. * Add a submesh to the manager in order to render it this frame
  19424. * @param subMesh The submesh to dispatch
  19425. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19426. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19427. */
  19428. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19429. /**
  19430. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19431. * This allowed control for front to back rendering or reversly depending of the special needs.
  19432. *
  19433. * @param renderingGroupId The rendering group id corresponding to its index
  19434. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19435. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19436. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19437. */
  19438. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  19439. /**
  19440. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19441. *
  19442. * @param renderingGroupId The rendering group id corresponding to its index
  19443. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19444. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19445. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19446. */
  19447. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19448. /**
  19449. * Gets the current auto clear configuration for one rendering group of the rendering
  19450. * manager.
  19451. * @param index the rendering group index to get the information for
  19452. * @returns The auto clear setup for the requested rendering group
  19453. */
  19454. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19455. }
  19456. }
  19457. declare module BABYLON {
  19458. /**
  19459. * This Helps creating a texture that will be created from a camera in your scene.
  19460. * It is basically a dynamic texture that could be used to create special effects for instance.
  19461. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19462. */
  19463. export class RenderTargetTexture extends Texture {
  19464. isCube: boolean;
  19465. /**
  19466. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19467. */
  19468. static readonly REFRESHRATE_RENDER_ONCE: number;
  19469. /**
  19470. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19471. */
  19472. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19473. /**
  19474. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19475. * the central point of your effect and can save a lot of performances.
  19476. */
  19477. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19478. /**
  19479. * Use this predicate to dynamically define the list of mesh you want to render.
  19480. * If set, the renderList property will be overwritten.
  19481. */
  19482. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19483. private _renderList;
  19484. /**
  19485. * Use this list to define the list of mesh you want to render.
  19486. */
  19487. renderList: Nullable<Array<AbstractMesh>>;
  19488. private _hookArray;
  19489. /**
  19490. * Define if particles should be rendered in your texture.
  19491. */
  19492. renderParticles: boolean;
  19493. /**
  19494. * Define if sprites should be rendered in your texture.
  19495. */
  19496. renderSprites: boolean;
  19497. /**
  19498. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19499. */
  19500. coordinatesMode: number;
  19501. /**
  19502. * Define the camera used to render the texture.
  19503. */
  19504. activeCamera: Nullable<Camera>;
  19505. /**
  19506. * Override the render function of the texture with your own one.
  19507. */
  19508. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19509. /**
  19510. * Define if camera post processes should be use while rendering the texture.
  19511. */
  19512. useCameraPostProcesses: boolean;
  19513. /**
  19514. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19515. */
  19516. ignoreCameraViewport: boolean;
  19517. private _postProcessManager;
  19518. private _postProcesses;
  19519. private _resizeObserver;
  19520. /**
  19521. * An event triggered when the texture is unbind.
  19522. */
  19523. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19524. /**
  19525. * An event triggered when the texture is unbind.
  19526. */
  19527. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19528. private _onAfterUnbindObserver;
  19529. /**
  19530. * Set a after unbind callback in the texture.
  19531. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19532. */
  19533. onAfterUnbind: () => void;
  19534. /**
  19535. * An event triggered before rendering the texture
  19536. */
  19537. onBeforeRenderObservable: Observable<number>;
  19538. private _onBeforeRenderObserver;
  19539. /**
  19540. * Set a before render callback in the texture.
  19541. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19542. */
  19543. onBeforeRender: (faceIndex: number) => void;
  19544. /**
  19545. * An event triggered after rendering the texture
  19546. */
  19547. onAfterRenderObservable: Observable<number>;
  19548. private _onAfterRenderObserver;
  19549. /**
  19550. * Set a after render callback in the texture.
  19551. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19552. */
  19553. onAfterRender: (faceIndex: number) => void;
  19554. /**
  19555. * An event triggered after the texture clear
  19556. */
  19557. onClearObservable: Observable<Engine>;
  19558. private _onClearObserver;
  19559. /**
  19560. * Set a clear callback in the texture.
  19561. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19562. */
  19563. onClear: (Engine: Engine) => void;
  19564. /**
  19565. * An event triggered when the texture is resized.
  19566. */
  19567. onResizeObservable: Observable<RenderTargetTexture>;
  19568. /**
  19569. * Define the clear color of the Render Target if it should be different from the scene.
  19570. */
  19571. clearColor: Color4;
  19572. protected _size: number | {
  19573. width: number;
  19574. height: number;
  19575. };
  19576. protected _initialSizeParameter: number | {
  19577. width: number;
  19578. height: number;
  19579. } | {
  19580. ratio: number;
  19581. };
  19582. protected _sizeRatio: Nullable<number>;
  19583. /** @hidden */ private _generateMipMaps: boolean;
  19584. protected _renderingManager: RenderingManager;
  19585. /** @hidden */ private _waitingRenderList: string[];
  19586. protected _doNotChangeAspectRatio: boolean;
  19587. protected _currentRefreshId: number;
  19588. protected _refreshRate: number;
  19589. protected _textureMatrix: Matrix;
  19590. protected _samples: number;
  19591. protected _renderTargetOptions: RenderTargetCreationOptions;
  19592. /**
  19593. * Gets render target creation options that were used.
  19594. */
  19595. readonly renderTargetOptions: RenderTargetCreationOptions;
  19596. protected _engine: Engine;
  19597. protected _onRatioRescale(): void;
  19598. /**
  19599. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19600. * It must define where the camera used to render the texture is set
  19601. */
  19602. boundingBoxPosition: Vector3;
  19603. private _boundingBoxSize;
  19604. /**
  19605. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19606. * When defined, the cubemap will switch to local mode
  19607. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19608. * @example https://www.babylonjs-playground.com/#RNASML
  19609. */
  19610. boundingBoxSize: Vector3;
  19611. /**
  19612. * In case the RTT has been created with a depth texture, get the associated
  19613. * depth texture.
  19614. * Otherwise, return null.
  19615. */
  19616. depthStencilTexture: Nullable<InternalTexture>;
  19617. /**
  19618. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19619. * or used a shadow, depth texture...
  19620. * @param name The friendly name of the texture
  19621. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  19622. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19623. * @param generateMipMaps True if mip maps need to be generated after render.
  19624. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19625. * @param type The type of the buffer in the RTT (int, half float, float...)
  19626. * @param isCube True if a cube texture needs to be created
  19627. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19628. * @param generateDepthBuffer True to generate a depth buffer
  19629. * @param generateStencilBuffer True to generate a stencil buffer
  19630. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19631. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19632. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19633. */
  19634. constructor(name: string, size: number | {
  19635. width: number;
  19636. height: number;
  19637. } | {
  19638. ratio: number;
  19639. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19640. /**
  19641. * Creates a depth stencil texture.
  19642. * This is only available in WebGL 2 or with the depth texture extension available.
  19643. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19644. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19645. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19646. */
  19647. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19648. private _processSizeParameter;
  19649. /**
  19650. * Define the number of samples to use in case of MSAA.
  19651. * It defaults to one meaning no MSAA has been enabled.
  19652. */
  19653. samples: number;
  19654. /**
  19655. * Resets the refresh counter of the texture and start bak from scratch.
  19656. * Could be useful to regenerate the texture if it is setup to render only once.
  19657. */
  19658. resetRefreshCounter(): void;
  19659. /**
  19660. * Define the refresh rate of the texture or the rendering frequency.
  19661. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19662. */
  19663. refreshRate: number;
  19664. /**
  19665. * Adds a post process to the render target rendering passes.
  19666. * @param postProcess define the post process to add
  19667. */
  19668. addPostProcess(postProcess: PostProcess): void;
  19669. /**
  19670. * Clear all the post processes attached to the render target
  19671. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19672. */
  19673. clearPostProcesses(dispose?: boolean): void;
  19674. /**
  19675. * Remove one of the post process from the list of attached post processes to the texture
  19676. * @param postProcess define the post process to remove from the list
  19677. */
  19678. removePostProcess(postProcess: PostProcess): void;
  19679. /** @hidden */ private _shouldRender(): boolean;
  19680. /**
  19681. * Gets the actual render size of the texture.
  19682. * @returns the width of the render size
  19683. */
  19684. getRenderSize(): number;
  19685. /**
  19686. * Gets the actual render width of the texture.
  19687. * @returns the width of the render size
  19688. */
  19689. getRenderWidth(): number;
  19690. /**
  19691. * Gets the actual render height of the texture.
  19692. * @returns the height of the render size
  19693. */
  19694. getRenderHeight(): number;
  19695. /**
  19696. * Get if the texture can be rescaled or not.
  19697. */
  19698. readonly canRescale: boolean;
  19699. /**
  19700. * Resize the texture using a ratio.
  19701. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19702. */
  19703. scale(ratio: number): void;
  19704. /**
  19705. * Get the texture reflection matrix used to rotate/transform the reflection.
  19706. * @returns the reflection matrix
  19707. */
  19708. getReflectionTextureMatrix(): Matrix;
  19709. /**
  19710. * Resize the texture to a new desired size.
  19711. * Be carrefull as it will recreate all the data in the new texture.
  19712. * @param size Define the new size. It can be:
  19713. * - a number for squared texture,
  19714. * - an object containing { width: number, height: number }
  19715. * - or an object containing a ratio { ratio: number }
  19716. */
  19717. resize(size: number | {
  19718. width: number;
  19719. height: number;
  19720. } | {
  19721. ratio: number;
  19722. }): void;
  19723. /**
  19724. * Renders all the objects from the render list into the texture.
  19725. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19726. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19727. */
  19728. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19729. private _bestReflectionRenderTargetDimension;
  19730. /**
  19731. * @hidden
  19732. * @param faceIndex face index to bind to if this is a cubetexture
  19733. */ private _bindFrameBuffer(faceIndex?: number): void;
  19734. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19735. private renderToTarget;
  19736. /**
  19737. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19738. * This allowed control for front to back rendering or reversly depending of the special needs.
  19739. *
  19740. * @param renderingGroupId The rendering group id corresponding to its index
  19741. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19742. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19743. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19744. */
  19745. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  19746. /**
  19747. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19748. *
  19749. * @param renderingGroupId The rendering group id corresponding to its index
  19750. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19751. */
  19752. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19753. /**
  19754. * Clones the texture.
  19755. * @returns the cloned texture
  19756. */
  19757. clone(): RenderTargetTexture;
  19758. /**
  19759. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19760. * @returns The JSON representation of the texture
  19761. */
  19762. serialize(): any;
  19763. /**
  19764. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19765. */
  19766. disposeFramebufferObjects(): void;
  19767. /**
  19768. * Dispose the texture and release its associated resources.
  19769. */
  19770. dispose(): void;
  19771. /** @hidden */ private _rebuild(): void;
  19772. /**
  19773. * Clear the info related to rendering groups preventing retention point in material dispose.
  19774. */
  19775. freeRenderingGroups(): void;
  19776. /**
  19777. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19778. * @returns the view count
  19779. */
  19780. getViewCount(): number;
  19781. }
  19782. }
  19783. declare module BABYLON {
  19784. /**
  19785. * Base class for the main features of a material in Babylon.js
  19786. */
  19787. export class Material implements IAnimatable {
  19788. /**
  19789. * Returns the triangle fill mode
  19790. */
  19791. static readonly TriangleFillMode: number;
  19792. /**
  19793. * Returns the wireframe mode
  19794. */
  19795. static readonly WireFrameFillMode: number;
  19796. /**
  19797. * Returns the point fill mode
  19798. */
  19799. static readonly PointFillMode: number;
  19800. /**
  19801. * Returns the point list draw mode
  19802. */
  19803. static readonly PointListDrawMode: number;
  19804. /**
  19805. * Returns the line list draw mode
  19806. */
  19807. static readonly LineListDrawMode: number;
  19808. /**
  19809. * Returns the line loop draw mode
  19810. */
  19811. static readonly LineLoopDrawMode: number;
  19812. /**
  19813. * Returns the line strip draw mode
  19814. */
  19815. static readonly LineStripDrawMode: number;
  19816. /**
  19817. * Returns the triangle strip draw mode
  19818. */
  19819. static readonly TriangleStripDrawMode: number;
  19820. /**
  19821. * Returns the triangle fan draw mode
  19822. */
  19823. static readonly TriangleFanDrawMode: number;
  19824. /**
  19825. * Stores the clock-wise side orientation
  19826. */
  19827. static readonly ClockWiseSideOrientation: number;
  19828. /**
  19829. * Stores the counter clock-wise side orientation
  19830. */
  19831. static readonly CounterClockWiseSideOrientation: number;
  19832. /**
  19833. * The dirty texture flag value
  19834. */
  19835. static readonly TextureDirtyFlag: number;
  19836. /**
  19837. * The dirty light flag value
  19838. */
  19839. static readonly LightDirtyFlag: number;
  19840. /**
  19841. * The dirty fresnel flag value
  19842. */
  19843. static readonly FresnelDirtyFlag: number;
  19844. /**
  19845. * The dirty attribute flag value
  19846. */
  19847. static readonly AttributesDirtyFlag: number;
  19848. /**
  19849. * The dirty misc flag value
  19850. */
  19851. static readonly MiscDirtyFlag: number;
  19852. /**
  19853. * The all dirty flag value
  19854. */
  19855. static readonly AllDirtyFlag: number;
  19856. /**
  19857. * The ID of the material
  19858. */
  19859. id: string;
  19860. /**
  19861. * Gets or sets the unique id of the material
  19862. */
  19863. uniqueId: number;
  19864. /**
  19865. * The name of the material
  19866. */
  19867. name: string;
  19868. /**
  19869. * Gets or sets user defined metadata
  19870. */
  19871. metadata: any;
  19872. /**
  19873. * For internal use only. Please do not use.
  19874. */
  19875. reservedDataStore: any;
  19876. /**
  19877. * Specifies if the ready state should be checked on each call
  19878. */
  19879. checkReadyOnEveryCall: boolean;
  19880. /**
  19881. * Specifies if the ready state should be checked once
  19882. */
  19883. checkReadyOnlyOnce: boolean;
  19884. /**
  19885. * The state of the material
  19886. */
  19887. state: string;
  19888. /**
  19889. * The alpha value of the material
  19890. */
  19891. protected _alpha: number;
  19892. /**
  19893. * List of inspectable custom properties (used by the Inspector)
  19894. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19895. */
  19896. inspectableCustomProperties: IInspectable[];
  19897. /**
  19898. * Sets the alpha value of the material
  19899. */
  19900. /**
  19901. * Gets the alpha value of the material
  19902. */
  19903. alpha: number;
  19904. /**
  19905. * Specifies if back face culling is enabled
  19906. */
  19907. protected _backFaceCulling: boolean;
  19908. /**
  19909. * Sets the back-face culling state
  19910. */
  19911. /**
  19912. * Gets the back-face culling state
  19913. */
  19914. backFaceCulling: boolean;
  19915. /**
  19916. * Stores the value for side orientation
  19917. */
  19918. sideOrientation: number;
  19919. /**
  19920. * Callback triggered when the material is compiled
  19921. */
  19922. onCompiled: Nullable<(effect: Effect) => void>;
  19923. /**
  19924. * Callback triggered when an error occurs
  19925. */
  19926. onError: Nullable<(effect: Effect, errors: string) => void>;
  19927. /**
  19928. * Callback triggered to get the render target textures
  19929. */
  19930. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19931. /**
  19932. * Gets a boolean indicating that current material needs to register RTT
  19933. */
  19934. readonly hasRenderTargetTextures: boolean;
  19935. /**
  19936. * Specifies if the material should be serialized
  19937. */
  19938. doNotSerialize: boolean;
  19939. /**
  19940. * @hidden
  19941. */ private _storeEffectOnSubMeshes: boolean;
  19942. /**
  19943. * Stores the animations for the material
  19944. */
  19945. animations: Nullable<Array<Animation>>;
  19946. /**
  19947. * An event triggered when the material is disposed
  19948. */
  19949. onDisposeObservable: Observable<Material>;
  19950. /**
  19951. * An observer which watches for dispose events
  19952. */
  19953. private _onDisposeObserver;
  19954. private _onUnBindObservable;
  19955. /**
  19956. * Called during a dispose event
  19957. */
  19958. onDispose: () => void;
  19959. private _onBindObservable;
  19960. /**
  19961. * An event triggered when the material is bound
  19962. */
  19963. readonly onBindObservable: Observable<AbstractMesh>;
  19964. /**
  19965. * An observer which watches for bind events
  19966. */
  19967. private _onBindObserver;
  19968. /**
  19969. * Called during a bind event
  19970. */
  19971. onBind: (Mesh: AbstractMesh) => void;
  19972. /**
  19973. * An event triggered when the material is unbound
  19974. */
  19975. readonly onUnBindObservable: Observable<Material>;
  19976. /**
  19977. * Stores the value of the alpha mode
  19978. */
  19979. private _alphaMode;
  19980. /**
  19981. * Sets the value of the alpha mode.
  19982. *
  19983. * | Value | Type | Description |
  19984. * | --- | --- | --- |
  19985. * | 0 | ALPHA_DISABLE | |
  19986. * | 1 | ALPHA_ADD | |
  19987. * | 2 | ALPHA_COMBINE | |
  19988. * | 3 | ALPHA_SUBTRACT | |
  19989. * | 4 | ALPHA_MULTIPLY | |
  19990. * | 5 | ALPHA_MAXIMIZED | |
  19991. * | 6 | ALPHA_ONEONE | |
  19992. * | 7 | ALPHA_PREMULTIPLIED | |
  19993. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  19994. * | 9 | ALPHA_INTERPOLATE | |
  19995. * | 10 | ALPHA_SCREENMODE | |
  19996. *
  19997. */
  19998. /**
  19999. * Gets the value of the alpha mode
  20000. */
  20001. alphaMode: number;
  20002. /**
  20003. * Stores the state of the need depth pre-pass value
  20004. */
  20005. private _needDepthPrePass;
  20006. /**
  20007. * Sets the need depth pre-pass value
  20008. */
  20009. /**
  20010. * Gets the depth pre-pass value
  20011. */
  20012. needDepthPrePass: boolean;
  20013. /**
  20014. * Specifies if depth writing should be disabled
  20015. */
  20016. disableDepthWrite: boolean;
  20017. /**
  20018. * Specifies if depth writing should be forced
  20019. */
  20020. forceDepthWrite: boolean;
  20021. /**
  20022. * Specifies if there should be a separate pass for culling
  20023. */
  20024. separateCullingPass: boolean;
  20025. /**
  20026. * Stores the state specifing if fog should be enabled
  20027. */
  20028. private _fogEnabled;
  20029. /**
  20030. * Sets the state for enabling fog
  20031. */
  20032. /**
  20033. * Gets the value of the fog enabled state
  20034. */
  20035. fogEnabled: boolean;
  20036. /**
  20037. * Stores the size of points
  20038. */
  20039. pointSize: number;
  20040. /**
  20041. * Stores the z offset value
  20042. */
  20043. zOffset: number;
  20044. /**
  20045. * Gets a value specifying if wireframe mode is enabled
  20046. */
  20047. /**
  20048. * Sets the state of wireframe mode
  20049. */
  20050. wireframe: boolean;
  20051. /**
  20052. * Gets the value specifying if point clouds are enabled
  20053. */
  20054. /**
  20055. * Sets the state of point cloud mode
  20056. */
  20057. pointsCloud: boolean;
  20058. /**
  20059. * Gets the material fill mode
  20060. */
  20061. /**
  20062. * Sets the material fill mode
  20063. */
  20064. fillMode: number;
  20065. /**
  20066. * @hidden
  20067. * Stores the effects for the material
  20068. */ private _effect: Nullable<Effect>;
  20069. /**
  20070. * @hidden
  20071. * Specifies if the material was previously ready
  20072. */ private _wasPreviouslyReady: boolean;
  20073. /**
  20074. * Specifies if uniform buffers should be used
  20075. */
  20076. private _useUBO;
  20077. /**
  20078. * Stores a reference to the scene
  20079. */
  20080. private _scene;
  20081. /**
  20082. * Stores the fill mode state
  20083. */
  20084. private _fillMode;
  20085. /**
  20086. * Specifies if the depth write state should be cached
  20087. */
  20088. private _cachedDepthWriteState;
  20089. /**
  20090. * Stores the uniform buffer
  20091. */
  20092. protected _uniformBuffer: UniformBuffer;
  20093. /** @hidden */ private _indexInSceneMaterialArray: number;
  20094. /** @hidden */
  20095. meshMap: Nullable<{
  20096. [id: string]: AbstractMesh | undefined;
  20097. }>;
  20098. /**
  20099. * Creates a material instance
  20100. * @param name defines the name of the material
  20101. * @param scene defines the scene to reference
  20102. * @param doNotAdd specifies if the material should be added to the scene
  20103. */
  20104. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20105. /**
  20106. * Returns a string representation of the current material
  20107. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20108. * @returns a string with material information
  20109. */
  20110. toString(fullDetails?: boolean): string;
  20111. /**
  20112. * Gets the class name of the material
  20113. * @returns a string with the class name of the material
  20114. */
  20115. getClassName(): string;
  20116. /**
  20117. * Specifies if updates for the material been locked
  20118. */
  20119. readonly isFrozen: boolean;
  20120. /**
  20121. * Locks updates for the material
  20122. */
  20123. freeze(): void;
  20124. /**
  20125. * Unlocks updates for the material
  20126. */
  20127. unfreeze(): void;
  20128. /**
  20129. * Specifies if the material is ready to be used
  20130. * @param mesh defines the mesh to check
  20131. * @param useInstances specifies if instances should be used
  20132. * @returns a boolean indicating if the material is ready to be used
  20133. */
  20134. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20135. /**
  20136. * Specifies that the submesh is ready to be used
  20137. * @param mesh defines the mesh to check
  20138. * @param subMesh defines which submesh to check
  20139. * @param useInstances specifies that instances should be used
  20140. * @returns a boolean indicating that the submesh is ready or not
  20141. */
  20142. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20143. /**
  20144. * Returns the material effect
  20145. * @returns the effect associated with the material
  20146. */
  20147. getEffect(): Nullable<Effect>;
  20148. /**
  20149. * Returns the current scene
  20150. * @returns a Scene
  20151. */
  20152. getScene(): Scene;
  20153. /**
  20154. * Specifies if the material will require alpha blending
  20155. * @returns a boolean specifying if alpha blending is needed
  20156. */
  20157. needAlphaBlending(): boolean;
  20158. /**
  20159. * Specifies if the mesh will require alpha blending
  20160. * @param mesh defines the mesh to check
  20161. * @returns a boolean specifying if alpha blending is needed for the mesh
  20162. */
  20163. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20164. /**
  20165. * Specifies if this material should be rendered in alpha test mode
  20166. * @returns a boolean specifying if an alpha test is needed.
  20167. */
  20168. needAlphaTesting(): boolean;
  20169. /**
  20170. * Gets the texture used for the alpha test
  20171. * @returns the texture to use for alpha testing
  20172. */
  20173. getAlphaTestTexture(): Nullable<BaseTexture>;
  20174. /**
  20175. * Marks the material to indicate that it needs to be re-calculated
  20176. */
  20177. markDirty(): void;
  20178. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20179. /**
  20180. * Binds the material to the mesh
  20181. * @param world defines the world transformation matrix
  20182. * @param mesh defines the mesh to bind the material to
  20183. */
  20184. bind(world: Matrix, mesh?: Mesh): void;
  20185. /**
  20186. * Binds the submesh to the material
  20187. * @param world defines the world transformation matrix
  20188. * @param mesh defines the mesh containing the submesh
  20189. * @param subMesh defines the submesh to bind the material to
  20190. */
  20191. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20192. /**
  20193. * Binds the world matrix to the material
  20194. * @param world defines the world transformation matrix
  20195. */
  20196. bindOnlyWorldMatrix(world: Matrix): void;
  20197. /**
  20198. * Binds the scene's uniform buffer to the effect.
  20199. * @param effect defines the effect to bind to the scene uniform buffer
  20200. * @param sceneUbo defines the uniform buffer storing scene data
  20201. */
  20202. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20203. /**
  20204. * Binds the view matrix to the effect
  20205. * @param effect defines the effect to bind the view matrix to
  20206. */
  20207. bindView(effect: Effect): void;
  20208. /**
  20209. * Binds the view projection matrix to the effect
  20210. * @param effect defines the effect to bind the view projection matrix to
  20211. */
  20212. bindViewProjection(effect: Effect): void;
  20213. /**
  20214. * Specifies if material alpha testing should be turned on for the mesh
  20215. * @param mesh defines the mesh to check
  20216. */
  20217. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20218. /**
  20219. * Processes to execute after binding the material to a mesh
  20220. * @param mesh defines the rendered mesh
  20221. */
  20222. protected _afterBind(mesh?: Mesh): void;
  20223. /**
  20224. * Unbinds the material from the mesh
  20225. */
  20226. unbind(): void;
  20227. /**
  20228. * Gets the active textures from the material
  20229. * @returns an array of textures
  20230. */
  20231. getActiveTextures(): BaseTexture[];
  20232. /**
  20233. * Specifies if the material uses a texture
  20234. * @param texture defines the texture to check against the material
  20235. * @returns a boolean specifying if the material uses the texture
  20236. */
  20237. hasTexture(texture: BaseTexture): boolean;
  20238. /**
  20239. * Makes a duplicate of the material, and gives it a new name
  20240. * @param name defines the new name for the duplicated material
  20241. * @returns the cloned material
  20242. */
  20243. clone(name: string): Nullable<Material>;
  20244. /**
  20245. * Gets the meshes bound to the material
  20246. * @returns an array of meshes bound to the material
  20247. */
  20248. getBindedMeshes(): AbstractMesh[];
  20249. /**
  20250. * Force shader compilation
  20251. * @param mesh defines the mesh associated with this material
  20252. * @param onCompiled defines a function to execute once the material is compiled
  20253. * @param options defines the options to configure the compilation
  20254. * @param onError defines a function to execute if the material fails compiling
  20255. */
  20256. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20257. clipPlane: boolean;
  20258. }>, onError?: (reason: string) => void): void;
  20259. /**
  20260. * Force shader compilation
  20261. * @param mesh defines the mesh that will use this material
  20262. * @param options defines additional options for compiling the shaders
  20263. * @returns a promise that resolves when the compilation completes
  20264. */
  20265. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20266. clipPlane: boolean;
  20267. }>): Promise<void>;
  20268. private static readonly _AllDirtyCallBack;
  20269. private static readonly _ImageProcessingDirtyCallBack;
  20270. private static readonly _TextureDirtyCallBack;
  20271. private static readonly _FresnelDirtyCallBack;
  20272. private static readonly _MiscDirtyCallBack;
  20273. private static readonly _LightsDirtyCallBack;
  20274. private static readonly _AttributeDirtyCallBack;
  20275. private static _FresnelAndMiscDirtyCallBack;
  20276. private static _TextureAndMiscDirtyCallBack;
  20277. private static readonly _DirtyCallbackArray;
  20278. private static readonly _RunDirtyCallBacks;
  20279. /**
  20280. * Marks a define in the material to indicate that it needs to be re-computed
  20281. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20282. */
  20283. markAsDirty(flag: number): void;
  20284. /**
  20285. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20286. * @param func defines a function which checks material defines against the submeshes
  20287. */
  20288. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20289. /**
  20290. * Indicates that we need to re-calculated for all submeshes
  20291. */
  20292. protected _markAllSubMeshesAsAllDirty(): void;
  20293. /**
  20294. * Indicates that image processing needs to be re-calculated for all submeshes
  20295. */
  20296. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20297. /**
  20298. * Indicates that textures need to be re-calculated for all submeshes
  20299. */
  20300. protected _markAllSubMeshesAsTexturesDirty(): void;
  20301. /**
  20302. * Indicates that fresnel needs to be re-calculated for all submeshes
  20303. */
  20304. protected _markAllSubMeshesAsFresnelDirty(): void;
  20305. /**
  20306. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20307. */
  20308. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20309. /**
  20310. * Indicates that lights need to be re-calculated for all submeshes
  20311. */
  20312. protected _markAllSubMeshesAsLightsDirty(): void;
  20313. /**
  20314. * Indicates that attributes need to be re-calculated for all submeshes
  20315. */
  20316. protected _markAllSubMeshesAsAttributesDirty(): void;
  20317. /**
  20318. * Indicates that misc needs to be re-calculated for all submeshes
  20319. */
  20320. protected _markAllSubMeshesAsMiscDirty(): void;
  20321. /**
  20322. * Indicates that textures and misc need to be re-calculated for all submeshes
  20323. */
  20324. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20325. /**
  20326. * Disposes the material
  20327. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20328. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20329. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20330. */
  20331. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20332. /** @hidden */
  20333. private releaseVertexArrayObject;
  20334. /**
  20335. * Serializes this material
  20336. * @returns the serialized material object
  20337. */
  20338. serialize(): any;
  20339. /**
  20340. * Creates a material from parsed material data
  20341. * @param parsedMaterial defines parsed material data
  20342. * @param scene defines the hosting scene
  20343. * @param rootUrl defines the root URL to use to load textures
  20344. * @returns a new material
  20345. */
  20346. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20347. }
  20348. }
  20349. declare module BABYLON {
  20350. /**
  20351. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20352. * separate meshes. This can be use to improve performances.
  20353. * @see http://doc.babylonjs.com/how_to/multi_materials
  20354. */
  20355. export class MultiMaterial extends Material {
  20356. private _subMaterials;
  20357. /**
  20358. * Gets or Sets the list of Materials used within the multi material.
  20359. * They need to be ordered according to the submeshes order in the associated mesh
  20360. */
  20361. subMaterials: Nullable<Material>[];
  20362. /**
  20363. * Function used to align with Node.getChildren()
  20364. * @returns the list of Materials used within the multi material
  20365. */
  20366. getChildren(): Nullable<Material>[];
  20367. /**
  20368. * Instantiates a new Multi Material
  20369. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20370. * separate meshes. This can be use to improve performances.
  20371. * @see http://doc.babylonjs.com/how_to/multi_materials
  20372. * @param name Define the name in the scene
  20373. * @param scene Define the scene the material belongs to
  20374. */
  20375. constructor(name: string, scene: Scene);
  20376. private _hookArray;
  20377. /**
  20378. * Get one of the submaterial by its index in the submaterials array
  20379. * @param index The index to look the sub material at
  20380. * @returns The Material if the index has been defined
  20381. */
  20382. getSubMaterial(index: number): Nullable<Material>;
  20383. /**
  20384. * Get the list of active textures for the whole sub materials list.
  20385. * @returns All the textures that will be used during the rendering
  20386. */
  20387. getActiveTextures(): BaseTexture[];
  20388. /**
  20389. * Gets the current class name of the material e.g. "MultiMaterial"
  20390. * Mainly use in serialization.
  20391. * @returns the class name
  20392. */
  20393. getClassName(): string;
  20394. /**
  20395. * Checks if the material is ready to render the requested sub mesh
  20396. * @param mesh Define the mesh the submesh belongs to
  20397. * @param subMesh Define the sub mesh to look readyness for
  20398. * @param useInstances Define whether or not the material is used with instances
  20399. * @returns true if ready, otherwise false
  20400. */
  20401. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20402. /**
  20403. * Clones the current material and its related sub materials
  20404. * @param name Define the name of the newly cloned material
  20405. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20406. * @returns the cloned material
  20407. */
  20408. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20409. /**
  20410. * Serializes the materials into a JSON representation.
  20411. * @returns the JSON representation
  20412. */
  20413. serialize(): any;
  20414. /**
  20415. * Dispose the material and release its associated resources
  20416. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  20417. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  20418. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  20419. */
  20420. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20421. /**
  20422. * Creates a MultiMaterial from parsed MultiMaterial data.
  20423. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20424. * @param scene defines the hosting scene
  20425. * @returns a new MultiMaterial
  20426. */
  20427. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20428. }
  20429. }
  20430. declare module BABYLON {
  20431. /**
  20432. * Base class for submeshes
  20433. */
  20434. export class BaseSubMesh {
  20435. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20436. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20437. /**
  20438. * Gets associated effect
  20439. */
  20440. readonly effect: Nullable<Effect>;
  20441. /**
  20442. * Sets associated effect (effect used to render this submesh)
  20443. * @param effect defines the effect to associate with
  20444. * @param defines defines the set of defines used to compile this effect
  20445. */
  20446. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20447. }
  20448. /**
  20449. * Defines a subdivision inside a mesh
  20450. */
  20451. export class SubMesh extends BaseSubMesh implements ICullable {
  20452. /** the material index to use */
  20453. materialIndex: number;
  20454. /** vertex index start */
  20455. verticesStart: number;
  20456. /** vertices count */
  20457. verticesCount: number;
  20458. /** index start */
  20459. indexStart: number;
  20460. /** indices count */
  20461. indexCount: number;
  20462. /** @hidden */ private _linesIndexCount: number;
  20463. private _mesh;
  20464. private _renderingMesh;
  20465. private _boundingInfo;
  20466. private _linesIndexBuffer;
  20467. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20468. /** @hidden */ private _trianglePlanes: Plane[];
  20469. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20470. /** @hidden */ private _renderId: number;
  20471. /** @hidden */ private _alphaIndex: number;
  20472. /** @hidden */ private _distanceToCamera: number;
  20473. /** @hidden */ private _id: number;
  20474. private _currentMaterial;
  20475. /**
  20476. * Add a new submesh to a mesh
  20477. * @param materialIndex defines the material index to use
  20478. * @param verticesStart defines vertex index start
  20479. * @param verticesCount defines vertices count
  20480. * @param indexStart defines index start
  20481. * @param indexCount defines indices count
  20482. * @param mesh defines the parent mesh
  20483. * @param renderingMesh defines an optional rendering mesh
  20484. * @param createBoundingBox defines if bounding box should be created for this submesh
  20485. * @returns the new submesh
  20486. */
  20487. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20488. /**
  20489. * Creates a new submesh
  20490. * @param materialIndex defines the material index to use
  20491. * @param verticesStart defines vertex index start
  20492. * @param verticesCount defines vertices count
  20493. * @param indexStart defines index start
  20494. * @param indexCount defines indices count
  20495. * @param mesh defines the parent mesh
  20496. * @param renderingMesh defines an optional rendering mesh
  20497. * @param createBoundingBox defines if bounding box should be created for this submesh
  20498. */
  20499. constructor(
  20500. /** the material index to use */
  20501. materialIndex: number,
  20502. /** vertex index start */
  20503. verticesStart: number,
  20504. /** vertices count */
  20505. verticesCount: number,
  20506. /** index start */
  20507. indexStart: number,
  20508. /** indices count */
  20509. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20510. /**
  20511. * Returns true if this submesh covers the entire parent mesh
  20512. * @ignorenaming
  20513. */
  20514. readonly IsGlobal: boolean;
  20515. /**
  20516. * Returns the submesh BoudingInfo object
  20517. * @returns current bounding info (or mesh's one if the submesh is global)
  20518. */
  20519. getBoundingInfo(): BoundingInfo;
  20520. /**
  20521. * Sets the submesh BoundingInfo
  20522. * @param boundingInfo defines the new bounding info to use
  20523. * @returns the SubMesh
  20524. */
  20525. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20526. /**
  20527. * Returns the mesh of the current submesh
  20528. * @return the parent mesh
  20529. */
  20530. getMesh(): AbstractMesh;
  20531. /**
  20532. * Returns the rendering mesh of the submesh
  20533. * @returns the rendering mesh (could be different from parent mesh)
  20534. */
  20535. getRenderingMesh(): Mesh;
  20536. /**
  20537. * Returns the submesh material
  20538. * @returns null or the current material
  20539. */
  20540. getMaterial(): Nullable<Material>;
  20541. /**
  20542. * Sets a new updated BoundingInfo object to the submesh
  20543. * @param data defines an optional position array to use to determine the bounding info
  20544. * @returns the SubMesh
  20545. */
  20546. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20547. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20548. /**
  20549. * Updates the submesh BoundingInfo
  20550. * @param world defines the world matrix to use to update the bounding info
  20551. * @returns the submesh
  20552. */
  20553. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20554. /**
  20555. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20556. * @param frustumPlanes defines the frustum planes
  20557. * @returns true if the submesh is intersecting with the frustum
  20558. */
  20559. isInFrustum(frustumPlanes: Plane[]): boolean;
  20560. /**
  20561. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20562. * @param frustumPlanes defines the frustum planes
  20563. * @returns true if the submesh is inside the frustum
  20564. */
  20565. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20566. /**
  20567. * Renders the submesh
  20568. * @param enableAlphaMode defines if alpha needs to be used
  20569. * @returns the submesh
  20570. */
  20571. render(enableAlphaMode: boolean): SubMesh;
  20572. /**
  20573. * @hidden
  20574. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20575. /**
  20576. * Checks if the submesh intersects with a ray
  20577. * @param ray defines the ray to test
  20578. * @returns true is the passed ray intersects the submesh bounding box
  20579. */
  20580. canIntersects(ray: Ray): boolean;
  20581. /**
  20582. * Intersects current submesh with a ray
  20583. * @param ray defines the ray to test
  20584. * @param positions defines mesh's positions array
  20585. * @param indices defines mesh's indices array
  20586. * @param fastCheck defines if only bounding info should be used
  20587. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20588. * @returns intersection info or null if no intersection
  20589. */
  20590. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20591. /** @hidden */
  20592. private _intersectLines;
  20593. /** @hidden */
  20594. private _intersectUnIndexedLines;
  20595. /** @hidden */
  20596. private _intersectTriangles;
  20597. /** @hidden */
  20598. private _intersectUnIndexedTriangles;
  20599. /** @hidden */ private _rebuild(): void;
  20600. /**
  20601. * Creates a new submesh from the passed mesh
  20602. * @param newMesh defines the new hosting mesh
  20603. * @param newRenderingMesh defines an optional rendering mesh
  20604. * @returns the new submesh
  20605. */
  20606. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20607. /**
  20608. * Release associated resources
  20609. */
  20610. dispose(): void;
  20611. /**
  20612. * Gets the class name
  20613. * @returns the string "SubMesh".
  20614. */
  20615. getClassName(): string;
  20616. /**
  20617. * Creates a new submesh from indices data
  20618. * @param materialIndex the index of the main mesh material
  20619. * @param startIndex the index where to start the copy in the mesh indices array
  20620. * @param indexCount the number of indices to copy then from the startIndex
  20621. * @param mesh the main mesh to create the submesh from
  20622. * @param renderingMesh the optional rendering mesh
  20623. * @returns a new submesh
  20624. */
  20625. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20626. }
  20627. }
  20628. declare module BABYLON {
  20629. /**
  20630. * Class used to represent data loading progression
  20631. */
  20632. export class SceneLoaderFlags {
  20633. private static _ForceFullSceneLoadingForIncremental;
  20634. private static _ShowLoadingScreen;
  20635. private static _CleanBoneMatrixWeights;
  20636. private static _loggingLevel;
  20637. /**
  20638. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20639. */
  20640. static ForceFullSceneLoadingForIncremental: boolean;
  20641. /**
  20642. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20643. */
  20644. static ShowLoadingScreen: boolean;
  20645. /**
  20646. * Defines the current logging level (while loading the scene)
  20647. * @ignorenaming
  20648. */
  20649. static loggingLevel: number;
  20650. /**
  20651. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20652. */
  20653. static CleanBoneMatrixWeights: boolean;
  20654. }
  20655. }
  20656. declare module BABYLON {
  20657. /**
  20658. * Class used to store geometry data (vertex buffers + index buffer)
  20659. */
  20660. export class Geometry implements IGetSetVerticesData {
  20661. /**
  20662. * Gets or sets the ID of the geometry
  20663. */
  20664. id: string;
  20665. /**
  20666. * Gets or sets the unique ID of the geometry
  20667. */
  20668. uniqueId: number;
  20669. /**
  20670. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20671. */
  20672. delayLoadState: number;
  20673. /**
  20674. * Gets the file containing the data to load when running in delay load state
  20675. */
  20676. delayLoadingFile: Nullable<string>;
  20677. /**
  20678. * Callback called when the geometry is updated
  20679. */
  20680. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20681. private _scene;
  20682. private _engine;
  20683. private _meshes;
  20684. private _totalVertices;
  20685. /** @hidden */ private _indices: IndicesArray;
  20686. /** @hidden */ private _vertexBuffers: {
  20687. [key: string]: VertexBuffer;
  20688. };
  20689. private _isDisposed;
  20690. private _extend;
  20691. private _boundingBias;
  20692. /** @hidden */ private _delayInfo: Array<string>;
  20693. private _indexBuffer;
  20694. private _indexBufferIsUpdatable;
  20695. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20696. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20697. /** @hidden */ private _softwareSkinningFrameId: number;
  20698. private _vertexArrayObjects;
  20699. private _updatable;
  20700. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20701. /**
  20702. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  20703. */
  20704. /**
  20705. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  20706. */
  20707. boundingBias: Vector2;
  20708. /**
  20709. * Static function used to attach a new empty geometry to a mesh
  20710. * @param mesh defines the mesh to attach the geometry to
  20711. * @returns the new Geometry
  20712. */
  20713. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20714. /**
  20715. * Creates a new geometry
  20716. * @param id defines the unique ID
  20717. * @param scene defines the hosting scene
  20718. * @param vertexData defines the VertexData used to get geometry data
  20719. * @param updatable defines if geometry must be updatable (false by default)
  20720. * @param mesh defines the mesh that will be associated with the geometry
  20721. */
  20722. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20723. /**
  20724. * Gets the current extend of the geometry
  20725. */
  20726. readonly extend: {
  20727. minimum: Vector3;
  20728. maximum: Vector3;
  20729. };
  20730. /**
  20731. * Gets the hosting scene
  20732. * @returns the hosting Scene
  20733. */
  20734. getScene(): Scene;
  20735. /**
  20736. * Gets the hosting engine
  20737. * @returns the hosting Engine
  20738. */
  20739. getEngine(): Engine;
  20740. /**
  20741. * Defines if the geometry is ready to use
  20742. * @returns true if the geometry is ready to be used
  20743. */
  20744. isReady(): boolean;
  20745. /**
  20746. * Gets a value indicating that the geometry should not be serialized
  20747. */
  20748. readonly doNotSerialize: boolean;
  20749. /** @hidden */ private _rebuild(): void;
  20750. /**
  20751. * Affects all geometry data in one call
  20752. * @param vertexData defines the geometry data
  20753. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20754. */
  20755. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20756. /**
  20757. * Set specific vertex data
  20758. * @param kind defines the data kind (Position, normal, etc...)
  20759. * @param data defines the vertex data to use
  20760. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20761. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20762. */
  20763. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20764. /**
  20765. * Removes a specific vertex data
  20766. * @param kind defines the data kind (Position, normal, etc...)
  20767. */
  20768. removeVerticesData(kind: string): void;
  20769. /**
  20770. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20771. * @param buffer defines the vertex buffer to use
  20772. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20773. */
  20774. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20775. /**
  20776. * Update a specific vertex buffer
  20777. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20778. * It will do nothing if the buffer is not updatable
  20779. * @param kind defines the data kind (Position, normal, etc...)
  20780. * @param data defines the data to use
  20781. * @param offset defines the offset in the target buffer where to store the data
  20782. * @param useBytes set to true if the offset is in bytes
  20783. */
  20784. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20785. /**
  20786. * Update a specific vertex buffer
  20787. * This function will create a new buffer if the current one is not updatable
  20788. * @param kind defines the data kind (Position, normal, etc...)
  20789. * @param data defines the data to use
  20790. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20791. */
  20792. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20793. private _updateBoundingInfo;
  20794. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20795. /**
  20796. * Gets total number of vertices
  20797. * @returns the total number of vertices
  20798. */
  20799. getTotalVertices(): number;
  20800. /**
  20801. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20802. * @param kind defines the data kind (Position, normal, etc...)
  20803. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20804. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20805. * @returns a float array containing vertex data
  20806. */
  20807. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20808. /**
  20809. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20810. * @param kind defines the data kind (Position, normal, etc...)
  20811. * @returns true if the vertex buffer with the specified kind is updatable
  20812. */
  20813. isVertexBufferUpdatable(kind: string): boolean;
  20814. /**
  20815. * Gets a specific vertex buffer
  20816. * @param kind defines the data kind (Position, normal, etc...)
  20817. * @returns a VertexBuffer
  20818. */
  20819. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20820. /**
  20821. * Returns all vertex buffers
  20822. * @return an object holding all vertex buffers indexed by kind
  20823. */
  20824. getVertexBuffers(): Nullable<{
  20825. [key: string]: VertexBuffer;
  20826. }>;
  20827. /**
  20828. * Gets a boolean indicating if specific vertex buffer is present
  20829. * @param kind defines the data kind (Position, normal, etc...)
  20830. * @returns true if data is present
  20831. */
  20832. isVerticesDataPresent(kind: string): boolean;
  20833. /**
  20834. * Gets a list of all attached data kinds (Position, normal, etc...)
  20835. * @returns a list of string containing all kinds
  20836. */
  20837. getVerticesDataKinds(): string[];
  20838. /**
  20839. * Update index buffer
  20840. * @param indices defines the indices to store in the index buffer
  20841. * @param offset defines the offset in the target buffer where to store the data
  20842. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  20843. */
  20844. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20845. /**
  20846. * Creates a new index buffer
  20847. * @param indices defines the indices to store in the index buffer
  20848. * @param totalVertices defines the total number of vertices (could be null)
  20849. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20850. */
  20851. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20852. /**
  20853. * Return the total number of indices
  20854. * @returns the total number of indices
  20855. */
  20856. getTotalIndices(): number;
  20857. /**
  20858. * Gets the index buffer array
  20859. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20860. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20861. * @returns the index buffer array
  20862. */
  20863. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20864. /**
  20865. * Gets the index buffer
  20866. * @return the index buffer
  20867. */
  20868. getIndexBuffer(): Nullable<DataBuffer>;
  20869. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20870. /**
  20871. * Release the associated resources for a specific mesh
  20872. * @param mesh defines the source mesh
  20873. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20874. */
  20875. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20876. /**
  20877. * Apply current geometry to a given mesh
  20878. * @param mesh defines the mesh to apply geometry to
  20879. */
  20880. applyToMesh(mesh: Mesh): void;
  20881. private _updateExtend;
  20882. private _applyToMesh;
  20883. private notifyUpdate;
  20884. /**
  20885. * Load the geometry if it was flagged as delay loaded
  20886. * @param scene defines the hosting scene
  20887. * @param onLoaded defines a callback called when the geometry is loaded
  20888. */
  20889. load(scene: Scene, onLoaded?: () => void): void;
  20890. private _queueLoad;
  20891. /**
  20892. * Invert the geometry to move from a right handed system to a left handed one.
  20893. */
  20894. toLeftHanded(): void;
  20895. /** @hidden */ private _resetPointsArrayCache(): void;
  20896. /** @hidden */ private _generatePointsArray(): boolean;
  20897. /**
  20898. * Gets a value indicating if the geometry is disposed
  20899. * @returns true if the geometry was disposed
  20900. */
  20901. isDisposed(): boolean;
  20902. private _disposeVertexArrayObjects;
  20903. /**
  20904. * Free all associated resources
  20905. */
  20906. dispose(): void;
  20907. /**
  20908. * Clone the current geometry into a new geometry
  20909. * @param id defines the unique ID of the new geometry
  20910. * @returns a new geometry object
  20911. */
  20912. copy(id: string): Geometry;
  20913. /**
  20914. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20915. * @return a JSON representation of the current geometry data (without the vertices data)
  20916. */
  20917. serialize(): any;
  20918. private toNumberArray;
  20919. /**
  20920. * Serialize all vertices data into a JSON oject
  20921. * @returns a JSON representation of the current geometry data
  20922. */
  20923. serializeVerticeData(): any;
  20924. /**
  20925. * Extracts a clone of a mesh geometry
  20926. * @param mesh defines the source mesh
  20927. * @param id defines the unique ID of the new geometry object
  20928. * @returns the new geometry object
  20929. */
  20930. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20931. /**
  20932. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20933. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20934. * Be aware Math.random() could cause collisions, but:
  20935. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  20936. * @returns a string containing a new GUID
  20937. */
  20938. static RandomId(): string;
  20939. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20940. private static _CleanMatricesWeights;
  20941. /**
  20942. * Create a new geometry from persisted data (Using .babylon file format)
  20943. * @param parsedVertexData defines the persisted data
  20944. * @param scene defines the hosting scene
  20945. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20946. * @returns the new geometry object
  20947. */
  20948. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20949. }
  20950. }
  20951. declare module BABYLON {
  20952. /**
  20953. * Define an interface for all classes that will get and set the data on vertices
  20954. */
  20955. export interface IGetSetVerticesData {
  20956. /**
  20957. * Gets a boolean indicating if specific vertex data is present
  20958. * @param kind defines the vertex data kind to use
  20959. * @returns true is data kind is present
  20960. */
  20961. isVerticesDataPresent(kind: string): boolean;
  20962. /**
  20963. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20964. * @param kind defines the data kind (Position, normal, etc...)
  20965. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20966. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20967. * @returns a float array containing vertex data
  20968. */
  20969. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20970. /**
  20971. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20972. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  20973. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20974. * @returns the indices array or an empty array if the mesh has no geometry
  20975. */
  20976. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20977. /**
  20978. * Set specific vertex data
  20979. * @param kind defines the data kind (Position, normal, etc...)
  20980. * @param data defines the vertex data to use
  20981. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20982. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20983. */
  20984. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20985. /**
  20986. * Update a specific associated vertex buffer
  20987. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20988. * - VertexBuffer.PositionKind
  20989. * - VertexBuffer.UVKind
  20990. * - VertexBuffer.UV2Kind
  20991. * - VertexBuffer.UV3Kind
  20992. * - VertexBuffer.UV4Kind
  20993. * - VertexBuffer.UV5Kind
  20994. * - VertexBuffer.UV6Kind
  20995. * - VertexBuffer.ColorKind
  20996. * - VertexBuffer.MatricesIndicesKind
  20997. * - VertexBuffer.MatricesIndicesExtraKind
  20998. * - VertexBuffer.MatricesWeightsKind
  20999. * - VertexBuffer.MatricesWeightsExtraKind
  21000. * @param data defines the data source
  21001. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21002. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21003. */
  21004. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21005. /**
  21006. * Creates a new index buffer
  21007. * @param indices defines the indices to store in the index buffer
  21008. * @param totalVertices defines the total number of vertices (could be null)
  21009. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21010. */
  21011. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21012. }
  21013. /**
  21014. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21015. */
  21016. export class VertexData {
  21017. /**
  21018. * Mesh side orientation : usually the external or front surface
  21019. */
  21020. static readonly FRONTSIDE: number;
  21021. /**
  21022. * Mesh side orientation : usually the internal or back surface
  21023. */
  21024. static readonly BACKSIDE: number;
  21025. /**
  21026. * Mesh side orientation : both internal and external or front and back surfaces
  21027. */
  21028. static readonly DOUBLESIDE: number;
  21029. /**
  21030. * Mesh side orientation : by default, `FRONTSIDE`
  21031. */
  21032. static readonly DEFAULTSIDE: number;
  21033. /**
  21034. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21035. */
  21036. positions: Nullable<FloatArray>;
  21037. /**
  21038. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21039. */
  21040. normals: Nullable<FloatArray>;
  21041. /**
  21042. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21043. */
  21044. tangents: Nullable<FloatArray>;
  21045. /**
  21046. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21047. */
  21048. uvs: Nullable<FloatArray>;
  21049. /**
  21050. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21051. */
  21052. uvs2: Nullable<FloatArray>;
  21053. /**
  21054. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21055. */
  21056. uvs3: Nullable<FloatArray>;
  21057. /**
  21058. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21059. */
  21060. uvs4: Nullable<FloatArray>;
  21061. /**
  21062. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21063. */
  21064. uvs5: Nullable<FloatArray>;
  21065. /**
  21066. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21067. */
  21068. uvs6: Nullable<FloatArray>;
  21069. /**
  21070. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21071. */
  21072. colors: Nullable<FloatArray>;
  21073. /**
  21074. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  21075. */
  21076. matricesIndices: Nullable<FloatArray>;
  21077. /**
  21078. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21079. */
  21080. matricesWeights: Nullable<FloatArray>;
  21081. /**
  21082. * An array extending the number of possible indices
  21083. */
  21084. matricesIndicesExtra: Nullable<FloatArray>;
  21085. /**
  21086. * An array extending the number of possible weights when the number of indices is extended
  21087. */
  21088. matricesWeightsExtra: Nullable<FloatArray>;
  21089. /**
  21090. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21091. */
  21092. indices: Nullable<IndicesArray>;
  21093. /**
  21094. * Uses the passed data array to set the set the values for the specified kind of data
  21095. * @param data a linear array of floating numbers
  21096. * @param kind the type of data that is being set, eg positions, colors etc
  21097. */
  21098. set(data: FloatArray, kind: string): void;
  21099. /**
  21100. * Associates the vertexData to the passed Mesh.
  21101. * Sets it as updatable or not (default `false`)
  21102. * @param mesh the mesh the vertexData is applied to
  21103. * @param updatable when used and having the value true allows new data to update the vertexData
  21104. * @returns the VertexData
  21105. */
  21106. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21107. /**
  21108. * Associates the vertexData to the passed Geometry.
  21109. * Sets it as updatable or not (default `false`)
  21110. * @param geometry the geometry the vertexData is applied to
  21111. * @param updatable when used and having the value true allows new data to update the vertexData
  21112. * @returns VertexData
  21113. */
  21114. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21115. /**
  21116. * Updates the associated mesh
  21117. * @param mesh the mesh to be updated
  21118. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21119. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21120. * @returns VertexData
  21121. */
  21122. updateMesh(mesh: Mesh): VertexData;
  21123. /**
  21124. * Updates the associated geometry
  21125. * @param geometry the geometry to be updated
  21126. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21127. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  21128. * @returns VertexData.
  21129. */
  21130. updateGeometry(geometry: Geometry): VertexData;
  21131. private _applyTo;
  21132. private _update;
  21133. /**
  21134. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21135. * @param matrix the transforming matrix
  21136. * @returns the VertexData
  21137. */
  21138. transform(matrix: Matrix): VertexData;
  21139. /**
  21140. * Merges the passed VertexData into the current one
  21141. * @param other the VertexData to be merged into the current one
  21142. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21143. * @returns the modified VertexData
  21144. */
  21145. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21146. private _mergeElement;
  21147. private _validate;
  21148. /**
  21149. * Serializes the VertexData
  21150. * @returns a serialized object
  21151. */
  21152. serialize(): any;
  21153. /**
  21154. * Extracts the vertexData from a mesh
  21155. * @param mesh the mesh from which to extract the VertexData
  21156. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21157. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21158. * @returns the object VertexData associated to the passed mesh
  21159. */
  21160. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21161. /**
  21162. * Extracts the vertexData from the geometry
  21163. * @param geometry the geometry from which to extract the VertexData
  21164. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21165. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21166. * @returns the object VertexData associated to the passed mesh
  21167. */
  21168. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21169. private static _ExtractFrom;
  21170. /**
  21171. * Creates the VertexData for a Ribbon
  21172. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21173. * * pathArray array of paths, each of which an array of successive Vector3
  21174. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21175. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21176. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  21177. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21178. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21179. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21180. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21181. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21182. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21183. * @returns the VertexData of the ribbon
  21184. */
  21185. static CreateRibbon(options: {
  21186. pathArray: Vector3[][];
  21187. closeArray?: boolean;
  21188. closePath?: boolean;
  21189. offset?: number;
  21190. sideOrientation?: number;
  21191. frontUVs?: Vector4;
  21192. backUVs?: Vector4;
  21193. invertUV?: boolean;
  21194. uvs?: Vector2[];
  21195. colors?: Color4[];
  21196. }): VertexData;
  21197. /**
  21198. * Creates the VertexData for a box
  21199. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21200. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21201. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21202. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21203. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21204. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21205. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21207. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21208. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21209. * @returns the VertexData of the box
  21210. */
  21211. static CreateBox(options: {
  21212. size?: number;
  21213. width?: number;
  21214. height?: number;
  21215. depth?: number;
  21216. faceUV?: Vector4[];
  21217. faceColors?: Color4[];
  21218. sideOrientation?: number;
  21219. frontUVs?: Vector4;
  21220. backUVs?: Vector4;
  21221. }): VertexData;
  21222. /**
  21223. * Creates the VertexData for a tiled box
  21224. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21225. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21226. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21227. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21228. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21229. * @returns the VertexData of the box
  21230. */
  21231. static CreateTiledBox(options: {
  21232. pattern?: number;
  21233. width?: number;
  21234. height?: number;
  21235. depth?: number;
  21236. tileSize?: number;
  21237. tileWidth?: number;
  21238. tileHeight?: number;
  21239. alignHorizontal?: number;
  21240. alignVertical?: number;
  21241. faceUV?: Vector4[];
  21242. faceColors?: Color4[];
  21243. sideOrientation?: number;
  21244. }): VertexData;
  21245. /**
  21246. * Creates the VertexData for a tiled plane
  21247. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21248. * * pattern a limited pattern arrangement depending on the number
  21249. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21250. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21251. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21252. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21253. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21254. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21255. * @returns the VertexData of the tiled plane
  21256. */
  21257. static CreateTiledPlane(options: {
  21258. pattern?: number;
  21259. tileSize?: number;
  21260. tileWidth?: number;
  21261. tileHeight?: number;
  21262. size?: number;
  21263. width?: number;
  21264. height?: number;
  21265. alignHorizontal?: number;
  21266. alignVertical?: number;
  21267. sideOrientation?: number;
  21268. frontUVs?: Vector4;
  21269. backUVs?: Vector4;
  21270. }): VertexData;
  21271. /**
  21272. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21273. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21274. * * segments sets the number of horizontal strips optional, default 32
  21275. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21276. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21277. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21278. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21279. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  21280. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  21281. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21282. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21283. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21284. * @returns the VertexData of the ellipsoid
  21285. */
  21286. static CreateSphere(options: {
  21287. segments?: number;
  21288. diameter?: number;
  21289. diameterX?: number;
  21290. diameterY?: number;
  21291. diameterZ?: number;
  21292. arc?: number;
  21293. slice?: number;
  21294. sideOrientation?: number;
  21295. frontUVs?: Vector4;
  21296. backUVs?: Vector4;
  21297. }): VertexData;
  21298. /**
  21299. * Creates the VertexData for a cylinder, cone or prism
  21300. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21301. * * height sets the height (y direction) of the cylinder, optional, default 2
  21302. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21303. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21304. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21305. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21306. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21307. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  21308. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21309. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21310. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21311. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21312. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21313. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21314. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21315. * @returns the VertexData of the cylinder, cone or prism
  21316. */
  21317. static CreateCylinder(options: {
  21318. height?: number;
  21319. diameterTop?: number;
  21320. diameterBottom?: number;
  21321. diameter?: number;
  21322. tessellation?: number;
  21323. subdivisions?: number;
  21324. arc?: number;
  21325. faceColors?: Color4[];
  21326. faceUV?: Vector4[];
  21327. hasRings?: boolean;
  21328. enclose?: boolean;
  21329. sideOrientation?: number;
  21330. frontUVs?: Vector4;
  21331. backUVs?: Vector4;
  21332. }): VertexData;
  21333. /**
  21334. * Creates the VertexData for a torus
  21335. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21336. * * diameter the diameter of the torus, optional default 1
  21337. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21338. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21339. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21340. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21341. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21342. * @returns the VertexData of the torus
  21343. */
  21344. static CreateTorus(options: {
  21345. diameter?: number;
  21346. thickness?: number;
  21347. tessellation?: number;
  21348. sideOrientation?: number;
  21349. frontUVs?: Vector4;
  21350. backUVs?: Vector4;
  21351. }): VertexData;
  21352. /**
  21353. * Creates the VertexData of the LineSystem
  21354. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21355. * - lines an array of lines, each line being an array of successive Vector3
  21356. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21357. * @returns the VertexData of the LineSystem
  21358. */
  21359. static CreateLineSystem(options: {
  21360. lines: Vector3[][];
  21361. colors?: Nullable<Color4[][]>;
  21362. }): VertexData;
  21363. /**
  21364. * Create the VertexData for a DashedLines
  21365. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21366. * - points an array successive Vector3
  21367. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21368. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21369. * - dashNb the intended total number of dashes, optional, default 200
  21370. * @returns the VertexData for the DashedLines
  21371. */
  21372. static CreateDashedLines(options: {
  21373. points: Vector3[];
  21374. dashSize?: number;
  21375. gapSize?: number;
  21376. dashNb?: number;
  21377. }): VertexData;
  21378. /**
  21379. * Creates the VertexData for a Ground
  21380. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21381. * - width the width (x direction) of the ground, optional, default 1
  21382. * - height the height (z direction) of the ground, optional, default 1
  21383. * - subdivisions the number of subdivisions per side, optional, default 1
  21384. * @returns the VertexData of the Ground
  21385. */
  21386. static CreateGround(options: {
  21387. width?: number;
  21388. height?: number;
  21389. subdivisions?: number;
  21390. subdivisionsX?: number;
  21391. subdivisionsY?: number;
  21392. }): VertexData;
  21393. /**
  21394. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21395. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21396. * * xmin the ground minimum X coordinate, optional, default -1
  21397. * * zmin the ground minimum Z coordinate, optional, default -1
  21398. * * xmax the ground maximum X coordinate, optional, default 1
  21399. * * zmax the ground maximum Z coordinate, optional, default 1
  21400. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  21401. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  21402. * @returns the VertexData of the TiledGround
  21403. */
  21404. static CreateTiledGround(options: {
  21405. xmin: number;
  21406. zmin: number;
  21407. xmax: number;
  21408. zmax: number;
  21409. subdivisions?: {
  21410. w: number;
  21411. h: number;
  21412. };
  21413. precision?: {
  21414. w: number;
  21415. h: number;
  21416. };
  21417. }): VertexData;
  21418. /**
  21419. * Creates the VertexData of the Ground designed from a heightmap
  21420. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21421. * * width the width (x direction) of the ground
  21422. * * height the height (z direction) of the ground
  21423. * * subdivisions the number of subdivisions per side
  21424. * * minHeight the minimum altitude on the ground, optional, default 0
  21425. * * maxHeight the maximum altitude on the ground, optional default 1
  21426. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21427. * * buffer the array holding the image color data
  21428. * * bufferWidth the width of image
  21429. * * bufferHeight the height of image
  21430. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21431. * @returns the VertexData of the Ground designed from a heightmap
  21432. */
  21433. static CreateGroundFromHeightMap(options: {
  21434. width: number;
  21435. height: number;
  21436. subdivisions: number;
  21437. minHeight: number;
  21438. maxHeight: number;
  21439. colorFilter: Color3;
  21440. buffer: Uint8Array;
  21441. bufferWidth: number;
  21442. bufferHeight: number;
  21443. alphaFilter: number;
  21444. }): VertexData;
  21445. /**
  21446. * Creates the VertexData for a Plane
  21447. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21448. * * size sets the width and height of the plane to the value of size, optional default 1
  21449. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21450. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21451. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21452. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21453. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21454. * @returns the VertexData of the box
  21455. */
  21456. static CreatePlane(options: {
  21457. size?: number;
  21458. width?: number;
  21459. height?: number;
  21460. sideOrientation?: number;
  21461. frontUVs?: Vector4;
  21462. backUVs?: Vector4;
  21463. }): VertexData;
  21464. /**
  21465. * Creates the VertexData of the Disc or regular Polygon
  21466. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21467. * * radius the radius of the disc, optional default 0.5
  21468. * * tessellation the number of polygon sides, optional, default 64
  21469. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  21470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21471. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21472. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21473. * @returns the VertexData of the box
  21474. */
  21475. static CreateDisc(options: {
  21476. radius?: number;
  21477. tessellation?: number;
  21478. arc?: number;
  21479. sideOrientation?: number;
  21480. frontUVs?: Vector4;
  21481. backUVs?: Vector4;
  21482. }): VertexData;
  21483. /**
  21484. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21485. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21486. * @param polygon a mesh built from polygonTriangulation.build()
  21487. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21488. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21489. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21490. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21491. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21492. * @returns the VertexData of the Polygon
  21493. */
  21494. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21495. /**
  21496. * Creates the VertexData of the IcoSphere
  21497. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21498. * * radius the radius of the IcoSphere, optional default 1
  21499. * * radiusX allows stretching in the x direction, optional, default radius
  21500. * * radiusY allows stretching in the y direction, optional, default radius
  21501. * * radiusZ allows stretching in the z direction, optional, default radius
  21502. * * flat when true creates a flat shaded mesh, optional, default true
  21503. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21504. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21505. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21506. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21507. * @returns the VertexData of the IcoSphere
  21508. */
  21509. static CreateIcoSphere(options: {
  21510. radius?: number;
  21511. radiusX?: number;
  21512. radiusY?: number;
  21513. radiusZ?: number;
  21514. flat?: boolean;
  21515. subdivisions?: number;
  21516. sideOrientation?: number;
  21517. frontUVs?: Vector4;
  21518. backUVs?: Vector4;
  21519. }): VertexData;
  21520. /**
  21521. * Creates the VertexData for a Polyhedron
  21522. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21523. * * type provided types are:
  21524. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21525. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  21526. * * size the size of the IcoSphere, optional default 1
  21527. * * sizeX allows stretching in the x direction, optional, default size
  21528. * * sizeY allows stretching in the y direction, optional, default size
  21529. * * sizeZ allows stretching in the z direction, optional, default size
  21530. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  21531. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21532. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21533. * * flat when true creates a flat shaded mesh, optional, default true
  21534. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21535. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21536. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21537. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21538. * @returns the VertexData of the Polyhedron
  21539. */
  21540. static CreatePolyhedron(options: {
  21541. type?: number;
  21542. size?: number;
  21543. sizeX?: number;
  21544. sizeY?: number;
  21545. sizeZ?: number;
  21546. custom?: any;
  21547. faceUV?: Vector4[];
  21548. faceColors?: Color4[];
  21549. flat?: boolean;
  21550. sideOrientation?: number;
  21551. frontUVs?: Vector4;
  21552. backUVs?: Vector4;
  21553. }): VertexData;
  21554. /**
  21555. * Creates the VertexData for a TorusKnot
  21556. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21557. * * radius the radius of the torus knot, optional, default 2
  21558. * * tube the thickness of the tube, optional, default 0.5
  21559. * * radialSegments the number of sides on each tube segments, optional, default 32
  21560. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21561. * * p the number of windings around the z axis, optional, default 2
  21562. * * q the number of windings around the x axis, optional, default 3
  21563. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21564. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  21565. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  21566. * @returns the VertexData of the Torus Knot
  21567. */
  21568. static CreateTorusKnot(options: {
  21569. radius?: number;
  21570. tube?: number;
  21571. radialSegments?: number;
  21572. tubularSegments?: number;
  21573. p?: number;
  21574. q?: number;
  21575. sideOrientation?: number;
  21576. frontUVs?: Vector4;
  21577. backUVs?: Vector4;
  21578. }): VertexData;
  21579. /**
  21580. * Compute normals for given positions and indices
  21581. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21582. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21583. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21584. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21585. * * facetNormals : optional array of facet normals (vector3)
  21586. * * facetPositions : optional array of facet positions (vector3)
  21587. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21588. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21589. * * bInfo : optional bounding info, required for facetPartitioning computation
  21590. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21591. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21592. * * useRightHandedSystem: optional boolean to for right handed system computation
  21593. * * depthSort : optional boolean to enable the facet depth sort computation
  21594. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21595. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21596. */
  21597. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21598. facetNormals?: any;
  21599. facetPositions?: any;
  21600. facetPartitioning?: any;
  21601. ratio?: number;
  21602. bInfo?: any;
  21603. bbSize?: Vector3;
  21604. subDiv?: any;
  21605. useRightHandedSystem?: boolean;
  21606. depthSort?: boolean;
  21607. distanceTo?: Vector3;
  21608. depthSortedFacets?: any;
  21609. }): void;
  21610. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21611. /**
  21612. * Applies VertexData created from the imported parameters to the geometry
  21613. * @param parsedVertexData the parsed data from an imported file
  21614. * @param geometry the geometry to apply the VertexData to
  21615. */
  21616. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21617. }
  21618. }
  21619. declare module BABYLON {
  21620. /**
  21621. * Defines a target to use with MorphTargetManager
  21622. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21623. */
  21624. export class MorphTarget implements IAnimatable {
  21625. /** defines the name of the target */
  21626. name: string;
  21627. /**
  21628. * Gets or sets the list of animations
  21629. */
  21630. animations: Animation[];
  21631. private _scene;
  21632. private _positions;
  21633. private _normals;
  21634. private _tangents;
  21635. private _uvs;
  21636. private _influence;
  21637. /**
  21638. * Observable raised when the influence changes
  21639. */
  21640. onInfluenceChanged: Observable<boolean>;
  21641. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21642. /**
  21643. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21644. */
  21645. influence: number;
  21646. /**
  21647. * Gets or sets the id of the morph Target
  21648. */
  21649. id: string;
  21650. private _animationPropertiesOverride;
  21651. /**
  21652. * Gets or sets the animation properties override
  21653. */
  21654. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21655. /**
  21656. * Creates a new MorphTarget
  21657. * @param name defines the name of the target
  21658. * @param influence defines the influence to use
  21659. * @param scene defines the scene the morphtarget belongs to
  21660. */
  21661. constructor(
  21662. /** defines the name of the target */
  21663. name: string, influence?: number, scene?: Nullable<Scene>);
  21664. /**
  21665. * Gets a boolean defining if the target contains position data
  21666. */
  21667. readonly hasPositions: boolean;
  21668. /**
  21669. * Gets a boolean defining if the target contains normal data
  21670. */
  21671. readonly hasNormals: boolean;
  21672. /**
  21673. * Gets a boolean defining if the target contains tangent data
  21674. */
  21675. readonly hasTangents: boolean;
  21676. /**
  21677. * Gets a boolean defining if the target contains texture coordinates data
  21678. */
  21679. readonly hasUVs: boolean;
  21680. /**
  21681. * Affects position data to this target
  21682. * @param data defines the position data to use
  21683. */
  21684. setPositions(data: Nullable<FloatArray>): void;
  21685. /**
  21686. * Gets the position data stored in this target
  21687. * @returns a FloatArray containing the position data (or null if not present)
  21688. */
  21689. getPositions(): Nullable<FloatArray>;
  21690. /**
  21691. * Affects normal data to this target
  21692. * @param data defines the normal data to use
  21693. */
  21694. setNormals(data: Nullable<FloatArray>): void;
  21695. /**
  21696. * Gets the normal data stored in this target
  21697. * @returns a FloatArray containing the normal data (or null if not present)
  21698. */
  21699. getNormals(): Nullable<FloatArray>;
  21700. /**
  21701. * Affects tangent data to this target
  21702. * @param data defines the tangent data to use
  21703. */
  21704. setTangents(data: Nullable<FloatArray>): void;
  21705. /**
  21706. * Gets the tangent data stored in this target
  21707. * @returns a FloatArray containing the tangent data (or null if not present)
  21708. */
  21709. getTangents(): Nullable<FloatArray>;
  21710. /**
  21711. * Affects texture coordinates data to this target
  21712. * @param data defines the texture coordinates data to use
  21713. */
  21714. setUVs(data: Nullable<FloatArray>): void;
  21715. /**
  21716. * Gets the texture coordinates data stored in this target
  21717. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21718. */
  21719. getUVs(): Nullable<FloatArray>;
  21720. /**
  21721. * Serializes the current target into a Serialization object
  21722. * @returns the serialized object
  21723. */
  21724. serialize(): any;
  21725. /**
  21726. * Returns the string "MorphTarget"
  21727. * @returns "MorphTarget"
  21728. */
  21729. getClassName(): string;
  21730. /**
  21731. * Creates a new target from serialized data
  21732. * @param serializationObject defines the serialized data to use
  21733. * @returns a new MorphTarget
  21734. */
  21735. static Parse(serializationObject: any): MorphTarget;
  21736. /**
  21737. * Creates a MorphTarget from mesh data
  21738. * @param mesh defines the source mesh
  21739. * @param name defines the name to use for the new target
  21740. * @param influence defines the influence to attach to the target
  21741. * @returns a new MorphTarget
  21742. */
  21743. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21744. }
  21745. }
  21746. declare module BABYLON {
  21747. /**
  21748. * This class is used to deform meshes using morphing between different targets
  21749. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21750. */
  21751. export class MorphTargetManager {
  21752. private _targets;
  21753. private _targetInfluenceChangedObservers;
  21754. private _targetDataLayoutChangedObservers;
  21755. private _activeTargets;
  21756. private _scene;
  21757. private _influences;
  21758. private _supportsNormals;
  21759. private _supportsTangents;
  21760. private _supportsUVs;
  21761. private _vertexCount;
  21762. private _uniqueId;
  21763. private _tempInfluences;
  21764. /**
  21765. * Gets or sets a boolean indicating if normals must be morphed
  21766. */
  21767. enableNormalMorphing: boolean;
  21768. /**
  21769. * Gets or sets a boolean indicating if tangents must be morphed
  21770. */
  21771. enableTangentMorphing: boolean;
  21772. /**
  21773. * Gets or sets a boolean indicating if UV must be morphed
  21774. */
  21775. enableUVMorphing: boolean;
  21776. /**
  21777. * Creates a new MorphTargetManager
  21778. * @param scene defines the current scene
  21779. */
  21780. constructor(scene?: Nullable<Scene>);
  21781. /**
  21782. * Gets the unique ID of this manager
  21783. */
  21784. readonly uniqueId: number;
  21785. /**
  21786. * Gets the number of vertices handled by this manager
  21787. */
  21788. readonly vertexCount: number;
  21789. /**
  21790. * Gets a boolean indicating if this manager supports morphing of normals
  21791. */
  21792. readonly supportsNormals: boolean;
  21793. /**
  21794. * Gets a boolean indicating if this manager supports morphing of tangents
  21795. */
  21796. readonly supportsTangents: boolean;
  21797. /**
  21798. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21799. */
  21800. readonly supportsUVs: boolean;
  21801. /**
  21802. * Gets the number of targets stored in this manager
  21803. */
  21804. readonly numTargets: number;
  21805. /**
  21806. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21807. */
  21808. readonly numInfluencers: number;
  21809. /**
  21810. * Gets the list of influences (one per target)
  21811. */
  21812. readonly influences: Float32Array;
  21813. /**
  21814. * Gets the active target at specified index. An active target is a target with an influence > 0
  21815. * @param index defines the index to check
  21816. * @returns the requested target
  21817. */
  21818. getActiveTarget(index: number): MorphTarget;
  21819. /**
  21820. * Gets the target at specified index
  21821. * @param index defines the index to check
  21822. * @returns the requested target
  21823. */
  21824. getTarget(index: number): MorphTarget;
  21825. /**
  21826. * Add a new target to this manager
  21827. * @param target defines the target to add
  21828. */
  21829. addTarget(target: MorphTarget): void;
  21830. /**
  21831. * Removes a target from the manager
  21832. * @param target defines the target to remove
  21833. */
  21834. removeTarget(target: MorphTarget): void;
  21835. /**
  21836. * Serializes the current manager into a Serialization object
  21837. * @returns the serialized object
  21838. */
  21839. serialize(): any;
  21840. private _syncActiveTargets;
  21841. /**
  21842. * Syncrhonize the targets with all the meshes using this morph target manager
  21843. */
  21844. synchronize(): void;
  21845. /**
  21846. * Creates a new MorphTargetManager from serialized data
  21847. * @param serializationObject defines the serialized data
  21848. * @param scene defines the hosting scene
  21849. * @returns the new MorphTargetManager
  21850. */
  21851. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21852. }
  21853. }
  21854. declare module BABYLON {
  21855. /**
  21856. * Class used to represent a specific level of detail of a mesh
  21857. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21858. */
  21859. export class MeshLODLevel {
  21860. /** Defines the distance where this level should start being displayed */
  21861. distance: number;
  21862. /** Defines the mesh to use to render this level */
  21863. mesh: Nullable<Mesh>;
  21864. /**
  21865. * Creates a new LOD level
  21866. * @param distance defines the distance where this level should star being displayed
  21867. * @param mesh defines the mesh to use to render this level
  21868. */
  21869. constructor(
  21870. /** Defines the distance where this level should start being displayed */
  21871. distance: number,
  21872. /** Defines the mesh to use to render this level */
  21873. mesh: Nullable<Mesh>);
  21874. }
  21875. }
  21876. declare module BABYLON {
  21877. /**
  21878. * Mesh representing the gorund
  21879. */
  21880. export class GroundMesh extends Mesh {
  21881. /** If octree should be generated */
  21882. generateOctree: boolean;
  21883. private _heightQuads;
  21884. /** @hidden */ private _subdivisionsX: number;
  21885. /** @hidden */ private _subdivisionsY: number;
  21886. /** @hidden */ private _width: number;
  21887. /** @hidden */ private _height: number;
  21888. /** @hidden */ private _minX: number;
  21889. /** @hidden */ private _maxX: number;
  21890. /** @hidden */ private _minZ: number;
  21891. /** @hidden */ private _maxZ: number;
  21892. constructor(name: string, scene: Scene);
  21893. /**
  21894. * "GroundMesh"
  21895. * @returns "GroundMesh"
  21896. */
  21897. getClassName(): string;
  21898. /**
  21899. * The minimum of x and y subdivisions
  21900. */
  21901. readonly subdivisions: number;
  21902. /**
  21903. * X subdivisions
  21904. */
  21905. readonly subdivisionsX: number;
  21906. /**
  21907. * Y subdivisions
  21908. */
  21909. readonly subdivisionsY: number;
  21910. /**
  21911. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  21912. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21913. * @param chunksCount the number of subdivisions for x and y
  21914. * @param octreeBlocksSize (Default: 32)
  21915. */
  21916. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21917. /**
  21918. * Returns a height (y) value in the Worl system :
  21919. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21920. * @param x x coordinate
  21921. * @param z z coordinate
  21922. * @returns the ground y position if (x, z) are outside the ground surface.
  21923. */
  21924. getHeightAtCoordinates(x: number, z: number): number;
  21925. /**
  21926. * Returns a normalized vector (Vector3) orthogonal to the ground
  21927. * at the ground coordinates (x, z) expressed in the World system.
  21928. * @param x x coordinate
  21929. * @param z z coordinate
  21930. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21931. */
  21932. getNormalAtCoordinates(x: number, z: number): Vector3;
  21933. /**
  21934. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21935. * at the ground coordinates (x, z) expressed in the World system.
  21936. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21937. * @param x x coordinate
  21938. * @param z z coordinate
  21939. * @param ref vector to store the result
  21940. * @returns the GroundMesh.
  21941. */
  21942. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21943. /**
  21944. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21945. * if the ground has been updated.
  21946. * This can be used in the render loop.
  21947. * @returns the GroundMesh.
  21948. */
  21949. updateCoordinateHeights(): GroundMesh;
  21950. private _getFacetAt;
  21951. private _initHeightQuads;
  21952. private _computeHeightQuads;
  21953. /**
  21954. * Serializes this ground mesh
  21955. * @param serializationObject object to write serialization to
  21956. */
  21957. serialize(serializationObject: any): void;
  21958. /**
  21959. * Parses a serialized ground mesh
  21960. * @param parsedMesh the serialized mesh
  21961. * @param scene the scene to create the ground mesh in
  21962. * @returns the created ground mesh
  21963. */
  21964. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21965. }
  21966. }
  21967. declare module BABYLON {
  21968. /**
  21969. * Interface for Physics-Joint data
  21970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21971. */
  21972. export interface PhysicsJointData {
  21973. /**
  21974. * The main pivot of the joint
  21975. */
  21976. mainPivot?: Vector3;
  21977. /**
  21978. * The connected pivot of the joint
  21979. */
  21980. connectedPivot?: Vector3;
  21981. /**
  21982. * The main axis of the joint
  21983. */
  21984. mainAxis?: Vector3;
  21985. /**
  21986. * The connected axis of the joint
  21987. */
  21988. connectedAxis?: Vector3;
  21989. /**
  21990. * The collision of the joint
  21991. */
  21992. collision?: boolean;
  21993. /**
  21994. * Native Oimo/Cannon/Energy data
  21995. */
  21996. nativeParams?: any;
  21997. }
  21998. /**
  21999. * This is a holder class for the physics joint created by the physics plugin
  22000. * It holds a set of functions to control the underlying joint
  22001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22002. */
  22003. export class PhysicsJoint {
  22004. /**
  22005. * The type of the physics joint
  22006. */
  22007. type: number;
  22008. /**
  22009. * The data for the physics joint
  22010. */
  22011. jointData: PhysicsJointData;
  22012. private _physicsJoint;
  22013. protected _physicsPlugin: IPhysicsEnginePlugin;
  22014. /**
  22015. * Initializes the physics joint
  22016. * @param type The type of the physics joint
  22017. * @param jointData The data for the physics joint
  22018. */
  22019. constructor(
  22020. /**
  22021. * The type of the physics joint
  22022. */
  22023. type: number,
  22024. /**
  22025. * The data for the physics joint
  22026. */
  22027. jointData: PhysicsJointData);
  22028. /**
  22029. * Gets the physics joint
  22030. */
  22031. /**
  22032. * Sets the physics joint
  22033. */
  22034. physicsJoint: any;
  22035. /**
  22036. * Sets the physics plugin
  22037. */
  22038. physicsPlugin: IPhysicsEnginePlugin;
  22039. /**
  22040. * Execute a function that is physics-plugin specific.
  22041. * @param {Function} func the function that will be executed.
  22042. * It accepts two parameters: the physics world and the physics joint
  22043. */
  22044. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22045. /**
  22046. * Distance-Joint type
  22047. */
  22048. static DistanceJoint: number;
  22049. /**
  22050. * Hinge-Joint type
  22051. */
  22052. static HingeJoint: number;
  22053. /**
  22054. * Ball-and-Socket joint type
  22055. */
  22056. static BallAndSocketJoint: number;
  22057. /**
  22058. * Wheel-Joint type
  22059. */
  22060. static WheelJoint: number;
  22061. /**
  22062. * Slider-Joint type
  22063. */
  22064. static SliderJoint: number;
  22065. /**
  22066. * Prismatic-Joint type
  22067. */
  22068. static PrismaticJoint: number;
  22069. /**
  22070. * Universal-Joint type
  22071. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22072. */
  22073. static UniversalJoint: number;
  22074. /**
  22075. * Hinge-Joint 2 type
  22076. */
  22077. static Hinge2Joint: number;
  22078. /**
  22079. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22080. */
  22081. static PointToPointJoint: number;
  22082. /**
  22083. * Spring-Joint type
  22084. */
  22085. static SpringJoint: number;
  22086. /**
  22087. * Lock-Joint type
  22088. */
  22089. static LockJoint: number;
  22090. }
  22091. /**
  22092. * A class representing a physics distance joint
  22093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22094. */
  22095. export class DistanceJoint extends PhysicsJoint {
  22096. /**
  22097. *
  22098. * @param jointData The data for the Distance-Joint
  22099. */
  22100. constructor(jointData: DistanceJointData);
  22101. /**
  22102. * Update the predefined distance.
  22103. * @param maxDistance The maximum preferred distance
  22104. * @param minDistance The minimum preferred distance
  22105. */
  22106. updateDistance(maxDistance: number, minDistance?: number): void;
  22107. }
  22108. /**
  22109. * Represents a Motor-Enabled Joint
  22110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22111. */
  22112. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22113. /**
  22114. * Initializes the Motor-Enabled Joint
  22115. * @param type The type of the joint
  22116. * @param jointData The physica joint data for the joint
  22117. */
  22118. constructor(type: number, jointData: PhysicsJointData);
  22119. /**
  22120. * Set the motor values.
  22121. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22122. * @param force the force to apply
  22123. * @param maxForce max force for this motor.
  22124. */
  22125. setMotor(force?: number, maxForce?: number): void;
  22126. /**
  22127. * Set the motor's limits.
  22128. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22129. * @param upperLimit The upper limit of the motor
  22130. * @param lowerLimit The lower limit of the motor
  22131. */
  22132. setLimit(upperLimit: number, lowerLimit?: number): void;
  22133. }
  22134. /**
  22135. * This class represents a single physics Hinge-Joint
  22136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22137. */
  22138. export class HingeJoint extends MotorEnabledJoint {
  22139. /**
  22140. * Initializes the Hinge-Joint
  22141. * @param jointData The joint data for the Hinge-Joint
  22142. */
  22143. constructor(jointData: PhysicsJointData);
  22144. /**
  22145. * Set the motor values.
  22146. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22147. * @param {number} force the force to apply
  22148. * @param {number} maxForce max force for this motor.
  22149. */
  22150. setMotor(force?: number, maxForce?: number): void;
  22151. /**
  22152. * Set the motor's limits.
  22153. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22154. * @param upperLimit The upper limit of the motor
  22155. * @param lowerLimit The lower limit of the motor
  22156. */
  22157. setLimit(upperLimit: number, lowerLimit?: number): void;
  22158. }
  22159. /**
  22160. * This class represents a dual hinge physics joint (same as wheel joint)
  22161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22162. */
  22163. export class Hinge2Joint extends MotorEnabledJoint {
  22164. /**
  22165. * Initializes the Hinge2-Joint
  22166. * @param jointData The joint data for the Hinge2-Joint
  22167. */
  22168. constructor(jointData: PhysicsJointData);
  22169. /**
  22170. * Set the motor values.
  22171. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22172. * @param {number} targetSpeed the speed the motor is to reach
  22173. * @param {number} maxForce max force for this motor.
  22174. * @param {motorIndex} the motor's index, 0 or 1.
  22175. */
  22176. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22177. /**
  22178. * Set the motor limits.
  22179. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22180. * @param {number} upperLimit the upper limit
  22181. * @param {number} lowerLimit lower limit
  22182. * @param {motorIndex} the motor's index, 0 or 1.
  22183. */
  22184. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22185. }
  22186. /**
  22187. * Interface for a motor enabled joint
  22188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22189. */
  22190. export interface IMotorEnabledJoint {
  22191. /**
  22192. * Physics joint
  22193. */
  22194. physicsJoint: any;
  22195. /**
  22196. * Sets the motor of the motor-enabled joint
  22197. * @param force The force of the motor
  22198. * @param maxForce The maximum force of the motor
  22199. * @param motorIndex The index of the motor
  22200. */
  22201. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22202. /**
  22203. * Sets the limit of the motor
  22204. * @param upperLimit The upper limit of the motor
  22205. * @param lowerLimit The lower limit of the motor
  22206. * @param motorIndex The index of the motor
  22207. */
  22208. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22209. }
  22210. /**
  22211. * Joint data for a Distance-Joint
  22212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22213. */
  22214. export interface DistanceJointData extends PhysicsJointData {
  22215. /**
  22216. * Max distance the 2 joint objects can be apart
  22217. */
  22218. maxDistance: number;
  22219. }
  22220. /**
  22221. * Joint data from a spring joint
  22222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22223. */
  22224. export interface SpringJointData extends PhysicsJointData {
  22225. /**
  22226. * Length of the spring
  22227. */
  22228. length: number;
  22229. /**
  22230. * Stiffness of the spring
  22231. */
  22232. stiffness: number;
  22233. /**
  22234. * Damping of the spring
  22235. */
  22236. damping: number;
  22237. /** this callback will be called when applying the force to the impostors. */
  22238. forceApplicationCallback: () => void;
  22239. }
  22240. }
  22241. declare module BABYLON {
  22242. /**
  22243. * Holds the data for the raycast result
  22244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22245. */
  22246. export class PhysicsRaycastResult {
  22247. private _hasHit;
  22248. private _hitDistance;
  22249. private _hitNormalWorld;
  22250. private _hitPointWorld;
  22251. private _rayFromWorld;
  22252. private _rayToWorld;
  22253. /**
  22254. * Gets if there was a hit
  22255. */
  22256. readonly hasHit: boolean;
  22257. /**
  22258. * Gets the distance from the hit
  22259. */
  22260. readonly hitDistance: number;
  22261. /**
  22262. * Gets the hit normal/direction in the world
  22263. */
  22264. readonly hitNormalWorld: Vector3;
  22265. /**
  22266. * Gets the hit point in the world
  22267. */
  22268. readonly hitPointWorld: Vector3;
  22269. /**
  22270. * Gets the ray "start point" of the ray in the world
  22271. */
  22272. readonly rayFromWorld: Vector3;
  22273. /**
  22274. * Gets the ray "end point" of the ray in the world
  22275. */
  22276. readonly rayToWorld: Vector3;
  22277. /**
  22278. * Sets the hit data (normal & point in world space)
  22279. * @param hitNormalWorld defines the normal in world space
  22280. * @param hitPointWorld defines the point in world space
  22281. */
  22282. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22283. /**
  22284. * Sets the distance from the start point to the hit point
  22285. * @param distance
  22286. */
  22287. setHitDistance(distance: number): void;
  22288. /**
  22289. * Calculates the distance manually
  22290. */
  22291. calculateHitDistance(): void;
  22292. /**
  22293. * Resets all the values to default
  22294. * @param from The from point on world space
  22295. * @param to The to point on world space
  22296. */
  22297. reset(from?: Vector3, to?: Vector3): void;
  22298. }
  22299. /**
  22300. * Interface for the size containing width and height
  22301. */
  22302. interface IXYZ {
  22303. /**
  22304. * X
  22305. */
  22306. x: number;
  22307. /**
  22308. * Y
  22309. */
  22310. y: number;
  22311. /**
  22312. * Z
  22313. */
  22314. z: number;
  22315. }
  22316. }
  22317. declare module BABYLON {
  22318. /**
  22319. * Interface used to describe a physics joint
  22320. */
  22321. export interface PhysicsImpostorJoint {
  22322. /** Defines the main impostor to which the joint is linked */
  22323. mainImpostor: PhysicsImpostor;
  22324. /** Defines the impostor that is connected to the main impostor using this joint */
  22325. connectedImpostor: PhysicsImpostor;
  22326. /** Defines the joint itself */
  22327. joint: PhysicsJoint;
  22328. }
  22329. /** @hidden */
  22330. export interface IPhysicsEnginePlugin {
  22331. world: any;
  22332. name: string;
  22333. setGravity(gravity: Vector3): void;
  22334. setTimeStep(timeStep: number): void;
  22335. getTimeStep(): number;
  22336. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22337. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22338. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22339. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22340. removePhysicsBody(impostor: PhysicsImpostor): void;
  22341. generateJoint(joint: PhysicsImpostorJoint): void;
  22342. removeJoint(joint: PhysicsImpostorJoint): void;
  22343. isSupported(): boolean;
  22344. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22345. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22346. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22347. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22348. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22349. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22350. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22351. getBodyMass(impostor: PhysicsImpostor): number;
  22352. getBodyFriction(impostor: PhysicsImpostor): number;
  22353. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22354. getBodyRestitution(impostor: PhysicsImpostor): number;
  22355. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22356. getBodyPressure?(impostor: PhysicsImpostor): number;
  22357. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22358. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22359. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22360. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22361. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22362. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22363. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22364. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22365. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22366. sleepBody(impostor: PhysicsImpostor): void;
  22367. wakeUpBody(impostor: PhysicsImpostor): void;
  22368. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22369. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22370. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22371. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22372. getRadius(impostor: PhysicsImpostor): number;
  22373. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22374. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22375. dispose(): void;
  22376. }
  22377. /**
  22378. * Interface used to define a physics engine
  22379. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22380. */
  22381. export interface IPhysicsEngine {
  22382. /**
  22383. * Gets the gravity vector used by the simulation
  22384. */
  22385. gravity: Vector3;
  22386. /**
  22387. * Sets the gravity vector used by the simulation
  22388. * @param gravity defines the gravity vector to use
  22389. */
  22390. setGravity(gravity: Vector3): void;
  22391. /**
  22392. * Set the time step of the physics engine.
  22393. * Default is 1/60.
  22394. * To slow it down, enter 1/600 for example.
  22395. * To speed it up, 1/30
  22396. * @param newTimeStep the new timestep to apply to this world.
  22397. */
  22398. setTimeStep(newTimeStep: number): void;
  22399. /**
  22400. * Get the time step of the physics engine.
  22401. * @returns the current time step
  22402. */
  22403. getTimeStep(): number;
  22404. /**
  22405. * Release all resources
  22406. */
  22407. dispose(): void;
  22408. /**
  22409. * Gets the name of the current physics plugin
  22410. * @returns the name of the plugin
  22411. */
  22412. getPhysicsPluginName(): string;
  22413. /**
  22414. * Adding a new impostor for the impostor tracking.
  22415. * This will be done by the impostor itself.
  22416. * @param impostor the impostor to add
  22417. */
  22418. addImpostor(impostor: PhysicsImpostor): void;
  22419. /**
  22420. * Remove an impostor from the engine.
  22421. * This impostor and its mesh will not longer be updated by the physics engine.
  22422. * @param impostor the impostor to remove
  22423. */
  22424. removeImpostor(impostor: PhysicsImpostor): void;
  22425. /**
  22426. * Add a joint to the physics engine
  22427. * @param mainImpostor defines the main impostor to which the joint is added.
  22428. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22429. * @param joint defines the joint that will connect both impostors.
  22430. */
  22431. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22432. /**
  22433. * Removes a joint from the simulation
  22434. * @param mainImpostor defines the impostor used with the joint
  22435. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22436. * @param joint defines the joint to remove
  22437. */
  22438. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22439. /**
  22440. * Gets the current plugin used to run the simulation
  22441. * @returns current plugin
  22442. */
  22443. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22444. /**
  22445. * Gets the list of physic impostors
  22446. * @returns an array of PhysicsImpostor
  22447. */
  22448. getImpostors(): Array<PhysicsImpostor>;
  22449. /**
  22450. * Gets the impostor for a physics enabled object
  22451. * @param object defines the object impersonated by the impostor
  22452. * @returns the PhysicsImpostor or null if not found
  22453. */
  22454. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22455. /**
  22456. * Gets the impostor for a physics body object
  22457. * @param body defines physics body used by the impostor
  22458. * @returns the PhysicsImpostor or null if not found
  22459. */
  22460. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22461. /**
  22462. * Does a raycast in the physics world
  22463. * @param from when should the ray start?
  22464. * @param to when should the ray end?
  22465. * @returns PhysicsRaycastResult
  22466. */
  22467. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22468. /**
  22469. * Called by the scene. No need to call it.
  22470. * @param delta defines the timespam between frames
  22471. */ private _step(delta: number): void;
  22472. }
  22473. }
  22474. declare module BABYLON {
  22475. /**
  22476. * The interface for the physics imposter parameters
  22477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22478. */
  22479. export interface PhysicsImpostorParameters {
  22480. /**
  22481. * The mass of the physics imposter
  22482. */
  22483. mass: number;
  22484. /**
  22485. * The friction of the physics imposter
  22486. */
  22487. friction?: number;
  22488. /**
  22489. * The coefficient of restitution of the physics imposter
  22490. */
  22491. restitution?: number;
  22492. /**
  22493. * The native options of the physics imposter
  22494. */
  22495. nativeOptions?: any;
  22496. /**
  22497. * Specifies if the parent should be ignored
  22498. */
  22499. ignoreParent?: boolean;
  22500. /**
  22501. * Specifies if bi-directional transformations should be disabled
  22502. */
  22503. disableBidirectionalTransformation?: boolean;
  22504. /**
  22505. * The pressure inside the physics imposter, soft object only
  22506. */
  22507. pressure?: number;
  22508. /**
  22509. * The stiffness the physics imposter, soft object only
  22510. */
  22511. stiffness?: number;
  22512. /**
  22513. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22514. */
  22515. velocityIterations?: number;
  22516. /**
  22517. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22518. */
  22519. positionIterations?: number;
  22520. /**
  22521. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22522. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22523. * Add to fix multiple points
  22524. */
  22525. fixedPoints?: number;
  22526. /**
  22527. * The collision margin around a soft object
  22528. */
  22529. margin?: number;
  22530. /**
  22531. * The collision margin around a soft object
  22532. */
  22533. damping?: number;
  22534. /**
  22535. * The path for a rope based on an extrusion
  22536. */
  22537. path?: any;
  22538. /**
  22539. * The shape of an extrusion used for a rope based on an extrusion
  22540. */
  22541. shape?: any;
  22542. }
  22543. /**
  22544. * Interface for a physics-enabled object
  22545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22546. */
  22547. export interface IPhysicsEnabledObject {
  22548. /**
  22549. * The position of the physics-enabled object
  22550. */
  22551. position: Vector3;
  22552. /**
  22553. * The rotation of the physics-enabled object
  22554. */
  22555. rotationQuaternion: Nullable<Quaternion>;
  22556. /**
  22557. * The scale of the physics-enabled object
  22558. */
  22559. scaling: Vector3;
  22560. /**
  22561. * The rotation of the physics-enabled object
  22562. */
  22563. rotation?: Vector3;
  22564. /**
  22565. * The parent of the physics-enabled object
  22566. */
  22567. parent?: any;
  22568. /**
  22569. * The bounding info of the physics-enabled object
  22570. * @returns The bounding info of the physics-enabled object
  22571. */
  22572. getBoundingInfo(): BoundingInfo;
  22573. /**
  22574. * Computes the world matrix
  22575. * @param force Specifies if the world matrix should be computed by force
  22576. * @returns A world matrix
  22577. */
  22578. computeWorldMatrix(force: boolean): Matrix;
  22579. /**
  22580. * Gets the world matrix
  22581. * @returns A world matrix
  22582. */
  22583. getWorldMatrix?(): Matrix;
  22584. /**
  22585. * Gets the child meshes
  22586. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22587. * @returns An array of abstract meshes
  22588. */
  22589. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22590. /**
  22591. * Gets the vertex data
  22592. * @param kind The type of vertex data
  22593. * @returns A nullable array of numbers, or a float32 array
  22594. */
  22595. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22596. /**
  22597. * Gets the indices from the mesh
  22598. * @returns A nullable array of index arrays
  22599. */
  22600. getIndices?(): Nullable<IndicesArray>;
  22601. /**
  22602. * Gets the scene from the mesh
  22603. * @returns the indices array or null
  22604. */
  22605. getScene?(): Scene;
  22606. /**
  22607. * Gets the absolute position from the mesh
  22608. * @returns the absolute position
  22609. */
  22610. getAbsolutePosition(): Vector3;
  22611. /**
  22612. * Gets the absolute pivot point from the mesh
  22613. * @returns the absolute pivot point
  22614. */
  22615. getAbsolutePivotPoint(): Vector3;
  22616. /**
  22617. * Rotates the mesh
  22618. * @param axis The axis of rotation
  22619. * @param amount The amount of rotation
  22620. * @param space The space of the rotation
  22621. * @returns The rotation transform node
  22622. */
  22623. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22624. /**
  22625. * Translates the mesh
  22626. * @param axis The axis of translation
  22627. * @param distance The distance of translation
  22628. * @param space The space of the translation
  22629. * @returns The transform node
  22630. */
  22631. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22632. /**
  22633. * Sets the absolute position of the mesh
  22634. * @param absolutePosition The absolute position of the mesh
  22635. * @returns The transform node
  22636. */
  22637. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22638. /**
  22639. * Gets the class name of the mesh
  22640. * @returns The class name
  22641. */
  22642. getClassName(): string;
  22643. }
  22644. /**
  22645. * Represents a physics imposter
  22646. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22647. */
  22648. export class PhysicsImpostor {
  22649. /**
  22650. * The physics-enabled object used as the physics imposter
  22651. */
  22652. object: IPhysicsEnabledObject;
  22653. /**
  22654. * The type of the physics imposter
  22655. */
  22656. type: number;
  22657. private _options;
  22658. private _scene?;
  22659. /**
  22660. * The default object size of the imposter
  22661. */
  22662. static DEFAULT_OBJECT_SIZE: Vector3;
  22663. /**
  22664. * The identity quaternion of the imposter
  22665. */
  22666. static IDENTITY_QUATERNION: Quaternion;
  22667. /** @hidden */ private _pluginData: any;
  22668. private _physicsEngine;
  22669. private _physicsBody;
  22670. private _bodyUpdateRequired;
  22671. private _onBeforePhysicsStepCallbacks;
  22672. private _onAfterPhysicsStepCallbacks;
  22673. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22674. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22675. otherImpostors: Array<PhysicsImpostor>;
  22676. }>;
  22677. private _deltaPosition;
  22678. private _deltaRotation;
  22679. private _deltaRotationConjugated;
  22680. /** @hidden */ private _isFromLine: boolean;
  22681. private _parent;
  22682. private _isDisposed;
  22683. private static _tmpVecs;
  22684. private static _tmpQuat;
  22685. /**
  22686. * Specifies if the physics imposter is disposed
  22687. */
  22688. readonly isDisposed: boolean;
  22689. /**
  22690. * Gets the mass of the physics imposter
  22691. */
  22692. mass: number;
  22693. /**
  22694. * Gets the coefficient of friction
  22695. */
  22696. /**
  22697. * Sets the coefficient of friction
  22698. */
  22699. friction: number;
  22700. /**
  22701. * Gets the coefficient of restitution
  22702. */
  22703. /**
  22704. * Sets the coefficient of restitution
  22705. */
  22706. restitution: number;
  22707. /**
  22708. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22709. */
  22710. /**
  22711. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22712. */
  22713. pressure: number;
  22714. /**
  22715. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22716. */
  22717. /**
  22718. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22719. */
  22720. stiffness: number;
  22721. /**
  22722. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22723. */
  22724. /**
  22725. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22726. */
  22727. velocityIterations: number;
  22728. /**
  22729. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22730. */
  22731. /**
  22732. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22733. */
  22734. positionIterations: number;
  22735. /**
  22736. * The unique id of the physics imposter
  22737. * set by the physics engine when adding this impostor to the array
  22738. */
  22739. uniqueId: number;
  22740. /**
  22741. * @hidden
  22742. */
  22743. soft: boolean;
  22744. /**
  22745. * @hidden
  22746. */
  22747. segments: number;
  22748. private _joints;
  22749. /**
  22750. * Initializes the physics imposter
  22751. * @param object The physics-enabled object used as the physics imposter
  22752. * @param type The type of the physics imposter
  22753. * @param _options The options for the physics imposter
  22754. * @param _scene The Babylon scene
  22755. */
  22756. constructor(
  22757. /**
  22758. * The physics-enabled object used as the physics imposter
  22759. */
  22760. object: IPhysicsEnabledObject,
  22761. /**
  22762. * The type of the physics imposter
  22763. */
  22764. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22765. /**
  22766. * This function will completly initialize this impostor.
  22767. * It will create a new body - but only if this mesh has no parent.
  22768. * If it has, this impostor will not be used other than to define the impostor
  22769. * of the child mesh.
  22770. * @hidden
  22771. */ private _init(): void;
  22772. private _getPhysicsParent;
  22773. /**
  22774. * Should a new body be generated.
  22775. * @returns boolean specifying if body initialization is required
  22776. */
  22777. isBodyInitRequired(): boolean;
  22778. /**
  22779. * Sets the updated scaling
  22780. * @param updated Specifies if the scaling is updated
  22781. */
  22782. setScalingUpdated(): void;
  22783. /**
  22784. * Force a regeneration of this or the parent's impostor's body.
  22785. * Use under cautious - This will remove all joints already implemented.
  22786. */
  22787. forceUpdate(): void;
  22788. /**
  22789. * Gets the body that holds this impostor. Either its own, or its parent.
  22790. */
  22791. /**
  22792. * Set the physics body. Used mainly by the physics engine/plugin
  22793. */
  22794. physicsBody: any;
  22795. /**
  22796. * Get the parent of the physics imposter
  22797. * @returns Physics imposter or null
  22798. */
  22799. /**
  22800. * Sets the parent of the physics imposter
  22801. */
  22802. parent: Nullable<PhysicsImpostor>;
  22803. /**
  22804. * Resets the update flags
  22805. */
  22806. resetUpdateFlags(): void;
  22807. /**
  22808. * Gets the object extend size
  22809. * @returns the object extend size
  22810. */
  22811. getObjectExtendSize(): Vector3;
  22812. /**
  22813. * Gets the object center
  22814. * @returns The object center
  22815. */
  22816. getObjectCenter(): Vector3;
  22817. /**
  22818. * Get a specific parametes from the options parameter
  22819. * @param paramName The object parameter name
  22820. * @returns The object parameter
  22821. */
  22822. getParam(paramName: string): any;
  22823. /**
  22824. * Sets a specific parameter in the options given to the physics plugin
  22825. * @param paramName The parameter name
  22826. * @param value The value of the parameter
  22827. */
  22828. setParam(paramName: string, value: number): void;
  22829. /**
  22830. * Specifically change the body's mass option. Won't recreate the physics body object
  22831. * @param mass The mass of the physics imposter
  22832. */
  22833. setMass(mass: number): void;
  22834. /**
  22835. * Gets the linear velocity
  22836. * @returns linear velocity or null
  22837. */
  22838. getLinearVelocity(): Nullable<Vector3>;
  22839. /**
  22840. * Sets the linear velocity
  22841. * @param velocity linear velocity or null
  22842. */
  22843. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22844. /**
  22845. * Gets the angular velocity
  22846. * @returns angular velocity or null
  22847. */
  22848. getAngularVelocity(): Nullable<Vector3>;
  22849. /**
  22850. * Sets the angular velocity
  22851. * @param velocity The velocity or null
  22852. */
  22853. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22854. /**
  22855. * Execute a function with the physics plugin native code
  22856. * Provide a function the will have two variables - the world object and the physics body object
  22857. * @param func The function to execute with the physics plugin native code
  22858. */
  22859. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22860. /**
  22861. * Register a function that will be executed before the physics world is stepping forward
  22862. * @param func The function to execute before the physics world is stepped forward
  22863. */
  22864. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22865. /**
  22866. * Unregister a function that will be executed before the physics world is stepping forward
  22867. * @param func The function to execute before the physics world is stepped forward
  22868. */
  22869. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22870. /**
  22871. * Register a function that will be executed after the physics step
  22872. * @param func The function to execute after physics step
  22873. */
  22874. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22875. /**
  22876. * Unregisters a function that will be executed after the physics step
  22877. * @param func The function to execute after physics step
  22878. */
  22879. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22880. /**
  22881. * register a function that will be executed when this impostor collides against a different body
  22882. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22883. * @param func Callback that is executed on collision
  22884. */
  22885. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22886. /**
  22887. * Unregisters the physics imposter on contact
  22888. * @param collideAgainst The physics object to collide against
  22889. * @param func Callback to execute on collision
  22890. */
  22891. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22892. private _tmpQuat;
  22893. private _tmpQuat2;
  22894. /**
  22895. * Get the parent rotation
  22896. * @returns The parent rotation
  22897. */
  22898. getParentsRotation(): Quaternion;
  22899. /**
  22900. * this function is executed by the physics engine.
  22901. */
  22902. beforeStep: () => void;
  22903. /**
  22904. * this function is executed by the physics engine
  22905. */
  22906. afterStep: () => void;
  22907. /**
  22908. * Legacy collision detection event support
  22909. */
  22910. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22911. /**
  22912. * event and body object due to cannon's event-based architecture.
  22913. */
  22914. onCollide: (e: {
  22915. body: any;
  22916. }) => void;
  22917. /**
  22918. * Apply a force
  22919. * @param force The force to apply
  22920. * @param contactPoint The contact point for the force
  22921. * @returns The physics imposter
  22922. */
  22923. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22924. /**
  22925. * Apply an impulse
  22926. * @param force The impulse force
  22927. * @param contactPoint The contact point for the impulse force
  22928. * @returns The physics imposter
  22929. */
  22930. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22931. /**
  22932. * A help function to create a joint
  22933. * @param otherImpostor A physics imposter used to create a joint
  22934. * @param jointType The type of joint
  22935. * @param jointData The data for the joint
  22936. * @returns The physics imposter
  22937. */
  22938. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  22939. /**
  22940. * Add a joint to this impostor with a different impostor
  22941. * @param otherImpostor A physics imposter used to add a joint
  22942. * @param joint The joint to add
  22943. * @returns The physics imposter
  22944. */
  22945. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  22946. /**
  22947. * Add an anchor to a cloth impostor
  22948. * @param otherImpostor rigid impostor to anchor to
  22949. * @param width ratio across width from 0 to 1
  22950. * @param height ratio up height from 0 to 1
  22951. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  22952. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  22953. * @returns impostor the soft imposter
  22954. */
  22955. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22956. /**
  22957. * Add a hook to a rope impostor
  22958. * @param otherImpostor rigid impostor to anchor to
  22959. * @param length ratio across rope from 0 to 1
  22960. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  22961. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  22962. * @returns impostor the rope imposter
  22963. */
  22964. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22965. /**
  22966. * Will keep this body still, in a sleep mode.
  22967. * @returns the physics imposter
  22968. */
  22969. sleep(): PhysicsImpostor;
  22970. /**
  22971. * Wake the body up.
  22972. * @returns The physics imposter
  22973. */
  22974. wakeUp(): PhysicsImpostor;
  22975. /**
  22976. * Clones the physics imposter
  22977. * @param newObject The physics imposter clones to this physics-enabled object
  22978. * @returns A nullable physics imposter
  22979. */
  22980. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22981. /**
  22982. * Disposes the physics imposter
  22983. */
  22984. dispose(): void;
  22985. /**
  22986. * Sets the delta position
  22987. * @param position The delta position amount
  22988. */
  22989. setDeltaPosition(position: Vector3): void;
  22990. /**
  22991. * Sets the delta rotation
  22992. * @param rotation The delta rotation amount
  22993. */
  22994. setDeltaRotation(rotation: Quaternion): void;
  22995. /**
  22996. * Gets the box size of the physics imposter and stores the result in the input parameter
  22997. * @param result Stores the box size
  22998. * @returns The physics imposter
  22999. */
  23000. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23001. /**
  23002. * Gets the radius of the physics imposter
  23003. * @returns Radius of the physics imposter
  23004. */
  23005. getRadius(): number;
  23006. /**
  23007. * Sync a bone with this impostor
  23008. * @param bone The bone to sync to the impostor.
  23009. * @param boneMesh The mesh that the bone is influencing.
  23010. * @param jointPivot The pivot of the joint / bone in local space.
  23011. * @param distToJoint Optional distance from the impostor to the joint.
  23012. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23013. */
  23014. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23015. /**
  23016. * Sync impostor to a bone
  23017. * @param bone The bone that the impostor will be synced to.
  23018. * @param boneMesh The mesh that the bone is influencing.
  23019. * @param jointPivot The pivot of the joint / bone in local space.
  23020. * @param distToJoint Optional distance from the impostor to the joint.
  23021. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23022. * @param boneAxis Optional vector3 axis the bone is aligned with
  23023. */
  23024. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23025. /**
  23026. * No-Imposter type
  23027. */
  23028. static NoImpostor: number;
  23029. /**
  23030. * Sphere-Imposter type
  23031. */
  23032. static SphereImpostor: number;
  23033. /**
  23034. * Box-Imposter type
  23035. */
  23036. static BoxImpostor: number;
  23037. /**
  23038. * Plane-Imposter type
  23039. */
  23040. static PlaneImpostor: number;
  23041. /**
  23042. * Mesh-imposter type
  23043. */
  23044. static MeshImpostor: number;
  23045. /**
  23046. * Capsule-Impostor type (Ammo.js plugin only)
  23047. */
  23048. static CapsuleImpostor: number;
  23049. /**
  23050. * Cylinder-Imposter type
  23051. */
  23052. static CylinderImpostor: number;
  23053. /**
  23054. * Particle-Imposter type
  23055. */
  23056. static ParticleImpostor: number;
  23057. /**
  23058. * Heightmap-Imposter type
  23059. */
  23060. static HeightmapImpostor: number;
  23061. /**
  23062. * ConvexHull-Impostor type (Ammo.js plugin only)
  23063. */
  23064. static ConvexHullImpostor: number;
  23065. /**
  23066. * Rope-Imposter type
  23067. */
  23068. static RopeImpostor: number;
  23069. /**
  23070. * Cloth-Imposter type
  23071. */
  23072. static ClothImpostor: number;
  23073. /**
  23074. * Softbody-Imposter type
  23075. */
  23076. static SoftbodyImpostor: number;
  23077. }
  23078. }
  23079. declare module BABYLON {
  23080. /**
  23081. * @hidden
  23082. **/
  23083. export class _CreationDataStorage {
  23084. closePath?: boolean;
  23085. closeArray?: boolean;
  23086. idx: number[];
  23087. dashSize: number;
  23088. gapSize: number;
  23089. path3D: Path3D;
  23090. pathArray: Vector3[][];
  23091. arc: number;
  23092. radius: number;
  23093. cap: number;
  23094. tessellation: number;
  23095. }
  23096. /**
  23097. * @hidden
  23098. **/ private class _InstanceDataStorage {
  23099. visibleInstances: any;
  23100. batchCache: _InstancesBatch;
  23101. instancesBufferSize: number;
  23102. instancesBuffer: Nullable<Buffer>;
  23103. instancesData: Float32Array;
  23104. overridenInstanceCount: number;
  23105. isFrozen: boolean;
  23106. previousBatch: Nullable<_InstancesBatch>;
  23107. hardwareInstancedRendering: boolean;
  23108. sideOrientation: number;
  23109. }
  23110. /**
  23111. * @hidden
  23112. **/
  23113. export class _InstancesBatch {
  23114. mustReturn: boolean;
  23115. visibleInstances: Nullable<InstancedMesh[]>[];
  23116. renderSelf: boolean[];
  23117. hardwareInstancedRendering: boolean[];
  23118. }
  23119. /**
  23120. * Class used to represent renderable models
  23121. */
  23122. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23123. /**
  23124. * Mesh side orientation : usually the external or front surface
  23125. */
  23126. static readonly FRONTSIDE: number;
  23127. /**
  23128. * Mesh side orientation : usually the internal or back surface
  23129. */
  23130. static readonly BACKSIDE: number;
  23131. /**
  23132. * Mesh side orientation : both internal and external or front and back surfaces
  23133. */
  23134. static readonly DOUBLESIDE: number;
  23135. /**
  23136. * Mesh side orientation : by default, `FRONTSIDE`
  23137. */
  23138. static readonly DEFAULTSIDE: number;
  23139. /**
  23140. * Mesh cap setting : no cap
  23141. */
  23142. static readonly NO_CAP: number;
  23143. /**
  23144. * Mesh cap setting : one cap at the beginning of the mesh
  23145. */
  23146. static readonly CAP_START: number;
  23147. /**
  23148. * Mesh cap setting : one cap at the end of the mesh
  23149. */
  23150. static readonly CAP_END: number;
  23151. /**
  23152. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23153. */
  23154. static readonly CAP_ALL: number;
  23155. /**
  23156. * Mesh pattern setting : no flip or rotate
  23157. */
  23158. static readonly NO_FLIP: number;
  23159. /**
  23160. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23161. */
  23162. static readonly FLIP_TILE: number;
  23163. /**
  23164. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23165. */
  23166. static readonly ROTATE_TILE: number;
  23167. /**
  23168. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23169. */
  23170. static readonly FLIP_ROW: number;
  23171. /**
  23172. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23173. */
  23174. static readonly ROTATE_ROW: number;
  23175. /**
  23176. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23177. */
  23178. static readonly FLIP_N_ROTATE_TILE: number;
  23179. /**
  23180. * Mesh pattern setting : rotate pattern and rotate
  23181. */
  23182. static readonly FLIP_N_ROTATE_ROW: number;
  23183. /**
  23184. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23185. */
  23186. static readonly CENTER: number;
  23187. /**
  23188. * Mesh tile positioning : part tiles on left
  23189. */
  23190. static readonly LEFT: number;
  23191. /**
  23192. * Mesh tile positioning : part tiles on right
  23193. */
  23194. static readonly RIGHT: number;
  23195. /**
  23196. * Mesh tile positioning : part tiles on top
  23197. */
  23198. static readonly TOP: number;
  23199. /**
  23200. * Mesh tile positioning : part tiles on bottom
  23201. */
  23202. static readonly BOTTOM: number;
  23203. /**
  23204. * Gets the default side orientation.
  23205. * @param orientation the orientation to value to attempt to get
  23206. * @returns the default orientation
  23207. * @hidden
  23208. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23209. private _internalMeshDataInfo;
  23210. /**
  23211. * An event triggered before rendering the mesh
  23212. */
  23213. readonly onBeforeRenderObservable: Observable<Mesh>;
  23214. /**
  23215. * An event triggered before binding the mesh
  23216. */
  23217. readonly onBeforeBindObservable: Observable<Mesh>;
  23218. /**
  23219. * An event triggered after rendering the mesh
  23220. */
  23221. readonly onAfterRenderObservable: Observable<Mesh>;
  23222. /**
  23223. * An event triggered before drawing the mesh
  23224. */
  23225. readonly onBeforeDrawObservable: Observable<Mesh>;
  23226. private _onBeforeDrawObserver;
  23227. /**
  23228. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23229. */
  23230. onBeforeDraw: () => void;
  23231. readonly hasInstances: boolean;
  23232. /**
  23233. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23234. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23235. */
  23236. delayLoadState: number;
  23237. /**
  23238. * Gets the list of instances created from this mesh
  23239. * it is not supposed to be modified manually.
  23240. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23241. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23242. */
  23243. instances: InstancedMesh[];
  23244. /**
  23245. * Gets the file containing delay loading data for this mesh
  23246. */
  23247. delayLoadingFile: string;
  23248. /** @hidden */ private _binaryInfo: any;
  23249. /**
  23250. * User defined function used to change how LOD level selection is done
  23251. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23252. */
  23253. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23254. /**
  23255. * Gets or sets the morph target manager
  23256. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23257. */
  23258. morphTargetManager: Nullable<MorphTargetManager>;
  23259. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23260. /** @hidden */ private _geometry: Nullable<Geometry>;
  23261. /** @hidden */ private _delayInfo: Array<string>;
  23262. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23263. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23264. private _effectiveMaterial;
  23265. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23266. /** @hidden */ private _originalBuilderSideOrientation: number;
  23267. /**
  23268. * Use this property to change the original side orientation defined at construction time
  23269. */
  23270. overrideMaterialSideOrientation: Nullable<number>;
  23271. /**
  23272. * Gets the source mesh (the one used to clone this one from)
  23273. */
  23274. readonly source: Nullable<Mesh>;
  23275. /**
  23276. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23277. */
  23278. isUnIndexed: boolean;
  23279. /**
  23280. * @constructor
  23281. * @param name The value used by scene.getMeshByName() to do a lookup.
  23282. * @param scene The scene to add this mesh to.
  23283. * @param parent The parent of this mesh, if it has one
  23284. * @param source An optional Mesh from which geometry is shared, cloned.
  23285. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23286. * When false, achieved by calling a clone(), also passing False.
  23287. * This will make creation of children, recursive.
  23288. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23289. */
  23290. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23291. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  23292. /**
  23293. * Gets the class name
  23294. * @returns the string "Mesh".
  23295. */
  23296. getClassName(): string;
  23297. /** @hidden */ protected readonly _isMesh: boolean;
  23298. /**
  23299. * Returns a description of this mesh
  23300. * @param fullDetails define if full details about this mesh must be used
  23301. * @returns a descriptive string representing this mesh
  23302. */
  23303. toString(fullDetails?: boolean): string;
  23304. /** @hidden */ private _unBindEffect(): void;
  23305. /**
  23306. * Gets a boolean indicating if this mesh has LOD
  23307. */
  23308. readonly hasLODLevels: boolean;
  23309. /**
  23310. * Gets the list of MeshLODLevel associated with the current mesh
  23311. * @returns an array of MeshLODLevel
  23312. */
  23313. getLODLevels(): MeshLODLevel[];
  23314. private _sortLODLevels;
  23315. /**
  23316. * Add a mesh as LOD level triggered at the given distance.
  23317. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23318. * @param distance The distance from the center of the object to show this level
  23319. * @param mesh The mesh to be added as LOD level (can be null)
  23320. * @return This mesh (for chaining)
  23321. */
  23322. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23323. /**
  23324. * Returns the LOD level mesh at the passed distance or null if not found.
  23325. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23326. * @param distance The distance from the center of the object to show this level
  23327. * @returns a Mesh or `null`
  23328. */
  23329. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23330. /**
  23331. * Remove a mesh from the LOD array
  23332. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23333. * @param mesh defines the mesh to be removed
  23334. * @return This mesh (for chaining)
  23335. */
  23336. removeLODLevel(mesh: Mesh): Mesh;
  23337. /**
  23338. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23339. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23340. * @param camera defines the camera to use to compute distance
  23341. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23342. * @return This mesh (for chaining)
  23343. */
  23344. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23345. /**
  23346. * Gets the mesh internal Geometry object
  23347. */
  23348. readonly geometry: Nullable<Geometry>;
  23349. /**
  23350. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23351. * @returns the total number of vertices
  23352. */
  23353. getTotalVertices(): number;
  23354. /**
  23355. * Returns the content of an associated vertex buffer
  23356. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23357. * - VertexBuffer.PositionKind
  23358. * - VertexBuffer.UVKind
  23359. * - VertexBuffer.UV2Kind
  23360. * - VertexBuffer.UV3Kind
  23361. * - VertexBuffer.UV4Kind
  23362. * - VertexBuffer.UV5Kind
  23363. * - VertexBuffer.UV6Kind
  23364. * - VertexBuffer.ColorKind
  23365. * - VertexBuffer.MatricesIndicesKind
  23366. * - VertexBuffer.MatricesIndicesExtraKind
  23367. * - VertexBuffer.MatricesWeightsKind
  23368. * - VertexBuffer.MatricesWeightsExtraKind
  23369. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  23370. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23371. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23372. */
  23373. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23374. /**
  23375. * Returns the mesh VertexBuffer object from the requested `kind`
  23376. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23377. * - VertexBuffer.PositionKind
  23378. * - VertexBuffer.NormalKind
  23379. * - VertexBuffer.UVKind
  23380. * - VertexBuffer.UV2Kind
  23381. * - VertexBuffer.UV3Kind
  23382. * - VertexBuffer.UV4Kind
  23383. * - VertexBuffer.UV5Kind
  23384. * - VertexBuffer.UV6Kind
  23385. * - VertexBuffer.ColorKind
  23386. * - VertexBuffer.MatricesIndicesKind
  23387. * - VertexBuffer.MatricesIndicesExtraKind
  23388. * - VertexBuffer.MatricesWeightsKind
  23389. * - VertexBuffer.MatricesWeightsExtraKind
  23390. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23391. */
  23392. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23393. /**
  23394. * Tests if a specific vertex buffer is associated with this mesh
  23395. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23396. * - VertexBuffer.PositionKind
  23397. * - VertexBuffer.NormalKind
  23398. * - VertexBuffer.UVKind
  23399. * - VertexBuffer.UV2Kind
  23400. * - VertexBuffer.UV3Kind
  23401. * - VertexBuffer.UV4Kind
  23402. * - VertexBuffer.UV5Kind
  23403. * - VertexBuffer.UV6Kind
  23404. * - VertexBuffer.ColorKind
  23405. * - VertexBuffer.MatricesIndicesKind
  23406. * - VertexBuffer.MatricesIndicesExtraKind
  23407. * - VertexBuffer.MatricesWeightsKind
  23408. * - VertexBuffer.MatricesWeightsExtraKind
  23409. * @returns a boolean
  23410. */
  23411. isVerticesDataPresent(kind: string): boolean;
  23412. /**
  23413. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23414. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23415. * - VertexBuffer.PositionKind
  23416. * - VertexBuffer.UVKind
  23417. * - VertexBuffer.UV2Kind
  23418. * - VertexBuffer.UV3Kind
  23419. * - VertexBuffer.UV4Kind
  23420. * - VertexBuffer.UV5Kind
  23421. * - VertexBuffer.UV6Kind
  23422. * - VertexBuffer.ColorKind
  23423. * - VertexBuffer.MatricesIndicesKind
  23424. * - VertexBuffer.MatricesIndicesExtraKind
  23425. * - VertexBuffer.MatricesWeightsKind
  23426. * - VertexBuffer.MatricesWeightsExtraKind
  23427. * @returns a boolean
  23428. */
  23429. isVertexBufferUpdatable(kind: string): boolean;
  23430. /**
  23431. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23432. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23433. * - VertexBuffer.PositionKind
  23434. * - VertexBuffer.NormalKind
  23435. * - VertexBuffer.UVKind
  23436. * - VertexBuffer.UV2Kind
  23437. * - VertexBuffer.UV3Kind
  23438. * - VertexBuffer.UV4Kind
  23439. * - VertexBuffer.UV5Kind
  23440. * - VertexBuffer.UV6Kind
  23441. * - VertexBuffer.ColorKind
  23442. * - VertexBuffer.MatricesIndicesKind
  23443. * - VertexBuffer.MatricesIndicesExtraKind
  23444. * - VertexBuffer.MatricesWeightsKind
  23445. * - VertexBuffer.MatricesWeightsExtraKind
  23446. * @returns an array of strings
  23447. */
  23448. getVerticesDataKinds(): string[];
  23449. /**
  23450. * Returns a positive integer : the total number of indices in this mesh geometry.
  23451. * @returns the numner of indices or zero if the mesh has no geometry.
  23452. */
  23453. getTotalIndices(): number;
  23454. /**
  23455. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23456. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  23457. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23458. * @returns the indices array or an empty array if the mesh has no geometry
  23459. */
  23460. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23461. readonly isBlocked: boolean;
  23462. /**
  23463. * Determine if the current mesh is ready to be rendered
  23464. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23465. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23466. * @returns true if all associated assets are ready (material, textures, shaders)
  23467. */
  23468. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23469. /**
  23470. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  23471. */
  23472. readonly areNormalsFrozen: boolean;
  23473. /**
  23474. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  23475. * @returns the current mesh
  23476. */
  23477. freezeNormals(): Mesh;
  23478. /**
  23479. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  23480. * @returns the current mesh
  23481. */
  23482. unfreezeNormals(): Mesh;
  23483. /**
  23484. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23485. */
  23486. overridenInstanceCount: number;
  23487. /** @hidden */ private _preActivate(): Mesh;
  23488. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23489. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23490. /**
  23491. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23492. * This means the mesh underlying bounding box and sphere are recomputed.
  23493. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23494. * @returns the current mesh
  23495. */
  23496. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23497. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23498. /**
  23499. * This function will subdivide the mesh into multiple submeshes
  23500. * @param count defines the expected number of submeshes
  23501. */
  23502. subdivide(count: number): void;
  23503. /**
  23504. * Copy a FloatArray into a specific associated vertex buffer
  23505. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23506. * - VertexBuffer.PositionKind
  23507. * - VertexBuffer.UVKind
  23508. * - VertexBuffer.UV2Kind
  23509. * - VertexBuffer.UV3Kind
  23510. * - VertexBuffer.UV4Kind
  23511. * - VertexBuffer.UV5Kind
  23512. * - VertexBuffer.UV6Kind
  23513. * - VertexBuffer.ColorKind
  23514. * - VertexBuffer.MatricesIndicesKind
  23515. * - VertexBuffer.MatricesIndicesExtraKind
  23516. * - VertexBuffer.MatricesWeightsKind
  23517. * - VertexBuffer.MatricesWeightsExtraKind
  23518. * @param data defines the data source
  23519. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23520. * @param stride defines the data stride size (can be null)
  23521. * @returns the current mesh
  23522. */
  23523. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23524. /**
  23525. * Flags an associated vertex buffer as updatable
  23526. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23527. * - VertexBuffer.PositionKind
  23528. * - VertexBuffer.UVKind
  23529. * - VertexBuffer.UV2Kind
  23530. * - VertexBuffer.UV3Kind
  23531. * - VertexBuffer.UV4Kind
  23532. * - VertexBuffer.UV5Kind
  23533. * - VertexBuffer.UV6Kind
  23534. * - VertexBuffer.ColorKind
  23535. * - VertexBuffer.MatricesIndicesKind
  23536. * - VertexBuffer.MatricesIndicesExtraKind
  23537. * - VertexBuffer.MatricesWeightsKind
  23538. * - VertexBuffer.MatricesWeightsExtraKind
  23539. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23540. */
  23541. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23542. /**
  23543. * Sets the mesh global Vertex Buffer
  23544. * @param buffer defines the buffer to use
  23545. * @returns the current mesh
  23546. */
  23547. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23548. /**
  23549. * Update a specific associated vertex buffer
  23550. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23551. * - VertexBuffer.PositionKind
  23552. * - VertexBuffer.UVKind
  23553. * - VertexBuffer.UV2Kind
  23554. * - VertexBuffer.UV3Kind
  23555. * - VertexBuffer.UV4Kind
  23556. * - VertexBuffer.UV5Kind
  23557. * - VertexBuffer.UV6Kind
  23558. * - VertexBuffer.ColorKind
  23559. * - VertexBuffer.MatricesIndicesKind
  23560. * - VertexBuffer.MatricesIndicesExtraKind
  23561. * - VertexBuffer.MatricesWeightsKind
  23562. * - VertexBuffer.MatricesWeightsExtraKind
  23563. * @param data defines the data source
  23564. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23565. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  23566. * @returns the current mesh
  23567. */
  23568. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23569. /**
  23570. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23571. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23572. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23573. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23574. * @returns the current mesh
  23575. */
  23576. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23577. /**
  23578. * Creates a un-shared specific occurence of the geometry for the mesh.
  23579. * @returns the current mesh
  23580. */
  23581. makeGeometryUnique(): Mesh;
  23582. /**
  23583. * Set the index buffer of this mesh
  23584. * @param indices defines the source data
  23585. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23586. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23587. * @returns the current mesh
  23588. */
  23589. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  23590. /**
  23591. * Update the current index buffer
  23592. * @param indices defines the source data
  23593. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23594. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  23595. * @returns the current mesh
  23596. */
  23597. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  23598. /**
  23599. * Invert the geometry to move from a right handed system to a left handed one.
  23600. * @returns the current mesh
  23601. */
  23602. toLeftHanded(): Mesh;
  23603. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23604. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23605. /**
  23606. * Registers for this mesh a javascript function called just before the rendering process
  23607. * @param func defines the function to call before rendering this mesh
  23608. * @returns the current mesh
  23609. */
  23610. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23611. /**
  23612. * Disposes a previously registered javascript function called before the rendering
  23613. * @param func defines the function to remove
  23614. * @returns the current mesh
  23615. */
  23616. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23617. /**
  23618. * Registers for this mesh a javascript function called just after the rendering is complete
  23619. * @param func defines the function to call after rendering this mesh
  23620. * @returns the current mesh
  23621. */
  23622. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23623. /**
  23624. * Disposes a previously registered javascript function called after the rendering.
  23625. * @param func defines the function to remove
  23626. * @returns the current mesh
  23627. */
  23628. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23629. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23630. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23631. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23632. /** @hidden */ private _rebuild(): void;
  23633. /** @hidden */ private _freeze(): void;
  23634. /** @hidden */ private _unFreeze(): void;
  23635. /**
  23636. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  23637. * @param subMesh defines the subMesh to render
  23638. * @param enableAlphaMode defines if alpha mode can be changed
  23639. * @returns the current mesh
  23640. */
  23641. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23642. private _onBeforeDraw;
  23643. /**
  23644. * Renormalize the mesh and patch it up if there are no weights
  23645. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23646. * However in the case of zero weights then we set just a single influence to 1.
  23647. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23648. */
  23649. cleanMatrixWeights(): void;
  23650. private normalizeSkinFourWeights;
  23651. private normalizeSkinWeightsAndExtra;
  23652. /**
  23653. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23654. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23655. * the user know there was an issue with importing the mesh
  23656. * @returns a validation object with skinned, valid and report string
  23657. */
  23658. validateSkinning(): {
  23659. skinned: boolean;
  23660. valid: boolean;
  23661. report: string;
  23662. };
  23663. /** @hidden */ private _checkDelayState(): Mesh;
  23664. private _queueLoad;
  23665. /**
  23666. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23667. * A mesh is in the frustum if its bounding box intersects the frustum
  23668. * @param frustumPlanes defines the frustum to test
  23669. * @returns true if the mesh is in the frustum planes
  23670. */
  23671. isInFrustum(frustumPlanes: Plane[]): boolean;
  23672. /**
  23673. * Sets the mesh material by the material or multiMaterial `id` property
  23674. * @param id is a string identifying the material or the multiMaterial
  23675. * @returns the current mesh
  23676. */
  23677. setMaterialByID(id: string): Mesh;
  23678. /**
  23679. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23680. * @returns an array of IAnimatable
  23681. */
  23682. getAnimatables(): IAnimatable[];
  23683. /**
  23684. * Modifies the mesh geometry according to the passed transformation matrix.
  23685. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23686. * The mesh normals are modified using the same transformation.
  23687. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23688. * @param transform defines the transform matrix to use
  23689. * @see http://doc.babylonjs.com/resources/baking_transformations
  23690. * @returns the current mesh
  23691. */
  23692. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23693. /**
  23694. * Modifies the mesh geometry according to its own current World Matrix.
  23695. * The mesh World Matrix is then reset.
  23696. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23697. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23698. * @see http://doc.babylonjs.com/resources/baking_transformations
  23699. * @returns the current mesh
  23700. */
  23701. bakeCurrentTransformIntoVertices(): Mesh;
  23702. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23703. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23704. /** @hidden */ private _generatePointsArray(): boolean;
  23705. /**
  23706. * Returns a new Mesh object generated from the current mesh properties.
  23707. * This method must not get confused with createInstance()
  23708. * @param name is a string, the name given to the new mesh
  23709. * @param newParent can be any Node object (default `null`)
  23710. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23711. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23712. * @returns a new mesh
  23713. */
  23714. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  23715. /**
  23716. * Releases resources associated with this mesh.
  23717. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23718. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23719. */
  23720. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23721. /**
  23722. * Modifies the mesh geometry according to a displacement map.
  23723. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  23724. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23725. * @param url is a string, the URL from the image file is to be downloaded.
  23726. * @param minHeight is the lower limit of the displacement.
  23727. * @param maxHeight is the upper limit of the displacement.
  23728. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  23729. * @param uvOffset is an optional vector2 used to offset UV.
  23730. * @param uvScale is an optional vector2 used to scale UV.
  23731. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  23732. * @returns the Mesh.
  23733. */
  23734. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23735. /**
  23736. * Modifies the mesh geometry according to a displacementMap buffer.
  23737. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  23738. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23739. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23740. * @param heightMapWidth is the width of the buffer image.
  23741. * @param heightMapHeight is the height of the buffer image.
  23742. * @param minHeight is the lower limit of the displacement.
  23743. * @param maxHeight is the upper limit of the displacement.
  23744. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  23745. * @param uvOffset is an optional vector2 used to offset UV.
  23746. * @param uvScale is an optional vector2 used to scale UV.
  23747. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  23748. * @returns the Mesh.
  23749. */
  23750. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23751. /**
  23752. * Modify the mesh to get a flat shading rendering.
  23753. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23754. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23755. * @returns current mesh
  23756. */
  23757. convertToFlatShadedMesh(): Mesh;
  23758. /**
  23759. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23760. * In other words, more vertices, no more indices and a single bigger VBO.
  23761. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23762. * @returns current mesh
  23763. */
  23764. convertToUnIndexedMesh(): Mesh;
  23765. /**
  23766. * Inverses facet orientations.
  23767. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23768. * @param flipNormals will also inverts the normals
  23769. * @returns current mesh
  23770. */
  23771. flipFaces(flipNormals?: boolean): Mesh;
  23772. /**
  23773. * Increase the number of facets and hence vertices in a mesh
  23774. * Vertex normals are interpolated from existing vertex normals
  23775. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23776. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23777. */
  23778. increaseVertices(numberPerEdge: number): void;
  23779. /**
  23780. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23781. * This will undo any application of covertToFlatShadedMesh
  23782. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23783. */
  23784. forceSharedVertices(): void;
  23785. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23786. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23787. /**
  23788. * Creates a new InstancedMesh object from the mesh model.
  23789. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23790. * @param name defines the name of the new instance
  23791. * @returns a new InstancedMesh
  23792. */
  23793. createInstance(name: string): InstancedMesh;
  23794. /**
  23795. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23796. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23797. * @returns the current mesh
  23798. */
  23799. synchronizeInstances(): Mesh;
  23800. /**
  23801. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23802. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23803. * This should be used together with the simplification to avoid disappearing triangles.
  23804. * @param successCallback an optional success callback to be called after the optimization finished.
  23805. * @returns the current mesh
  23806. */
  23807. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23808. /**
  23809. * Serialize current mesh
  23810. * @param serializationObject defines the object which will receive the serialization data
  23811. */
  23812. serialize(serializationObject: any): void;
  23813. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23814. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23815. /**
  23816. * Returns a new Mesh object parsed from the source provided.
  23817. * @param parsedMesh is the source
  23818. * @param scene defines the hosting scene
  23819. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23820. * @returns a new Mesh
  23821. */
  23822. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23823. /**
  23824. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23825. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23826. * @param name defines the name of the mesh to create
  23827. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23828. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23829. * @param closePath creates a seam between the first and the last points of each path of the path array
  23830. * @param offset is taken in account only if the `pathArray` is containing a single path
  23831. * @param scene defines the hosting scene
  23832. * @param updatable defines if the mesh must be flagged as updatable
  23833. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23834. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  23835. * @returns a new Mesh
  23836. */
  23837. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23838. /**
  23839. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23840. * @param name defines the name of the mesh to create
  23841. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23842. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  23843. * @param scene defines the hosting scene
  23844. * @param updatable defines if the mesh must be flagged as updatable
  23845. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23846. * @returns a new Mesh
  23847. */
  23848. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23849. /**
  23850. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23851. * @param name defines the name of the mesh to create
  23852. * @param size sets the size (float) of each box side (default 1)
  23853. * @param scene defines the hosting scene
  23854. * @param updatable defines if the mesh must be flagged as updatable
  23855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23856. * @returns a new Mesh
  23857. */
  23858. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23859. /**
  23860. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23861. * @param name defines the name of the mesh to create
  23862. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23863. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23864. * @param scene defines the hosting scene
  23865. * @param updatable defines if the mesh must be flagged as updatable
  23866. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23867. * @returns a new Mesh
  23868. */
  23869. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23870. /**
  23871. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  23872. * @param name defines the name of the mesh to create
  23873. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23874. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23875. * @param scene defines the hosting scene
  23876. * @returns a new Mesh
  23877. */
  23878. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  23879. /**
  23880. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  23881. * @param name defines the name of the mesh to create
  23882. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  23883. * @param diameterTop set the top cap diameter (floats, default 1)
  23884. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  23885. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  23886. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  23887. * @param scene defines the hosting scene
  23888. * @param updatable defines if the mesh must be flagged as updatable
  23889. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23890. * @returns a new Mesh
  23891. */
  23892. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  23893. /**
  23894. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  23895. * @param name defines the name of the mesh to create
  23896. * @param diameter sets the diameter size (float) of the torus (default 1)
  23897. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  23898. * @param tessellation sets the number of torus sides (postive integer, default 16)
  23899. * @param scene defines the hosting scene
  23900. * @param updatable defines if the mesh must be flagged as updatable
  23901. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23902. * @returns a new Mesh
  23903. */
  23904. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23905. /**
  23906. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  23907. * @param name defines the name of the mesh to create
  23908. * @param radius sets the global radius size (float) of the torus knot (default 2)
  23909. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  23910. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  23911. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  23912. * @param p the number of windings on X axis (positive integers, default 2)
  23913. * @param q the number of windings on Y axis (positive integers, default 3)
  23914. * @param scene defines the hosting scene
  23915. * @param updatable defines if the mesh must be flagged as updatable
  23916. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23917. * @returns a new Mesh
  23918. */
  23919. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23920. /**
  23921. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  23922. * @param name defines the name of the mesh to create
  23923. * @param points is an array successive Vector3
  23924. * @param scene defines the hosting scene
  23925. * @param updatable defines if the mesh must be flagged as updatable
  23926. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  23927. * @returns a new Mesh
  23928. */
  23929. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  23930. /**
  23931. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  23932. * @param name defines the name of the mesh to create
  23933. * @param points is an array successive Vector3
  23934. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  23935. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23936. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  23937. * @param scene defines the hosting scene
  23938. * @param updatable defines if the mesh must be flagged as updatable
  23939. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  23940. * @returns a new Mesh
  23941. */
  23942. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  23943. /**
  23944. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  23945. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  23946. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  23947. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23948. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23949. * Remember you can only change the shape positions, not their number when updating a polygon.
  23950. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23951. * @param name defines the name of the mesh to create
  23952. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  23953. * @param scene defines the hosting scene
  23954. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23955. * @param updatable defines if the mesh must be flagged as updatable
  23956. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23957. * @param earcutInjection can be used to inject your own earcut reference
  23958. * @returns a new Mesh
  23959. */
  23960. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23961. /**
  23962. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  23963. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  23964. * @param name defines the name of the mesh to create
  23965. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  23966. * @param depth defines the height of extrusion
  23967. * @param scene defines the hosting scene
  23968. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23969. * @param updatable defines if the mesh must be flagged as updatable
  23970. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23971. * @param earcutInjection can be used to inject your own earcut reference
  23972. * @returns a new Mesh
  23973. */
  23974. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23975. /**
  23976. * Creates an extruded shape mesh.
  23977. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  23978. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23979. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23980. * @param name defines the name of the mesh to create
  23981. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  23982. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23983. * @param scale is the value to scale the shape
  23984. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  23985. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  23986. * @param scene defines the hosting scene
  23987. * @param updatable defines if the mesh must be flagged as updatable
  23988. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23989. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  23990. * @returns a new Mesh
  23991. */
  23992. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23993. /**
  23994. * Creates an custom extruded shape mesh.
  23995. * The custom extrusion is a parametric shape.
  23996. * It has no predefined shape. Its final shape will depend on the input parameters.
  23997. * Please consider using the same method from the MeshBuilder class instead
  23998. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23999. * @param name defines the name of the mesh to create
  24000. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  24001. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24002. * @param scaleFunction is a custom Javascript function called on each path point
  24003. * @param rotationFunction is a custom Javascript function called on each path point
  24004. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24005. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24006. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24007. * @param scene defines the hosting scene
  24008. * @param updatable defines if the mesh must be flagged as updatable
  24009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24010. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  24011. * @returns a new Mesh
  24012. */
  24013. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24014. /**
  24015. * Creates lathe mesh.
  24016. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24017. * Please consider using the same method from the MeshBuilder class instead
  24018. * @param name defines the name of the mesh to create
  24019. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  24020. * @param radius is the radius value of the lathe
  24021. * @param tessellation is the side number of the lathe.
  24022. * @param scene defines the hosting scene
  24023. * @param updatable defines if the mesh must be flagged as updatable
  24024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24025. * @returns a new Mesh
  24026. */
  24027. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24028. /**
  24029. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24030. * @param name defines the name of the mesh to create
  24031. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24032. * @param scene defines the hosting scene
  24033. * @param updatable defines if the mesh must be flagged as updatable
  24034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24035. * @returns a new Mesh
  24036. */
  24037. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24038. /**
  24039. * Creates a ground mesh.
  24040. * Please consider using the same method from the MeshBuilder class instead
  24041. * @param name defines the name of the mesh to create
  24042. * @param width set the width of the ground
  24043. * @param height set the height of the ground
  24044. * @param subdivisions sets the number of subdivisions per side
  24045. * @param scene defines the hosting scene
  24046. * @param updatable defines if the mesh must be flagged as updatable
  24047. * @returns a new Mesh
  24048. */
  24049. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24050. /**
  24051. * Creates a tiled ground mesh.
  24052. * Please consider using the same method from the MeshBuilder class instead
  24053. * @param name defines the name of the mesh to create
  24054. * @param xmin set the ground minimum X coordinate
  24055. * @param zmin set the ground minimum Y coordinate
  24056. * @param xmax set the ground maximum X coordinate
  24057. * @param zmax set the ground maximum Z coordinate
  24058. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  24059. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  24060. * @param scene defines the hosting scene
  24061. * @param updatable defines if the mesh must be flagged as updatable
  24062. * @returns a new Mesh
  24063. */
  24064. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24065. w: number;
  24066. h: number;
  24067. }, precision: {
  24068. w: number;
  24069. h: number;
  24070. }, scene: Scene, updatable?: boolean): Mesh;
  24071. /**
  24072. * Creates a ground mesh from a height map.
  24073. * Please consider using the same method from the MeshBuilder class instead
  24074. * @see http://doc.babylonjs.com/babylon101/height_map
  24075. * @param name defines the name of the mesh to create
  24076. * @param url sets the URL of the height map image resource
  24077. * @param width set the ground width size
  24078. * @param height set the ground height size
  24079. * @param subdivisions sets the number of subdivision per side
  24080. * @param minHeight is the minimum altitude on the ground
  24081. * @param maxHeight is the maximum altitude on the ground
  24082. * @param scene defines the hosting scene
  24083. * @param updatable defines if the mesh must be flagged as updatable
  24084. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24085. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24086. * @returns a new Mesh
  24087. */
  24088. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  24089. /**
  24090. * Creates a tube mesh.
  24091. * The tube is a parametric shape.
  24092. * It has no predefined shape. Its final shape will depend on the input parameters.
  24093. * Please consider using the same method from the MeshBuilder class instead
  24094. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24095. * @param name defines the name of the mesh to create
  24096. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24097. * @param radius sets the tube radius size
  24098. * @param tessellation is the number of sides on the tubular surface
  24099. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  24100. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  24101. * @param scene defines the hosting scene
  24102. * @param updatable defines if the mesh must be flagged as updatable
  24103. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24104. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  24105. * @returns a new Mesh
  24106. */
  24107. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24108. (i: number, distance: number): number;
  24109. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24110. /**
  24111. * Creates a polyhedron mesh.
  24112. * Please consider using the same method from the MeshBuilder class instead.
  24113. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  24114. * * The parameter `size` (positive float, default 1) sets the polygon size
  24115. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24116. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  24117. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  24118. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  24119. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  24120. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  24121. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24122. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24124. * @param name defines the name of the mesh to create
  24125. * @param options defines the options used to create the mesh
  24126. * @param scene defines the hosting scene
  24127. * @returns a new Mesh
  24128. */
  24129. static CreatePolyhedron(name: string, options: {
  24130. type?: number;
  24131. size?: number;
  24132. sizeX?: number;
  24133. sizeY?: number;
  24134. sizeZ?: number;
  24135. custom?: any;
  24136. faceUV?: Vector4[];
  24137. faceColors?: Color4[];
  24138. updatable?: boolean;
  24139. sideOrientation?: number;
  24140. }, scene: Scene): Mesh;
  24141. /**
  24142. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24143. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24144. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  24145. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24146. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  24147. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24148. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24150. * @param name defines the name of the mesh
  24151. * @param options defines the options used to create the mesh
  24152. * @param scene defines the hosting scene
  24153. * @returns a new Mesh
  24154. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24155. */
  24156. static CreateIcoSphere(name: string, options: {
  24157. radius?: number;
  24158. flat?: boolean;
  24159. subdivisions?: number;
  24160. sideOrientation?: number;
  24161. updatable?: boolean;
  24162. }, scene: Scene): Mesh;
  24163. /**
  24164. * Creates a decal mesh.
  24165. * Please consider using the same method from the MeshBuilder class instead.
  24166. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24167. * @param name defines the name of the mesh
  24168. * @param sourceMesh defines the mesh receiving the decal
  24169. * @param position sets the position of the decal in world coordinates
  24170. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24171. * @param size sets the decal scaling
  24172. * @param angle sets the angle to rotate the decal
  24173. * @returns a new Mesh
  24174. */
  24175. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24176. /**
  24177. * Prepare internal position array for software CPU skinning
  24178. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24179. */
  24180. setPositionsForCPUSkinning(): Float32Array;
  24181. /**
  24182. * Prepare internal normal array for software CPU skinning
  24183. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24184. */
  24185. setNormalsForCPUSkinning(): Float32Array;
  24186. /**
  24187. * Updates the vertex buffer by applying transformation from the bones
  24188. * @param skeleton defines the skeleton to apply to current mesh
  24189. * @returns the current mesh
  24190. */
  24191. applySkeleton(skeleton: Skeleton): Mesh;
  24192. /**
  24193. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  24194. * @param meshes defines the list of meshes to scan
  24195. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24196. */
  24197. static MinMax(meshes: AbstractMesh[]): {
  24198. min: Vector3;
  24199. max: Vector3;
  24200. };
  24201. /**
  24202. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24203. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24204. * @returns a vector3
  24205. */
  24206. static Center(meshesOrMinMaxVector: {
  24207. min: Vector3;
  24208. max: Vector3;
  24209. } | AbstractMesh[]): Vector3;
  24210. /**
  24211. * Merge the array of meshes into a single mesh for performance reasons.
  24212. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24213. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24214. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24215. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24216. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24217. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24218. * @returns a new mesh
  24219. */
  24220. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24221. /** @hidden */
  24222. addInstance(instance: InstancedMesh): void;
  24223. /** @hidden */
  24224. removeInstance(instance: InstancedMesh): void;
  24225. }
  24226. }
  24227. declare module BABYLON {
  24228. /**
  24229. * This is the base class of all the camera used in the application.
  24230. * @see http://doc.babylonjs.com/features/cameras
  24231. */
  24232. export class Camera extends Node {
  24233. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24234. /**
  24235. * This is the default projection mode used by the cameras.
  24236. * It helps recreating a feeling of perspective and better appreciate depth.
  24237. * This is the best way to simulate real life cameras.
  24238. */
  24239. static readonly PERSPECTIVE_CAMERA: number;
  24240. /**
  24241. * This helps creating camera with an orthographic mode.
  24242. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  24243. */
  24244. static readonly ORTHOGRAPHIC_CAMERA: number;
  24245. /**
  24246. * This is the default FOV mode for perspective cameras.
  24247. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24248. */
  24249. static readonly FOVMODE_VERTICAL_FIXED: number;
  24250. /**
  24251. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24252. */
  24253. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24254. /**
  24255. * This specifies ther is no need for a camera rig.
  24256. * Basically only one eye is rendered corresponding to the camera.
  24257. */
  24258. static readonly RIG_MODE_NONE: number;
  24259. /**
  24260. * Simulates a camera Rig with one blue eye and one red eye.
  24261. * This can be use with 3d blue and red glasses.
  24262. */
  24263. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24264. /**
  24265. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24266. */
  24267. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24268. /**
  24269. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24270. */
  24271. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24272. /**
  24273. * Defines that both eyes of the camera will be rendered over under each other.
  24274. */
  24275. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24276. /**
  24277. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24278. */
  24279. static readonly RIG_MODE_VR: number;
  24280. /**
  24281. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24282. */
  24283. static readonly RIG_MODE_WEBVR: number;
  24284. /**
  24285. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24286. */
  24287. static readonly RIG_MODE_CUSTOM: number;
  24288. /**
  24289. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24290. */
  24291. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24292. /**
  24293. * Define the input manager associated with the camera.
  24294. */
  24295. inputs: CameraInputsManager<Camera>;
  24296. /** @hidden */ private _position: Vector3;
  24297. /**
  24298. * Define the current local position of the camera in the scene
  24299. */
  24300. position: Vector3;
  24301. /**
  24302. * The vector the camera should consider as up.
  24303. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24304. */
  24305. upVector: Vector3;
  24306. /**
  24307. * Define the current limit on the left side for an orthographic camera
  24308. * In scene unit
  24309. */
  24310. orthoLeft: Nullable<number>;
  24311. /**
  24312. * Define the current limit on the right side for an orthographic camera
  24313. * In scene unit
  24314. */
  24315. orthoRight: Nullable<number>;
  24316. /**
  24317. * Define the current limit on the bottom side for an orthographic camera
  24318. * In scene unit
  24319. */
  24320. orthoBottom: Nullable<number>;
  24321. /**
  24322. * Define the current limit on the top side for an orthographic camera
  24323. * In scene unit
  24324. */
  24325. orthoTop: Nullable<number>;
  24326. /**
  24327. * Field Of View is set in Radians. (default is 0.8)
  24328. */
  24329. fov: number;
  24330. /**
  24331. * Define the minimum distance the camera can see from.
  24332. * This is important to note that the depth buffer are not infinite and the closer it starts
  24333. * the more your scene might encounter depth fighting issue.
  24334. */
  24335. minZ: number;
  24336. /**
  24337. * Define the maximum distance the camera can see to.
  24338. * This is important to note that the depth buffer are not infinite and the further it end
  24339. * the more your scene might encounter depth fighting issue.
  24340. */
  24341. maxZ: number;
  24342. /**
  24343. * Define the default inertia of the camera.
  24344. * This helps giving a smooth feeling to the camera movement.
  24345. */
  24346. inertia: number;
  24347. /**
  24348. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24349. */
  24350. mode: number;
  24351. /**
  24352. * Define wether the camera is intermediate.
  24353. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24354. */
  24355. isIntermediate: boolean;
  24356. /**
  24357. * Define the viewport of the camera.
  24358. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24359. */
  24360. viewport: Viewport;
  24361. /**
  24362. * Restricts the camera to viewing objects with the same layerMask.
  24363. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24364. */
  24365. layerMask: number;
  24366. /**
  24367. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24368. */
  24369. fovMode: number;
  24370. /**
  24371. * Rig mode of the camera.
  24372. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24373. * This is normally controlled byt the camera themselves as internal use.
  24374. */
  24375. cameraRigMode: number;
  24376. /**
  24377. * Defines the distance between both "eyes" in case of a RIG
  24378. */
  24379. interaxialDistance: number;
  24380. /**
  24381. * Defines if stereoscopic rendering is done side by side or over under.
  24382. */
  24383. isStereoscopicSideBySide: boolean;
  24384. /**
  24385. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  24386. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24387. * else in the scene. (Eg. security camera)
  24388. *
  24389. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  24390. */
  24391. customRenderTargets: RenderTargetTexture[];
  24392. /**
  24393. * When set, the camera will render to this render target instead of the default canvas
  24394. *
  24395. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24396. */
  24397. outputRenderTarget: Nullable<RenderTargetTexture>;
  24398. /**
  24399. * Observable triggered when the camera view matrix has changed.
  24400. */
  24401. onViewMatrixChangedObservable: Observable<Camera>;
  24402. /**
  24403. * Observable triggered when the camera Projection matrix has changed.
  24404. */
  24405. onProjectionMatrixChangedObservable: Observable<Camera>;
  24406. /**
  24407. * Observable triggered when the inputs have been processed.
  24408. */
  24409. onAfterCheckInputsObservable: Observable<Camera>;
  24410. /**
  24411. * Observable triggered when reset has been called and applied to the camera.
  24412. */
  24413. onRestoreStateObservable: Observable<Camera>;
  24414. /** @hidden */ private _cameraRigParams: any;
  24415. /** @hidden */ private _rigCameras: Camera[];
  24416. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24417. protected _webvrViewMatrix: Matrix;
  24418. /** @hidden */ private _skipRendering: boolean;
  24419. /** @hidden */ private _projectionMatrix: Matrix;
  24420. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24421. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24422. protected _globalPosition: Vector3;
  24423. /** @hidden */ private _computedViewMatrix: Matrix;
  24424. private _doNotComputeProjectionMatrix;
  24425. private _transformMatrix;
  24426. private _frustumPlanes;
  24427. private _refreshFrustumPlanes;
  24428. private _storedFov;
  24429. private _stateStored;
  24430. /**
  24431. * Instantiates a new camera object.
  24432. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24433. * @see http://doc.babylonjs.com/features/cameras
  24434. * @param name Defines the name of the camera in the scene
  24435. * @param position Defines the position of the camera
  24436. * @param scene Defines the scene the camera belongs too
  24437. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24438. */
  24439. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24440. /**
  24441. * Store current camera state (fov, position, etc..)
  24442. * @returns the camera
  24443. */
  24444. storeState(): Camera;
  24445. /**
  24446. * Restores the camera state values if it has been stored. You must call storeState() first
  24447. */
  24448. protected _restoreStateValues(): boolean;
  24449. /**
  24450. * Restored camera state. You must call storeState() first.
  24451. * @returns true if restored and false otherwise
  24452. */
  24453. restoreState(): boolean;
  24454. /**
  24455. * Gets the class name of the camera.
  24456. * @returns the class name
  24457. */
  24458. getClassName(): string;
  24459. /** @hidden */ protected readonly _isCamera: boolean;
  24460. /**
  24461. * Gets a string representation of the camera useful for debug purpose.
  24462. * @param fullDetails Defines that a more verboe level of logging is required
  24463. * @returns the string representation
  24464. */
  24465. toString(fullDetails?: boolean): string;
  24466. /**
  24467. * Gets the current world space position of the camera.
  24468. */
  24469. readonly globalPosition: Vector3;
  24470. /**
  24471. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24472. * @returns the active meshe list
  24473. */
  24474. getActiveMeshes(): SmartArray<AbstractMesh>;
  24475. /**
  24476. * Check wether a mesh is part of the current active mesh list of the camera
  24477. * @param mesh Defines the mesh to check
  24478. * @returns true if active, false otherwise
  24479. */
  24480. isActiveMesh(mesh: Mesh): boolean;
  24481. /**
  24482. * Is this camera ready to be used/rendered
  24483. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24484. * @return true if the camera is ready
  24485. */
  24486. isReady(completeCheck?: boolean): boolean;
  24487. /** @hidden */ private _initCache(): void;
  24488. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24489. /** @hidden */ private _isSynchronized(): boolean;
  24490. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24491. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24492. /**
  24493. * Attach the input controls to a specific dom element to get the input from.
  24494. * @param element Defines the element the controls should be listened from
  24495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24496. */
  24497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24498. /**
  24499. * Detach the current controls from the specified dom element.
  24500. * @param element Defines the element to stop listening the inputs from
  24501. */
  24502. detachControl(element: HTMLElement): void;
  24503. /**
  24504. * Update the camera state according to the different inputs gathered during the frame.
  24505. */
  24506. update(): void;
  24507. /** @hidden */ private _checkInputs(): void;
  24508. /** @hidden */
  24509. readonly rigCameras: Camera[];
  24510. /**
  24511. * Gets the post process used by the rig cameras
  24512. */
  24513. readonly rigPostProcess: Nullable<PostProcess>;
  24514. /**
  24515. * Internal, gets the first post proces.
  24516. * @returns the first post process to be run on this camera.
  24517. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24518. private _cascadePostProcessesToRigCams;
  24519. /**
  24520. * Attach a post process to the camera.
  24521. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24522. * @param postProcess The post process to attach to the camera
  24523. * @param insertAt The position of the post process in case several of them are in use in the scene
  24524. * @returns the position the post process has been inserted at
  24525. */
  24526. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24527. /**
  24528. * Detach a post process to the camera.
  24529. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24530. * @param postProcess The post process to detach from the camera
  24531. */
  24532. detachPostProcess(postProcess: PostProcess): void;
  24533. /**
  24534. * Gets the current world matrix of the camera
  24535. */
  24536. getWorldMatrix(): Matrix;
  24537. /** @hidden */ private _getViewMatrix(): Matrix;
  24538. /**
  24539. * Gets the current view matrix of the camera.
  24540. * @param force forces the camera to recompute the matrix without looking at the cached state
  24541. * @returns the view matrix
  24542. */
  24543. getViewMatrix(force?: boolean): Matrix;
  24544. /**
  24545. * Freeze the projection matrix.
  24546. * It will prevent the cache check of the camera projection compute and can speed up perf
  24547. * if no parameter of the camera are meant to change
  24548. * @param projection Defines manually a projection if necessary
  24549. */
  24550. freezeProjectionMatrix(projection?: Matrix): void;
  24551. /**
  24552. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24553. */
  24554. unfreezeProjectionMatrix(): void;
  24555. /**
  24556. * Gets the current projection matrix of the camera.
  24557. * @param force forces the camera to recompute the matrix without looking at the cached state
  24558. * @returns the projection matrix
  24559. */
  24560. getProjectionMatrix(force?: boolean): Matrix;
  24561. /**
  24562. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24563. * @returns a Matrix
  24564. */
  24565. getTransformationMatrix(): Matrix;
  24566. private _updateFrustumPlanes;
  24567. /**
  24568. * Checks if a cullable object (mesh...) is in the camera frustum
  24569. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24570. * @param target The object to check
  24571. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24572. * @returns true if the object is in frustum otherwise false
  24573. */
  24574. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24575. /**
  24576. * Checks if a cullable object (mesh...) is in the camera frustum
  24577. * Unlike isInFrustum this cheks the full bounding box
  24578. * @param target The object to check
  24579. * @returns true if the object is in frustum otherwise false
  24580. */
  24581. isCompletelyInFrustum(target: ICullable): boolean;
  24582. /**
  24583. * Gets a ray in the forward direction from the camera.
  24584. * @param length Defines the length of the ray to create
  24585. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24586. * @param origin Defines the start point of the ray which defaults to the camera position
  24587. * @returns the forward ray
  24588. */
  24589. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24590. /**
  24591. * Releases resources associated with this node.
  24592. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24593. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24594. */
  24595. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24596. /** @hidden */ private _isLeftCamera: boolean;
  24597. /**
  24598. * Gets the left camera of a rig setup in case of Rigged Camera
  24599. */
  24600. readonly isLeftCamera: boolean;
  24601. /** @hidden */ private _isRightCamera: boolean;
  24602. /**
  24603. * Gets the right camera of a rig setup in case of Rigged Camera
  24604. */
  24605. readonly isRightCamera: boolean;
  24606. /**
  24607. * Gets the left camera of a rig setup in case of Rigged Camera
  24608. */
  24609. readonly leftCamera: Nullable<FreeCamera>;
  24610. /**
  24611. * Gets the right camera of a rig setup in case of Rigged Camera
  24612. */
  24613. readonly rightCamera: Nullable<FreeCamera>;
  24614. /**
  24615. * Gets the left camera target of a rig setup in case of Rigged Camera
  24616. * @returns the target position
  24617. */
  24618. getLeftTarget(): Nullable<Vector3>;
  24619. /**
  24620. * Gets the right camera target of a rig setup in case of Rigged Camera
  24621. * @returns the target position
  24622. */
  24623. getRightTarget(): Nullable<Vector3>;
  24624. /**
  24625. * @hidden
  24626. */
  24627. setCameraRigMode(mode: number, rigParams: any): void;
  24628. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24629. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24630. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24631. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24632. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24633. protected _updateCameraRotationMatrix(): void;
  24634. protected _updateWebVRCameraRotationMatrix(): void;
  24635. /**
  24636. * This function MUST be overwritten by the different WebVR cameras available.
  24637. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24638. * @hidden
  24639. */ private _getWebVRProjectionMatrix(): Matrix;
  24640. /**
  24641. * This function MUST be overwritten by the different WebVR cameras available.
  24642. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24643. * @hidden
  24644. */ private _getWebVRViewMatrix(): Matrix;
  24645. /** @hidden */
  24646. setCameraRigParameter(name: string, value: any): void;
  24647. /**
  24648. * needs to be overridden by children so sub has required properties to be copied
  24649. * @hidden
  24650. */
  24651. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24652. /**
  24653. * May need to be overridden by children
  24654. * @hidden
  24655. */ private _updateRigCameras(): void;
  24656. /** @hidden */ private _setupInputs(): void;
  24657. /**
  24658. * Serialiaze the camera setup to a json represention
  24659. * @returns the JSON representation
  24660. */
  24661. serialize(): any;
  24662. /**
  24663. * Clones the current camera.
  24664. * @param name The cloned camera name
  24665. * @returns the cloned camera
  24666. */
  24667. clone(name: string): Camera;
  24668. /**
  24669. * Gets the direction of the camera relative to a given local axis.
  24670. * @param localAxis Defines the reference axis to provide a relative direction.
  24671. * @return the direction
  24672. */
  24673. getDirection(localAxis: Vector3): Vector3;
  24674. /**
  24675. * Returns the current camera absolute rotation
  24676. */
  24677. readonly absoluteRotation: Quaternion;
  24678. /**
  24679. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24680. * @param localAxis Defines the reference axis to provide a relative direction.
  24681. * @param result Defines the vector to store the result in
  24682. */
  24683. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24684. /**
  24685. * Gets a camera constructor for a given camera type
  24686. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24687. * @param name The name of the camera the result will be able to instantiate
  24688. * @param scene The scene the result will construct the camera in
  24689. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24690. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24691. * @returns a factory method to construc the camera
  24692. */
  24693. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24694. /**
  24695. * Compute the world matrix of the camera.
  24696. * @returns the camera workd matrix
  24697. */
  24698. computeWorldMatrix(): Matrix;
  24699. /**
  24700. * Parse a JSON and creates the camera from the parsed information
  24701. * @param parsedCamera The JSON to parse
  24702. * @param scene The scene to instantiate the camera in
  24703. * @returns the newly constructed camera
  24704. */
  24705. static Parse(parsedCamera: any, scene: Scene): Camera;
  24706. }
  24707. }
  24708. declare module BABYLON {
  24709. /**
  24710. * Class containing static functions to help procedurally build meshes
  24711. */
  24712. export class DiscBuilder {
  24713. /**
  24714. * Creates a plane polygonal mesh. By default, this is a disc
  24715. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24716. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  24717. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  24718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24721. * @param name defines the name of the mesh
  24722. * @param options defines the options used to create the mesh
  24723. * @param scene defines the hosting scene
  24724. * @returns the plane polygonal mesh
  24725. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24726. */
  24727. static CreateDisc(name: string, options: {
  24728. radius?: number;
  24729. tessellation?: number;
  24730. arc?: number;
  24731. updatable?: boolean;
  24732. sideOrientation?: number;
  24733. frontUVs?: Vector4;
  24734. backUVs?: Vector4;
  24735. }, scene?: Nullable<Scene>): Mesh;
  24736. }
  24737. }
  24738. declare module BABYLON {
  24739. /**
  24740. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24741. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  24742. * The SPS is also a particle system. It provides some methods to manage the particles.
  24743. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24744. *
  24745. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24746. */
  24747. export class SolidParticleSystem implements IDisposable {
  24748. /**
  24749. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24750. * Example : var p = SPS.particles[i];
  24751. */
  24752. particles: SolidParticle[];
  24753. /**
  24754. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24755. */
  24756. nbParticles: number;
  24757. /**
  24758. * If the particles must ever face the camera (default false). Useful for planar particles.
  24759. */
  24760. billboard: boolean;
  24761. /**
  24762. * Recompute normals when adding a shape
  24763. */
  24764. recomputeNormals: boolean;
  24765. /**
  24766. * This a counter ofr your own usage. It's not set by any SPS functions.
  24767. */
  24768. counter: number;
  24769. /**
  24770. * The SPS name. This name is also given to the underlying mesh.
  24771. */
  24772. name: string;
  24773. /**
  24774. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24775. */
  24776. mesh: Mesh;
  24777. /**
  24778. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24779. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24780. */
  24781. vars: any;
  24782. /**
  24783. * This array is populated when the SPS is set as 'pickable'.
  24784. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24785. * Each element of this array is an object `{idx: int, faceId: int}`.
  24786. * `idx` is the picked particle index in the `SPS.particles` array
  24787. * `faceId` is the picked face index counted within this particle.
  24788. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24789. */
  24790. pickedParticles: {
  24791. idx: number;
  24792. faceId: number;
  24793. }[];
  24794. /**
  24795. * This array is populated when `enableDepthSort` is set to true.
  24796. * Each element of this array is an instance of the class DepthSortedParticle.
  24797. */
  24798. depthSortedParticles: DepthSortedParticle[];
  24799. /**
  24800. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24801. * @hidden
  24802. */ private _bSphereOnly: boolean;
  24803. /**
  24804. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24805. * @hidden
  24806. */ private _bSphereRadiusFactor: number;
  24807. private _scene;
  24808. private _positions;
  24809. private _indices;
  24810. private _normals;
  24811. private _colors;
  24812. private _uvs;
  24813. private _indices32;
  24814. private _positions32;
  24815. private _normals32;
  24816. private _fixedNormal32;
  24817. private _colors32;
  24818. private _uvs32;
  24819. private _index;
  24820. private _updatable;
  24821. private _pickable;
  24822. private _isVisibilityBoxLocked;
  24823. private _alwaysVisible;
  24824. private _depthSort;
  24825. private _shapeCounter;
  24826. private _copy;
  24827. private _color;
  24828. private _computeParticleColor;
  24829. private _computeParticleTexture;
  24830. private _computeParticleRotation;
  24831. private _computeParticleVertex;
  24832. private _computeBoundingBox;
  24833. private _depthSortParticles;
  24834. private _camera;
  24835. private _mustUnrotateFixedNormals;
  24836. private _particlesIntersect;
  24837. private _needs32Bits;
  24838. /**
  24839. * Creates a SPS (Solid Particle System) object.
  24840. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24841. * @param scene (Scene) is the scene in which the SPS is added.
  24842. * @param options defines the options of the sps e.g.
  24843. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24844. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24845. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24846. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24847. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24848. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24849. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24850. */
  24851. constructor(name: string, scene: Scene, options?: {
  24852. updatable?: boolean;
  24853. isPickable?: boolean;
  24854. enableDepthSort?: boolean;
  24855. particleIntersection?: boolean;
  24856. boundingSphereOnly?: boolean;
  24857. bSphereRadiusFactor?: number;
  24858. });
  24859. /**
  24860. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24861. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24862. * @returns the created mesh
  24863. */
  24864. buildMesh(): Mesh;
  24865. /**
  24866. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24867. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24868. * Thus the particles generated from `digest()` have their property `position` set yet.
  24869. * @param mesh ( Mesh ) is the mesh to be digested
  24870. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  24871. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24872. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24873. * @returns the current SPS
  24874. */
  24875. digest(mesh: Mesh, options?: {
  24876. facetNb?: number;
  24877. number?: number;
  24878. delta?: number;
  24879. }): SolidParticleSystem;
  24880. private _unrotateFixedNormals;
  24881. private _resetCopy;
  24882. private _meshBuilder;
  24883. private _posToShape;
  24884. private _uvsToShapeUV;
  24885. private _addParticle;
  24886. /**
  24887. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24888. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  24889. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24890. * @param nb (positive integer) the number of particles to be created from this model
  24891. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24892. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24893. * @returns the number of shapes in the system
  24894. */
  24895. addShape(mesh: Mesh, nb: number, options?: {
  24896. positionFunction?: any;
  24897. vertexFunction?: any;
  24898. }): number;
  24899. private _rebuildParticle;
  24900. /**
  24901. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24902. * @returns the SPS.
  24903. */
  24904. rebuildMesh(): SolidParticleSystem;
  24905. /**
  24906. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24907. * This method calls `updateParticle()` for each particle of the SPS.
  24908. * For an animated SPS, it is usually called within the render loop.
  24909. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24910. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24911. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24912. * @returns the SPS.
  24913. */
  24914. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24915. /**
  24916. * Disposes the SPS.
  24917. */
  24918. dispose(): void;
  24919. /**
  24920. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24921. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24922. * @returns the SPS.
  24923. */
  24924. refreshVisibleSize(): SolidParticleSystem;
  24925. /**
  24926. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24927. * @param size the size (float) of the visibility box
  24928. * note : this doesn't lock the SPS mesh bounding box.
  24929. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24930. */
  24931. setVisibilityBox(size: number): void;
  24932. /**
  24933. * Gets whether the SPS as always visible or not
  24934. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24935. */
  24936. /**
  24937. * Sets the SPS as always visible or not
  24938. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24939. */
  24940. isAlwaysVisible: boolean;
  24941. /**
  24942. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24943. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24944. */
  24945. /**
  24946. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24947. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24948. */
  24949. isVisibilityBoxLocked: boolean;
  24950. /**
  24951. * Tells to `setParticles()` to compute the particle rotations or not.
  24952. * Default value : true. The SPS is faster when it's set to false.
  24953. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24954. */
  24955. /**
  24956. * Gets if `setParticles()` computes the particle rotations or not.
  24957. * Default value : true. The SPS is faster when it's set to false.
  24958. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24959. */
  24960. computeParticleRotation: boolean;
  24961. /**
  24962. * Tells to `setParticles()` to compute the particle colors or not.
  24963. * Default value : true. The SPS is faster when it's set to false.
  24964. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24965. */
  24966. /**
  24967. * Gets if `setParticles()` computes the particle colors or not.
  24968. * Default value : true. The SPS is faster when it's set to false.
  24969. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24970. */
  24971. computeParticleColor: boolean;
  24972. /**
  24973. * Gets if `setParticles()` computes the particle textures or not.
  24974. * Default value : true. The SPS is faster when it's set to false.
  24975. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24976. */
  24977. computeParticleTexture: boolean;
  24978. /**
  24979. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24980. * Default value : false. The SPS is faster when it's set to false.
  24981. * Note : the particle custom vertex positions aren't stored values.
  24982. */
  24983. /**
  24984. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24985. * Default value : false. The SPS is faster when it's set to false.
  24986. * Note : the particle custom vertex positions aren't stored values.
  24987. */
  24988. computeParticleVertex: boolean;
  24989. /**
  24990. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24991. */
  24992. /**
  24993. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24994. */
  24995. computeBoundingBox: boolean;
  24996. /**
  24997. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24998. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24999. * Default : `true`
  25000. */
  25001. /**
  25002. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25003. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25004. * Default : `true`
  25005. */
  25006. depthSortParticles: boolean;
  25007. /**
  25008. * This function does nothing. It may be overwritten to set all the particle first values.
  25009. * The SPS doesn't call this function, you may have to call it by your own.
  25010. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25011. */
  25012. initParticles(): void;
  25013. /**
  25014. * This function does nothing. It may be overwritten to recycle a particle.
  25015. * The SPS doesn't call this function, you may have to call it by your own.
  25016. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25017. * @param particle The particle to recycle
  25018. * @returns the recycled particle
  25019. */
  25020. recycleParticle(particle: SolidParticle): SolidParticle;
  25021. /**
  25022. * Updates a particle : this function should be overwritten by the user.
  25023. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25024. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25025. * @example : just set a particle position or velocity and recycle conditions
  25026. * @param particle The particle to update
  25027. * @returns the updated particle
  25028. */
  25029. updateParticle(particle: SolidParticle): SolidParticle;
  25030. /**
  25031. * Updates a vertex of a particle : it can be overwritten by the user.
  25032. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25033. * @param particle the current particle
  25034. * @param vertex the current index of the current particle
  25035. * @param pt the index of the current vertex in the particle shape
  25036. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25037. * @example : just set a vertex particle position
  25038. * @returns the updated vertex
  25039. */
  25040. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25041. /**
  25042. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25043. * This does nothing and may be overwritten by the user.
  25044. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25045. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25046. * @param update the boolean update value actually passed to setParticles()
  25047. */
  25048. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25049. /**
  25050. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25051. * This will be passed three parameters.
  25052. * This does nothing and may be overwritten by the user.
  25053. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25054. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25055. * @param update the boolean update value actually passed to setParticles()
  25056. */
  25057. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25058. }
  25059. }
  25060. declare module BABYLON {
  25061. /**
  25062. * Represents one particle of a solid particle system.
  25063. */
  25064. export class SolidParticle {
  25065. /**
  25066. * particle global index
  25067. */
  25068. idx: number;
  25069. /**
  25070. * The color of the particle
  25071. */
  25072. color: Nullable<Color4>;
  25073. /**
  25074. * The world space position of the particle.
  25075. */
  25076. position: Vector3;
  25077. /**
  25078. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25079. */
  25080. rotation: Vector3;
  25081. /**
  25082. * The world space rotation quaternion of the particle.
  25083. */
  25084. rotationQuaternion: Nullable<Quaternion>;
  25085. /**
  25086. * The scaling of the particle.
  25087. */
  25088. scaling: Vector3;
  25089. /**
  25090. * The uvs of the particle.
  25091. */
  25092. uvs: Vector4;
  25093. /**
  25094. * The current speed of the particle.
  25095. */
  25096. velocity: Vector3;
  25097. /**
  25098. * The pivot point in the particle local space.
  25099. */
  25100. pivot: Vector3;
  25101. /**
  25102. * Must the particle be translated from its pivot point in its local space ?
  25103. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25104. * Default : false
  25105. */
  25106. translateFromPivot: boolean;
  25107. /**
  25108. * Is the particle active or not ?
  25109. */
  25110. alive: boolean;
  25111. /**
  25112. * Is the particle visible or not ?
  25113. */
  25114. isVisible: boolean;
  25115. /**
  25116. * Index of this particle in the global "positions" array (Internal use)
  25117. * @hidden
  25118. */ private _pos: number;
  25119. /**
  25120. * @hidden Index of this particle in the global "indices" array (Internal use)
  25121. */ private _ind: number;
  25122. /**
  25123. * @hidden ModelShape of this particle (Internal use)
  25124. */ private _model: ModelShape;
  25125. /**
  25126. * ModelShape id of this particle
  25127. */
  25128. shapeId: number;
  25129. /**
  25130. * Index of the particle in its shape id
  25131. */
  25132. idxInShape: number;
  25133. /**
  25134. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  25135. */ private _modelBoundingInfo: BoundingInfo;
  25136. /**
  25137. * @hidden Particle BoundingInfo object (Internal use)
  25138. */ private _boundingInfo: BoundingInfo;
  25139. /**
  25140. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  25141. */ private _sps: SolidParticleSystem;
  25142. /**
  25143. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  25144. */ private _stillInvisible: boolean;
  25145. /**
  25146. * @hidden Last computed particle rotation matrix
  25147. */ private _rotationMatrix: number[];
  25148. /**
  25149. * Parent particle Id, if any.
  25150. * Default null.
  25151. */
  25152. parentId: Nullable<number>;
  25153. /**
  25154. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  25155. * The possible values are :
  25156. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25157. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25158. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25159. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25160. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25161. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  25162. * */
  25163. cullingStrategy: number;
  25164. /**
  25165. * @hidden Internal global position in the SPS.
  25166. */ private _globalPosition: Vector3;
  25167. /**
  25168. * Creates a Solid Particle object.
  25169. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25170. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25171. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25172. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25173. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25174. * @param shapeId (integer) is the model shape identifier in the SPS.
  25175. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25176. * @param sps defines the sps it is associated to
  25177. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25178. */
  25179. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25180. /**
  25181. * Legacy support, changed scale to scaling
  25182. */
  25183. /**
  25184. * Legacy support, changed scale to scaling
  25185. */
  25186. scale: Vector3;
  25187. /**
  25188. * Legacy support, changed quaternion to rotationQuaternion
  25189. */
  25190. /**
  25191. * Legacy support, changed quaternion to rotationQuaternion
  25192. */
  25193. quaternion: Nullable<Quaternion>;
  25194. /**
  25195. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25196. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25197. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25198. * @returns true if it intersects
  25199. */
  25200. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25201. /**
  25202. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25203. * A particle is in the frustum if its bounding box intersects the frustum
  25204. * @param frustumPlanes defines the frustum to test
  25205. * @returns true if the particle is in the frustum planes
  25206. */
  25207. isInFrustum(frustumPlanes: Plane[]): boolean;
  25208. /**
  25209. * get the rotation matrix of the particle
  25210. * @hidden
  25211. */
  25212. getRotationMatrix(m: Matrix): void;
  25213. }
  25214. /**
  25215. * Represents the shape of the model used by one particle of a solid particle system.
  25216. * SPS internal tool, don't use it manually.
  25217. */
  25218. export class ModelShape {
  25219. /**
  25220. * The shape id
  25221. * @hidden
  25222. */
  25223. shapeID: number;
  25224. /**
  25225. * flat array of model positions (internal use)
  25226. * @hidden
  25227. */ private _shape: Vector3[];
  25228. /**
  25229. * flat array of model UVs (internal use)
  25230. * @hidden
  25231. */ private _shapeUV: number[];
  25232. /**
  25233. * length of the shape in the model indices array (internal use)
  25234. * @hidden
  25235. */ private _indicesLength: number;
  25236. /**
  25237. * Custom position function (internal use)
  25238. * @hidden
  25239. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25240. /**
  25241. * Custom vertex function (internal use)
  25242. * @hidden
  25243. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25244. /**
  25245. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  25246. * SPS internal tool, don't use it manually.
  25247. * @hidden
  25248. */
  25249. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  25250. }
  25251. /**
  25252. * Represents a Depth Sorted Particle in the solid particle system.
  25253. */
  25254. export class DepthSortedParticle {
  25255. /**
  25256. * Index of the particle in the "indices" array
  25257. */
  25258. ind: number;
  25259. /**
  25260. * Length of the particle shape in the "indices" array
  25261. */
  25262. indicesLength: number;
  25263. /**
  25264. * Squared distance from the particle to the camera
  25265. */
  25266. sqDistance: number;
  25267. }
  25268. }
  25269. declare module BABYLON {
  25270. /**
  25271. * @hidden
  25272. */
  25273. export class _MeshCollisionData { private _checkCollisions: boolean; private _collisionMask: number; private _collisionGroup: number; private _collider: Nullable<Collider>; private _oldPositionForCollisions: Vector3; private _diffPositionForCollisions: Vector3; private _onCollideObserver: Nullable<Observer<AbstractMesh>>; private _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25274. }
  25275. }
  25276. declare module BABYLON {
  25277. /** @hidden */ private class _FacetDataStorage {
  25278. facetPositions: Vector3[];
  25279. facetNormals: Vector3[];
  25280. facetPartitioning: number[][];
  25281. facetNb: number;
  25282. partitioningSubdivisions: number;
  25283. partitioningBBoxRatio: number;
  25284. facetDataEnabled: boolean;
  25285. facetParameters: any;
  25286. bbSize: Vector3;
  25287. subDiv: {
  25288. max: number;
  25289. X: number;
  25290. Y: number;
  25291. Z: number;
  25292. };
  25293. facetDepthSort: boolean;
  25294. facetDepthSortEnabled: boolean;
  25295. depthSortedIndices: IndicesArray;
  25296. depthSortedFacets: {
  25297. ind: number;
  25298. sqDistance: number;
  25299. }[];
  25300. facetDepthSortFunction: (f1: {
  25301. ind: number;
  25302. sqDistance: number;
  25303. }, f2: {
  25304. ind: number;
  25305. sqDistance: number;
  25306. }) => number;
  25307. facetDepthSortFrom: Vector3;
  25308. facetDepthSortOrigin: Vector3;
  25309. invertedMatrix: Matrix;
  25310. }
  25311. /**
  25312. * @hidden
  25313. **/ private class _InternalAbstractMeshDataInfo { private _hasVertexAlpha: boolean; private _useVertexColors: boolean; private _numBoneInfluencers: number; private _applyFog: boolean; private _receiveShadows: boolean; private _facetData: _FacetDataStorage; private _visibility: number; private _skeleton: Nullable<Skeleton>; private _layerMask: number; private _computeBonesUsingShaders: boolean; private _isActive: boolean; private _onlyForInstances: boolean; private _isActiveIntermediate: boolean; private _onlyForInstancesIntermediate: boolean;
  25314. }
  25315. /**
  25316. * Class used to store all common mesh properties
  25317. */
  25318. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25319. /** No occlusion */
  25320. static OCCLUSION_TYPE_NONE: number;
  25321. /** Occlusion set to optimisitic */
  25322. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25323. /** Occlusion set to strict */
  25324. static OCCLUSION_TYPE_STRICT: number;
  25325. /** Use an accurante occlusion algorithm */
  25326. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25327. /** Use a conservative occlusion algorithm */
  25328. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25329. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25330. * Test order :
  25331. * Is the bounding sphere outside the frustum ?
  25332. * If not, are the bounding box vertices outside the frustum ?
  25333. * It not, then the cullable object is in the frustum.
  25334. */
  25335. static readonly CULLINGSTRATEGY_STANDARD: number;
  25336. /** Culling strategy : Bounding Sphere Only.
  25337. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25338. * It's also less accurate than the standard because some not visible objects can still be selected.
  25339. * Test : is the bounding sphere outside the frustum ?
  25340. * If not, then the cullable object is in the frustum.
  25341. */
  25342. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25343. /** Culling strategy : Optimistic Inclusion.
  25344. * This in an inclusion test first, then the standard exclusion test.
  25345. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25346. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  25347. * Anyway, it's as accurate as the standard strategy.
  25348. * Test :
  25349. * Is the cullable object bounding sphere center in the frustum ?
  25350. * If not, apply the default culling strategy.
  25351. */
  25352. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25353. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25354. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25355. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25356. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  25357. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25358. * Test :
  25359. * Is the cullable object bounding sphere center in the frustum ?
  25360. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25361. */
  25362. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25363. /**
  25364. * No billboard
  25365. */
  25366. static readonly BILLBOARDMODE_NONE: number;
  25367. /** Billboard on X axis */
  25368. static readonly BILLBOARDMODE_X: number;
  25369. /** Billboard on Y axis */
  25370. static readonly BILLBOARDMODE_Y: number;
  25371. /** Billboard on Z axis */
  25372. static readonly BILLBOARDMODE_Z: number;
  25373. /** Billboard on all axes */
  25374. static readonly BILLBOARDMODE_ALL: number;
  25375. /** Billboard on using position instead of orientation */
  25376. static readonly BILLBOARDMODE_USE_POSITION: number;
  25377. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25378. /**
  25379. * The culling strategy to use to check whether the mesh must be rendered or not.
  25380. * This value can be changed at any time and will be used on the next render mesh selection.
  25381. * The possible values are :
  25382. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25383. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25384. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25385. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25386. * Please read each static variable documentation to get details about the culling process.
  25387. * */
  25388. cullingStrategy: number;
  25389. /**
  25390. * Gets the number of facets in the mesh
  25391. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25392. */
  25393. readonly facetNb: number;
  25394. /**
  25395. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25397. */
  25398. partitioningSubdivisions: number;
  25399. /**
  25400. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25401. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25402. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25403. */
  25404. partitioningBBoxRatio: number;
  25405. /**
  25406. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25407. * Works only for updatable meshes.
  25408. * Doesn't work with multi-materials
  25409. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25410. */
  25411. mustDepthSortFacets: boolean;
  25412. /**
  25413. * The location (Vector3) where the facet depth sort must be computed from.
  25414. * By default, the active camera position.
  25415. * Used only when facet depth sort is enabled
  25416. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25417. */
  25418. facetDepthSortFrom: Vector3;
  25419. /**
  25420. * gets a boolean indicating if facetData is enabled
  25421. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25422. */
  25423. readonly isFacetDataEnabled: boolean;
  25424. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25425. /**
  25426. * An event triggered when this mesh collides with another one
  25427. */
  25428. onCollideObservable: Observable<AbstractMesh>;
  25429. /** Set a function to call when this mesh collides with another one */
  25430. onCollide: () => void;
  25431. /**
  25432. * An event triggered when the collision's position changes
  25433. */
  25434. onCollisionPositionChangeObservable: Observable<Vector3>;
  25435. /** Set a function to call when the collision's position changes */
  25436. onCollisionPositionChange: () => void;
  25437. /**
  25438. * An event triggered when material is changed
  25439. */
  25440. onMaterialChangedObservable: Observable<AbstractMesh>;
  25441. /**
  25442. * Gets or sets the orientation for POV movement & rotation
  25443. */
  25444. definedFacingForward: boolean;
  25445. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25446. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25447. /**
  25448. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25449. */
  25450. /**
  25451. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25452. */
  25453. visibility: number;
  25454. /** Gets or sets the alpha index used to sort transparent meshes
  25455. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25456. */
  25457. alphaIndex: number;
  25458. /**
  25459. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25460. */
  25461. isVisible: boolean;
  25462. /**
  25463. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25464. */
  25465. isPickable: boolean;
  25466. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25467. showSubMeshesBoundingBox: boolean;
  25468. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25469. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25470. */
  25471. isBlocker: boolean;
  25472. /**
  25473. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25474. */
  25475. enablePointerMoveEvents: boolean;
  25476. /**
  25477. * Specifies the rendering group id for this mesh (0 by default)
  25478. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25479. */
  25480. renderingGroupId: number;
  25481. private _material;
  25482. /** Gets or sets current material */
  25483. material: Nullable<Material>;
  25484. /**
  25485. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25486. * @see http://doc.babylonjs.com/babylon101/shadows
  25487. */
  25488. receiveShadows: boolean;
  25489. /** Defines color to use when rendering outline */
  25490. outlineColor: Color3;
  25491. /** Define width to use when rendering outline */
  25492. outlineWidth: number;
  25493. /** Defines color to use when rendering overlay */
  25494. overlayColor: Color3;
  25495. /** Defines alpha to use when rendering overlay */
  25496. overlayAlpha: number;
  25497. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25498. hasVertexAlpha: boolean;
  25499. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  25500. useVertexColors: boolean;
  25501. /**
  25502. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25503. */
  25504. computeBonesUsingShaders: boolean;
  25505. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25506. numBoneInfluencers: number;
  25507. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25508. applyFog: boolean;
  25509. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25510. useOctreeForRenderingSelection: boolean;
  25511. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25512. useOctreeForPicking: boolean;
  25513. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25514. useOctreeForCollisions: boolean;
  25515. /**
  25516. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25517. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25518. */
  25519. layerMask: number;
  25520. /**
  25521. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25522. */
  25523. alwaysSelectAsActiveMesh: boolean;
  25524. /**
  25525. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25526. */
  25527. doNotSyncBoundingInfo: boolean;
  25528. /**
  25529. * Gets or sets the current action manager
  25530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25531. */
  25532. actionManager: Nullable<AbstractActionManager>;
  25533. private _meshCollisionData;
  25534. /**
  25535. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25536. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25537. */
  25538. ellipsoid: Vector3;
  25539. /**
  25540. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25541. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25542. */
  25543. ellipsoidOffset: Vector3;
  25544. /**
  25545. * Gets or sets a collision mask used to mask collisions (default is -1).
  25546. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25547. */
  25548. collisionMask: number;
  25549. /**
  25550. * Gets or sets the current collision group mask (-1 by default).
  25551. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25552. */
  25553. collisionGroup: number;
  25554. /**
  25555. * Defines edge width used when edgesRenderer is enabled
  25556. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25557. */
  25558. edgesWidth: number;
  25559. /**
  25560. * Defines edge color used when edgesRenderer is enabled
  25561. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25562. */
  25563. edgesColor: Color4;
  25564. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25565. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25566. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25567. /** @hidden */ private _renderId: number;
  25568. /**
  25569. * Gets or sets the list of subMeshes
  25570. * @see http://doc.babylonjs.com/how_to/multi_materials
  25571. */
  25572. subMeshes: SubMesh[];
  25573. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25574. /** @hidden */ private _unIndexed: boolean;
  25575. /** @hidden */ private _lightSources: Light[];
  25576. /** Gets the list of lights affecting that mesh */
  25577. readonly lightSources: Light[];
  25578. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25579. /** @hidden */ private _waitingData: {
  25580. lods: Nullable<any>;
  25581. actions: Nullable<any>;
  25582. freezeWorldMatrix: Nullable<boolean>;
  25583. };
  25584. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25585. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25586. /**
  25587. * Gets or sets a skeleton to apply skining transformations
  25588. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25589. */
  25590. skeleton: Nullable<Skeleton>;
  25591. /**
  25592. * An event triggered when the mesh is rebuilt.
  25593. */
  25594. onRebuildObservable: Observable<AbstractMesh>;
  25595. /**
  25596. * Creates a new AbstractMesh
  25597. * @param name defines the name of the mesh
  25598. * @param scene defines the hosting scene
  25599. */
  25600. constructor(name: string, scene?: Nullable<Scene>);
  25601. /**
  25602. * Returns the string "AbstractMesh"
  25603. * @returns "AbstractMesh"
  25604. */
  25605. getClassName(): string;
  25606. /**
  25607. * Gets a string representation of the current mesh
  25608. * @param fullDetails defines a boolean indicating if full details must be included
  25609. * @returns a string representation of the current mesh
  25610. */
  25611. toString(fullDetails?: boolean): string;
  25612. /**
  25613. * @hidden
  25614. */
  25615. protected _getEffectiveParent(): Nullable<Node>;
  25616. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25617. /** @hidden */ private _rebuild(): void;
  25618. /** @hidden */ private _resyncLightSources(): void;
  25619. /** @hidden */ private _resyncLighSource(light: Light): void;
  25620. /** @hidden */ private _unBindEffect(): void;
  25621. /** @hidden */ private _removeLightSource(light: Light, dispose: boolean): void;
  25622. private _markSubMeshesAsDirty;
  25623. /** @hidden */ private _markSubMeshesAsLightDirty(dispose?: boolean): void;
  25624. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25625. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25626. /**
  25627. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25628. */
  25629. scaling: Vector3;
  25630. /**
  25631. * Returns true if the mesh is blocked. Implemented by child classes
  25632. */
  25633. readonly isBlocked: boolean;
  25634. /**
  25635. * Returns the mesh itself by default. Implemented by child classes
  25636. * @param camera defines the camera to use to pick the right LOD level
  25637. * @returns the currentAbstractMesh
  25638. */
  25639. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25640. /**
  25641. * Returns 0 by default. Implemented by child classes
  25642. * @returns an integer
  25643. */
  25644. getTotalVertices(): number;
  25645. /**
  25646. * Returns a positive integer : the total number of indices in this mesh geometry.
  25647. * @returns the numner of indices or zero if the mesh has no geometry.
  25648. */
  25649. getTotalIndices(): number;
  25650. /**
  25651. * Returns null by default. Implemented by child classes
  25652. * @returns null
  25653. */
  25654. getIndices(): Nullable<IndicesArray>;
  25655. /**
  25656. * Returns the array of the requested vertex data kind. Implemented by child classes
  25657. * @param kind defines the vertex data kind to use
  25658. * @returns null
  25659. */
  25660. getVerticesData(kind: string): Nullable<FloatArray>;
  25661. /**
  25662. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25663. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25664. * Note that a new underlying VertexBuffer object is created each call.
  25665. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25666. * @param kind defines vertex data kind:
  25667. * * VertexBuffer.PositionKind
  25668. * * VertexBuffer.UVKind
  25669. * * VertexBuffer.UV2Kind
  25670. * * VertexBuffer.UV3Kind
  25671. * * VertexBuffer.UV4Kind
  25672. * * VertexBuffer.UV5Kind
  25673. * * VertexBuffer.UV6Kind
  25674. * * VertexBuffer.ColorKind
  25675. * * VertexBuffer.MatricesIndicesKind
  25676. * * VertexBuffer.MatricesIndicesExtraKind
  25677. * * VertexBuffer.MatricesWeightsKind
  25678. * * VertexBuffer.MatricesWeightsExtraKind
  25679. * @param data defines the data source
  25680. * @param updatable defines if the data must be flagged as updatable (or static)
  25681. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  25682. * @returns the current mesh
  25683. */
  25684. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25685. /**
  25686. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25687. * If the mesh has no geometry, it is simply returned as it is.
  25688. * @param kind defines vertex data kind:
  25689. * * VertexBuffer.PositionKind
  25690. * * VertexBuffer.UVKind
  25691. * * VertexBuffer.UV2Kind
  25692. * * VertexBuffer.UV3Kind
  25693. * * VertexBuffer.UV4Kind
  25694. * * VertexBuffer.UV5Kind
  25695. * * VertexBuffer.UV6Kind
  25696. * * VertexBuffer.ColorKind
  25697. * * VertexBuffer.MatricesIndicesKind
  25698. * * VertexBuffer.MatricesIndicesExtraKind
  25699. * * VertexBuffer.MatricesWeightsKind
  25700. * * VertexBuffer.MatricesWeightsExtraKind
  25701. * @param data defines the data source
  25702. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  25703. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25704. * @returns the current mesh
  25705. */
  25706. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25707. /**
  25708. * Sets the mesh indices,
  25709. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25710. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25711. * @param totalVertices Defines the total number of vertices
  25712. * @returns the current mesh
  25713. */
  25714. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25715. /**
  25716. * Gets a boolean indicating if specific vertex data is present
  25717. * @param kind defines the vertex data kind to use
  25718. * @returns true is data kind is present
  25719. */
  25720. isVerticesDataPresent(kind: string): boolean;
  25721. /**
  25722. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25723. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25724. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25725. * @returns a BoundingInfo
  25726. */
  25727. getBoundingInfo(): BoundingInfo;
  25728. /**
  25729. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25730. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25731. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25732. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25733. * @returns the current mesh
  25734. */
  25735. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25736. /**
  25737. * Overwrite the current bounding info
  25738. * @param boundingInfo defines the new bounding info
  25739. * @returns the current mesh
  25740. */
  25741. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25742. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25743. readonly useBones: boolean;
  25744. /** @hidden */ private _preActivate(): void;
  25745. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25746. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25747. /** @hidden */ private _postActivate(): void;
  25748. /** @hidden */ private _freeze(): void;
  25749. /** @hidden */ private _unFreeze(): void;
  25750. /**
  25751. * Gets the current world matrix
  25752. * @returns a Matrix
  25753. */
  25754. getWorldMatrix(): Matrix;
  25755. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25756. /**
  25757. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25758. */
  25759. readonly isAnInstance: boolean;
  25760. /**
  25761. * Gets a boolean indicating if this mesh has instances
  25762. */
  25763. readonly hasInstances: boolean;
  25764. /**
  25765. * Perform relative position change from the point of view of behind the front of the mesh.
  25766. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25767. * Supports definition of mesh facing forward or backward
  25768. * @param amountRight defines the distance on the right axis
  25769. * @param amountUp defines the distance on the up axis
  25770. * @param amountForward defines the distance on the forward axis
  25771. * @returns the current mesh
  25772. */
  25773. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25774. /**
  25775. * Calculate relative position change from the point of view of behind the front of the mesh.
  25776. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25777. * Supports definition of mesh facing forward or backward
  25778. * @param amountRight defines the distance on the right axis
  25779. * @param amountUp defines the distance on the up axis
  25780. * @param amountForward defines the distance on the forward axis
  25781. * @returns the new displacement vector
  25782. */
  25783. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25784. /**
  25785. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25786. * Supports definition of mesh facing forward or backward
  25787. * @param flipBack defines the flip
  25788. * @param twirlClockwise defines the twirl
  25789. * @param tiltRight defines the tilt
  25790. * @returns the current mesh
  25791. */
  25792. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25793. /**
  25794. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25795. * Supports definition of mesh facing forward or backward.
  25796. * @param flipBack defines the flip
  25797. * @param twirlClockwise defines the twirl
  25798. * @param tiltRight defines the tilt
  25799. * @returns the new rotation vector
  25800. */
  25801. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25802. /**
  25803. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25804. * This means the mesh underlying bounding box and sphere are recomputed.
  25805. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25806. * @returns the current mesh
  25807. */
  25808. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25809. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25810. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25811. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25812. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25813. /** @hidden */
  25814. protected _afterComputeWorldMatrix(): void;
  25815. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25816. /**
  25817. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25818. * A mesh is in the frustum if its bounding box intersects the frustum
  25819. * @param frustumPlanes defines the frustum to test
  25820. * @returns true if the mesh is in the frustum planes
  25821. */
  25822. isInFrustum(frustumPlanes: Plane[]): boolean;
  25823. /**
  25824. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25825. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25826. * @param frustumPlanes defines the frustum to test
  25827. * @returns true if the mesh is completely in the frustum planes
  25828. */
  25829. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25830. /**
  25831. * True if the mesh intersects another mesh or a SolidParticle object
  25832. * @param mesh defines a target mesh or SolidParticle to test
  25833. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  25834. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25835. * @returns true if there is an intersection
  25836. */
  25837. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25838. /**
  25839. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25840. * @param point defines the point to test
  25841. * @returns true if there is an intersection
  25842. */
  25843. intersectsPoint(point: Vector3): boolean;
  25844. /**
  25845. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25846. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25847. */
  25848. checkCollisions: boolean;
  25849. /**
  25850. * Gets Collider object used to compute collisions (not physics)
  25851. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25852. */
  25853. readonly collider: Nullable<Collider>;
  25854. /**
  25855. * Move the mesh using collision engine
  25856. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25857. * @param displacement defines the requested displacement vector
  25858. * @returns the current mesh
  25859. */
  25860. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25861. private _onCollisionPositionChange;
  25862. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25863. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25864. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  25865. /** @hidden */ private _generatePointsArray(): boolean;
  25866. /**
  25867. * Checks if the passed Ray intersects with the mesh
  25868. * @param ray defines the ray to use
  25869. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25870. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25871. * @returns the picking info
  25872. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25873. */
  25874. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25875. /**
  25876. * Clones the current mesh
  25877. * @param name defines the mesh name
  25878. * @param newParent defines the new mesh parent
  25879. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25880. * @returns the new mesh
  25881. */
  25882. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25883. /**
  25884. * Disposes all the submeshes of the current meshnp
  25885. * @returns the current mesh
  25886. */
  25887. releaseSubMeshes(): AbstractMesh;
  25888. /**
  25889. * Releases resources associated with this abstract mesh.
  25890. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25891. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25892. */
  25893. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25894. /**
  25895. * Adds the passed mesh as a child to the current mesh
  25896. * @param mesh defines the child mesh
  25897. * @returns the current mesh
  25898. */
  25899. addChild(mesh: AbstractMesh): AbstractMesh;
  25900. /**
  25901. * Removes the passed mesh from the current mesh children list
  25902. * @param mesh defines the child mesh
  25903. * @returns the current mesh
  25904. */
  25905. removeChild(mesh: AbstractMesh): AbstractMesh;
  25906. /** @hidden */
  25907. private _initFacetData;
  25908. /**
  25909. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25910. * This method can be called within the render loop.
  25911. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  25912. * @returns the current mesh
  25913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25914. */
  25915. updateFacetData(): AbstractMesh;
  25916. /**
  25917. * Returns the facetLocalNormals array.
  25918. * The normals are expressed in the mesh local spac
  25919. * @returns an array of Vector3
  25920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25921. */
  25922. getFacetLocalNormals(): Vector3[];
  25923. /**
  25924. * Returns the facetLocalPositions array.
  25925. * The facet positions are expressed in the mesh local space
  25926. * @returns an array of Vector3
  25927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25928. */
  25929. getFacetLocalPositions(): Vector3[];
  25930. /**
  25931. * Returns the facetLocalPartioning array
  25932. * @returns an array of array of numbers
  25933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25934. */
  25935. getFacetLocalPartitioning(): number[][];
  25936. /**
  25937. * Returns the i-th facet position in the world system.
  25938. * This method allocates a new Vector3 per call
  25939. * @param i defines the facet index
  25940. * @returns a new Vector3
  25941. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25942. */
  25943. getFacetPosition(i: number): Vector3;
  25944. /**
  25945. * Sets the reference Vector3 with the i-th facet position in the world system
  25946. * @param i defines the facet index
  25947. * @param ref defines the target vector
  25948. * @returns the current mesh
  25949. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25950. */
  25951. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25952. /**
  25953. * Returns the i-th facet normal in the world system.
  25954. * This method allocates a new Vector3 per call
  25955. * @param i defines the facet index
  25956. * @returns a new Vector3
  25957. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25958. */
  25959. getFacetNormal(i: number): Vector3;
  25960. /**
  25961. * Sets the reference Vector3 with the i-th facet normal in the world system
  25962. * @param i defines the facet index
  25963. * @param ref defines the target vector
  25964. * @returns the current mesh
  25965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25966. */
  25967. getFacetNormalToRef(i: number, ref: Vector3): this;
  25968. /**
  25969. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  25970. * @param x defines x coordinate
  25971. * @param y defines y coordinate
  25972. * @param z defines z coordinate
  25973. * @returns the array of facet indexes
  25974. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25975. */
  25976. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25977. /**
  25978. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25979. * @param projected sets as the (x,y,z) world projection on the facet
  25980. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  25981. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  25982. * @param x defines x coordinate
  25983. * @param y defines y coordinate
  25984. * @param z defines z coordinate
  25985. * @returns the face index if found (or null instead)
  25986. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25987. */
  25988. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25989. /**
  25990. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25991. * @param projected sets as the (x,y,z) local projection on the facet
  25992. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  25993. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  25994. * @param x defines x coordinate
  25995. * @param y defines y coordinate
  25996. * @param z defines z coordinate
  25997. * @returns the face index if found (or null instead)
  25998. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25999. */
  26000. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26001. /**
  26002. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26003. * @returns the parameters
  26004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26005. */
  26006. getFacetDataParameters(): any;
  26007. /**
  26008. * Disables the feature FacetData and frees the related memory
  26009. * @returns the current mesh
  26010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26011. */
  26012. disableFacetData(): AbstractMesh;
  26013. /**
  26014. * Updates the AbstractMesh indices array
  26015. * @param indices defines the data source
  26016. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26017. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  26018. * @returns the current mesh
  26019. */
  26020. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26021. /**
  26022. * Creates new normals data for the mesh
  26023. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26024. * @returns the current mesh
  26025. */
  26026. createNormals(updatable: boolean): AbstractMesh;
  26027. /**
  26028. * Align the mesh with a normal
  26029. * @param normal defines the normal to use
  26030. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26031. * @returns the current mesh
  26032. */
  26033. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26034. /** @hidden */ private _checkOcclusionQuery(): boolean;
  26035. /**
  26036. * Disables the mesh edge rendering mode
  26037. * @returns the currentAbstractMesh
  26038. */
  26039. disableEdgesRendering(): AbstractMesh;
  26040. /**
  26041. * Enables the edge rendering mode on the mesh.
  26042. * This mode makes the mesh edges visible
  26043. * @param epsilon defines the maximal distance between two angles to detect a face
  26044. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  26045. * @returns the currentAbstractMesh
  26046. * @see https://www.babylonjs-playground.com/#19O9TU#0
  26047. */
  26048. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  26049. }
  26050. }
  26051. declare module BABYLON {
  26052. /**
  26053. * Interface used to define ActionEvent
  26054. */
  26055. export interface IActionEvent {
  26056. /** The mesh or sprite that triggered the action */
  26057. source: any;
  26058. /** The X mouse cursor position at the time of the event */
  26059. pointerX: number;
  26060. /** The Y mouse cursor position at the time of the event */
  26061. pointerY: number;
  26062. /** The mesh that is currently pointed at (can be null) */
  26063. meshUnderPointer: Nullable<AbstractMesh>;
  26064. /** the original (browser) event that triggered the ActionEvent */
  26065. sourceEvent?: any;
  26066. /** additional data for the event */
  26067. additionalData?: any;
  26068. }
  26069. /**
  26070. * ActionEvent is the event being sent when an action is triggered.
  26071. */
  26072. export class ActionEvent implements IActionEvent {
  26073. /** The mesh or sprite that triggered the action */
  26074. source: any;
  26075. /** The X mouse cursor position at the time of the event */
  26076. pointerX: number;
  26077. /** The Y mouse cursor position at the time of the event */
  26078. pointerY: number;
  26079. /** The mesh that is currently pointed at (can be null) */
  26080. meshUnderPointer: Nullable<AbstractMesh>;
  26081. /** the original (browser) event that triggered the ActionEvent */
  26082. sourceEvent?: any;
  26083. /** additional data for the event */
  26084. additionalData?: any;
  26085. /**
  26086. * Creates a new ActionEvent
  26087. * @param source The mesh or sprite that triggered the action
  26088. * @param pointerX The X mouse cursor position at the time of the event
  26089. * @param pointerY The Y mouse cursor position at the time of the event
  26090. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26091. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26092. * @param additionalData additional data for the event
  26093. */
  26094. constructor(
  26095. /** The mesh or sprite that triggered the action */
  26096. source: any,
  26097. /** The X mouse cursor position at the time of the event */
  26098. pointerX: number,
  26099. /** The Y mouse cursor position at the time of the event */
  26100. pointerY: number,
  26101. /** The mesh that is currently pointed at (can be null) */
  26102. meshUnderPointer: Nullable<AbstractMesh>,
  26103. /** the original (browser) event that triggered the ActionEvent */
  26104. sourceEvent?: any,
  26105. /** additional data for the event */
  26106. additionalData?: any);
  26107. /**
  26108. * Helper function to auto-create an ActionEvent from a source mesh.
  26109. * @param source The source mesh that triggered the event
  26110. * @param evt The original (browser) event
  26111. * @param additionalData additional data for the event
  26112. * @returns the new ActionEvent
  26113. */
  26114. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26115. /**
  26116. * Helper function to auto-create an ActionEvent from a source sprite
  26117. * @param source The source sprite that triggered the event
  26118. * @param scene Scene associated with the sprite
  26119. * @param evt The original (browser) event
  26120. * @param additionalData additional data for the event
  26121. * @returns the new ActionEvent
  26122. */
  26123. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26124. /**
  26125. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26126. * @param scene the scene where the event occurred
  26127. * @param evt The original (browser) event
  26128. * @returns the new ActionEvent
  26129. */
  26130. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26131. /**
  26132. * Helper function to auto-create an ActionEvent from a primitive
  26133. * @param prim defines the target primitive
  26134. * @param pointerPos defines the pointer position
  26135. * @param evt The original (browser) event
  26136. * @param additionalData additional data for the event
  26137. * @returns the new ActionEvent
  26138. */
  26139. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26140. }
  26141. }
  26142. declare module BABYLON {
  26143. /**
  26144. * Abstract class used to decouple action Manager from scene and meshes.
  26145. * Do not instantiate.
  26146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26147. */
  26148. export abstract class AbstractActionManager implements IDisposable {
  26149. /** Gets the list of active triggers */
  26150. static Triggers: {
  26151. [key: string]: number;
  26152. };
  26153. /** Gets the cursor to use when hovering items */
  26154. hoverCursor: string;
  26155. /** Gets the list of actions */
  26156. actions: IAction[];
  26157. /**
  26158. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26159. */
  26160. isRecursive: boolean;
  26161. /**
  26162. * Releases all associated resources
  26163. */
  26164. abstract dispose(): void;
  26165. /**
  26166. * Does this action manager has pointer triggers
  26167. */
  26168. abstract readonly hasPointerTriggers: boolean;
  26169. /**
  26170. * Does this action manager has pick triggers
  26171. */
  26172. abstract readonly hasPickTriggers: boolean;
  26173. /**
  26174. * Process a specific trigger
  26175. * @param trigger defines the trigger to process
  26176. * @param evt defines the event details to be processed
  26177. */
  26178. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26179. /**
  26180. * Does this action manager handles actions of any of the given triggers
  26181. * @param triggers defines the triggers to be tested
  26182. * @return a boolean indicating whether one (or more) of the triggers is handled
  26183. */
  26184. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26185. /**
  26186. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26187. * speed.
  26188. * @param triggerA defines the trigger to be tested
  26189. * @param triggerB defines the trigger to be tested
  26190. * @return a boolean indicating whether one (or more) of the triggers is handled
  26191. */
  26192. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26193. /**
  26194. * Does this action manager handles actions of a given trigger
  26195. * @param trigger defines the trigger to be tested
  26196. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26197. * @return whether the trigger is handled
  26198. */
  26199. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26200. /**
  26201. * Serialize this manager to a JSON object
  26202. * @param name defines the property name to store this manager
  26203. * @returns a JSON representation of this manager
  26204. */
  26205. abstract serialize(name: string): any;
  26206. /**
  26207. * Registers an action to this action manager
  26208. * @param action defines the action to be registered
  26209. * @return the action amended (prepared) after registration
  26210. */
  26211. abstract registerAction(action: IAction): Nullable<IAction>;
  26212. /**
  26213. * Unregisters an action to this action manager
  26214. * @param action defines the action to be unregistered
  26215. * @return a boolean indicating whether the action has been unregistered
  26216. */
  26217. abstract unregisterAction(action: IAction): Boolean;
  26218. /**
  26219. * Does exist one action manager with at least one trigger
  26220. **/
  26221. static readonly HasTriggers: boolean;
  26222. /**
  26223. * Does exist one action manager with at least one pick trigger
  26224. **/
  26225. static readonly HasPickTriggers: boolean;
  26226. /**
  26227. * Does exist one action manager that handles actions of a given trigger
  26228. * @param trigger defines the trigger to be tested
  26229. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26230. **/
  26231. static HasSpecificTrigger(trigger: number): boolean;
  26232. }
  26233. }
  26234. declare module BABYLON {
  26235. /**
  26236. * Defines how a node can be built from a string name.
  26237. */
  26238. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26239. /**
  26240. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26241. */
  26242. export class Node implements IBehaviorAware<Node> {
  26243. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26244. private static _NodeConstructors;
  26245. /**
  26246. * Add a new node constructor
  26247. * @param type defines the type name of the node to construct
  26248. * @param constructorFunc defines the constructor function
  26249. */
  26250. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26251. /**
  26252. * Returns a node constructor based on type name
  26253. * @param type defines the type name
  26254. * @param name defines the new node name
  26255. * @param scene defines the hosting scene
  26256. * @param options defines optional options to transmit to constructors
  26257. * @returns the new constructor or null
  26258. */
  26259. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26260. /**
  26261. * Gets or sets the name of the node
  26262. */
  26263. name: string;
  26264. /**
  26265. * Gets or sets the id of the node
  26266. */
  26267. id: string;
  26268. /**
  26269. * Gets or sets the unique id of the node
  26270. */
  26271. uniqueId: number;
  26272. /**
  26273. * Gets or sets a string used to store user defined state for the node
  26274. */
  26275. state: string;
  26276. /**
  26277. * Gets or sets an object used to store user defined information for the node
  26278. */
  26279. metadata: any;
  26280. /**
  26281. * For internal use only. Please do not use.
  26282. */
  26283. reservedDataStore: any;
  26284. /**
  26285. * List of inspectable custom properties (used by the Inspector)
  26286. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26287. */
  26288. inspectableCustomProperties: IInspectable[];
  26289. private _doNotSerialize;
  26290. /**
  26291. * Gets or sets a boolean used to define if the node must be serialized
  26292. */
  26293. doNotSerialize: boolean;
  26294. /** @hidden */ private _isDisposed: boolean;
  26295. /**
  26296. * Gets a list of Animations associated with the node
  26297. */
  26298. animations: Animation[];
  26299. protected _ranges: {
  26300. [name: string]: Nullable<AnimationRange>;
  26301. };
  26302. /**
  26303. * Callback raised when the node is ready to be used
  26304. */
  26305. onReady: Nullable<(node: Node) => void>;
  26306. private _isEnabled;
  26307. private _isParentEnabled;
  26308. private _isReady;
  26309. /** @hidden */ private _currentRenderId: number;
  26310. private _parentUpdateId;
  26311. /** @hidden */ private _childUpdateId: number;
  26312. /** @hidden */ private _waitingParentId: Nullable<string>;
  26313. /** @hidden */ private _scene: Scene;
  26314. /** @hidden */ private _cache: any;
  26315. private _parentNode;
  26316. private _children;
  26317. /** @hidden */ private _worldMatrix: Matrix;
  26318. /** @hidden */ private _worldMatrixDeterminant: number;
  26319. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26320. /** @hidden */
  26321. private _sceneRootNodesIndex;
  26322. /**
  26323. * Gets a boolean indicating if the node has been disposed
  26324. * @returns true if the node was disposed
  26325. */
  26326. isDisposed(): boolean;
  26327. /**
  26328. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26329. * @see https://doc.babylonjs.com/how_to/parenting
  26330. */
  26331. parent: Nullable<Node>;
  26332. private addToSceneRootNodes;
  26333. private removeFromSceneRootNodes;
  26334. private _animationPropertiesOverride;
  26335. /**
  26336. * Gets or sets the animation properties override
  26337. */
  26338. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26339. /**
  26340. * Gets a string idenfifying the name of the class
  26341. * @returns "Node" string
  26342. */
  26343. getClassName(): string;
  26344. /** @hidden */ protected readonly _isNode: boolean;
  26345. /**
  26346. * An event triggered when the mesh is disposed
  26347. */
  26348. onDisposeObservable: Observable<Node>;
  26349. private _onDisposeObserver;
  26350. /**
  26351. * Sets a callback that will be raised when the node will be disposed
  26352. */
  26353. onDispose: () => void;
  26354. /**
  26355. * Creates a new Node
  26356. * @param name the name and id to be given to this node
  26357. * @param scene the scene this node will be added to
  26358. * @param addToRootNodes the node will be added to scene.rootNodes
  26359. */
  26360. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26361. /**
  26362. * Gets the scene of the node
  26363. * @returns a scene
  26364. */
  26365. getScene(): Scene;
  26366. /**
  26367. * Gets the engine of the node
  26368. * @returns a Engine
  26369. */
  26370. getEngine(): Engine;
  26371. private _behaviors;
  26372. /**
  26373. * Attach a behavior to the node
  26374. * @see http://doc.babylonjs.com/features/behaviour
  26375. * @param behavior defines the behavior to attach
  26376. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26377. * @returns the current Node
  26378. */
  26379. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26380. /**
  26381. * Remove an attached behavior
  26382. * @see http://doc.babylonjs.com/features/behaviour
  26383. * @param behavior defines the behavior to attach
  26384. * @returns the current Node
  26385. */
  26386. removeBehavior(behavior: Behavior<Node>): Node;
  26387. /**
  26388. * Gets the list of attached behaviors
  26389. * @see http://doc.babylonjs.com/features/behaviour
  26390. */
  26391. readonly behaviors: Behavior<Node>[];
  26392. /**
  26393. * Gets an attached behavior by name
  26394. * @param name defines the name of the behavior to look for
  26395. * @see http://doc.babylonjs.com/features/behaviour
  26396. * @returns null if behavior was not found else the requested behavior
  26397. */
  26398. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26399. /**
  26400. * Returns the latest update of the World matrix
  26401. * @returns a Matrix
  26402. */
  26403. getWorldMatrix(): Matrix;
  26404. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26405. /**
  26406. * Returns directly the latest state of the mesh World matrix.
  26407. * A Matrix is returned.
  26408. */
  26409. readonly worldMatrixFromCache: Matrix;
  26410. /** @hidden */ private _initCache(): void;
  26411. /** @hidden */
  26412. updateCache(force?: boolean): void;
  26413. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26414. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26415. /** @hidden */ private _isSynchronized(): boolean;
  26416. /** @hidden */ private _markSyncedWithParent(): void;
  26417. /** @hidden */
  26418. isSynchronizedWithParent(): boolean;
  26419. /** @hidden */
  26420. isSynchronized(): boolean;
  26421. /**
  26422. * Is this node ready to be used/rendered
  26423. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26424. * @return true if the node is ready
  26425. */
  26426. isReady(completeCheck?: boolean): boolean;
  26427. /**
  26428. * Is this node enabled?
  26429. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  26430. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  26431. * @return whether this node (and its parent) is enabled
  26432. */
  26433. isEnabled(checkAncestors?: boolean): boolean;
  26434. /** @hidden */
  26435. protected _syncParentEnabledState(): void;
  26436. /**
  26437. * Set the enabled state of this node
  26438. * @param value defines the new enabled state
  26439. */
  26440. setEnabled(value: boolean): void;
  26441. /**
  26442. * Is this node a descendant of the given node?
  26443. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26444. * @param ancestor defines the parent node to inspect
  26445. * @returns a boolean indicating if this node is a descendant of the given node
  26446. */
  26447. isDescendantOf(ancestor: Node): boolean;
  26448. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26449. /**
  26450. * Will return all nodes that have this node as ascendant
  26451. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  26452. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26453. * @return all children nodes of all types
  26454. */
  26455. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26456. /**
  26457. * Get all child-meshes of this node
  26458. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  26459. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26460. * @returns an array of AbstractMesh
  26461. */
  26462. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26463. /**
  26464. * Get all direct children of this node
  26465. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  26466. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  26467. * @returns an array of Node
  26468. */
  26469. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26470. /** @hidden */ private _setReady(state: boolean): void;
  26471. /**
  26472. * Get an animation by name
  26473. * @param name defines the name of the animation to look for
  26474. * @returns null if not found else the requested animation
  26475. */
  26476. getAnimationByName(name: string): Nullable<Animation>;
  26477. /**
  26478. * Creates an animation range for this node
  26479. * @param name defines the name of the range
  26480. * @param from defines the starting key
  26481. * @param to defines the end key
  26482. */
  26483. createAnimationRange(name: string, from: number, to: number): void;
  26484. /**
  26485. * Delete a specific animation range
  26486. * @param name defines the name of the range to delete
  26487. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26488. */
  26489. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26490. /**
  26491. * Get an animation range by name
  26492. * @param name defines the name of the animation range to look for
  26493. * @returns null if not found else the requested animation range
  26494. */
  26495. getAnimationRange(name: string): Nullable<AnimationRange>;
  26496. /**
  26497. * Gets the list of all animation ranges defined on this node
  26498. * @returns an array
  26499. */
  26500. getAnimationRanges(): Nullable<AnimationRange>[];
  26501. /**
  26502. * Will start the animation sequence
  26503. * @param name defines the range frames for animation sequence
  26504. * @param loop defines if the animation should loop (false by default)
  26505. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26506. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26507. * @returns the object created for this animation. If range does not exist, it will return null
  26508. */
  26509. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26510. /**
  26511. * Serialize animation ranges into a JSON compatible object
  26512. * @returns serialization object
  26513. */
  26514. serializeAnimationRanges(): any;
  26515. /**
  26516. * Computes the world matrix of the node
  26517. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26518. * @returns the world matrix
  26519. */
  26520. computeWorldMatrix(force?: boolean): Matrix;
  26521. /**
  26522. * Releases resources associated with this node.
  26523. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26524. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26525. */
  26526. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26527. /**
  26528. * Parse animation range data from a serialization object and store them into a given node
  26529. * @param node defines where to store the animation ranges
  26530. * @param parsedNode defines the serialization object to read data from
  26531. * @param scene defines the hosting scene
  26532. */
  26533. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26534. /**
  26535. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26536. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26537. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  26538. * @returns the new bounding vectors
  26539. */
  26540. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26541. min: Vector3;
  26542. max: Vector3;
  26543. };
  26544. }
  26545. }
  26546. declare module BABYLON {
  26547. /**
  26548. * @hidden
  26549. */
  26550. export class _IAnimationState {
  26551. key: number;
  26552. repeatCount: number;
  26553. workValue?: any;
  26554. loopMode?: number;
  26555. offsetValue?: any;
  26556. highLimitValue?: any;
  26557. }
  26558. /**
  26559. * Class used to store any kind of animation
  26560. */
  26561. export class Animation {
  26562. /**Name of the animation */
  26563. name: string;
  26564. /**Property to animate */
  26565. targetProperty: string;
  26566. /**The frames per second of the animation */
  26567. framePerSecond: number;
  26568. /**The data type of the animation */
  26569. dataType: number;
  26570. /**The loop mode of the animation */
  26571. loopMode?: number | undefined;
  26572. /**Specifies if blending should be enabled */
  26573. enableBlending?: boolean | undefined;
  26574. /**
  26575. * Use matrix interpolation instead of using direct key value when animating matrices
  26576. */
  26577. static AllowMatricesInterpolation: boolean;
  26578. /**
  26579. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26580. */
  26581. static AllowMatrixDecomposeForInterpolation: boolean;
  26582. /**
  26583. * Stores the key frames of the animation
  26584. */
  26585. private _keys;
  26586. /**
  26587. * Stores the easing function of the animation
  26588. */
  26589. private _easingFunction;
  26590. /**
  26591. * @hidden Internal use only
  26592. */ private _runtimeAnimations: RuntimeAnimation[];
  26593. /**
  26594. * The set of event that will be linked to this animation
  26595. */
  26596. private _events;
  26597. /**
  26598. * Stores an array of target property paths
  26599. */
  26600. targetPropertyPath: string[];
  26601. /**
  26602. * Stores the blending speed of the animation
  26603. */
  26604. blendingSpeed: number;
  26605. /**
  26606. * Stores the animation ranges for the animation
  26607. */
  26608. private _ranges;
  26609. /**
  26610. * @hidden Internal use
  26611. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26612. /**
  26613. * Sets up an animation
  26614. * @param property The property to animate
  26615. * @param animationType The animation type to apply
  26616. * @param framePerSecond The frames per second of the animation
  26617. * @param easingFunction The easing function used in the animation
  26618. * @returns The created animation
  26619. */
  26620. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26621. /**
  26622. * Create and start an animation on a node
  26623. * @param name defines the name of the global animation that will be run on all nodes
  26624. * @param node defines the root node where the animation will take place
  26625. * @param targetProperty defines property to animate
  26626. * @param framePerSecond defines the number of frame per second yo use
  26627. * @param totalFrame defines the number of frames in total
  26628. * @param from defines the initial value
  26629. * @param to defines the final value
  26630. * @param loopMode defines which loop mode you want to use (off by default)
  26631. * @param easingFunction defines the easing function to use (linear by default)
  26632. * @param onAnimationEnd defines the callback to call when animation end
  26633. * @returns the animatable created for this animation
  26634. */
  26635. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26636. /**
  26637. * Create and start an animation on a node and its descendants
  26638. * @param name defines the name of the global animation that will be run on all nodes
  26639. * @param node defines the root node where the animation will take place
  26640. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  26641. * @param targetProperty defines property to animate
  26642. * @param framePerSecond defines the number of frame per second to use
  26643. * @param totalFrame defines the number of frames in total
  26644. * @param from defines the initial value
  26645. * @param to defines the final value
  26646. * @param loopMode defines which loop mode you want to use (off by default)
  26647. * @param easingFunction defines the easing function to use (linear by default)
  26648. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26649. * @returns the list of animatables created for all nodes
  26650. * @example https://www.babylonjs-playground.com/#MH0VLI
  26651. */
  26652. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  26653. /**
  26654. * Creates a new animation, merges it with the existing animations and starts it
  26655. * @param name Name of the animation
  26656. * @param node Node which contains the scene that begins the animations
  26657. * @param targetProperty Specifies which property to animate
  26658. * @param framePerSecond The frames per second of the animation
  26659. * @param totalFrame The total number of frames
  26660. * @param from The frame at the beginning of the animation
  26661. * @param to The frame at the end of the animation
  26662. * @param loopMode Specifies the loop mode of the animation
  26663. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26664. * @param onAnimationEnd Callback to run once the animation is complete
  26665. * @returns Nullable animation
  26666. */
  26667. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26668. /**
  26669. * Transition property of an host to the target Value
  26670. * @param property The property to transition
  26671. * @param targetValue The target Value of the property
  26672. * @param host The object where the property to animate belongs
  26673. * @param scene Scene used to run the animation
  26674. * @param frameRate Framerate (in frame/s) to use
  26675. * @param transition The transition type we want to use
  26676. * @param duration The duration of the animation, in milliseconds
  26677. * @param onAnimationEnd Callback trigger at the end of the animation
  26678. * @returns Nullable animation
  26679. */
  26680. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26681. /**
  26682. * Return the array of runtime animations currently using this animation
  26683. */
  26684. readonly runtimeAnimations: RuntimeAnimation[];
  26685. /**
  26686. * Specifies if any of the runtime animations are currently running
  26687. */
  26688. readonly hasRunningRuntimeAnimations: boolean;
  26689. /**
  26690. * Initializes the animation
  26691. * @param name Name of the animation
  26692. * @param targetProperty Property to animate
  26693. * @param framePerSecond The frames per second of the animation
  26694. * @param dataType The data type of the animation
  26695. * @param loopMode The loop mode of the animation
  26696. * @param enableBlending Specifies if blending should be enabled
  26697. */
  26698. constructor(
  26699. /**Name of the animation */
  26700. name: string,
  26701. /**Property to animate */
  26702. targetProperty: string,
  26703. /**The frames per second of the animation */
  26704. framePerSecond: number,
  26705. /**The data type of the animation */
  26706. dataType: number,
  26707. /**The loop mode of the animation */
  26708. loopMode?: number | undefined,
  26709. /**Specifies if blending should be enabled */
  26710. enableBlending?: boolean | undefined);
  26711. /**
  26712. * Converts the animation to a string
  26713. * @param fullDetails support for multiple levels of logging within scene loading
  26714. * @returns String form of the animation
  26715. */
  26716. toString(fullDetails?: boolean): string;
  26717. /**
  26718. * Add an event to this animation
  26719. * @param event Event to add
  26720. */
  26721. addEvent(event: AnimationEvent): void;
  26722. /**
  26723. * Remove all events found at the given frame
  26724. * @param frame The frame to remove events from
  26725. */
  26726. removeEvents(frame: number): void;
  26727. /**
  26728. * Retrieves all the events from the animation
  26729. * @returns Events from the animation
  26730. */
  26731. getEvents(): AnimationEvent[];
  26732. /**
  26733. * Creates an animation range
  26734. * @param name Name of the animation range
  26735. * @param from Starting frame of the animation range
  26736. * @param to Ending frame of the animation
  26737. */
  26738. createRange(name: string, from: number, to: number): void;
  26739. /**
  26740. * Deletes an animation range by name
  26741. * @param name Name of the animation range to delete
  26742. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26743. */
  26744. deleteRange(name: string, deleteFrames?: boolean): void;
  26745. /**
  26746. * Gets the animation range by name, or null if not defined
  26747. * @param name Name of the animation range
  26748. * @returns Nullable animation range
  26749. */
  26750. getRange(name: string): Nullable<AnimationRange>;
  26751. /**
  26752. * Gets the key frames from the animation
  26753. * @returns The key frames of the animation
  26754. */
  26755. getKeys(): Array<IAnimationKey>;
  26756. /**
  26757. * Gets the highest frame rate of the animation
  26758. * @returns Highest frame rate of the animation
  26759. */
  26760. getHighestFrame(): number;
  26761. /**
  26762. * Gets the easing function of the animation
  26763. * @returns Easing function of the animation
  26764. */
  26765. getEasingFunction(): IEasingFunction;
  26766. /**
  26767. * Sets the easing function of the animation
  26768. * @param easingFunction A custom mathematical formula for animation
  26769. */
  26770. setEasingFunction(easingFunction: EasingFunction): void;
  26771. /**
  26772. * Interpolates a scalar linearly
  26773. * @param startValue Start value of the animation curve
  26774. * @param endValue End value of the animation curve
  26775. * @param gradient Scalar amount to interpolate
  26776. * @returns Interpolated scalar value
  26777. */
  26778. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26779. /**
  26780. * Interpolates a scalar cubically
  26781. * @param startValue Start value of the animation curve
  26782. * @param outTangent End tangent of the animation
  26783. * @param endValue End value of the animation curve
  26784. * @param inTangent Start tangent of the animation curve
  26785. * @param gradient Scalar amount to interpolate
  26786. * @returns Interpolated scalar value
  26787. */
  26788. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26789. /**
  26790. * Interpolates a quaternion using a spherical linear interpolation
  26791. * @param startValue Start value of the animation curve
  26792. * @param endValue End value of the animation curve
  26793. * @param gradient Scalar amount to interpolate
  26794. * @returns Interpolated quaternion value
  26795. */
  26796. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26797. /**
  26798. * Interpolates a quaternion cubically
  26799. * @param startValue Start value of the animation curve
  26800. * @param outTangent End tangent of the animation curve
  26801. * @param endValue End value of the animation curve
  26802. * @param inTangent Start tangent of the animation curve
  26803. * @param gradient Scalar amount to interpolate
  26804. * @returns Interpolated quaternion value
  26805. */
  26806. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26807. /**
  26808. * Interpolates a Vector3 linearl
  26809. * @param startValue Start value of the animation curve
  26810. * @param endValue End value of the animation curve
  26811. * @param gradient Scalar amount to interpolate
  26812. * @returns Interpolated scalar value
  26813. */
  26814. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26815. /**
  26816. * Interpolates a Vector3 cubically
  26817. * @param startValue Start value of the animation curve
  26818. * @param outTangent End tangent of the animation
  26819. * @param endValue End value of the animation curve
  26820. * @param inTangent Start tangent of the animation curve
  26821. * @param gradient Scalar amount to interpolate
  26822. * @returns InterpolatedVector3 value
  26823. */
  26824. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26825. /**
  26826. * Interpolates a Vector2 linearly
  26827. * @param startValue Start value of the animation curve
  26828. * @param endValue End value of the animation curve
  26829. * @param gradient Scalar amount to interpolate
  26830. * @returns Interpolated Vector2 value
  26831. */
  26832. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26833. /**
  26834. * Interpolates a Vector2 cubically
  26835. * @param startValue Start value of the animation curve
  26836. * @param outTangent End tangent of the animation
  26837. * @param endValue End value of the animation curve
  26838. * @param inTangent Start tangent of the animation curve
  26839. * @param gradient Scalar amount to interpolate
  26840. * @returns Interpolated Vector2 value
  26841. */
  26842. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26843. /**
  26844. * Interpolates a size linearly
  26845. * @param startValue Start value of the animation curve
  26846. * @param endValue End value of the animation curve
  26847. * @param gradient Scalar amount to interpolate
  26848. * @returns Interpolated Size value
  26849. */
  26850. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26851. /**
  26852. * Interpolates a Color3 linearly
  26853. * @param startValue Start value of the animation curve
  26854. * @param endValue End value of the animation curve
  26855. * @param gradient Scalar amount to interpolate
  26856. * @returns Interpolated Color3 value
  26857. */
  26858. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26859. /**
  26860. * @hidden Internal use only
  26861. */ private _getKeyValue(value: any): any;
  26862. /**
  26863. * @hidden Internal use only
  26864. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  26865. /**
  26866. * Defines the function to use to interpolate matrices
  26867. * @param startValue defines the start matrix
  26868. * @param endValue defines the end matrix
  26869. * @param gradient defines the gradient between both matrices
  26870. * @param result defines an optional target matrix where to store the interpolation
  26871. * @returns the interpolated matrix
  26872. */
  26873. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26874. /**
  26875. * Makes a copy of the animation
  26876. * @returns Cloned animation
  26877. */
  26878. clone(): Animation;
  26879. /**
  26880. * Sets the key frames of the animation
  26881. * @param values The animation key frames to set
  26882. */
  26883. setKeys(values: Array<IAnimationKey>): void;
  26884. /**
  26885. * Serializes the animation to an object
  26886. * @returns Serialized object
  26887. */
  26888. serialize(): any;
  26889. /**
  26890. * Float animation type
  26891. */
  26892. private static _ANIMATIONTYPE_FLOAT;
  26893. /**
  26894. * Vector3 animation type
  26895. */
  26896. private static _ANIMATIONTYPE_VECTOR3;
  26897. /**
  26898. * Quaternion animation type
  26899. */
  26900. private static _ANIMATIONTYPE_QUATERNION;
  26901. /**
  26902. * Matrix animation type
  26903. */
  26904. private static _ANIMATIONTYPE_MATRIX;
  26905. /**
  26906. * Color3 animation type
  26907. */
  26908. private static _ANIMATIONTYPE_COLOR3;
  26909. /**
  26910. * Vector2 animation type
  26911. */
  26912. private static _ANIMATIONTYPE_VECTOR2;
  26913. /**
  26914. * Size animation type
  26915. */
  26916. private static _ANIMATIONTYPE_SIZE;
  26917. /**
  26918. * Relative Loop Mode
  26919. */
  26920. private static _ANIMATIONLOOPMODE_RELATIVE;
  26921. /**
  26922. * Cycle Loop Mode
  26923. */
  26924. private static _ANIMATIONLOOPMODE_CYCLE;
  26925. /**
  26926. * Constant Loop Mode
  26927. */
  26928. private static _ANIMATIONLOOPMODE_CONSTANT;
  26929. /**
  26930. * Get the float animation type
  26931. */
  26932. static readonly ANIMATIONTYPE_FLOAT: number;
  26933. /**
  26934. * Get the Vector3 animation type
  26935. */
  26936. static readonly ANIMATIONTYPE_VECTOR3: number;
  26937. /**
  26938. * Get the Vector2 animation type
  26939. */
  26940. static readonly ANIMATIONTYPE_VECTOR2: number;
  26941. /**
  26942. * Get the Size animation type
  26943. */
  26944. static readonly ANIMATIONTYPE_SIZE: number;
  26945. /**
  26946. * Get the Quaternion animation type
  26947. */
  26948. static readonly ANIMATIONTYPE_QUATERNION: number;
  26949. /**
  26950. * Get the Matrix animation type
  26951. */
  26952. static readonly ANIMATIONTYPE_MATRIX: number;
  26953. /**
  26954. * Get the Color3 animation type
  26955. */
  26956. static readonly ANIMATIONTYPE_COLOR3: number;
  26957. /**
  26958. * Get the Relative Loop Mode
  26959. */
  26960. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26961. /**
  26962. * Get the Cycle Loop Mode
  26963. */
  26964. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26965. /**
  26966. * Get the Constant Loop Mode
  26967. */
  26968. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26969. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  26970. /**
  26971. * Parses an animation object and creates an animation
  26972. * @param parsedAnimation Parsed animation object
  26973. * @returns Animation object
  26974. */
  26975. static Parse(parsedAnimation: any): Animation;
  26976. /**
  26977. * Appends the serialized animations from the source animations
  26978. * @param source Source containing the animations
  26979. * @param destination Target to store the animations
  26980. */
  26981. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26982. }
  26983. }
  26984. declare module BABYLON {
  26985. /**
  26986. * Interface containing an array of animations
  26987. */
  26988. export interface IAnimatable {
  26989. /**
  26990. * Array of animations
  26991. */
  26992. animations: Nullable<Array<Animation>>;
  26993. }
  26994. }
  26995. declare module BABYLON {
  26996. /**
  26997. * This represents all the required information to add a fresnel effect on a material:
  26998. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26999. */
  27000. export class FresnelParameters {
  27001. private _isEnabled;
  27002. /**
  27003. * Define if the fresnel effect is enable or not.
  27004. */
  27005. isEnabled: boolean;
  27006. /**
  27007. * Define the color used on edges (grazing angle)
  27008. */
  27009. leftColor: Color3;
  27010. /**
  27011. * Define the color used on center
  27012. */
  27013. rightColor: Color3;
  27014. /**
  27015. * Define bias applied to computed fresnel term
  27016. */
  27017. bias: number;
  27018. /**
  27019. * Defined the power exponent applied to fresnel term
  27020. */
  27021. power: number;
  27022. /**
  27023. * Clones the current fresnel and its valuues
  27024. * @returns a clone fresnel configuration
  27025. */
  27026. clone(): FresnelParameters;
  27027. /**
  27028. * Serializes the current fresnel parameters to a JSON representation.
  27029. * @return the JSON serialization
  27030. */
  27031. serialize(): any;
  27032. /**
  27033. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27034. * @param parsedFresnelParameters Define the JSON representation
  27035. * @returns the parsed parameters
  27036. */
  27037. static Parse(parsedFresnelParameters: any): FresnelParameters;
  27038. }
  27039. }
  27040. declare module BABYLON {
  27041. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  27042. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27043. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27044. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27045. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27046. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27047. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27048. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27049. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27050. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27051. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27052. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27053. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27054. /**
  27055. * Decorator used to define property that can be serialized as reference to a camera
  27056. * @param sourceName defines the name of the property to decorate
  27057. */
  27058. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  27059. /**
  27060. * Class used to help serialization objects
  27061. */
  27062. export class SerializationHelper {
  27063. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  27064. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  27065. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  27066. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  27067. /**
  27068. * Appends the serialized animations from the source animations
  27069. * @param source Source containing the animations
  27070. * @param destination Target to store the animations
  27071. */
  27072. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  27073. /**
  27074. * Static function used to serialized a specific entity
  27075. * @param entity defines the entity to serialize
  27076. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  27077. * @returns a JSON compatible object representing the serialization of the entity
  27078. */
  27079. static Serialize<T>(entity: T, serializationObject?: any): any;
  27080. /**
  27081. * Creates a new entity from a serialization data object
  27082. * @param creationFunction defines a function used to instanciated the new entity
  27083. * @param source defines the source serialization data
  27084. * @param scene defines the hosting scene
  27085. * @param rootUrl defines the root url for resources
  27086. * @returns a new entity
  27087. */
  27088. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  27089. /**
  27090. * Clones an object
  27091. * @param creationFunction defines the function used to instanciate the new object
  27092. * @param source defines the source object
  27093. * @returns the cloned object
  27094. */
  27095. static Clone<T>(creationFunction: () => T, source: T): T;
  27096. /**
  27097. * Instanciates a new object based on a source one (some data will be shared between both object)
  27098. * @param creationFunction defines the function used to instanciate the new object
  27099. * @param source defines the source object
  27100. * @returns the new object
  27101. */
  27102. static Instanciate<T>(creationFunction: () => T, source: T): T;
  27103. }
  27104. }
  27105. declare module BABYLON {
  27106. /**
  27107. * Class used to manipulate GUIDs
  27108. */
  27109. export class GUID {
  27110. /**
  27111. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27112. * Be aware Math.random() could cause collisions, but:
  27113. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  27114. * @returns a pseudo random id
  27115. */
  27116. static RandomId(): string;
  27117. }
  27118. }
  27119. declare module BABYLON {
  27120. /**
  27121. * Base class of all the textures in babylon.
  27122. * It groups all the common properties the materials, post process, lights... might need
  27123. * in order to make a correct use of the texture.
  27124. */
  27125. export class BaseTexture implements IAnimatable {
  27126. /**
  27127. * Default anisotropic filtering level for the application.
  27128. * It is set to 4 as a good tradeoff between perf and quality.
  27129. */
  27130. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27131. /**
  27132. * Gets or sets the unique id of the texture
  27133. */
  27134. uniqueId: number;
  27135. /**
  27136. * Define the name of the texture.
  27137. */
  27138. name: string;
  27139. /**
  27140. * Gets or sets an object used to store user defined information.
  27141. */
  27142. metadata: any;
  27143. /**
  27144. * For internal use only. Please do not use.
  27145. */
  27146. reservedDataStore: any;
  27147. private _hasAlpha;
  27148. /**
  27149. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27150. */
  27151. hasAlpha: boolean;
  27152. /**
  27153. * Defines if the alpha value should be determined via the rgb values.
  27154. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27155. */
  27156. getAlphaFromRGB: boolean;
  27157. /**
  27158. * Intensity or strength of the texture.
  27159. * It is commonly used by materials to fine tune the intensity of the texture
  27160. */
  27161. level: number;
  27162. /**
  27163. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27164. * This is part of the texture as textures usually maps to one uv set.
  27165. */
  27166. coordinatesIndex: number;
  27167. private _coordinatesMode;
  27168. /**
  27169. * How a texture is mapped.
  27170. *
  27171. * | Value | Type | Description |
  27172. * | ----- | ----------------------------------- | ----------- |
  27173. * | 0 | EXPLICIT_MODE | |
  27174. * | 1 | SPHERICAL_MODE | |
  27175. * | 2 | PLANAR_MODE | |
  27176. * | 3 | CUBIC_MODE | |
  27177. * | 4 | PROJECTION_MODE | |
  27178. * | 5 | SKYBOX_MODE | |
  27179. * | 6 | INVCUBIC_MODE | |
  27180. * | 7 | EQUIRECTANGULAR_MODE | |
  27181. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27182. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27183. */
  27184. coordinatesMode: number;
  27185. /**
  27186. * | Value | Type | Description |
  27187. * | ----- | ------------------ | ----------- |
  27188. * | 0 | CLAMP_ADDRESSMODE | |
  27189. * | 1 | WRAP_ADDRESSMODE | |
  27190. * | 2 | MIRROR_ADDRESSMODE | |
  27191. */
  27192. wrapU: number;
  27193. /**
  27194. * | Value | Type | Description |
  27195. * | ----- | ------------------ | ----------- |
  27196. * | 0 | CLAMP_ADDRESSMODE | |
  27197. * | 1 | WRAP_ADDRESSMODE | |
  27198. * | 2 | MIRROR_ADDRESSMODE | |
  27199. */
  27200. wrapV: number;
  27201. /**
  27202. * | Value | Type | Description |
  27203. * | ----- | ------------------ | ----------- |
  27204. * | 0 | CLAMP_ADDRESSMODE | |
  27205. * | 1 | WRAP_ADDRESSMODE | |
  27206. * | 2 | MIRROR_ADDRESSMODE | |
  27207. */
  27208. wrapR: number;
  27209. /**
  27210. * With compliant hardware and browser (supporting anisotropic filtering)
  27211. * this defines the level of anisotropic filtering in the texture.
  27212. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27213. */
  27214. anisotropicFilteringLevel: number;
  27215. /**
  27216. * Define if the texture is a cube texture or if false a 2d texture.
  27217. */
  27218. isCube: boolean;
  27219. /**
  27220. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27221. */
  27222. is3D: boolean;
  27223. /**
  27224. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27225. * HDR texture are usually stored in linear space.
  27226. * This only impacts the PBR and Background materials
  27227. */
  27228. gammaSpace: boolean;
  27229. /**
  27230. * Gets or sets whether or not the texture contains RGBD data.
  27231. */
  27232. isRGBD: boolean;
  27233. /**
  27234. * Is Z inverted in the texture (useful in a cube texture).
  27235. */
  27236. invertZ: boolean;
  27237. /**
  27238. * Are mip maps generated for this texture or not.
  27239. */
  27240. readonly noMipmap: boolean;
  27241. /**
  27242. * @hidden
  27243. */
  27244. lodLevelInAlpha: boolean;
  27245. /**
  27246. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27247. */
  27248. lodGenerationOffset: number;
  27249. /**
  27250. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27251. */
  27252. lodGenerationScale: number;
  27253. /**
  27254. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27255. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27256. * average roughness values.
  27257. */
  27258. linearSpecularLOD: boolean;
  27259. /**
  27260. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27261. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27262. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27263. */
  27264. irradianceTexture: Nullable<BaseTexture>;
  27265. /**
  27266. * Define if the texture is a render target.
  27267. */
  27268. isRenderTarget: boolean;
  27269. /**
  27270. * Define the unique id of the texture in the scene.
  27271. */
  27272. readonly uid: string;
  27273. /**
  27274. * Return a string representation of the texture.
  27275. * @returns the texture as a string
  27276. */
  27277. toString(): string;
  27278. /**
  27279. * Get the class name of the texture.
  27280. * @returns "BaseTexture"
  27281. */
  27282. getClassName(): string;
  27283. /**
  27284. * Define the list of animation attached to the texture.
  27285. */
  27286. animations: Animation[];
  27287. /**
  27288. * An event triggered when the texture is disposed.
  27289. */
  27290. onDisposeObservable: Observable<BaseTexture>;
  27291. private _onDisposeObserver;
  27292. /**
  27293. * Callback triggered when the texture has been disposed.
  27294. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27295. */
  27296. onDispose: () => void;
  27297. /**
  27298. * Define the current state of the loading sequence when in delayed load mode.
  27299. */
  27300. delayLoadState: number;
  27301. private _scene;
  27302. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27303. private _uid;
  27304. /**
  27305. * Define if the texture is preventinga material to render or not.
  27306. * If not and the texture is not ready, the engine will use a default black texture instead.
  27307. */
  27308. readonly isBlocking: boolean;
  27309. /**
  27310. * Instantiates a new BaseTexture.
  27311. * Base class of all the textures in babylon.
  27312. * It groups all the common properties the materials, post process, lights... might need
  27313. * in order to make a correct use of the texture.
  27314. * @param scene Define the scene the texture blongs to
  27315. */
  27316. constructor(scene: Nullable<Scene>);
  27317. /**
  27318. * Get the scene the texture belongs to.
  27319. * @returns the scene or null if undefined
  27320. */
  27321. getScene(): Nullable<Scene>;
  27322. /**
  27323. * Get the texture transform matrix used to offset tile the texture for istance.
  27324. * @returns the transformation matrix
  27325. */
  27326. getTextureMatrix(): Matrix;
  27327. /**
  27328. * Get the texture reflection matrix used to rotate/transform the reflection.
  27329. * @returns the reflection matrix
  27330. */
  27331. getReflectionTextureMatrix(): Matrix;
  27332. /**
  27333. * Get the underlying lower level texture from Babylon.
  27334. * @returns the insternal texture
  27335. */
  27336. getInternalTexture(): Nullable<InternalTexture>;
  27337. /**
  27338. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27339. * @returns true if ready or not blocking
  27340. */
  27341. isReadyOrNotBlocking(): boolean;
  27342. /**
  27343. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27344. * @returns true if fully ready
  27345. */
  27346. isReady(): boolean;
  27347. private _cachedSize;
  27348. /**
  27349. * Get the size of the texture.
  27350. * @returns the texture size.
  27351. */
  27352. getSize(): ISize;
  27353. /**
  27354. * Get the base size of the texture.
  27355. * It can be different from the size if the texture has been resized for POT for instance
  27356. * @returns the base size
  27357. */
  27358. getBaseSize(): ISize;
  27359. /**
  27360. * Update the sampling mode of the texture.
  27361. * Default is Trilinear mode.
  27362. *
  27363. * | Value | Type | Description |
  27364. * | ----- | ------------------ | ----------- |
  27365. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27366. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27367. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27368. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27369. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27370. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27371. * | 7 | NEAREST_LINEAR | |
  27372. * | 8 | NEAREST_NEAREST | |
  27373. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27374. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27375. * | 11 | LINEAR_LINEAR | |
  27376. * | 12 | LINEAR_NEAREST | |
  27377. *
  27378. * > _mag_: magnification filter (close to the viewer)
  27379. * > _min_: minification filter (far from the viewer)
  27380. * > _mip_: filter used between mip map levels
  27381. *@param samplingMode Define the new sampling mode of the texture
  27382. */
  27383. updateSamplingMode(samplingMode: number): void;
  27384. /**
  27385. * Scales the texture if is `canRescale()`
  27386. * @param ratio the resize factor we want to use to rescale
  27387. */
  27388. scale(ratio: number): void;
  27389. /**
  27390. * Get if the texture can rescale.
  27391. */
  27392. readonly canRescale: boolean;
  27393. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27394. /** @hidden */ private _rebuild(): void;
  27395. /**
  27396. * Triggers the load sequence in delayed load mode.
  27397. */
  27398. delayLoad(): void;
  27399. /**
  27400. * Clones the texture.
  27401. * @returns the cloned texture
  27402. */
  27403. clone(): Nullable<BaseTexture>;
  27404. /**
  27405. * Get the texture underlying type (INT, FLOAT...)
  27406. */
  27407. readonly textureType: number;
  27408. /**
  27409. * Get the texture underlying format (RGB, RGBA...)
  27410. */
  27411. readonly textureFormat: number;
  27412. /**
  27413. * Indicates that textures need to be re-calculated for all materials
  27414. */
  27415. protected _markAllSubMeshesAsTexturesDirty(): void;
  27416. /**
  27417. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27418. * This will returns an RGBA array buffer containing either in values (0-255) or
  27419. * float values (0-1) depending of the underlying buffer type.
  27420. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27421. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27422. * @param buffer defines a user defined buffer to fill with data (can be null)
  27423. * @returns The Array buffer containing the pixels data.
  27424. */
  27425. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27426. /**
  27427. * Release and destroy the underlying lower level texture aka internalTexture.
  27428. */
  27429. releaseInternalTexture(): void;
  27430. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27431. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27432. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27433. /**
  27434. * Dispose the texture and release its associated resources.
  27435. */
  27436. dispose(): void;
  27437. /**
  27438. * Serialize the texture into a JSON representation that can be parsed later on.
  27439. * @returns the JSON representation of the texture
  27440. */
  27441. serialize(): any;
  27442. /**
  27443. * Helper function to be called back once a list of texture contains only ready textures.
  27444. * @param textures Define the list of textures to wait for
  27445. * @param callback Define the callback triggered once the entire list will be ready
  27446. */
  27447. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27448. }
  27449. }
  27450. declare module BABYLON {
  27451. /**
  27452. * Options to be used when creating an effect.
  27453. */
  27454. export interface IEffectCreationOptions {
  27455. /**
  27456. * Atrributes that will be used in the shader.
  27457. */
  27458. attributes: string[];
  27459. /**
  27460. * Uniform varible names that will be set in the shader.
  27461. */
  27462. uniformsNames: string[];
  27463. /**
  27464. * Uniform buffer varible names that will be set in the shader.
  27465. */
  27466. uniformBuffersNames: string[];
  27467. /**
  27468. * Sampler texture variable names that will be set in the shader.
  27469. */
  27470. samplers: string[];
  27471. /**
  27472. * Define statements that will be set in the shader.
  27473. */
  27474. defines: any;
  27475. /**
  27476. * Possible fallbacks for this effect to improve performance when needed.
  27477. */
  27478. fallbacks: Nullable<IEffectFallbacks>;
  27479. /**
  27480. * Callback that will be called when the shader is compiled.
  27481. */
  27482. onCompiled: Nullable<(effect: Effect) => void>;
  27483. /**
  27484. * Callback that will be called if an error occurs during shader compilation.
  27485. */
  27486. onError: Nullable<(effect: Effect, errors: string) => void>;
  27487. /**
  27488. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27489. */
  27490. indexParameters?: any;
  27491. /**
  27492. * Max number of lights that can be used in the shader.
  27493. */
  27494. maxSimultaneousLights?: number;
  27495. /**
  27496. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27497. */
  27498. transformFeedbackVaryings?: Nullable<string[]>;
  27499. }
  27500. /**
  27501. * Effect containing vertex and fragment shader that can be executed on an object.
  27502. */
  27503. export class Effect implements IDisposable {
  27504. /**
  27505. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27506. */
  27507. static ShadersRepository: string;
  27508. /**
  27509. * Name of the effect.
  27510. */
  27511. name: any;
  27512. /**
  27513. * String container all the define statements that should be set on the shader.
  27514. */
  27515. defines: string;
  27516. /**
  27517. * Callback that will be called when the shader is compiled.
  27518. */
  27519. onCompiled: Nullable<(effect: Effect) => void>;
  27520. /**
  27521. * Callback that will be called if an error occurs during shader compilation.
  27522. */
  27523. onError: Nullable<(effect: Effect, errors: string) => void>;
  27524. /**
  27525. * Callback that will be called when effect is bound.
  27526. */
  27527. onBind: Nullable<(effect: Effect) => void>;
  27528. /**
  27529. * Unique ID of the effect.
  27530. */
  27531. uniqueId: number;
  27532. /**
  27533. * Observable that will be called when the shader is compiled.
  27534. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27535. */
  27536. onCompileObservable: Observable<Effect>;
  27537. /**
  27538. * Observable that will be called if an error occurs during shader compilation.
  27539. */
  27540. onErrorObservable: Observable<Effect>;
  27541. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27542. /**
  27543. * Observable that will be called when effect is bound.
  27544. */
  27545. readonly onBindObservable: Observable<Effect>;
  27546. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27547. private static _uniqueIdSeed;
  27548. private _engine;
  27549. private _uniformBuffersNames;
  27550. private _uniformsNames;
  27551. private _samplerList;
  27552. private _samplers;
  27553. private _isReady;
  27554. private _compilationError;
  27555. private _allFallbacksProcessed;
  27556. private _attributesNames;
  27557. private _attributes;
  27558. private _uniforms;
  27559. /**
  27560. * Key for the effect.
  27561. * @hidden
  27562. */ private _key: string;
  27563. private _indexParameters;
  27564. private _fallbacks;
  27565. private _vertexSourceCode;
  27566. private _fragmentSourceCode;
  27567. private _vertexSourceCodeOverride;
  27568. private _fragmentSourceCodeOverride;
  27569. private _transformFeedbackVaryings;
  27570. /**
  27571. * Compiled shader to webGL program.
  27572. * @hidden
  27573. */ private _pipelineContext: Nullable<IPipelineContext>;
  27574. private _valueCache;
  27575. private static _baseCache;
  27576. /**
  27577. * Instantiates an effect.
  27578. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27579. * @param baseName Name of the effect.
  27580. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27581. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27582. * @param samplers List of sampler variables that will be passed to the shader.
  27583. * @param engine Engine to be used to render the effect
  27584. * @param defines Define statements to be added to the shader.
  27585. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27586. * @param onCompiled Callback that will be called when the shader is compiled.
  27587. * @param onError Callback that will be called if an error occurs during shader compilation.
  27588. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27589. */
  27590. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  27591. private _useFinalCode;
  27592. /**
  27593. * Unique key for this effect
  27594. */
  27595. readonly key: string;
  27596. /**
  27597. * If the effect has been compiled and prepared.
  27598. * @returns if the effect is compiled and prepared.
  27599. */
  27600. isReady(): boolean;
  27601. private _isReadyInternal;
  27602. /**
  27603. * The engine the effect was initialized with.
  27604. * @returns the engine.
  27605. */
  27606. getEngine(): Engine;
  27607. /**
  27608. * The pipeline context for this effect
  27609. * @returns the associated pipeline context
  27610. */
  27611. getPipelineContext(): Nullable<IPipelineContext>;
  27612. /**
  27613. * The set of names of attribute variables for the shader.
  27614. * @returns An array of attribute names.
  27615. */
  27616. getAttributesNames(): string[];
  27617. /**
  27618. * Returns the attribute at the given index.
  27619. * @param index The index of the attribute.
  27620. * @returns The location of the attribute.
  27621. */
  27622. getAttributeLocation(index: number): number;
  27623. /**
  27624. * Returns the attribute based on the name of the variable.
  27625. * @param name of the attribute to look up.
  27626. * @returns the attribute location.
  27627. */
  27628. getAttributeLocationByName(name: string): number;
  27629. /**
  27630. * The number of attributes.
  27631. * @returns the numnber of attributes.
  27632. */
  27633. getAttributesCount(): number;
  27634. /**
  27635. * Gets the index of a uniform variable.
  27636. * @param uniformName of the uniform to look up.
  27637. * @returns the index.
  27638. */
  27639. getUniformIndex(uniformName: string): number;
  27640. /**
  27641. * Returns the attribute based on the name of the variable.
  27642. * @param uniformName of the uniform to look up.
  27643. * @returns the location of the uniform.
  27644. */
  27645. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27646. /**
  27647. * Returns an array of sampler variable names
  27648. * @returns The array of sampler variable neames.
  27649. */
  27650. getSamplers(): string[];
  27651. /**
  27652. * The error from the last compilation.
  27653. * @returns the error string.
  27654. */
  27655. getCompilationError(): string;
  27656. /**
  27657. * Gets a boolean indicating that all fallbacks were used during compilation
  27658. * @returns true if all fallbacks were used
  27659. */
  27660. allFallbacksProcessed(): boolean;
  27661. /**
  27662. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27663. * @param func The callback to be used.
  27664. */
  27665. executeWhenCompiled(func: (effect: Effect) => void): void;
  27666. private _checkIsReady;
  27667. private _loadShader;
  27668. /**
  27669. * Recompiles the webGL program
  27670. * @param vertexSourceCode The source code for the vertex shader.
  27671. * @param fragmentSourceCode The source code for the fragment shader.
  27672. * @param onCompiled Callback called when completed.
  27673. * @param onError Callback called on error.
  27674. * @hidden
  27675. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27676. /**
  27677. * Prepares the effect
  27678. * @hidden
  27679. */ private _prepareEffect(): void;
  27680. private _processCompilationErrors;
  27681. /**
  27682. * Checks if the effect is supported. (Must be called after compilation)
  27683. */
  27684. readonly isSupported: boolean;
  27685. /**
  27686. * Binds a texture to the engine to be used as output of the shader.
  27687. * @param channel Name of the output variable.
  27688. * @param texture Texture to bind.
  27689. * @hidden
  27690. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  27691. /**
  27692. * Sets a texture on the engine to be used in the shader.
  27693. * @param channel Name of the sampler variable.
  27694. * @param texture Texture to set.
  27695. */
  27696. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27697. /**
  27698. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27699. * @param channel Name of the sampler variable.
  27700. * @param texture Texture to set.
  27701. */
  27702. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27703. /**
  27704. * Sets an array of textures on the engine to be used in the shader.
  27705. * @param channel Name of the variable.
  27706. * @param textures Textures to set.
  27707. */
  27708. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27709. /**
  27710. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  27711. * @param channel Name of the sampler variable.
  27712. * @param postProcess Post process to get the input texture from.
  27713. */
  27714. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27715. /**
  27716. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27717. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  27718. * @param channel Name of the sampler variable.
  27719. * @param postProcess Post process to get the output texture from.
  27720. */
  27721. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27722. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  27723. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27724. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27725. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27726. /**
  27727. * Binds a buffer to a uniform.
  27728. * @param buffer Buffer to bind.
  27729. * @param name Name of the uniform variable to bind to.
  27730. */
  27731. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  27732. /**
  27733. * Binds block to a uniform.
  27734. * @param blockName Name of the block to bind.
  27735. * @param index Index to bind.
  27736. */
  27737. bindUniformBlock(blockName: string, index: number): void;
  27738. /**
  27739. * Sets an interger value on a uniform variable.
  27740. * @param uniformName Name of the variable.
  27741. * @param value Value to be set.
  27742. * @returns this effect.
  27743. */
  27744. setInt(uniformName: string, value: number): Effect;
  27745. /**
  27746. * Sets an int array on a uniform variable.
  27747. * @param uniformName Name of the variable.
  27748. * @param array array to be set.
  27749. * @returns this effect.
  27750. */
  27751. setIntArray(uniformName: string, array: Int32Array): Effect;
  27752. /**
  27753. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  27754. * @param uniformName Name of the variable.
  27755. * @param array array to be set.
  27756. * @returns this effect.
  27757. */
  27758. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27759. /**
  27760. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  27761. * @param uniformName Name of the variable.
  27762. * @param array array to be set.
  27763. * @returns this effect.
  27764. */
  27765. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27766. /**
  27767. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  27768. * @param uniformName Name of the variable.
  27769. * @param array array to be set.
  27770. * @returns this effect.
  27771. */
  27772. setIntArray4(uniformName: string, array: Int32Array): Effect;
  27773. /**
  27774. * Sets an float array on a uniform variable.
  27775. * @param uniformName Name of the variable.
  27776. * @param array array to be set.
  27777. * @returns this effect.
  27778. */
  27779. setFloatArray(uniformName: string, array: Float32Array): Effect;
  27780. /**
  27781. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  27782. * @param uniformName Name of the variable.
  27783. * @param array array to be set.
  27784. * @returns this effect.
  27785. */
  27786. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  27787. /**
  27788. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  27789. * @param uniformName Name of the variable.
  27790. * @param array array to be set.
  27791. * @returns this effect.
  27792. */
  27793. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  27794. /**
  27795. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  27796. * @param uniformName Name of the variable.
  27797. * @param array array to be set.
  27798. * @returns this effect.
  27799. */
  27800. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  27801. /**
  27802. * Sets an array on a uniform variable.
  27803. * @param uniformName Name of the variable.
  27804. * @param array array to be set.
  27805. * @returns this effect.
  27806. */
  27807. setArray(uniformName: string, array: number[]): Effect;
  27808. /**
  27809. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  27810. * @param uniformName Name of the variable.
  27811. * @param array array to be set.
  27812. * @returns this effect.
  27813. */
  27814. setArray2(uniformName: string, array: number[]): Effect;
  27815. /**
  27816. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  27817. * @param uniformName Name of the variable.
  27818. * @param array array to be set.
  27819. * @returns this effect.
  27820. */
  27821. setArray3(uniformName: string, array: number[]): Effect;
  27822. /**
  27823. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  27824. * @param uniformName Name of the variable.
  27825. * @param array array to be set.
  27826. * @returns this effect.
  27827. */
  27828. setArray4(uniformName: string, array: number[]): Effect;
  27829. /**
  27830. * Sets matrices on a uniform variable.
  27831. * @param uniformName Name of the variable.
  27832. * @param matrices matrices to be set.
  27833. * @returns this effect.
  27834. */
  27835. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  27836. /**
  27837. * Sets matrix on a uniform variable.
  27838. * @param uniformName Name of the variable.
  27839. * @param matrix matrix to be set.
  27840. * @returns this effect.
  27841. */
  27842. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  27843. /**
  27844. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  27845. * @param uniformName Name of the variable.
  27846. * @param matrix matrix to be set.
  27847. * @returns this effect.
  27848. */
  27849. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  27850. /**
  27851. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  27852. * @param uniformName Name of the variable.
  27853. * @param matrix matrix to be set.
  27854. * @returns this effect.
  27855. */
  27856. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  27857. /**
  27858. * Sets a float on a uniform variable.
  27859. * @param uniformName Name of the variable.
  27860. * @param value value to be set.
  27861. * @returns this effect.
  27862. */
  27863. setFloat(uniformName: string, value: number): Effect;
  27864. /**
  27865. * Sets a boolean on a uniform variable.
  27866. * @param uniformName Name of the variable.
  27867. * @param bool value to be set.
  27868. * @returns this effect.
  27869. */
  27870. setBool(uniformName: string, bool: boolean): Effect;
  27871. /**
  27872. * Sets a Vector2 on a uniform variable.
  27873. * @param uniformName Name of the variable.
  27874. * @param vector2 vector2 to be set.
  27875. * @returns this effect.
  27876. */
  27877. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  27878. /**
  27879. * Sets a float2 on a uniform variable.
  27880. * @param uniformName Name of the variable.
  27881. * @param x First float in float2.
  27882. * @param y Second float in float2.
  27883. * @returns this effect.
  27884. */
  27885. setFloat2(uniformName: string, x: number, y: number): Effect;
  27886. /**
  27887. * Sets a Vector3 on a uniform variable.
  27888. * @param uniformName Name of the variable.
  27889. * @param vector3 Value to be set.
  27890. * @returns this effect.
  27891. */
  27892. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  27893. /**
  27894. * Sets a float3 on a uniform variable.
  27895. * @param uniformName Name of the variable.
  27896. * @param x First float in float3.
  27897. * @param y Second float in float3.
  27898. * @param z Third float in float3.
  27899. * @returns this effect.
  27900. */
  27901. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  27902. /**
  27903. * Sets a Vector4 on a uniform variable.
  27904. * @param uniformName Name of the variable.
  27905. * @param vector4 Value to be set.
  27906. * @returns this effect.
  27907. */
  27908. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  27909. /**
  27910. * Sets a float4 on a uniform variable.
  27911. * @param uniformName Name of the variable.
  27912. * @param x First float in float4.
  27913. * @param y Second float in float4.
  27914. * @param z Third float in float4.
  27915. * @param w Fourth float in float4.
  27916. * @returns this effect.
  27917. */
  27918. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  27919. /**
  27920. * Sets a Color3 on a uniform variable.
  27921. * @param uniformName Name of the variable.
  27922. * @param color3 Value to be set.
  27923. * @returns this effect.
  27924. */
  27925. setColor3(uniformName: string, color3: IColor3Like): Effect;
  27926. /**
  27927. * Sets a Color4 on a uniform variable.
  27928. * @param uniformName Name of the variable.
  27929. * @param color3 Value to be set.
  27930. * @param alpha Alpha value to be set.
  27931. * @returns this effect.
  27932. */
  27933. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  27934. /**
  27935. * Sets a Color4 on a uniform variable
  27936. * @param uniformName defines the name of the variable
  27937. * @param color4 defines the value to be set
  27938. * @returns this effect.
  27939. */
  27940. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  27941. /** Release all associated resources */
  27942. dispose(): void;
  27943. /**
  27944. * This function will add a new shader to the shader store
  27945. * @param name the name of the shader
  27946. * @param pixelShader optional pixel shader content
  27947. * @param vertexShader optional vertex shader content
  27948. */
  27949. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  27950. /**
  27951. * Store of each shader (The can be looked up using effect.key)
  27952. */
  27953. static ShadersStore: {
  27954. [key: string]: string;
  27955. };
  27956. /**
  27957. * Store of each included file for a shader (The can be looked up using effect.key)
  27958. */
  27959. static IncludesShadersStore: {
  27960. [key: string]: string;
  27961. };
  27962. /**
  27963. * Resets the cache of effects.
  27964. */
  27965. static ResetCache(): void;
  27966. }
  27967. }
  27968. declare module BABYLON {
  27969. /**
  27970. * Class used to describe the capabilities of the engine relatively to the current browser
  27971. */
  27972. export class EngineCapabilities {
  27973. /** Maximum textures units per fragment shader */
  27974. maxTexturesImageUnits: number;
  27975. /** Maximum texture units per vertex shader */
  27976. maxVertexTextureImageUnits: number;
  27977. /** Maximum textures units in the entire pipeline */
  27978. maxCombinedTexturesImageUnits: number;
  27979. /** Maximum texture size */
  27980. maxTextureSize: number;
  27981. /** Maximum cube texture size */
  27982. maxCubemapTextureSize: number;
  27983. /** Maximum render texture size */
  27984. maxRenderTextureSize: number;
  27985. /** Maximum number of vertex attributes */
  27986. maxVertexAttribs: number;
  27987. /** Maximum number of varyings */
  27988. maxVaryingVectors: number;
  27989. /** Maximum number of uniforms per vertex shader */
  27990. maxVertexUniformVectors: number;
  27991. /** Maximum number of uniforms per fragment shader */
  27992. maxFragmentUniformVectors: number;
  27993. /** Defines if standard derivates (dx/dy) are supported */
  27994. standardDerivatives: boolean;
  27995. /** Defines if s3tc texture compression is supported */
  27996. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27997. /** Defines if pvrtc texture compression is supported */
  27998. pvrtc: any;
  27999. /** Defines if etc1 texture compression is supported */
  28000. etc1: any;
  28001. /** Defines if etc2 texture compression is supported */
  28002. etc2: any;
  28003. /** Defines if astc texture compression is supported */
  28004. astc: any;
  28005. /** Defines if float textures are supported */
  28006. textureFloat: boolean;
  28007. /** Defines if vertex array objects are supported */
  28008. vertexArrayObject: boolean;
  28009. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28010. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28011. /** Gets the maximum level of anisotropy supported */
  28012. maxAnisotropy: number;
  28013. /** Defines if instancing is supported */
  28014. instancedArrays: boolean;
  28015. /** Defines if 32 bits indices are supported */
  28016. uintIndices: boolean;
  28017. /** Defines if high precision shaders are supported */
  28018. highPrecisionShaderSupported: boolean;
  28019. /** Defines if depth reading in the fragment shader is supported */
  28020. fragmentDepthSupported: boolean;
  28021. /** Defines if float texture linear filtering is supported*/
  28022. textureFloatLinearFiltering: boolean;
  28023. /** Defines if rendering to float textures is supported */
  28024. textureFloatRender: boolean;
  28025. /** Defines if half float textures are supported*/
  28026. textureHalfFloat: boolean;
  28027. /** Defines if half float texture linear filtering is supported*/
  28028. textureHalfFloatLinearFiltering: boolean;
  28029. /** Defines if rendering to half float textures is supported */
  28030. textureHalfFloatRender: boolean;
  28031. /** Defines if textureLOD shader command is supported */
  28032. textureLOD: boolean;
  28033. /** Defines if draw buffers extension is supported */
  28034. drawBuffersExtension: boolean;
  28035. /** Defines if depth textures are supported */
  28036. depthTextureExtension: boolean;
  28037. /** Defines if float color buffer are supported */
  28038. colorBufferFloat: boolean;
  28039. /** Gets disjoint timer query extension (null if not supported) */
  28040. timerQuery: EXT_disjoint_timer_query;
  28041. /** Defines if timestamp can be used with timer query */
  28042. canUseTimestampForTimerQuery: boolean;
  28043. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28044. multiview: any;
  28045. /** Function used to let the system compiles shaders in background */
  28046. parallelShaderCompile: {
  28047. COMPLETION_STATUS_KHR: number;
  28048. };
  28049. /** Max number of texture samples for MSAA */
  28050. maxMSAASamples: number;
  28051. /** Defines if the blend min max extension is supported */
  28052. blendMinMax: boolean;
  28053. }
  28054. }
  28055. declare module BABYLON {
  28056. /**
  28057. * @hidden
  28058. **/
  28059. export class DepthCullingState {
  28060. private _isDepthTestDirty;
  28061. private _isDepthMaskDirty;
  28062. private _isDepthFuncDirty;
  28063. private _isCullFaceDirty;
  28064. private _isCullDirty;
  28065. private _isZOffsetDirty;
  28066. private _isFrontFaceDirty;
  28067. private _depthTest;
  28068. private _depthMask;
  28069. private _depthFunc;
  28070. private _cull;
  28071. private _cullFace;
  28072. private _zOffset;
  28073. private _frontFace;
  28074. /**
  28075. * Initializes the state.
  28076. */
  28077. constructor();
  28078. readonly isDirty: boolean;
  28079. zOffset: number;
  28080. cullFace: Nullable<number>;
  28081. cull: Nullable<boolean>;
  28082. depthFunc: Nullable<number>;
  28083. depthMask: boolean;
  28084. depthTest: boolean;
  28085. frontFace: Nullable<number>;
  28086. reset(): void;
  28087. apply(gl: WebGLRenderingContext): void;
  28088. }
  28089. }
  28090. declare module BABYLON {
  28091. /**
  28092. * @hidden
  28093. **/
  28094. export class StencilState {
  28095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  28096. static readonly ALWAYS: number;
  28097. /** Passed to stencilOperation to specify that stencil value must be kept */
  28098. static readonly KEEP: number;
  28099. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28100. static readonly REPLACE: number;
  28101. private _isStencilTestDirty;
  28102. private _isStencilMaskDirty;
  28103. private _isStencilFuncDirty;
  28104. private _isStencilOpDirty;
  28105. private _stencilTest;
  28106. private _stencilMask;
  28107. private _stencilFunc;
  28108. private _stencilFuncRef;
  28109. private _stencilFuncMask;
  28110. private _stencilOpStencilFail;
  28111. private _stencilOpDepthFail;
  28112. private _stencilOpStencilDepthPass;
  28113. readonly isDirty: boolean;
  28114. stencilFunc: number;
  28115. stencilFuncRef: number;
  28116. stencilFuncMask: number;
  28117. stencilOpStencilFail: number;
  28118. stencilOpDepthFail: number;
  28119. stencilOpStencilDepthPass: number;
  28120. stencilMask: number;
  28121. stencilTest: boolean;
  28122. constructor();
  28123. reset(): void;
  28124. apply(gl: WebGLRenderingContext): void;
  28125. }
  28126. }
  28127. declare module BABYLON {
  28128. /**
  28129. * @hidden
  28130. **/
  28131. export class AlphaState {
  28132. private _isAlphaBlendDirty;
  28133. private _isBlendFunctionParametersDirty;
  28134. private _isBlendEquationParametersDirty;
  28135. private _isBlendConstantsDirty;
  28136. private _alphaBlend;
  28137. private _blendFunctionParameters;
  28138. private _blendEquationParameters;
  28139. private _blendConstants;
  28140. /**
  28141. * Initializes the state.
  28142. */
  28143. constructor();
  28144. readonly isDirty: boolean;
  28145. alphaBlend: boolean;
  28146. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  28147. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  28148. setAlphaEquationParameters(rgb: number, alpha: number): void;
  28149. reset(): void;
  28150. apply(gl: WebGLRenderingContext): void;
  28151. }
  28152. }
  28153. declare module BABYLON {
  28154. /** @hidden */
  28155. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28156. attributeProcessor(attribute: string): string;
  28157. varyingProcessor(varying: string, isFragment: boolean): string;
  28158. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28159. }
  28160. }
  28161. declare module BABYLON {
  28162. /**
  28163. * Interface for attribute information associated with buffer instanciation
  28164. */
  28165. export class InstancingAttributeInfo {
  28166. /**
  28167. * Index/offset of the attribute in the vertex shader
  28168. */
  28169. index: number;
  28170. /**
  28171. * size of the attribute, 1, 2, 3 or 4
  28172. */
  28173. attributeSize: number;
  28174. /**
  28175. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28176. * default is FLOAT
  28177. */
  28178. attribyteType: number;
  28179. /**
  28180. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28181. */
  28182. normalized: boolean;
  28183. /**
  28184. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28185. */
  28186. offset: number;
  28187. /**
  28188. * Name of the GLSL attribute, for debugging purpose only
  28189. */
  28190. attributeName: string;
  28191. }
  28192. }
  28193. declare module BABYLON {
  28194. interface ThinEngine {
  28195. /**
  28196. * Update a video texture
  28197. * @param texture defines the texture to update
  28198. * @param video defines the video element to use
  28199. * @param invertY defines if data must be stored with Y axis inverted
  28200. */
  28201. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28202. }
  28203. }
  28204. declare module BABYLON {
  28205. /**
  28206. * Settings for finer control over video usage
  28207. */
  28208. export interface VideoTextureSettings {
  28209. /**
  28210. * Applies `autoplay` to video, if specified
  28211. */
  28212. autoPlay?: boolean;
  28213. /**
  28214. * Applies `loop` to video, if specified
  28215. */
  28216. loop?: boolean;
  28217. /**
  28218. * Automatically updates internal texture from video at every frame in the render loop
  28219. */
  28220. autoUpdateTexture: boolean;
  28221. /**
  28222. * Image src displayed during the video loading or until the user interacts with the video.
  28223. */
  28224. poster?: string;
  28225. }
  28226. /**
  28227. * If you want to display a video in your scene, this is the special texture for that.
  28228. * This special texture works similar to other textures, with the exception of a few parameters.
  28229. * @see https://doc.babylonjs.com/how_to/video_texture
  28230. */
  28231. export class VideoTexture extends Texture {
  28232. /**
  28233. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28234. */
  28235. readonly autoUpdateTexture: boolean;
  28236. /**
  28237. * The video instance used by the texture internally
  28238. */
  28239. readonly video: HTMLVideoElement;
  28240. private _onUserActionRequestedObservable;
  28241. /**
  28242. * Event triggerd when a dom action is required by the user to play the video.
  28243. * This happens due to recent changes in browser policies preventing video to auto start.
  28244. */
  28245. readonly onUserActionRequestedObservable: Observable<Texture>;
  28246. private _generateMipMaps;
  28247. private _engine;
  28248. private _stillImageCaptured;
  28249. private _displayingPosterTexture;
  28250. private _settings;
  28251. private _createInternalTextureOnEvent;
  28252. private _frameId;
  28253. /**
  28254. * Creates a video texture.
  28255. * If you want to display a video in your scene, this is the special texture for that.
  28256. * This special texture works similar to other textures, with the exception of a few parameters.
  28257. * @see https://doc.babylonjs.com/how_to/video_texture
  28258. * @param name optional name, will detect from video source, if not defined
  28259. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28260. * @param scene is obviously the current scene.
  28261. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28262. * @param invertY is false by default but can be used to invert video on Y axis
  28263. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28264. * @param settings allows finer control over video usage
  28265. */
  28266. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28267. private _getName;
  28268. private _getVideo;
  28269. private _createInternalTexture;
  28270. private reset;
  28271. /**
  28272. * @hidden Internal method to initiate `update`.
  28273. */ private _rebuild(): void;
  28274. /**
  28275. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28276. */
  28277. update(): void;
  28278. /**
  28279. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28280. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28281. */
  28282. updateTexture(isVisible: boolean): void;
  28283. protected _updateInternalTexture: () => void;
  28284. /**
  28285. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28286. * @param url New url.
  28287. */
  28288. updateURL(url: string): void;
  28289. /**
  28290. * Dispose the texture and release its associated resources.
  28291. */
  28292. dispose(): void;
  28293. /**
  28294. * Creates a video texture straight from a stream.
  28295. * @param scene Define the scene the texture should be created in
  28296. * @param stream Define the stream the texture should be created from
  28297. * @returns The created video texture as a promise
  28298. */
  28299. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28300. /**
  28301. * Creates a video texture straight from your WebCam video feed.
  28302. * @param scene Define the scene the texture should be created in
  28303. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28304. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28305. * @returns The created video texture as a promise
  28306. */
  28307. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28308. minWidth: number;
  28309. maxWidth: number;
  28310. minHeight: number;
  28311. maxHeight: number;
  28312. deviceId: string;
  28313. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28314. /**
  28315. * Creates a video texture straight from your WebCam video feed.
  28316. * @param scene Define the scene the texture should be created in
  28317. * @param onReady Define a callback to triggered once the texture will be ready
  28318. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28319. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28320. */
  28321. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28322. minWidth: number;
  28323. maxWidth: number;
  28324. minHeight: number;
  28325. maxHeight: number;
  28326. deviceId: string;
  28327. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28328. }
  28329. }
  28330. declare module BABYLON {
  28331. /**
  28332. * Defines the interface used by objects working like Scene
  28333. * @hidden
  28334. */
  28335. interface ISceneLike { private _addPendingData(data: any): void; private _removePendingData(data: any): void;
  28336. offlineProvider: IOfflineProvider;
  28337. }
  28338. /** Interface defining initialization parameters for Engine class */
  28339. export interface EngineOptions extends WebGLContextAttributes {
  28340. /**
  28341. * Defines if the engine should no exceed a specified device ratio
  28342. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28343. */
  28344. limitDeviceRatio?: number;
  28345. /**
  28346. * Defines if webvr should be enabled automatically
  28347. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28348. */
  28349. autoEnableWebVR?: boolean;
  28350. /**
  28351. * Defines if webgl2 should be turned off even if supported
  28352. * @see http://doc.babylonjs.com/features/webgl2
  28353. */
  28354. disableWebGL2Support?: boolean;
  28355. /**
  28356. * Defines if webaudio should be initialized as well
  28357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28358. */
  28359. audioEngine?: boolean;
  28360. /**
  28361. * Defines if animations should run using a deterministic lock step
  28362. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28363. */
  28364. deterministicLockstep?: boolean;
  28365. /** Defines the maximum steps to use with deterministic lock step mode */
  28366. lockstepMaxSteps?: number;
  28367. /**
  28368. * Defines that engine should ignore context lost events
  28369. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28370. */
  28371. doNotHandleContextLost?: boolean;
  28372. /**
  28373. * Defines that engine should ignore modifying touch action attribute and style
  28374. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28375. */
  28376. doNotHandleTouchAction?: boolean;
  28377. /**
  28378. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28379. */
  28380. useHighPrecisionFloats?: boolean;
  28381. }
  28382. /**
  28383. * The base engine class (root of all engines)
  28384. */
  28385. export class ThinEngine {
  28386. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28387. static ExceptionList: ({
  28388. key: string;
  28389. capture: string;
  28390. captureConstraint: number;
  28391. targets: string[];
  28392. } | {
  28393. key: string;
  28394. capture: null;
  28395. captureConstraint: null;
  28396. targets: string[];
  28397. })[];
  28398. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  28399. /**
  28400. * Returns the current npm package of the sdk
  28401. */
  28402. static readonly NpmPackage: string;
  28403. /**
  28404. * Returns the current version of the framework
  28405. */
  28406. static readonly Version: string;
  28407. /**
  28408. * Returns a string describing the current engine
  28409. */
  28410. readonly description: string;
  28411. /**
  28412. * Gets or sets the epsilon value used by collision engine
  28413. */
  28414. static CollisionsEpsilon: number;
  28415. /**
  28416. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28417. */
  28418. static ShadersRepository: string;
  28419. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  28420. /**
  28421. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28422. */
  28423. forcePOTTextures: boolean;
  28424. /**
  28425. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28426. */
  28427. isFullscreen: boolean;
  28428. /**
  28429. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28430. */
  28431. cullBackFaces: boolean;
  28432. /**
  28433. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28434. */
  28435. renderEvenInBackground: boolean;
  28436. /**
  28437. * Gets or sets a boolean indicating that cache can be kept between frames
  28438. */
  28439. preventCacheWipeBetweenFrames: boolean;
  28440. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28441. validateShaderPrograms: boolean;
  28442. /**
  28443. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28444. */
  28445. disableUniformBuffers: boolean;
  28446. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  28447. /**
  28448. * Gets a boolean indicating that the engine supports uniform buffers
  28449. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28450. */
  28451. readonly supportsUniformBuffers: boolean;
  28452. /** @hidden */ private _gl: WebGLRenderingContext;
  28453. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  28454. protected _windowIsBackground: boolean;
  28455. protected _webGLVersion: number;
  28456. protected _highPrecisionShadersAllowed: boolean;
  28457. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  28458. /**
  28459. * Gets a boolean indicating that only power of 2 textures are supported
  28460. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28461. */
  28462. readonly needPOTTextures: boolean;
  28463. /** @hidden */ private _badOS: boolean;
  28464. /** @hidden */ private _badDesktopOS: boolean;
  28465. private _hardwareScalingLevel;
  28466. /** @hidden */ private _caps: EngineCapabilities;
  28467. private _isStencilEnable;
  28468. protected _colorWrite: boolean;
  28469. private _glVersion;
  28470. private _glRenderer;
  28471. private _glVendor;
  28472. /** @hidden */ private _videoTextureSupported: boolean;
  28473. protected _renderingQueueLaunched: boolean;
  28474. protected _activeRenderLoops: (() => void)[];
  28475. /**
  28476. * Observable signaled when a context lost event is raised
  28477. */
  28478. onContextLostObservable: Observable<ThinEngine>;
  28479. /**
  28480. * Observable signaled when a context restored event is raised
  28481. */
  28482. onContextRestoredObservable: Observable<ThinEngine>;
  28483. private _onContextLost;
  28484. private _onContextRestored;
  28485. protected _contextWasLost: boolean;
  28486. /** @hidden */ private _doNotHandleContextLost: boolean;
  28487. /**
  28488. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28489. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28490. */
  28491. doNotHandleContextLost: boolean;
  28492. /**
  28493. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28494. */
  28495. disableVertexArrayObjects: boolean;
  28496. /** @hidden */
  28497. protected _depthCullingState: DepthCullingState;
  28498. /** @hidden */
  28499. protected _stencilState: StencilState;
  28500. /** @hidden */
  28501. protected _alphaState: AlphaState;
  28502. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  28503. /** @hidden */
  28504. protected _activeChannel: number;
  28505. private _currentTextureChannel;
  28506. /** @hidden */
  28507. protected _boundTexturesCache: {
  28508. [key: string]: Nullable<InternalTexture>;
  28509. };
  28510. /** @hidden */
  28511. protected _currentEffect: Nullable<Effect>;
  28512. /** @hidden */
  28513. protected _currentProgram: Nullable<WebGLProgram>;
  28514. private _compiledEffects;
  28515. private _vertexAttribArraysEnabled;
  28516. /** @hidden */
  28517. protected _cachedViewport: Nullable<IViewportLike>;
  28518. private _cachedVertexArrayObject;
  28519. /** @hidden */
  28520. protected _cachedVertexBuffers: any;
  28521. /** @hidden */
  28522. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28523. /** @hidden */
  28524. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28525. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  28526. private _uintIndicesCurrentlySet;
  28527. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  28528. /** @hidden */
  28529. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28530. private _currentBufferPointers;
  28531. private _currentInstanceLocations;
  28532. private _currentInstanceBuffers;
  28533. private _textureUnits;
  28534. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  28535. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  28536. /** @hidden */ private _bindedRenderFunction: any;
  28537. private _vaoRecordInProgress;
  28538. private _mustWipeVertexAttributes;
  28539. private _emptyTexture;
  28540. private _emptyCubeTexture;
  28541. private _emptyTexture3D;
  28542. /** @hidden */ private _frameHandler: number;
  28543. private _nextFreeTextureSlots;
  28544. private _maxSimultaneousTextures;
  28545. private _activeRequests;
  28546. protected _texturesSupported: string[];
  28547. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  28548. protected readonly _supportsHardwareTextureRescaling: boolean;
  28549. /**
  28550. * Gets the list of texture formats supported
  28551. */
  28552. readonly texturesSupported: Array<string>;
  28553. /**
  28554. * Gets the list of texture formats in use
  28555. */
  28556. readonly textureFormatInUse: Nullable<string>;
  28557. /**
  28558. * Gets the current viewport
  28559. */
  28560. readonly currentViewport: Nullable<IViewportLike>;
  28561. /**
  28562. * Gets the default empty texture
  28563. */
  28564. readonly emptyTexture: InternalTexture;
  28565. /**
  28566. * Gets the default empty 3D texture
  28567. */
  28568. readonly emptyTexture3D: InternalTexture;
  28569. /**
  28570. * Gets the default empty cube texture
  28571. */
  28572. readonly emptyCubeTexture: InternalTexture;
  28573. /**
  28574. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28575. */
  28576. readonly premultipliedAlpha: boolean;
  28577. /**
  28578. * Observable event triggered before each texture is initialized
  28579. */
  28580. onBeforeTextureInitObservable: Observable<Texture>;
  28581. /**
  28582. * Creates a new engine
  28583. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  28584. * @param antialias defines enable antialiasing (default: false)
  28585. * @param options defines further options to be sent to the getContext() function
  28586. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28587. */
  28588. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28589. private _rebuildInternalTextures;
  28590. private _rebuildEffects;
  28591. /**
  28592. * Gets a boolean indicating if all created effects are ready
  28593. * @returns true if all effects are ready
  28594. */
  28595. areAllEffectsReady(): boolean;
  28596. protected _rebuildBuffers(): void;
  28597. private _initGLContext;
  28598. /**
  28599. * Gets version of the current webGL context
  28600. */
  28601. readonly webGLVersion: number;
  28602. /**
  28603. * Gets a string idenfifying the name of the class
  28604. * @returns "Engine" string
  28605. */
  28606. getClassName(): string;
  28607. /**
  28608. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28609. */
  28610. readonly isStencilEnable: boolean;
  28611. /** @hidden */ private _prepareWorkingCanvas(): void;
  28612. /**
  28613. * Reset the texture cache to empty state
  28614. */
  28615. resetTextureCache(): void;
  28616. /**
  28617. * Gets an object containing information about the current webGL context
  28618. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28619. */
  28620. getGlInfo(): {
  28621. vendor: string;
  28622. renderer: string;
  28623. version: string;
  28624. };
  28625. /**
  28626. * Defines the hardware scaling level.
  28627. * By default the hardware scaling level is computed from the window device ratio.
  28628. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  28629. * @param level defines the level to use
  28630. */
  28631. setHardwareScalingLevel(level: number): void;
  28632. /**
  28633. * Gets the current hardware scaling level.
  28634. * By default the hardware scaling level is computed from the window device ratio.
  28635. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  28636. * @returns a number indicating the current hardware scaling level
  28637. */
  28638. getHardwareScalingLevel(): number;
  28639. /**
  28640. * Gets the list of loaded textures
  28641. * @returns an array containing all loaded textures
  28642. */
  28643. getLoadedTexturesCache(): InternalTexture[];
  28644. /**
  28645. * Gets the object containing all engine capabilities
  28646. * @returns the EngineCapabilities object
  28647. */
  28648. getCaps(): EngineCapabilities;
  28649. /**
  28650. * stop executing a render loop function and remove it from the execution array
  28651. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28652. */
  28653. stopRenderLoop(renderFunction?: () => void): void;
  28654. /** @hidden */ private _renderLoop(): void;
  28655. /**
  28656. * Gets the HTML canvas attached with the current webGL context
  28657. * @returns a HTML canvas
  28658. */
  28659. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28660. /**
  28661. * Gets host window
  28662. * @returns the host window object
  28663. */
  28664. getHostWindow(): Window;
  28665. /**
  28666. * Gets the current render width
  28667. * @param useScreen defines if screen size must be used (or the current render target if any)
  28668. * @returns a number defining the current render width
  28669. */
  28670. getRenderWidth(useScreen?: boolean): number;
  28671. /**
  28672. * Gets the current render height
  28673. * @param useScreen defines if screen size must be used (or the current render target if any)
  28674. * @returns a number defining the current render height
  28675. */
  28676. getRenderHeight(useScreen?: boolean): number;
  28677. /**
  28678. * Can be used to override the current requestAnimationFrame requester.
  28679. * @hidden
  28680. */
  28681. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  28682. /**
  28683. * Register and execute a render loop. The engine can have more than one render function
  28684. * @param renderFunction defines the function to continuously execute
  28685. */
  28686. runRenderLoop(renderFunction: () => void): void;
  28687. /**
  28688. * Clear the current render buffer or the current render target (if any is set up)
  28689. * @param color defines the color to use
  28690. * @param backBuffer defines if the back buffer must be cleared
  28691. * @param depth defines if the depth buffer must be cleared
  28692. * @param stencil defines if the stencil buffer must be cleared
  28693. */
  28694. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28695. private _viewportCached;
  28696. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  28697. /**
  28698. * Set the WebGL's viewport
  28699. * @param viewport defines the viewport element to be used
  28700. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28701. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28702. */
  28703. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  28704. /**
  28705. * Begin a new frame
  28706. */
  28707. beginFrame(): void;
  28708. /**
  28709. * Enf the current frame
  28710. */
  28711. endFrame(): void;
  28712. /**
  28713. * Resize the view according to the canvas' size
  28714. */
  28715. resize(): void;
  28716. /**
  28717. * Force a specific size of the canvas
  28718. * @param width defines the new canvas' width
  28719. * @param height defines the new canvas' height
  28720. */
  28721. setSize(width: number, height: number): void;
  28722. /**
  28723. * Binds the frame buffer to the specified texture.
  28724. * @param texture The texture to render to or null for the default canvas
  28725. * @param faceIndex The face of the texture to render to in case of cube texture
  28726. * @param requiredWidth The width of the target to render to
  28727. * @param requiredHeight The height of the target to render to
  28728. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28729. * @param depthStencilTexture The depth stencil texture to use to render
  28730. * @param lodLevel defines le lod level to bind to the frame buffer
  28731. */
  28732. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28733. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28734. /**
  28735. * Unbind the current render target texture from the webGL context
  28736. * @param texture defines the render target texture to unbind
  28737. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28738. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28739. */
  28740. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28741. /**
  28742. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28743. */
  28744. flushFramebuffer(): void;
  28745. /**
  28746. * Unbind the current render target and bind the default framebuffer
  28747. */
  28748. restoreDefaultFramebuffer(): void;
  28749. private _resetVertexBufferBinding;
  28750. /**
  28751. * Creates a vertex buffer
  28752. * @param data the data for the vertex buffer
  28753. * @returns the new WebGL static buffer
  28754. */
  28755. createVertexBuffer(data: DataArray): DataBuffer;
  28756. private _createVertexBuffer;
  28757. /**
  28758. * Creates a dynamic vertex buffer
  28759. * @param data the data for the dynamic vertex buffer
  28760. * @returns the new WebGL dynamic buffer
  28761. */
  28762. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28763. /**
  28764. * Updates a dynamic vertex buffer.
  28765. * @param vertexBuffer the vertex buffer to update
  28766. * @param data the data used to update the vertex buffer
  28767. * @param byteOffset the byte offset of the data
  28768. * @param byteLength the byte length of the data
  28769. */
  28770. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28771. protected _resetIndexBufferBinding(): void;
  28772. /**
  28773. * Creates a new index buffer
  28774. * @param indices defines the content of the index buffer
  28775. * @param updatable defines if the index buffer must be updatable
  28776. * @returns a new webGL buffer
  28777. */
  28778. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28779. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  28780. /**
  28781. * Bind a webGL buffer to the webGL context
  28782. * @param buffer defines the buffer to bind
  28783. */
  28784. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28785. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  28786. private bindBuffer;
  28787. /**
  28788. * update the bound buffer with the given data
  28789. * @param data defines the data to update
  28790. */
  28791. updateArrayBuffer(data: Float32Array): void;
  28792. private _vertexAttribPointer;
  28793. private _bindIndexBufferWithCache;
  28794. private _bindVertexBuffersAttributes;
  28795. /**
  28796. * Records a vertex array object
  28797. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28798. * @param vertexBuffers defines the list of vertex buffers to store
  28799. * @param indexBuffer defines the index buffer to store
  28800. * @param effect defines the effect to store
  28801. * @returns the new vertex array object
  28802. */
  28803. recordVertexArrayObject(vertexBuffers: {
  28804. [key: string]: VertexBuffer;
  28805. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28806. /**
  28807. * Bind a specific vertex array object
  28808. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28809. * @param vertexArrayObject defines the vertex array object to bind
  28810. * @param indexBuffer defines the index buffer to bind
  28811. */
  28812. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28813. /**
  28814. * Bind webGl buffers directly to the webGL context
  28815. * @param vertexBuffer defines the vertex buffer to bind
  28816. * @param indexBuffer defines the index buffer to bind
  28817. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28818. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28819. * @param effect defines the effect associated with the vertex buffer
  28820. */
  28821. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28822. private _unbindVertexArrayObject;
  28823. /**
  28824. * Bind a list of vertex buffers to the webGL context
  28825. * @param vertexBuffers defines the list of vertex buffers to bind
  28826. * @param indexBuffer defines the index buffer to bind
  28827. * @param effect defines the effect associated with the vertex buffers
  28828. */
  28829. bindBuffers(vertexBuffers: {
  28830. [key: string]: Nullable<VertexBuffer>;
  28831. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28832. /**
  28833. * Unbind all instance attributes
  28834. */
  28835. unbindInstanceAttributes(): void;
  28836. /**
  28837. * Release and free the memory of a vertex array object
  28838. * @param vao defines the vertex array object to delete
  28839. */
  28840. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28841. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  28842. protected _deleteBuffer(buffer: DataBuffer): void;
  28843. /**
  28844. * Creates a webGL buffer to use with instanciation
  28845. * @param capacity defines the size of the buffer
  28846. * @returns the webGL buffer
  28847. */
  28848. createInstancesBuffer(capacity: number): DataBuffer;
  28849. /**
  28850. * Delete a webGL buffer used with instanciation
  28851. * @param buffer defines the webGL buffer to delete
  28852. */
  28853. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28854. /**
  28855. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28856. * @param instancesBuffer defines the webGL buffer to update and bind
  28857. * @param data defines the data to store in the buffer
  28858. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28859. */
  28860. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28861. /**
  28862. * Apply all cached states (depth, culling, stencil and alpha)
  28863. */
  28864. applyStates(): void;
  28865. /**
  28866. * Send a draw order
  28867. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28868. * @param indexStart defines the starting index
  28869. * @param indexCount defines the number of index to draw
  28870. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28871. */
  28872. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28873. /**
  28874. * Draw a list of points
  28875. * @param verticesStart defines the index of first vertex to draw
  28876. * @param verticesCount defines the count of vertices to draw
  28877. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28878. */
  28879. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28880. /**
  28881. * Draw a list of unindexed primitives
  28882. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28883. * @param verticesStart defines the index of first vertex to draw
  28884. * @param verticesCount defines the count of vertices to draw
  28885. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28886. */
  28887. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28888. /**
  28889. * Draw a list of indexed primitives
  28890. * @param fillMode defines the primitive to use
  28891. * @param indexStart defines the starting index
  28892. * @param indexCount defines the number of index to draw
  28893. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28894. */
  28895. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28896. /**
  28897. * Draw a list of unindexed primitives
  28898. * @param fillMode defines the primitive to use
  28899. * @param verticesStart defines the index of first vertex to draw
  28900. * @param verticesCount defines the count of vertices to draw
  28901. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28902. */
  28903. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28904. private _drawMode;
  28905. /** @hidden */
  28906. protected _reportDrawCall(): void;
  28907. /** @hidden */ private _releaseEffect(effect: Effect): void;
  28908. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28909. /**
  28910. * Create a new effect (used to store vertex/fragment shaders)
  28911. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28912. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  28913. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28914. * @param samplers defines an array of string used to represent textures
  28915. * @param defines defines the string containing the defines to use to compile the shaders
  28916. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28917. * @param onCompiled defines a function to call when the effect creation is successful
  28918. * @param onError defines a function to call when the effect creation has failed
  28919. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28920. * @returns the new Effect
  28921. */
  28922. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28923. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  28924. private _compileShader;
  28925. private _compileRawShader;
  28926. /**
  28927. * Directly creates a webGL program
  28928. * @param pipelineContext defines the pipeline context to attach to
  28929. * @param vertexCode defines the vertex shader code to use
  28930. * @param fragmentCode defines the fragment shader code to use
  28931. * @param context defines the webGL context to use (if not set, the current one will be used)
  28932. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28933. * @returns the new webGL program
  28934. */
  28935. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28936. /**
  28937. * Creates a webGL program
  28938. * @param pipelineContext defines the pipeline context to attach to
  28939. * @param vertexCode defines the vertex shader code to use
  28940. * @param fragmentCode defines the fragment shader code to use
  28941. * @param defines defines the string containing the defines to use to compile the shaders
  28942. * @param context defines the webGL context to use (if not set, the current one will be used)
  28943. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28944. * @returns the new webGL program
  28945. */
  28946. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28947. /**
  28948. * Creates a new pipeline context
  28949. * @returns the new pipeline
  28950. */
  28951. createPipelineContext(): IPipelineContext;
  28952. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28953. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  28954. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28955. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28956. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28957. /**
  28958. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28959. * @param pipelineContext defines the pipeline context to use
  28960. * @param uniformsNames defines the list of uniform names
  28961. * @returns an array of webGL uniform locations
  28962. */
  28963. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28964. /**
  28965. * Gets the lsit of active attributes for a given webGL program
  28966. * @param pipelineContext defines the pipeline context to use
  28967. * @param attributesNames defines the list of attribute names to get
  28968. * @returns an array of indices indicating the offset of each attribute
  28969. */
  28970. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28971. /**
  28972. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28973. * @param effect defines the effect to activate
  28974. */
  28975. enableEffect(effect: Nullable<Effect>): void;
  28976. /**
  28977. * Set the value of an uniform to an array of int32
  28978. * @param uniform defines the webGL uniform location where to store the value
  28979. * @param array defines the array of int32 to store
  28980. */
  28981. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28982. /**
  28983. * Set the value of an uniform to an array of int32 (stored as vec2)
  28984. * @param uniform defines the webGL uniform location where to store the value
  28985. * @param array defines the array of int32 to store
  28986. */
  28987. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28988. /**
  28989. * Set the value of an uniform to an array of int32 (stored as vec3)
  28990. * @param uniform defines the webGL uniform location where to store the value
  28991. * @param array defines the array of int32 to store
  28992. */
  28993. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28994. /**
  28995. * Set the value of an uniform to an array of int32 (stored as vec4)
  28996. * @param uniform defines the webGL uniform location where to store the value
  28997. * @param array defines the array of int32 to store
  28998. */
  28999. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29000. /**
  29001. * Set the value of an uniform to an array of float32
  29002. * @param uniform defines the webGL uniform location where to store the value
  29003. * @param array defines the array of float32 to store
  29004. */
  29005. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29006. /**
  29007. * Set the value of an uniform to an array of float32 (stored as vec2)
  29008. * @param uniform defines the webGL uniform location where to store the value
  29009. * @param array defines the array of float32 to store
  29010. */
  29011. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29012. /**
  29013. * Set the value of an uniform to an array of float32 (stored as vec3)
  29014. * @param uniform defines the webGL uniform location where to store the value
  29015. * @param array defines the array of float32 to store
  29016. */
  29017. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29018. /**
  29019. * Set the value of an uniform to an array of float32 (stored as vec4)
  29020. * @param uniform defines the webGL uniform location where to store the value
  29021. * @param array defines the array of float32 to store
  29022. */
  29023. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29024. /**
  29025. * Set the value of an uniform to an array of number
  29026. * @param uniform defines the webGL uniform location where to store the value
  29027. * @param array defines the array of number to store
  29028. */
  29029. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29030. /**
  29031. * Set the value of an uniform to an array of number (stored as vec2)
  29032. * @param uniform defines the webGL uniform location where to store the value
  29033. * @param array defines the array of number to store
  29034. */
  29035. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29036. /**
  29037. * Set the value of an uniform to an array of number (stored as vec3)
  29038. * @param uniform defines the webGL uniform location where to store the value
  29039. * @param array defines the array of number to store
  29040. */
  29041. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29042. /**
  29043. * Set the value of an uniform to an array of number (stored as vec4)
  29044. * @param uniform defines the webGL uniform location where to store the value
  29045. * @param array defines the array of number to store
  29046. */
  29047. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29048. /**
  29049. * Set the value of an uniform to an array of float32 (stored as matrices)
  29050. * @param uniform defines the webGL uniform location where to store the value
  29051. * @param matrices defines the array of float32 to store
  29052. */
  29053. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29054. /**
  29055. * Set the value of an uniform to a matrix (3x3)
  29056. * @param uniform defines the webGL uniform location where to store the value
  29057. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29058. */
  29059. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29060. /**
  29061. * Set the value of an uniform to a matrix (2x2)
  29062. * @param uniform defines the webGL uniform location where to store the value
  29063. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29064. */
  29065. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29066. /**
  29067. * Set the value of an uniform to a number (int)
  29068. * @param uniform defines the webGL uniform location where to store the value
  29069. * @param value defines the int number to store
  29070. */
  29071. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29072. /**
  29073. * Set the value of an uniform to a number (float)
  29074. * @param uniform defines the webGL uniform location where to store the value
  29075. * @param value defines the float number to store
  29076. */
  29077. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29078. /**
  29079. * Set the value of an uniform to a vec2
  29080. * @param uniform defines the webGL uniform location where to store the value
  29081. * @param x defines the 1st component of the value
  29082. * @param y defines the 2nd component of the value
  29083. */
  29084. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29085. /**
  29086. * Set the value of an uniform to a vec3
  29087. * @param uniform defines the webGL uniform location where to store the value
  29088. * @param x defines the 1st component of the value
  29089. * @param y defines the 2nd component of the value
  29090. * @param z defines the 3rd component of the value
  29091. */
  29092. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29093. /**
  29094. * Set the value of an uniform to a boolean
  29095. * @param uniform defines the webGL uniform location where to store the value
  29096. * @param bool defines the boolean to store
  29097. */
  29098. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29099. /**
  29100. * Set the value of an uniform to a vec4
  29101. * @param uniform defines the webGL uniform location where to store the value
  29102. * @param x defines the 1st component of the value
  29103. * @param y defines the 2nd component of the value
  29104. * @param z defines the 3rd component of the value
  29105. * @param w defines the 4th component of the value
  29106. */
  29107. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29108. /**
  29109. * Sets a Color4 on a uniform variable
  29110. * @param uniform defines the uniform location
  29111. * @param color4 defines the value to be set
  29112. */
  29113. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  29114. /**
  29115. * Gets the depth culling state manager
  29116. */
  29117. readonly depthCullingState: DepthCullingState;
  29118. /**
  29119. * Gets the alpha state manager
  29120. */
  29121. readonly alphaState: AlphaState;
  29122. /**
  29123. * Gets the stencil state manager
  29124. */
  29125. readonly stencilState: StencilState;
  29126. /**
  29127. * Clears the list of texture accessible through engine.
  29128. * This can help preventing texture load conflict due to name collision.
  29129. */
  29130. clearInternalTexturesCache(): void;
  29131. /**
  29132. * Force the entire cache to be cleared
  29133. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29134. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29135. */
  29136. wipeCaches(bruteForce?: boolean): void;
  29137. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29138. min: number;
  29139. mag: number;
  29140. };
  29141. /** @hidden */ private _createTexture(): WebGLTexture;
  29142. /**
  29143. * Usually called from Texture.ts.
  29144. * Passed information to create a WebGLTexture
  29145. * @param urlArg defines a value which contains one of the following:
  29146. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29147. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29148. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29149. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29150. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  29151. * @param scene needed for loading to the correct scene
  29152. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29153. * @param onLoad optional callback to be called upon successful completion
  29154. * @param onError optional callback to be called upon failure
  29155. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  29156. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29157. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29158. * @param forcedExtension defines the extension to use to pick the right loader
  29159. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29160. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29161. */
  29162. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  29163. /**
  29164. * @hidden
  29165. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  29166. /**
  29167. * Creates a raw texture
  29168. * @param data defines the data to store in the texture
  29169. * @param width defines the width of the texture
  29170. * @param height defines the height of the texture
  29171. * @param format defines the format of the data
  29172. * @param generateMipMaps defines if the engine should generate the mip levels
  29173. * @param invertY defines if data must be stored with Y axis inverted
  29174. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29175. * @param compression defines the compression used (null by default)
  29176. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  29177. * @returns the raw texture inside an InternalTexture
  29178. */
  29179. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  29180. /**
  29181. * Creates a new raw cube texture
  29182. * @param data defines the array of data to use to create each face
  29183. * @param size defines the size of the textures
  29184. * @param format defines the format of the data
  29185. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  29186. * @param generateMipMaps defines if the engine should generate the mip levels
  29187. * @param invertY defines if data must be stored with Y axis inverted
  29188. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29189. * @param compression defines the compression used (null by default)
  29190. * @returns the cube texture as an InternalTexture
  29191. */
  29192. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  29193. /**
  29194. * Creates a new raw 3D texture
  29195. * @param data defines the data used to create the texture
  29196. * @param width defines the width of the texture
  29197. * @param height defines the height of the texture
  29198. * @param depth defines the depth of the texture
  29199. * @param format defines the format of the texture
  29200. * @param generateMipMaps defines if the engine must generate mip levels
  29201. * @param invertY defines if data must be stored with Y axis inverted
  29202. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  29203. * @param compression defines the compressed used (can be null)
  29204. * @param textureType defines the compressed used (can be null)
  29205. * @returns a new raw 3D texture (stored in an InternalTexture)
  29206. */
  29207. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  29208. private _unpackFlipYCached;
  29209. /**
  29210. * In case you are sharing the context with other applications, it might
  29211. * be interested to not cache the unpack flip y state to ensure a consistent
  29212. * value would be set.
  29213. */
  29214. enableUnpackFlipYCached: boolean;
  29215. /** @hidden */ private _unpackFlipY(value: boolean): void;
  29216. /** @hidden */ private _getUnpackAlignement(): number;
  29217. /**
  29218. * Update the sampling mode of a given texture
  29219. * @param samplingMode defines the required sampling mode
  29220. * @param texture defines the texture to update
  29221. */
  29222. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29223. /**
  29224. * Updates a depth texture Comparison Mode and Function.
  29225. * If the comparison Function is equal to 0, the mode will be set to none.
  29226. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29227. * @param texture The texture to set the comparison function for
  29228. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29229. */
  29230. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29231. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29232. width: number;
  29233. height: number;
  29234. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29235. /**
  29236. * Creates a depth stencil texture.
  29237. * This is only available in WebGL 2 or with the depth texture extension available.
  29238. * @param size The size of face edge in the texture.
  29239. * @param options The options defining the texture.
  29240. * @returns The texture
  29241. */
  29242. createDepthStencilTexture(size: number | {
  29243. width: number;
  29244. height: number;
  29245. }, options: DepthTextureCreationOptions): InternalTexture;
  29246. /**
  29247. * Creates a depth stencil texture.
  29248. * This is only available in WebGL 2 or with the depth texture extension available.
  29249. * @param size The size of face edge in the texture.
  29250. * @param options The options defining the texture.
  29251. * @returns The texture
  29252. */
  29253. private _createDepthStencilTexture;
  29254. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29255. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29256. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29257. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29258. /**
  29259. * @hidden
  29260. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  29261. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  29262. private _prepareWebGLTexture;
  29263. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29264. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  29265. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  29266. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  29267. protected _setProgram(program: WebGLProgram): void;
  29268. protected _boundUniforms: {
  29269. [key: number]: WebGLUniformLocation;
  29270. };
  29271. /**
  29272. * Binds an effect to the webGL context
  29273. * @param effect defines the effect to bind
  29274. */
  29275. bindSamplers(effect: Effect): void;
  29276. private _activateCurrentTexture;
  29277. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29278. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29279. /**
  29280. * Unbind all textures from the webGL context
  29281. */
  29282. unbindAllTextures(): void;
  29283. /**
  29284. * Sets a texture to the according uniform.
  29285. * @param channel The texture channel
  29286. * @param uniform The uniform to set
  29287. * @param texture The texture to apply
  29288. */
  29289. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29290. private _bindSamplerUniformToChannel;
  29291. private _getTextureWrapMode;
  29292. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  29293. /**
  29294. * Sets an array of texture to the webGL context
  29295. * @param channel defines the channel where the texture array must be set
  29296. * @param uniform defines the associated uniform location
  29297. * @param textures defines the array of textures to bind
  29298. */
  29299. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29300. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29301. private _setTextureParameterFloat;
  29302. private _setTextureParameterInteger;
  29303. /**
  29304. * Unbind all vertex attributes from the webGL context
  29305. */
  29306. unbindAllAttributes(): void;
  29307. /**
  29308. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  29309. */
  29310. releaseEffects(): void;
  29311. /**
  29312. * Dispose and release all associated resources
  29313. */
  29314. dispose(): void;
  29315. /**
  29316. * Attach a new callback raised when context lost event is fired
  29317. * @param callback defines the callback to call
  29318. */
  29319. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29320. /**
  29321. * Attach a new callback raised when context restored event is fired
  29322. * @param callback defines the callback to call
  29323. */
  29324. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29325. /**
  29326. * Get the current error code of the webGL context
  29327. * @returns the error code
  29328. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29329. */
  29330. getError(): number;
  29331. private _canRenderToFloatFramebuffer;
  29332. private _canRenderToHalfFloatFramebuffer;
  29333. private _canRenderToFramebuffer;
  29334. /** @hidden */ private _getWebGLTextureType(type: number): number;
  29335. /** @hidden */ private _getInternalFormat(format: number): number;
  29336. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29337. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  29338. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  29339. /**
  29340. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29341. * @returns true if the engine can be created
  29342. * @ignorenaming
  29343. */
  29344. static isSupported(): boolean;
  29345. /**
  29346. * Find the next highest power of two.
  29347. * @param x Number to start search from.
  29348. * @return Next highest power of two.
  29349. */
  29350. static CeilingPOT(x: number): number;
  29351. /**
  29352. * Find the next lowest power of two.
  29353. * @param x Number to start search from.
  29354. * @return Next lowest power of two.
  29355. */
  29356. static FloorPOT(x: number): number;
  29357. /**
  29358. * Find the nearest power of two.
  29359. * @param x Number to start search from.
  29360. * @return Next nearest power of two.
  29361. */
  29362. static NearestPOT(x: number): number;
  29363. /**
  29364. * Get the closest exponent of two
  29365. * @param value defines the value to approximate
  29366. * @param max defines the maximum value to return
  29367. * @param mode defines how to define the closest value
  29368. * @returns closest exponent of two of the given value
  29369. */
  29370. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  29371. /**
  29372. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  29373. * @param func - the function to be called
  29374. * @param requester - the object that will request the next frame. Falls back to window.
  29375. * @returns frame number
  29376. */
  29377. static QueueNewFrame(func: () => void, requester?: any): number;
  29378. }
  29379. }
  29380. declare module BABYLON {
  29381. /**
  29382. * Class representing spherical harmonics coefficients to the 3rd degree
  29383. */
  29384. export class SphericalHarmonics {
  29385. /**
  29386. * Defines whether or not the harmonics have been prescaled for rendering.
  29387. */
  29388. preScaled: boolean;
  29389. /**
  29390. * The l0,0 coefficients of the spherical harmonics
  29391. */
  29392. l00: Vector3;
  29393. /**
  29394. * The l1,-1 coefficients of the spherical harmonics
  29395. */
  29396. l1_1: Vector3;
  29397. /**
  29398. * The l1,0 coefficients of the spherical harmonics
  29399. */
  29400. l10: Vector3;
  29401. /**
  29402. * The l1,1 coefficients of the spherical harmonics
  29403. */
  29404. l11: Vector3;
  29405. /**
  29406. * The l2,-2 coefficients of the spherical harmonics
  29407. */
  29408. l2_2: Vector3;
  29409. /**
  29410. * The l2,-1 coefficients of the spherical harmonics
  29411. */
  29412. l2_1: Vector3;
  29413. /**
  29414. * The l2,0 coefficients of the spherical harmonics
  29415. */
  29416. l20: Vector3;
  29417. /**
  29418. * The l2,1 coefficients of the spherical harmonics
  29419. */
  29420. l21: Vector3;
  29421. /**
  29422. * The l2,2 coefficients of the spherical harmonics
  29423. */
  29424. l22: Vector3;
  29425. /**
  29426. * Adds a light to the spherical harmonics
  29427. * @param direction the direction of the light
  29428. * @param color the color of the light
  29429. * @param deltaSolidAngle the delta solid angle of the light
  29430. */
  29431. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  29432. /**
  29433. * Scales the spherical harmonics by the given amount
  29434. * @param scale the amount to scale
  29435. */
  29436. scaleInPlace(scale: number): void;
  29437. /**
  29438. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  29439. *
  29440. * ```
  29441. * E_lm = A_l * L_lm
  29442. * ```
  29443. *
  29444. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  29445. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  29446. * the scaling factors are given in equation 9.
  29447. */
  29448. convertIncidentRadianceToIrradiance(): void;
  29449. /**
  29450. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  29451. *
  29452. * ```
  29453. * L = (1/pi) * E * rho
  29454. * ```
  29455. *
  29456. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  29457. */
  29458. convertIrradianceToLambertianRadiance(): void;
  29459. /**
  29460. * Integrates the reconstruction coefficients directly in to the SH preventing further
  29461. * required operations at run time.
  29462. *
  29463. * This is simply done by scaling back the SH with Ylm constants parameter.
  29464. * The trigonometric part being applied by the shader at run time.
  29465. */
  29466. preScaleForRendering(): void;
  29467. /**
  29468. * Constructs a spherical harmonics from an array.
  29469. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  29470. * @returns the spherical harmonics
  29471. */
  29472. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  29473. /**
  29474. * Gets the spherical harmonics from polynomial
  29475. * @param polynomial the spherical polynomial
  29476. * @returns the spherical harmonics
  29477. */
  29478. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  29479. }
  29480. /**
  29481. * Class representing spherical polynomial coefficients to the 3rd degree
  29482. */
  29483. export class SphericalPolynomial {
  29484. private _harmonics;
  29485. /**
  29486. * The spherical harmonics used to create the polynomials.
  29487. */
  29488. readonly preScaledHarmonics: SphericalHarmonics;
  29489. /**
  29490. * The x coefficients of the spherical polynomial
  29491. */
  29492. x: Vector3;
  29493. /**
  29494. * The y coefficients of the spherical polynomial
  29495. */
  29496. y: Vector3;
  29497. /**
  29498. * The z coefficients of the spherical polynomial
  29499. */
  29500. z: Vector3;
  29501. /**
  29502. * The xx coefficients of the spherical polynomial
  29503. */
  29504. xx: Vector3;
  29505. /**
  29506. * The yy coefficients of the spherical polynomial
  29507. */
  29508. yy: Vector3;
  29509. /**
  29510. * The zz coefficients of the spherical polynomial
  29511. */
  29512. zz: Vector3;
  29513. /**
  29514. * The xy coefficients of the spherical polynomial
  29515. */
  29516. xy: Vector3;
  29517. /**
  29518. * The yz coefficients of the spherical polynomial
  29519. */
  29520. yz: Vector3;
  29521. /**
  29522. * The zx coefficients of the spherical polynomial
  29523. */
  29524. zx: Vector3;
  29525. /**
  29526. * Adds an ambient color to the spherical polynomial
  29527. * @param color the color to add
  29528. */
  29529. addAmbient(color: Color3): void;
  29530. /**
  29531. * Scales the spherical polynomial by the given amount
  29532. * @param scale the amount to scale
  29533. */
  29534. scaleInPlace(scale: number): void;
  29535. /**
  29536. * Gets the spherical polynomial from harmonics
  29537. * @param harmonics the spherical harmonics
  29538. * @returns the spherical polynomial
  29539. */
  29540. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  29541. /**
  29542. * Constructs a spherical polynomial from an array.
  29543. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  29544. * @returns the spherical polynomial
  29545. */
  29546. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  29547. }
  29548. }
  29549. declare module BABYLON {
  29550. /**
  29551. * Defines the source of the internal texture
  29552. */
  29553. export enum InternalTextureSource {
  29554. /**
  29555. * The source of the texture data is unknown
  29556. */
  29557. Unknown = 0,
  29558. /**
  29559. * Texture data comes from an URL
  29560. */
  29561. Url = 1,
  29562. /**
  29563. * Texture data is only used for temporary storage
  29564. */
  29565. Temp = 2,
  29566. /**
  29567. * Texture data comes from raw data (ArrayBuffer)
  29568. */
  29569. Raw = 3,
  29570. /**
  29571. * Texture content is dynamic (video or dynamic texture)
  29572. */
  29573. Dynamic = 4,
  29574. /**
  29575. * Texture content is generated by rendering to it
  29576. */
  29577. RenderTarget = 5,
  29578. /**
  29579. * Texture content is part of a multi render target process
  29580. */
  29581. MultiRenderTarget = 6,
  29582. /**
  29583. * Texture data comes from a cube data file
  29584. */
  29585. Cube = 7,
  29586. /**
  29587. * Texture data comes from a raw cube data
  29588. */
  29589. CubeRaw = 8,
  29590. /**
  29591. * Texture data come from a prefiltered cube data file
  29592. */
  29593. CubePrefiltered = 9,
  29594. /**
  29595. * Texture content is raw 3D data
  29596. */
  29597. Raw3D = 10,
  29598. /**
  29599. * Texture content is a depth texture
  29600. */
  29601. Depth = 11,
  29602. /**
  29603. * Texture data comes from a raw cube data encoded with RGBD
  29604. */
  29605. CubeRawRGBD = 12
  29606. }
  29607. /**
  29608. * Class used to store data associated with WebGL texture data for the engine
  29609. * This class should not be used directly
  29610. */
  29611. export class InternalTexture {
  29612. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  29613. /**
  29614. * Defines if the texture is ready
  29615. */
  29616. isReady: boolean;
  29617. /**
  29618. * Defines if the texture is a cube texture
  29619. */
  29620. isCube: boolean;
  29621. /**
  29622. * Defines if the texture contains 3D data
  29623. */
  29624. is3D: boolean;
  29625. /**
  29626. * Defines if the texture contains multiview data
  29627. */
  29628. isMultiview: boolean;
  29629. /**
  29630. * Gets the URL used to load this texture
  29631. */
  29632. url: string;
  29633. /**
  29634. * Gets the sampling mode of the texture
  29635. */
  29636. samplingMode: number;
  29637. /**
  29638. * Gets a boolean indicating if the texture needs mipmaps generation
  29639. */
  29640. generateMipMaps: boolean;
  29641. /**
  29642. * Gets the number of samples used by the texture (WebGL2+ only)
  29643. */
  29644. samples: number;
  29645. /**
  29646. * Gets the type of the texture (int, float...)
  29647. */
  29648. type: number;
  29649. /**
  29650. * Gets the format of the texture (RGB, RGBA...)
  29651. */
  29652. format: number;
  29653. /**
  29654. * Observable called when the texture is loaded
  29655. */
  29656. onLoadedObservable: Observable<InternalTexture>;
  29657. /**
  29658. * Gets the width of the texture
  29659. */
  29660. width: number;
  29661. /**
  29662. * Gets the height of the texture
  29663. */
  29664. height: number;
  29665. /**
  29666. * Gets the depth of the texture
  29667. */
  29668. depth: number;
  29669. /**
  29670. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  29671. */
  29672. baseWidth: number;
  29673. /**
  29674. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  29675. */
  29676. baseHeight: number;
  29677. /**
  29678. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  29679. */
  29680. baseDepth: number;
  29681. /**
  29682. * Gets a boolean indicating if the texture is inverted on Y axis
  29683. */
  29684. invertY: boolean;
  29685. /** @hidden */ private _invertVScale: boolean;
  29686. /** @hidden */ private _associatedChannel: number;
  29687. /** @hidden */ private _source: InternalTextureSource;
  29688. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  29689. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  29690. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  29691. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  29692. /** @hidden */ private _size: number;
  29693. /** @hidden */ private _extension: string;
  29694. /** @hidden */ private _files: Nullable<string[]>;
  29695. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  29696. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  29697. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  29698. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  29699. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  29700. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  29701. /** @hidden */ private _attachments: Nullable<number[]>;
  29702. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  29703. /** @hidden */ private _cachedWrapU: Nullable<number>;
  29704. /** @hidden */ private _cachedWrapV: Nullable<number>;
  29705. /** @hidden */ private _cachedWrapR: Nullable<number>;
  29706. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  29707. /** @hidden */ private _isDisabled: boolean;
  29708. /** @hidden */ private _compression: Nullable<string>;
  29709. /** @hidden */ private _generateStencilBuffer: boolean;
  29710. /** @hidden */ private _generateDepthBuffer: boolean;
  29711. /** @hidden */ private _comparisonFunction: number;
  29712. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29713. /** @hidden */ private _lodGenerationScale: number;
  29714. /** @hidden */ private _lodGenerationOffset: number;
  29715. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  29716. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  29717. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  29718. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  29719. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  29720. /** @hidden */ private _isRGBD: boolean;
  29721. /** @hidden */ private _linearSpecularLOD: boolean;
  29722. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  29723. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  29724. /** @hidden */ private _references: number;
  29725. private _engine;
  29726. /**
  29727. * Gets the Engine the texture belongs to.
  29728. * @returns The babylon engine
  29729. */
  29730. getEngine(): ThinEngine;
  29731. /**
  29732. * Gets the data source type of the texture
  29733. */
  29734. readonly source: InternalTextureSource;
  29735. /**
  29736. * Creates a new InternalTexture
  29737. * @param engine defines the engine to use
  29738. * @param source defines the type of data that will be used
  29739. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29740. */
  29741. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  29742. /**
  29743. * Increments the number of references (ie. the number of Texture that point to it)
  29744. */
  29745. incrementReferences(): void;
  29746. /**
  29747. * Change the size of the texture (not the size of the content)
  29748. * @param width defines the new width
  29749. * @param height defines the new height
  29750. * @param depth defines the new depth (1 by default)
  29751. */
  29752. updateSize(width: int, height: int, depth?: int): void;
  29753. /** @hidden */ private _rebuild(): void;
  29754. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  29755. /**
  29756. * Dispose the current allocated resources
  29757. */
  29758. dispose(): void;
  29759. }
  29760. }
  29761. declare module BABYLON {
  29762. /**
  29763. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29765. */
  29766. export class Analyser {
  29767. /**
  29768. * Gets or sets the smoothing
  29769. * @ignorenaming
  29770. */
  29771. SMOOTHING: number;
  29772. /**
  29773. * Gets or sets the FFT table size
  29774. * @ignorenaming
  29775. */
  29776. FFT_SIZE: number;
  29777. /**
  29778. * Gets or sets the bar graph amplitude
  29779. * @ignorenaming
  29780. */
  29781. BARGRAPHAMPLITUDE: number;
  29782. /**
  29783. * Gets or sets the position of the debug canvas
  29784. * @ignorenaming
  29785. */
  29786. DEBUGCANVASPOS: {
  29787. x: number;
  29788. y: number;
  29789. };
  29790. /**
  29791. * Gets or sets the debug canvas size
  29792. * @ignorenaming
  29793. */
  29794. DEBUGCANVASSIZE: {
  29795. width: number;
  29796. height: number;
  29797. };
  29798. private _byteFreqs;
  29799. private _byteTime;
  29800. private _floatFreqs;
  29801. private _webAudioAnalyser;
  29802. private _debugCanvas;
  29803. private _debugCanvasContext;
  29804. private _scene;
  29805. private _registerFunc;
  29806. private _audioEngine;
  29807. /**
  29808. * Creates a new analyser
  29809. * @param scene defines hosting scene
  29810. */
  29811. constructor(scene: Scene);
  29812. /**
  29813. * Get the number of data values you will have to play with for the visualization
  29814. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29815. * @returns a number
  29816. */
  29817. getFrequencyBinCount(): number;
  29818. /**
  29819. * Gets the current frequency data as a byte array
  29820. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29821. * @returns a Uint8Array
  29822. */
  29823. getByteFrequencyData(): Uint8Array;
  29824. /**
  29825. * Gets the current waveform as a byte array
  29826. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29827. * @returns a Uint8Array
  29828. */
  29829. getByteTimeDomainData(): Uint8Array;
  29830. /**
  29831. * Gets the current frequency data as a float array
  29832. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29833. * @returns a Float32Array
  29834. */
  29835. getFloatFrequencyData(): Float32Array;
  29836. /**
  29837. * Renders the debug canvas
  29838. */
  29839. drawDebugCanvas(): void;
  29840. /**
  29841. * Stops rendering the debug canvas and removes it
  29842. */
  29843. stopDebugCanvas(): void;
  29844. /**
  29845. * Connects two audio nodes
  29846. * @param inputAudioNode defines first node to connect
  29847. * @param outputAudioNode defines second node to connect
  29848. */
  29849. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29850. /**
  29851. * Releases all associated resources
  29852. */
  29853. dispose(): void;
  29854. }
  29855. }
  29856. declare module BABYLON {
  29857. /**
  29858. * This represents an audio engine and it is responsible
  29859. * to play, synchronize and analyse sounds throughout the application.
  29860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29861. */
  29862. export interface IAudioEngine extends IDisposable {
  29863. /**
  29864. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29865. */
  29866. readonly canUseWebAudio: boolean;
  29867. /**
  29868. * Gets the current AudioContext if available.
  29869. */
  29870. readonly audioContext: Nullable<AudioContext>;
  29871. /**
  29872. * The master gain node defines the global audio volume of your audio engine.
  29873. */
  29874. readonly masterGain: GainNode;
  29875. /**
  29876. * Gets whether or not mp3 are supported by your browser.
  29877. */
  29878. readonly isMP3supported: boolean;
  29879. /**
  29880. * Gets whether or not ogg are supported by your browser.
  29881. */
  29882. readonly isOGGsupported: boolean;
  29883. /**
  29884. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29885. * @ignoreNaming
  29886. */
  29887. WarnedWebAudioUnsupported: boolean;
  29888. /**
  29889. * Defines if the audio engine relies on a custom unlocked button.
  29890. * In this case, the embedded button will not be displayed.
  29891. */
  29892. useCustomUnlockedButton: boolean;
  29893. /**
  29894. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29895. */
  29896. readonly unlocked: boolean;
  29897. /**
  29898. * Event raised when audio has been unlocked on the browser.
  29899. */
  29900. onAudioUnlockedObservable: Observable<AudioEngine>;
  29901. /**
  29902. * Event raised when audio has been locked on the browser.
  29903. */
  29904. onAudioLockedObservable: Observable<AudioEngine>;
  29905. /**
  29906. * Flags the audio engine in Locked state.
  29907. * This happens due to new browser policies preventing audio to autoplay.
  29908. */
  29909. lock(): void;
  29910. /**
  29911. * Unlocks the audio engine once a user action has been done on the dom.
  29912. * This is helpful to resume play once browser policies have been satisfied.
  29913. */
  29914. unlock(): void;
  29915. }
  29916. /**
  29917. * This represents the default audio engine used in babylon.
  29918. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29919. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29920. */
  29921. export class AudioEngine implements IAudioEngine {
  29922. private _audioContext;
  29923. private _audioContextInitialized;
  29924. private _muteButton;
  29925. private _hostElement;
  29926. /**
  29927. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29928. */
  29929. canUseWebAudio: boolean;
  29930. /**
  29931. * The master gain node defines the global audio volume of your audio engine.
  29932. */
  29933. masterGain: GainNode;
  29934. /**
  29935. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29936. * @ignoreNaming
  29937. */
  29938. WarnedWebAudioUnsupported: boolean;
  29939. /**
  29940. * Gets whether or not mp3 are supported by your browser.
  29941. */
  29942. isMP3supported: boolean;
  29943. /**
  29944. * Gets whether or not ogg are supported by your browser.
  29945. */
  29946. isOGGsupported: boolean;
  29947. /**
  29948. * Gets whether audio has been unlocked on the device.
  29949. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29950. * a user interaction has happened.
  29951. */
  29952. unlocked: boolean;
  29953. /**
  29954. * Defines if the audio engine relies on a custom unlocked button.
  29955. * In this case, the embedded button will not be displayed.
  29956. */
  29957. useCustomUnlockedButton: boolean;
  29958. /**
  29959. * Event raised when audio has been unlocked on the browser.
  29960. */
  29961. onAudioUnlockedObservable: Observable<AudioEngine>;
  29962. /**
  29963. * Event raised when audio has been locked on the browser.
  29964. */
  29965. onAudioLockedObservable: Observable<AudioEngine>;
  29966. /**
  29967. * Gets the current AudioContext if available.
  29968. */
  29969. readonly audioContext: Nullable<AudioContext>;
  29970. private _connectedAnalyser;
  29971. /**
  29972. * Instantiates a new audio engine.
  29973. *
  29974. * There should be only one per page as some browsers restrict the number
  29975. * of audio contexts you can create.
  29976. * @param hostElement defines the host element where to display the mute icon if necessary
  29977. */
  29978. constructor(hostElement?: Nullable<HTMLElement>);
  29979. /**
  29980. * Flags the audio engine in Locked state.
  29981. * This happens due to new browser policies preventing audio to autoplay.
  29982. */
  29983. lock(): void;
  29984. /**
  29985. * Unlocks the audio engine once a user action has been done on the dom.
  29986. * This is helpful to resume play once browser policies have been satisfied.
  29987. */
  29988. unlock(): void;
  29989. private _resumeAudioContext;
  29990. private _initializeAudioContext;
  29991. private _tryToRun;
  29992. private _triggerRunningState;
  29993. private _triggerSuspendedState;
  29994. private _displayMuteButton;
  29995. private _moveButtonToTopLeft;
  29996. private _onResize;
  29997. private _hideMuteButton;
  29998. /**
  29999. * Destroy and release the resources associated with the audio ccontext.
  30000. */
  30001. dispose(): void;
  30002. /**
  30003. * Gets the global volume sets on the master gain.
  30004. * @returns the global volume if set or -1 otherwise
  30005. */
  30006. getGlobalVolume(): number;
  30007. /**
  30008. * Sets the global volume of your experience (sets on the master gain).
  30009. * @param newVolume Defines the new global volume of the application
  30010. */
  30011. setGlobalVolume(newVolume: number): void;
  30012. /**
  30013. * Connect the audio engine to an audio analyser allowing some amazing
  30014. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30015. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30016. * @param analyser The analyser to connect to the engine
  30017. */
  30018. connectToAnalyser(analyser: Analyser): void;
  30019. }
  30020. }
  30021. declare module BABYLON {
  30022. /**
  30023. * Interface used to present a loading screen while loading a scene
  30024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30025. */
  30026. export interface ILoadingScreen {
  30027. /**
  30028. * Function called to display the loading screen
  30029. */
  30030. displayLoadingUI: () => void;
  30031. /**
  30032. * Function called to hide the loading screen
  30033. */
  30034. hideLoadingUI: () => void;
  30035. /**
  30036. * Gets or sets the color to use for the background
  30037. */
  30038. loadingUIBackgroundColor: string;
  30039. /**
  30040. * Gets or sets the text to display while loading
  30041. */
  30042. loadingUIText: string;
  30043. }
  30044. /**
  30045. * Class used for the default loading screen
  30046. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30047. */
  30048. export class DefaultLoadingScreen implements ILoadingScreen {
  30049. private _renderingCanvas;
  30050. private _loadingText;
  30051. private _loadingDivBackgroundColor;
  30052. private _loadingDiv;
  30053. private _loadingTextDiv;
  30054. /** Gets or sets the logo url to use for the default loading screen */
  30055. static DefaultLogoUrl: string;
  30056. /** Gets or sets the spinner url to use for the default loading screen */
  30057. static DefaultSpinnerUrl: string;
  30058. /**
  30059. * Creates a new default loading screen
  30060. * @param _renderingCanvas defines the canvas used to render the scene
  30061. * @param _loadingText defines the default text to display
  30062. * @param _loadingDivBackgroundColor defines the default background color
  30063. */
  30064. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30065. /**
  30066. * Function called to display the loading screen
  30067. */
  30068. displayLoadingUI(): void;
  30069. /**
  30070. * Function called to hide the loading screen
  30071. */
  30072. hideLoadingUI(): void;
  30073. /**
  30074. * Gets or sets the text to display while loading
  30075. */
  30076. loadingUIText: string;
  30077. /**
  30078. * Gets or sets the color to use for the background
  30079. */
  30080. loadingUIBackgroundColor: string;
  30081. private _resizeLoadingUI;
  30082. }
  30083. }
  30084. declare module BABYLON {
  30085. /**
  30086. * Interface for any object that can request an animation frame
  30087. */
  30088. export interface ICustomAnimationFrameRequester {
  30089. /**
  30090. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30091. */
  30092. renderFunction?: Function;
  30093. /**
  30094. * Called to request the next frame to render to
  30095. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30096. */
  30097. requestAnimationFrame: Function;
  30098. /**
  30099. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30100. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30101. */
  30102. requestID?: number;
  30103. }
  30104. }
  30105. declare module BABYLON {
  30106. /**
  30107. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  30108. */
  30109. export class PerformanceMonitor {
  30110. private _enabled;
  30111. private _rollingFrameTime;
  30112. private _lastFrameTimeMs;
  30113. /**
  30114. * constructor
  30115. * @param frameSampleSize The number of samples required to saturate the sliding window
  30116. */
  30117. constructor(frameSampleSize?: number);
  30118. /**
  30119. * Samples current frame
  30120. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  30121. */
  30122. sampleFrame(timeMs?: number): void;
  30123. /**
  30124. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30125. */
  30126. readonly averageFrameTime: number;
  30127. /**
  30128. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  30129. */
  30130. readonly averageFrameTimeVariance: number;
  30131. /**
  30132. * Returns the frame time of the most recent frame
  30133. */
  30134. readonly instantaneousFrameTime: number;
  30135. /**
  30136. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  30137. */
  30138. readonly averageFPS: number;
  30139. /**
  30140. * Returns the average framerate in frames per second using the most recent frame time
  30141. */
  30142. readonly instantaneousFPS: number;
  30143. /**
  30144. * Returns true if enough samples have been taken to completely fill the sliding window
  30145. */
  30146. readonly isSaturated: boolean;
  30147. /**
  30148. * Enables contributions to the sliding window sample set
  30149. */
  30150. enable(): void;
  30151. /**
  30152. * Disables contributions to the sliding window sample set
  30153. * Samples will not be interpolated over the disabled period
  30154. */
  30155. disable(): void;
  30156. /**
  30157. * Returns true if sampling is enabled
  30158. */
  30159. readonly isEnabled: boolean;
  30160. /**
  30161. * Resets performance monitor
  30162. */
  30163. reset(): void;
  30164. }
  30165. /**
  30166. * RollingAverage
  30167. *
  30168. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  30169. */
  30170. export class RollingAverage {
  30171. /**
  30172. * Current average
  30173. */
  30174. average: number;
  30175. /**
  30176. * Current variance
  30177. */
  30178. variance: number;
  30179. protected _samples: Array<number>;
  30180. protected _sampleCount: number;
  30181. protected _pos: number;
  30182. protected _m2: number;
  30183. /**
  30184. * constructor
  30185. * @param length The number of samples required to saturate the sliding window
  30186. */
  30187. constructor(length: number);
  30188. /**
  30189. * Adds a sample to the sample set
  30190. * @param v The sample value
  30191. */
  30192. add(v: number): void;
  30193. /**
  30194. * Returns previously added values or null if outside of history or outside the sliding window domain
  30195. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  30196. * @return Value previously recorded with add() or null if outside of range
  30197. */
  30198. history(i: number): number;
  30199. /**
  30200. * Returns true if enough samples have been taken to completely fill the sliding window
  30201. * @return true if sample-set saturated
  30202. */
  30203. isSaturated(): boolean;
  30204. /**
  30205. * Resets the rolling average (equivalent to 0 samples taken so far)
  30206. */
  30207. reset(): void;
  30208. /**
  30209. * Wraps a value around the sample range boundaries
  30210. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  30211. * @return Wrapped position in sample range
  30212. */
  30213. protected _wrapPosition(i: number): number;
  30214. }
  30215. }
  30216. declare module BABYLON {
  30217. /**
  30218. * This class is used to track a performance counter which is number based.
  30219. * The user has access to many properties which give statistics of different nature.
  30220. *
  30221. * The implementer can track two kinds of Performance Counter: time and count.
  30222. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  30223. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  30224. */
  30225. export class PerfCounter {
  30226. /**
  30227. * Gets or sets a global boolean to turn on and off all the counters
  30228. */
  30229. static Enabled: boolean;
  30230. /**
  30231. * Returns the smallest value ever
  30232. */
  30233. readonly min: number;
  30234. /**
  30235. * Returns the biggest value ever
  30236. */
  30237. readonly max: number;
  30238. /**
  30239. * Returns the average value since the performance counter is running
  30240. */
  30241. readonly average: number;
  30242. /**
  30243. * Returns the average value of the last second the counter was monitored
  30244. */
  30245. readonly lastSecAverage: number;
  30246. /**
  30247. * Returns the current value
  30248. */
  30249. readonly current: number;
  30250. /**
  30251. * Gets the accumulated total
  30252. */
  30253. readonly total: number;
  30254. /**
  30255. * Gets the total value count
  30256. */
  30257. readonly count: number;
  30258. /**
  30259. * Creates a new counter
  30260. */
  30261. constructor();
  30262. /**
  30263. * Call this method to start monitoring a new frame.
  30264. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  30265. */
  30266. fetchNewFrame(): void;
  30267. /**
  30268. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30269. * @param newCount the count value to add to the monitored count
  30270. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  30271. */
  30272. addCount(newCount: number, fetchResult: boolean): void;
  30273. /**
  30274. * Start monitoring this performance counter
  30275. */
  30276. beginMonitoring(): void;
  30277. /**
  30278. * Compute the time lapsed since the previous beginMonitoring() call.
  30279. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  30280. */
  30281. endMonitoring(newFrame?: boolean): void;
  30282. private _fetchResult;
  30283. private _startMonitoringTime;
  30284. private _min;
  30285. private _max;
  30286. private _average;
  30287. private _current;
  30288. private _totalValueCount;
  30289. private _totalAccumulated;
  30290. private _lastSecAverage;
  30291. private _lastSecAccumulated;
  30292. private _lastSecTime;
  30293. private _lastSecValueCount;
  30294. }
  30295. }
  30296. declare module BABYLON {
  30297. /**
  30298. * Defines the interface used by display changed events
  30299. */
  30300. export interface IDisplayChangedEventArgs {
  30301. /** Gets the vrDisplay object (if any) */
  30302. vrDisplay: Nullable<any>;
  30303. /** Gets a boolean indicating if webVR is supported */
  30304. vrSupported: boolean;
  30305. }
  30306. /**
  30307. * Defines the interface used by objects containing a viewport (like a camera)
  30308. */
  30309. interface IViewportOwnerLike {
  30310. /**
  30311. * Gets or sets the viewport
  30312. */
  30313. viewport: IViewportLike;
  30314. }
  30315. /**
  30316. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30317. */
  30318. export class Engine extends ThinEngine {
  30319. /** Defines that alpha blending is disabled */
  30320. static readonly ALPHA_DISABLE: number;
  30321. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30322. static readonly ALPHA_ADD: number;
  30323. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30324. static readonly ALPHA_COMBINE: number;
  30325. /** Defines that alpha blending to DEST - SRC * DEST */
  30326. static readonly ALPHA_SUBTRACT: number;
  30327. /** Defines that alpha blending to SRC * DEST */
  30328. static readonly ALPHA_MULTIPLY: number;
  30329. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30330. static readonly ALPHA_MAXIMIZED: number;
  30331. /** Defines that alpha blending to SRC + DEST */
  30332. static readonly ALPHA_ONEONE: number;
  30333. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30334. static readonly ALPHA_PREMULTIPLIED: number;
  30335. /**
  30336. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30337. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30338. */
  30339. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30340. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30341. static readonly ALPHA_INTERPOLATE: number;
  30342. /**
  30343. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30344. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30345. */
  30346. static readonly ALPHA_SCREENMODE: number;
  30347. /** Defines that the ressource is not delayed*/
  30348. static readonly DELAYLOADSTATE_NONE: number;
  30349. /** Defines that the ressource was successfully delay loaded */
  30350. static readonly DELAYLOADSTATE_LOADED: number;
  30351. /** Defines that the ressource is currently delay loading */
  30352. static readonly DELAYLOADSTATE_LOADING: number;
  30353. /** Defines that the ressource is delayed and has not started loading */
  30354. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30355. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30356. static readonly NEVER: number;
  30357. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  30358. static readonly ALWAYS: number;
  30359. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30360. static readonly LESS: number;
  30361. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30362. static readonly EQUAL: number;
  30363. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  30364. static readonly LEQUAL: number;
  30365. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30366. static readonly GREATER: number;
  30367. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  30368. static readonly GEQUAL: number;
  30369. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  30370. static readonly NOTEQUAL: number;
  30371. /** Passed to stencilOperation to specify that stencil value must be kept */
  30372. static readonly KEEP: number;
  30373. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30374. static readonly REPLACE: number;
  30375. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30376. static readonly INCR: number;
  30377. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30378. static readonly DECR: number;
  30379. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30380. static readonly INVERT: number;
  30381. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30382. static readonly INCR_WRAP: number;
  30383. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30384. static readonly DECR_WRAP: number;
  30385. /** Texture is not repeating outside of 0..1 UVs */
  30386. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30387. /** Texture is repeating outside of 0..1 UVs */
  30388. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30389. /** Texture is repeating and mirrored */
  30390. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30391. /** ALPHA */
  30392. static readonly TEXTUREFORMAT_ALPHA: number;
  30393. /** LUMINANCE */
  30394. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30395. /** LUMINANCE_ALPHA */
  30396. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30397. /** RGB */
  30398. static readonly TEXTUREFORMAT_RGB: number;
  30399. /** RGBA */
  30400. static readonly TEXTUREFORMAT_RGBA: number;
  30401. /** RED */
  30402. static readonly TEXTUREFORMAT_RED: number;
  30403. /** RED (2nd reference) */
  30404. static readonly TEXTUREFORMAT_R: number;
  30405. /** RG */
  30406. static readonly TEXTUREFORMAT_RG: number;
  30407. /** RED_INTEGER */
  30408. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30409. /** RED_INTEGER (2nd reference) */
  30410. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30411. /** RG_INTEGER */
  30412. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30413. /** RGB_INTEGER */
  30414. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30415. /** RGBA_INTEGER */
  30416. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30417. /** UNSIGNED_BYTE */
  30418. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30419. /** UNSIGNED_BYTE (2nd reference) */
  30420. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30421. /** FLOAT */
  30422. static readonly TEXTURETYPE_FLOAT: number;
  30423. /** HALF_FLOAT */
  30424. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30425. /** BYTE */
  30426. static readonly TEXTURETYPE_BYTE: number;
  30427. /** SHORT */
  30428. static readonly TEXTURETYPE_SHORT: number;
  30429. /** UNSIGNED_SHORT */
  30430. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30431. /** INT */
  30432. static readonly TEXTURETYPE_INT: number;
  30433. /** UNSIGNED_INT */
  30434. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30435. /** UNSIGNED_SHORT_4_4_4_4 */
  30436. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30437. /** UNSIGNED_SHORT_5_5_5_1 */
  30438. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30439. /** UNSIGNED_SHORT_5_6_5 */
  30440. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30441. /** UNSIGNED_INT_2_10_10_10_REV */
  30442. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30443. /** UNSIGNED_INT_24_8 */
  30444. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30445. /** UNSIGNED_INT_10F_11F_11F_REV */
  30446. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30447. /** UNSIGNED_INT_5_9_9_9_REV */
  30448. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30449. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30450. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30451. /** nearest is mag = nearest and min = nearest and mip = linear */
  30452. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30453. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30454. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30455. /** Trilinear is mag = linear and min = linear and mip = linear */
  30456. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30457. /** nearest is mag = nearest and min = nearest and mip = linear */
  30458. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30459. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30460. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30461. /** Trilinear is mag = linear and min = linear and mip = linear */
  30462. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30463. /** mag = nearest and min = nearest and mip = nearest */
  30464. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30465. /** mag = nearest and min = linear and mip = nearest */
  30466. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30467. /** mag = nearest and min = linear and mip = linear */
  30468. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30469. /** mag = nearest and min = linear and mip = none */
  30470. static readonly TEXTURE_NEAREST_LINEAR: number;
  30471. /** mag = nearest and min = nearest and mip = none */
  30472. static readonly TEXTURE_NEAREST_NEAREST: number;
  30473. /** mag = linear and min = nearest and mip = nearest */
  30474. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30475. /** mag = linear and min = nearest and mip = linear */
  30476. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30477. /** mag = linear and min = linear and mip = none */
  30478. static readonly TEXTURE_LINEAR_LINEAR: number;
  30479. /** mag = linear and min = nearest and mip = none */
  30480. static readonly TEXTURE_LINEAR_NEAREST: number;
  30481. /** Explicit coordinates mode */
  30482. static readonly TEXTURE_EXPLICIT_MODE: number;
  30483. /** Spherical coordinates mode */
  30484. static readonly TEXTURE_SPHERICAL_MODE: number;
  30485. /** Planar coordinates mode */
  30486. static readonly TEXTURE_PLANAR_MODE: number;
  30487. /** Cubic coordinates mode */
  30488. static readonly TEXTURE_CUBIC_MODE: number;
  30489. /** Projection coordinates mode */
  30490. static readonly TEXTURE_PROJECTION_MODE: number;
  30491. /** Skybox coordinates mode */
  30492. static readonly TEXTURE_SKYBOX_MODE: number;
  30493. /** Inverse Cubic coordinates mode */
  30494. static readonly TEXTURE_INVCUBIC_MODE: number;
  30495. /** Equirectangular coordinates mode */
  30496. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30497. /** Equirectangular Fixed coordinates mode */
  30498. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30499. /** Equirectangular Fixed Mirrored coordinates mode */
  30500. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30501. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30502. static readonly SCALEMODE_FLOOR: number;
  30503. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30504. static readonly SCALEMODE_NEAREST: number;
  30505. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30506. static readonly SCALEMODE_CEILING: number;
  30507. /**
  30508. * Returns the current npm package of the sdk
  30509. */
  30510. static readonly NpmPackage: string;
  30511. /**
  30512. * Returns the current version of the framework
  30513. */
  30514. static readonly Version: string;
  30515. /** Gets the list of created engines */
  30516. static readonly Instances: Engine[];
  30517. /**
  30518. * Gets the latest created engine
  30519. */
  30520. static readonly LastCreatedEngine: Nullable<Engine>;
  30521. /**
  30522. * Gets the latest created scene
  30523. */
  30524. static readonly LastCreatedScene: Nullable<Scene>;
  30525. /**
  30526. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30527. * @param flag defines which part of the materials must be marked as dirty
  30528. * @param predicate defines a predicate used to filter which materials should be affected
  30529. */
  30530. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30531. /**
  30532. * Method called to create the default loading screen.
  30533. * This can be overriden in your own app.
  30534. * @param canvas The rendering canvas element
  30535. * @returns The loading screen
  30536. */
  30537. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30538. /**
  30539. * Method called to create the default rescale post process on each engine.
  30540. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30541. /**
  30542. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30543. **/
  30544. enableOfflineSupport: boolean;
  30545. /**
  30546. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  30547. **/
  30548. disableManifestCheck: boolean;
  30549. /**
  30550. * Gets the list of created scenes
  30551. */
  30552. scenes: Scene[];
  30553. /**
  30554. * Event raised when a new scene is created
  30555. */
  30556. onNewSceneAddedObservable: Observable<Scene>;
  30557. /**
  30558. * Gets the list of created postprocesses
  30559. */
  30560. postProcesses: PostProcess[];
  30561. /**
  30562. * Gets a boolean indicating if the pointer is currently locked
  30563. */
  30564. isPointerLock: boolean;
  30565. /**
  30566. * Observable event triggered each time the rendering canvas is resized
  30567. */
  30568. onResizeObservable: Observable<Engine>;
  30569. /**
  30570. * Observable event triggered each time the canvas loses focus
  30571. */
  30572. onCanvasBlurObservable: Observable<Engine>;
  30573. /**
  30574. * Observable event triggered each time the canvas gains focus
  30575. */
  30576. onCanvasFocusObservable: Observable<Engine>;
  30577. /**
  30578. * Observable event triggered each time the canvas receives pointerout event
  30579. */
  30580. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30581. /**
  30582. * Observable raised when the engine begins a new frame
  30583. */
  30584. onBeginFrameObservable: Observable<Engine>;
  30585. /**
  30586. * If set, will be used to request the next animation frame for the render loop
  30587. */
  30588. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30589. /**
  30590. * Observable raised when the engine ends the current frame
  30591. */
  30592. onEndFrameObservable: Observable<Engine>;
  30593. /**
  30594. * Observable raised when the engine is about to compile a shader
  30595. */
  30596. onBeforeShaderCompilationObservable: Observable<Engine>;
  30597. /**
  30598. * Observable raised when the engine has jsut compiled a shader
  30599. */
  30600. onAfterShaderCompilationObservable: Observable<Engine>;
  30601. /**
  30602. * Gets the audio engine
  30603. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30604. * @ignorenaming
  30605. */
  30606. static audioEngine: IAudioEngine;
  30607. /**
  30608. * Default AudioEngine factory responsible of creating the Audio Engine.
  30609. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30610. */
  30611. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30612. /**
  30613. * Default offline support factory responsible of creating a tool used to store data locally.
  30614. * By default, this will create a Database object if the workload has been embedded.
  30615. */
  30616. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30617. private _loadingScreen;
  30618. private _pointerLockRequested;
  30619. private _dummyFramebuffer;
  30620. private _rescalePostProcess;
  30621. /** @hidden */
  30622. protected _alphaMode: number;
  30623. /** @hidden */
  30624. protected _alphaEquation: number;
  30625. private _deterministicLockstep;
  30626. private _lockstepMaxSteps;
  30627. protected readonly _supportsHardwareTextureRescaling: boolean;
  30628. private _fps;
  30629. private _deltaTime;
  30630. /** @hidden */ private _drawCalls: PerfCounter;
  30631. /**
  30632. * Turn this value on if you want to pause FPS computation when in background
  30633. */
  30634. disablePerformanceMonitorInBackground: boolean;
  30635. private _performanceMonitor;
  30636. /**
  30637. * Gets the performance monitor attached to this engine
  30638. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30639. */
  30640. readonly performanceMonitor: PerformanceMonitor;
  30641. private _onFocus;
  30642. private _onBlur;
  30643. private _onCanvasPointerOut;
  30644. private _onCanvasBlur;
  30645. private _onCanvasFocus;
  30646. private _onFullscreenChange;
  30647. private _onPointerLockChange;
  30648. /**
  30649. * Creates a new engine
  30650. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  30651. * @param antialias defines enable antialiasing (default: false)
  30652. * @param options defines further options to be sent to the getContext() function
  30653. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30654. */
  30655. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30656. /**
  30657. * Gets current aspect ratio
  30658. * @param viewportOwner defines the camera to use to get the aspect ratio
  30659. * @param useScreen defines if screen size must be used (or the current render target if any)
  30660. * @returns a number defining the aspect ratio
  30661. */
  30662. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  30663. /**
  30664. * Gets current screen aspect ratio
  30665. * @returns a number defining the aspect ratio
  30666. */
  30667. getScreenAspectRatio(): number;
  30668. /**
  30669. * Gets host document
  30670. * @returns the host document object
  30671. */
  30672. getHostDocument(): Document;
  30673. /**
  30674. * Gets the client rect of the HTML canvas attached with the current webGL context
  30675. * @returns a client rectanglee
  30676. */
  30677. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  30678. /**
  30679. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  30680. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30681. * @returns true if engine is in deterministic lock step mode
  30682. */
  30683. isDeterministicLockStep(): boolean;
  30684. /**
  30685. * Gets the max steps when engine is running in deterministic lock step
  30686. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30687. * @returns the max steps
  30688. */
  30689. getLockstepMaxSteps(): number;
  30690. /**
  30691. * Force the mipmap generation for the given render target texture
  30692. * @param texture defines the render target texture to use
  30693. */
  30694. generateMipMapsForCubemap(texture: InternalTexture): void;
  30695. /** States */
  30696. /**
  30697. * Set various states to the webGL context
  30698. * @param culling defines backface culling state
  30699. * @param zOffset defines the value to apply to zOffset (0 by default)
  30700. * @param force defines if states must be applied even if cache is up to date
  30701. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30702. */
  30703. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30704. /**
  30705. * Set the z offset to apply to current rendering
  30706. * @param value defines the offset to apply
  30707. */
  30708. setZOffset(value: number): void;
  30709. /**
  30710. * Gets the current value of the zOffset
  30711. * @returns the current zOffset state
  30712. */
  30713. getZOffset(): number;
  30714. /**
  30715. * Enable or disable depth buffering
  30716. * @param enable defines the state to set
  30717. */
  30718. setDepthBuffer(enable: boolean): void;
  30719. /**
  30720. * Gets a boolean indicating if depth writing is enabled
  30721. * @returns the current depth writing state
  30722. */
  30723. getDepthWrite(): boolean;
  30724. /**
  30725. * Enable or disable depth writing
  30726. * @param enable defines the state to set
  30727. */
  30728. setDepthWrite(enable: boolean): void;
  30729. /**
  30730. * Enable or disable color writing
  30731. * @param enable defines the state to set
  30732. */
  30733. setColorWrite(enable: boolean): void;
  30734. /**
  30735. * Gets a boolean indicating if color writing is enabled
  30736. * @returns the current color writing state
  30737. */
  30738. getColorWrite(): boolean;
  30739. /**
  30740. * Sets alpha constants used by some alpha blending modes
  30741. * @param r defines the red component
  30742. * @param g defines the green component
  30743. * @param b defines the blue component
  30744. * @param a defines the alpha component
  30745. */
  30746. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30747. /**
  30748. * Sets the current alpha mode
  30749. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30750. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30751. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30752. */
  30753. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30754. /**
  30755. * Gets the current alpha mode
  30756. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30757. * @returns the current alpha mode
  30758. */
  30759. getAlphaMode(): number;
  30760. /**
  30761. * Sets the current alpha equation
  30762. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  30763. */
  30764. setAlphaEquation(equation: number): void;
  30765. /**
  30766. * Gets the current alpha equation.
  30767. * @returns the current alpha equation
  30768. */
  30769. getAlphaEquation(): number;
  30770. /**
  30771. * Gets a boolean indicating if stencil buffer is enabled
  30772. * @returns the current stencil buffer state
  30773. */
  30774. getStencilBuffer(): boolean;
  30775. /**
  30776. * Enable or disable the stencil buffer
  30777. * @param enable defines if the stencil buffer must be enabled or disabled
  30778. */
  30779. setStencilBuffer(enable: boolean): void;
  30780. /**
  30781. * Gets the current stencil mask
  30782. * @returns a number defining the new stencil mask to use
  30783. */
  30784. getStencilMask(): number;
  30785. /**
  30786. * Sets the current stencil mask
  30787. * @param mask defines the new stencil mask to use
  30788. */
  30789. setStencilMask(mask: number): void;
  30790. /**
  30791. * Gets the current stencil function
  30792. * @returns a number defining the stencil function to use
  30793. */
  30794. getStencilFunction(): number;
  30795. /**
  30796. * Gets the current stencil reference value
  30797. * @returns a number defining the stencil reference value to use
  30798. */
  30799. getStencilFunctionReference(): number;
  30800. /**
  30801. * Gets the current stencil mask
  30802. * @returns a number defining the stencil mask to use
  30803. */
  30804. getStencilFunctionMask(): number;
  30805. /**
  30806. * Sets the current stencil function
  30807. * @param stencilFunc defines the new stencil function to use
  30808. */
  30809. setStencilFunction(stencilFunc: number): void;
  30810. /**
  30811. * Sets the current stencil reference
  30812. * @param reference defines the new stencil reference to use
  30813. */
  30814. setStencilFunctionReference(reference: number): void;
  30815. /**
  30816. * Sets the current stencil mask
  30817. * @param mask defines the new stencil mask to use
  30818. */
  30819. setStencilFunctionMask(mask: number): void;
  30820. /**
  30821. * Gets the current stencil operation when stencil fails
  30822. * @returns a number defining stencil operation to use when stencil fails
  30823. */
  30824. getStencilOperationFail(): number;
  30825. /**
  30826. * Gets the current stencil operation when depth fails
  30827. * @returns a number defining stencil operation to use when depth fails
  30828. */
  30829. getStencilOperationDepthFail(): number;
  30830. /**
  30831. * Gets the current stencil operation when stencil passes
  30832. * @returns a number defining stencil operation to use when stencil passes
  30833. */
  30834. getStencilOperationPass(): number;
  30835. /**
  30836. * Sets the stencil operation to use when stencil fails
  30837. * @param operation defines the stencil operation to use when stencil fails
  30838. */
  30839. setStencilOperationFail(operation: number): void;
  30840. /**
  30841. * Sets the stencil operation to use when depth fails
  30842. * @param operation defines the stencil operation to use when depth fails
  30843. */
  30844. setStencilOperationDepthFail(operation: number): void;
  30845. /**
  30846. * Sets the stencil operation to use when stencil passes
  30847. * @param operation defines the stencil operation to use when stencil passes
  30848. */
  30849. setStencilOperationPass(operation: number): void;
  30850. /**
  30851. * Sets a boolean indicating if the dithering state is enabled or disabled
  30852. * @param value defines the dithering state
  30853. */
  30854. setDitheringState(value: boolean): void;
  30855. /**
  30856. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  30857. * @param value defines the rasterizer state
  30858. */
  30859. setRasterizerState(value: boolean): void;
  30860. /**
  30861. * Gets the current depth function
  30862. * @returns a number defining the depth function
  30863. */
  30864. getDepthFunction(): Nullable<number>;
  30865. /**
  30866. * Sets the current depth function
  30867. * @param depthFunc defines the function to use
  30868. */
  30869. setDepthFunction(depthFunc: number): void;
  30870. /**
  30871. * Sets the current depth function to GREATER
  30872. */
  30873. setDepthFunctionToGreater(): void;
  30874. /**
  30875. * Sets the current depth function to GEQUAL
  30876. */
  30877. setDepthFunctionToGreaterOrEqual(): void;
  30878. /**
  30879. * Sets the current depth function to LESS
  30880. */
  30881. setDepthFunctionToLess(): void;
  30882. /**
  30883. * Sets the current depth function to LEQUAL
  30884. */
  30885. setDepthFunctionToLessOrEqual(): void;
  30886. private _cachedStencilBuffer;
  30887. private _cachedStencilFunction;
  30888. private _cachedStencilMask;
  30889. private _cachedStencilOperationPass;
  30890. private _cachedStencilOperationFail;
  30891. private _cachedStencilOperationDepthFail;
  30892. private _cachedStencilReference;
  30893. /**
  30894. * Caches the the state of the stencil buffer
  30895. */
  30896. cacheStencilState(): void;
  30897. /**
  30898. * Restores the state of the stencil buffer
  30899. */
  30900. restoreStencilState(): void;
  30901. /**
  30902. * Directly set the WebGL Viewport
  30903. * @param x defines the x coordinate of the viewport (in screen space)
  30904. * @param y defines the y coordinate of the viewport (in screen space)
  30905. * @param width defines the width of the viewport (in screen space)
  30906. * @param height defines the height of the viewport (in screen space)
  30907. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  30908. */
  30909. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30910. /**
  30911. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  30912. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30913. * @param y defines the y-coordinate of the corner of the clear rectangle
  30914. * @param width defines the width of the clear rectangle
  30915. * @param height defines the height of the clear rectangle
  30916. * @param clearColor defines the clear color
  30917. */
  30918. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  30919. /**
  30920. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  30921. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30922. * @param y defines the y-coordinate of the corner of the clear rectangle
  30923. * @param width defines the width of the clear rectangle
  30924. * @param height defines the height of the clear rectangle
  30925. */
  30926. enableScissor(x: number, y: number, width: number, height: number): void;
  30927. /**
  30928. * Disable previously set scissor test rectangle
  30929. */
  30930. disableScissor(): void;
  30931. protected _reportDrawCall(): void;
  30932. /**
  30933. * Initializes a webVR display and starts listening to display change events
  30934. * The onVRDisplayChangedObservable will be notified upon these changes
  30935. * @returns The onVRDisplayChangedObservable
  30936. */
  30937. initWebVR(): Observable<IDisplayChangedEventArgs>;
  30938. /** @hidden */ private _prepareVRComponent(): void;
  30939. /** @hidden */ private _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  30940. /** @hidden */ private _submitVRFrame(): void;
  30941. /**
  30942. * Call this function to leave webVR mode
  30943. * Will do nothing if webVR is not supported or if there is no webVR device
  30944. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30945. */
  30946. disableVR(): void;
  30947. /**
  30948. * Gets a boolean indicating that the system is in VR mode and is presenting
  30949. * @returns true if VR mode is engaged
  30950. */
  30951. isVRPresenting(): boolean;
  30952. /** @hidden */ private _requestVRFrame(): void;
  30953. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30954. /**
  30955. * Gets the source code of the vertex shader associated with a specific webGL program
  30956. * @param program defines the program to use
  30957. * @returns a string containing the source code of the vertex shader associated with the program
  30958. */
  30959. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30960. /**
  30961. * Gets the source code of the fragment shader associated with a specific webGL program
  30962. * @param program defines the program to use
  30963. * @returns a string containing the source code of the fragment shader associated with the program
  30964. */
  30965. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30966. /**
  30967. * Reads pixels from the current frame buffer. Please note that this function can be slow
  30968. * @param x defines the x coordinate of the rectangle where pixels must be read
  30969. * @param y defines the y coordinate of the rectangle where pixels must be read
  30970. * @param width defines the width of the rectangle where pixels must be read
  30971. * @param height defines the height of the rectangle where pixels must be read
  30972. * @returns a Uint8Array containing RGBA colors
  30973. */
  30974. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  30975. /**
  30976. * Sets a depth stencil texture from a render target to the according uniform.
  30977. * @param channel The texture channel
  30978. * @param uniform The uniform to set
  30979. * @param texture The render target texture containing the depth stencil texture to apply
  30980. */
  30981. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  30982. /**
  30983. * Sets a texture to the webGL context from a postprocess
  30984. * @param channel defines the channel to use
  30985. * @param postProcess defines the source postprocess
  30986. */
  30987. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  30988. /**
  30989. * Binds the output of the passed in post process to the texture channel specified
  30990. * @param channel The channel the texture should be bound to
  30991. * @param postProcess The post process which's output should be bound
  30992. */
  30993. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  30994. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  30995. protected _rebuildBuffers(): void; private _renderLoop(): void;
  30996. /**
  30997. * Toggle full screen mode
  30998. * @param requestPointerLock defines if a pointer lock should be requested from the user
  30999. */
  31000. switchFullscreen(requestPointerLock: boolean): void;
  31001. /**
  31002. * Enters full screen mode
  31003. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31004. */
  31005. enterFullscreen(requestPointerLock: boolean): void;
  31006. /**
  31007. * Exits full screen mode
  31008. */
  31009. exitFullscreen(): void;
  31010. /**
  31011. * Enters Pointerlock mode
  31012. */
  31013. enterPointerlock(): void;
  31014. /**
  31015. * Exits Pointerlock mode
  31016. */
  31017. exitPointerlock(): void;
  31018. /**
  31019. * Begin a new frame
  31020. */
  31021. beginFrame(): void;
  31022. /**
  31023. * Enf the current frame
  31024. */
  31025. endFrame(): void;
  31026. resize(): void;
  31027. /**
  31028. * Set the compressed texture format to use, based on the formats you have, and the formats
  31029. * supported by the hardware / browser.
  31030. *
  31031. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31032. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31033. * to API arguments needed to compressed textures. This puts the burden on the container
  31034. * generator to house the arcane code for determining these for current & future formats.
  31035. *
  31036. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31037. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31038. *
  31039. * Note: The result of this call is not taken into account when a texture is base64.
  31040. *
  31041. * @param formatsAvailable defines the list of those format families you have created
  31042. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31043. *
  31044. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31045. * @returns The extension selected.
  31046. */
  31047. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31048. /**
  31049. * Force a specific size of the canvas
  31050. * @param width defines the new canvas' width
  31051. * @param height defines the new canvas' height
  31052. */
  31053. setSize(width: number, height: number): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31054. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31055. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram; private _releaseTexture(texture: InternalTexture): void;
  31056. /**
  31057. * @hidden
  31058. * Rescales a texture
  31059. * @param source input texutre
  31060. * @param destination destination texture
  31061. * @param scene scene to use to render the resize
  31062. * @param internalFormat format to use when resizing
  31063. * @param onComplete callback to be called when resize has completed
  31064. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31065. /**
  31066. * Gets the current framerate
  31067. * @returns a number representing the framerate
  31068. */
  31069. getFps(): number;
  31070. /**
  31071. * Gets the time spent between current and previous frame
  31072. * @returns a number representing the delta time in ms
  31073. */
  31074. getDeltaTime(): number;
  31075. private _measureFps;
  31076. /**
  31077. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31078. * @param renderTarget The render target to set the frame buffer for
  31079. */
  31080. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31081. /**
  31082. * Update a dynamic index buffer
  31083. * @param indexBuffer defines the target index buffer
  31084. * @param indices defines the data to update
  31085. * @param offset defines the offset in the target index buffer where update should start
  31086. */
  31087. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31088. /**
  31089. * Updates the sample count of a render target texture
  31090. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31091. * @param texture defines the texture to update
  31092. * @param samples defines the sample count to set
  31093. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31094. */
  31095. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  31096. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  31097. dispose(): void;
  31098. private _disableTouchAction;
  31099. /**
  31100. * Display the loading screen
  31101. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31102. */
  31103. displayLoadingUI(): void;
  31104. /**
  31105. * Hide the loading screen
  31106. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31107. */
  31108. hideLoadingUI(): void;
  31109. /**
  31110. * Gets the current loading screen object
  31111. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31112. */
  31113. /**
  31114. * Sets the current loading screen object
  31115. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31116. */
  31117. loadingScreen: ILoadingScreen;
  31118. /**
  31119. * Sets the current loading screen text
  31120. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31121. */
  31122. loadingUIText: string;
  31123. /**
  31124. * Sets the current loading screen background color
  31125. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31126. */
  31127. loadingUIBackgroundColor: string;
  31128. /** Pointerlock and fullscreen */
  31129. /**
  31130. * Ask the browser to promote the current element to pointerlock mode
  31131. * @param element defines the DOM element to promote
  31132. */ private static _RequestPointerlock(element: HTMLElement): void;
  31133. /**
  31134. * Asks the browser to exit pointerlock mode
  31135. */ private static _ExitPointerlock(): void;
  31136. /**
  31137. * Ask the browser to promote the current element to fullscreen rendering mode
  31138. * @param element defines the DOM element to promote
  31139. */ private static _RequestFullscreen(element: HTMLElement): void;
  31140. /**
  31141. * Asks the browser to exit fullscreen mode
  31142. */ private static _ExitFullscreen(): void;
  31143. }
  31144. }
  31145. declare module BABYLON {
  31146. /**
  31147. * The engine store class is responsible to hold all the instances of Engine and Scene created
  31148. * during the life time of the application.
  31149. */
  31150. export class EngineStore {
  31151. /** Gets the list of created engines */
  31152. static Instances: Engine[];
  31153. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  31154. /**
  31155. * Gets the latest created engine
  31156. */
  31157. static readonly LastCreatedEngine: Nullable<Engine>;
  31158. /**
  31159. * Gets the latest created scene
  31160. */
  31161. static readonly LastCreatedScene: Nullable<Scene>;
  31162. /**
  31163. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31164. * @ignorenaming
  31165. */
  31166. static UseFallbackTexture: boolean;
  31167. /**
  31168. * Texture content used if a texture cannot loaded
  31169. * @ignorenaming
  31170. */
  31171. static FallbackTexture: string;
  31172. }
  31173. }
  31174. declare module BABYLON {
  31175. /**
  31176. * Helper class that provides a small promise polyfill
  31177. */
  31178. export class PromisePolyfill {
  31179. /**
  31180. * Static function used to check if the polyfill is required
  31181. * If this is the case then the function will inject the polyfill to window.Promise
  31182. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  31183. */
  31184. static Apply(force?: boolean): void;
  31185. }
  31186. }
  31187. declare module BABYLON {
  31188. /**
  31189. * Interface for screenshot methods with describe argument called `size` as object with options
  31190. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31191. */
  31192. export interface IScreenshotSize {
  31193. /**
  31194. * number in pixels for canvas height
  31195. */
  31196. height?: number;
  31197. /**
  31198. * multiplier allowing render at a higher or lower resolution
  31199. * If value is defined then height and width will be ignored and taken from camera
  31200. */
  31201. precision?: number;
  31202. /**
  31203. * number in pixels for canvas width
  31204. */
  31205. width?: number;
  31206. }
  31207. }
  31208. declare module BABYLON {
  31209. interface IColor4Like {
  31210. r: float;
  31211. g: float;
  31212. b: float;
  31213. a: float;
  31214. }
  31215. /**
  31216. * Class containing a set of static utilities functions
  31217. */
  31218. export class Tools {
  31219. /**
  31220. * Gets or sets the base URL to use to load assets
  31221. */
  31222. static BaseUrl: string;
  31223. /**
  31224. * Enable/Disable Custom HTTP Request Headers globally.
  31225. * default = false
  31226. * @see CustomRequestHeaders
  31227. */
  31228. static UseCustomRequestHeaders: boolean;
  31229. /**
  31230. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31231. * i.e. when loading files, where the server/service expects an Authorization header
  31232. */
  31233. static CustomRequestHeaders: {
  31234. [key: string]: string;
  31235. };
  31236. /**
  31237. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31238. */
  31239. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31240. /**
  31241. * Default behaviour for cors in the application.
  31242. * It can be a string if the expected behavior is identical in the entire app.
  31243. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31244. */
  31245. static CorsBehavior: string | ((url: string | string[]) => string);
  31246. /**
  31247. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31248. * @ignorenaming
  31249. */
  31250. static UseFallbackTexture: boolean;
  31251. /**
  31252. * Use this object to register external classes like custom textures or material
  31253. * to allow the laoders to instantiate them
  31254. */
  31255. static RegisteredExternalClasses: {
  31256. [key: string]: Object;
  31257. };
  31258. /**
  31259. * Texture content used if a texture cannot loaded
  31260. * @ignorenaming
  31261. */
  31262. static fallbackTexture: string;
  31263. /**
  31264. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31265. * @param u defines the coordinate on X axis
  31266. * @param v defines the coordinate on Y axis
  31267. * @param width defines the width of the source data
  31268. * @param height defines the height of the source data
  31269. * @param pixels defines the source byte array
  31270. * @param color defines the output color
  31271. */
  31272. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31273. /**
  31274. * Interpolates between a and b via alpha
  31275. * @param a The lower value (returned when alpha = 0)
  31276. * @param b The upper value (returned when alpha = 1)
  31277. * @param alpha The interpolation-factor
  31278. * @return The mixed value
  31279. */
  31280. static Mix(a: number, b: number, alpha: number): number;
  31281. /**
  31282. * Tries to instantiate a new object from a given class name
  31283. * @param className defines the class name to instantiate
  31284. * @returns the new object or null if the system was not able to do the instantiation
  31285. */
  31286. static Instantiate(className: string): any;
  31287. /**
  31288. * Provides a slice function that will work even on IE
  31289. * @param data defines the array to slice
  31290. * @param start defines the start of the data (optional)
  31291. * @param end defines the end of the data (optional)
  31292. * @returns the new sliced array
  31293. */
  31294. static Slice<T>(data: T, start?: number, end?: number): T;
  31295. /**
  31296. * Polyfill for setImmediate
  31297. * @param action defines the action to execute after the current execution block
  31298. */
  31299. static SetImmediate(action: () => void): void;
  31300. /**
  31301. * Function indicating if a number is an exponent of 2
  31302. * @param value defines the value to test
  31303. * @returns true if the value is an exponent of 2
  31304. */
  31305. static IsExponentOfTwo(value: number): boolean;
  31306. private static _tmpFloatArray;
  31307. /**
  31308. * Returns the nearest 32-bit single precision float representation of a Number
  31309. * @param value A Number. If the parameter is of a different type, it will get converted
  31310. * to a number or to NaN if it cannot be converted
  31311. * @returns number
  31312. */
  31313. static FloatRound(value: number): number;
  31314. /**
  31315. * Extracts the filename from a path
  31316. * @param path defines the path to use
  31317. * @returns the filename
  31318. */
  31319. static GetFilename(path: string): string;
  31320. /**
  31321. * Extracts the "folder" part of a path (everything before the filename).
  31322. * @param uri The URI to extract the info from
  31323. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31324. * @returns The "folder" part of the path
  31325. */
  31326. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31327. /**
  31328. * Extracts text content from a DOM element hierarchy
  31329. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31330. */
  31331. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31332. /**
  31333. * Convert an angle in radians to degrees
  31334. * @param angle defines the angle to convert
  31335. * @returns the angle in degrees
  31336. */
  31337. static ToDegrees(angle: number): number;
  31338. /**
  31339. * Convert an angle in degrees to radians
  31340. * @param angle defines the angle to convert
  31341. * @returns the angle in radians
  31342. */
  31343. static ToRadians(angle: number): number;
  31344. /**
  31345. * Encode a buffer to a base64 string
  31346. * @param buffer defines the buffer to encode
  31347. * @returns the encoded string
  31348. */
  31349. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31350. /**
  31351. * Returns an array if obj is not an array
  31352. * @param obj defines the object to evaluate as an array
  31353. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31354. * @returns either obj directly if obj is an array or a new array containing obj
  31355. */
  31356. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31357. /**
  31358. * Gets the pointer prefix to use
  31359. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31360. */
  31361. static GetPointerPrefix(): string;
  31362. /**
  31363. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31364. * @param url define the url we are trying
  31365. * @param element define the dom element where to configure the cors policy
  31366. */
  31367. static SetCorsBehavior(url: string | string[], element: {
  31368. crossOrigin: string | null;
  31369. }): void;
  31370. /**
  31371. * Removes unwanted characters from an url
  31372. * @param url defines the url to clean
  31373. * @returns the cleaned url
  31374. */
  31375. static CleanUrl(url: string): string;
  31376. /**
  31377. * Gets or sets a function used to pre-process url before using them to load assets
  31378. */
  31379. static PreprocessUrl: (url: string) => string;
  31380. /**
  31381. * Loads an image as an HTMLImageElement.
  31382. * @param input url string, ArrayBuffer, or Blob to load
  31383. * @param onLoad callback called when the image successfully loads
  31384. * @param onError callback called when the image fails to load
  31385. * @param offlineProvider offline provider for caching
  31386. * @returns the HTMLImageElement of the loaded image
  31387. */
  31388. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31389. /**
  31390. * Loads a file
  31391. * @param url url string, ArrayBuffer, or Blob to load
  31392. * @param onSuccess callback called when the file successfully loads
  31393. * @param onProgress callback called while file is loading (if the server supports this mode)
  31394. * @param offlineProvider defines the offline provider for caching
  31395. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31396. * @param onError callback called when the file fails to load
  31397. * @returns a file request object
  31398. */
  31399. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31400. /**
  31401. * Loads a file from a url
  31402. * @param url the file url to load
  31403. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31404. */
  31405. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31406. /**
  31407. * Load a script (identified by an url). When the url returns, the
  31408. * content of this file is added into a new script element, attached to the DOM (body element)
  31409. * @param scriptUrl defines the url of the script to laod
  31410. * @param onSuccess defines the callback called when the script is loaded
  31411. * @param onError defines the callback to call if an error occurs
  31412. * @param scriptId defines the id of the script element
  31413. */
  31414. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31415. /**
  31416. * Load an asynchronous script (identified by an url). When the url returns, the
  31417. * content of this file is added into a new script element, attached to the DOM (body element)
  31418. * @param scriptUrl defines the url of the script to laod
  31419. * @param scriptId defines the id of the script element
  31420. * @returns a promise request object
  31421. */
  31422. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31423. /**
  31424. * Loads a file from a blob
  31425. * @param fileToLoad defines the blob to use
  31426. * @param callback defines the callback to call when data is loaded
  31427. * @param progressCallback defines the callback to call during loading process
  31428. * @returns a file request object
  31429. */
  31430. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31431. /**
  31432. * Loads a file
  31433. * @param fileToLoad defines the file to load
  31434. * @param callback defines the callback to call when data is loaded
  31435. * @param progressCallBack defines the callback to call during loading process
  31436. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31437. * @returns a file request object
  31438. */
  31439. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31440. /**
  31441. * Creates a data url from a given string content
  31442. * @param content defines the content to convert
  31443. * @returns the new data url link
  31444. */
  31445. static FileAsURL(content: string): string;
  31446. /**
  31447. * Format the given number to a specific decimal format
  31448. * @param value defines the number to format
  31449. * @param decimals defines the number of decimals to use
  31450. * @returns the formatted string
  31451. */
  31452. static Format(value: number, decimals?: number): string;
  31453. /**
  31454. * Tries to copy an object by duplicating every property
  31455. * @param source defines the source object
  31456. * @param destination defines the target object
  31457. * @param doNotCopyList defines a list of properties to avoid
  31458. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31459. */
  31460. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31461. /**
  31462. * Gets a boolean indicating if the given object has no own property
  31463. * @param obj defines the object to test
  31464. * @returns true if object has no own property
  31465. */
  31466. static IsEmpty(obj: any): boolean;
  31467. /**
  31468. * Function used to register events at window level
  31469. * @param windowElement defines the Window object to use
  31470. * @param events defines the events to register
  31471. */
  31472. static RegisterTopRootEvents(windowElement: Window, events: {
  31473. name: string;
  31474. handler: Nullable<(e: FocusEvent) => any>;
  31475. }[]): void;
  31476. /**
  31477. * Function used to unregister events from window level
  31478. * @param windowElement defines the Window object to use
  31479. * @param events defines the events to unregister
  31480. */
  31481. static UnregisterTopRootEvents(windowElement: Window, events: {
  31482. name: string;
  31483. handler: Nullable<(e: FocusEvent) => any>;
  31484. }[]): void;
  31485. /**
  31486. * @ignore
  31487. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31488. /**
  31489. * Dumps the current bound framebuffer
  31490. * @param width defines the rendering width
  31491. * @param height defines the rendering height
  31492. * @param engine defines the hosting engine
  31493. * @param successCallback defines the callback triggered once the data are available
  31494. * @param mimeType defines the mime type of the result
  31495. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31496. */
  31497. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31498. /**
  31499. * Converts the canvas data to blob.
  31500. * This acts as a polyfill for browsers not supporting the to blob function.
  31501. * @param canvas Defines the canvas to extract the data from
  31502. * @param successCallback Defines the callback triggered once the data are available
  31503. * @param mimeType Defines the mime type of the result
  31504. */
  31505. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31506. /**
  31507. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31508. * @param successCallback defines the callback triggered once the data are available
  31509. * @param mimeType defines the mime type of the result
  31510. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31511. */
  31512. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31513. /**
  31514. * Downloads a blob in the browser
  31515. * @param blob defines the blob to download
  31516. * @param fileName defines the name of the downloaded file
  31517. */
  31518. static Download(blob: Blob, fileName: string): void;
  31519. /**
  31520. * Captures a screenshot of the current rendering
  31521. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31522. * @param engine defines the rendering engine
  31523. * @param camera defines the source camera
  31524. * @param size This parameter can be set to a single number or to an object with the
  31525. * following (optional) properties: precision, width, height. If a single number is passed,
  31526. * it will be used for both width and height. If an object is passed, the screenshot size
  31527. * will be derived from the parameters. The precision property is a multiplier allowing
  31528. * rendering at a higher or lower resolution
  31529. * @param successCallback defines the callback receives a single parameter which contains the
  31530. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31531. * src parameter of an <img> to display it
  31532. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31533. * Check your browser for supported MIME types
  31534. */
  31535. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31536. /**
  31537. * Captures a screenshot of the current rendering
  31538. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31539. * @param engine defines the rendering engine
  31540. * @param camera defines the source camera
  31541. * @param size This parameter can be set to a single number or to an object with the
  31542. * following (optional) properties: precision, width, height. If a single number is passed,
  31543. * it will be used for both width and height. If an object is passed, the screenshot size
  31544. * will be derived from the parameters. The precision property is a multiplier allowing
  31545. * rendering at a higher or lower resolution
  31546. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31547. * Check your browser for supported MIME types
  31548. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31549. * to the src parameter of an <img> to display it
  31550. */
  31551. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31552. /**
  31553. * Generates an image screenshot from the specified camera.
  31554. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31555. * @param engine The engine to use for rendering
  31556. * @param camera The camera to use for rendering
  31557. * @param size This parameter can be set to a single number or to an object with the
  31558. * following (optional) properties: precision, width, height. If a single number is passed,
  31559. * it will be used for both width and height. If an object is passed, the screenshot size
  31560. * will be derived from the parameters. The precision property is a multiplier allowing
  31561. * rendering at a higher or lower resolution
  31562. * @param successCallback The callback receives a single parameter which contains the
  31563. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31564. * src parameter of an <img> to display it
  31565. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31566. * Check your browser for supported MIME types
  31567. * @param samples Texture samples (default: 1)
  31568. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31569. * @param fileName A name for for the downloaded file.
  31570. */
  31571. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31572. /**
  31573. * Generates an image screenshot from the specified camera.
  31574. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31575. * @param engine The engine to use for rendering
  31576. * @param camera The camera to use for rendering
  31577. * @param size This parameter can be set to a single number or to an object with the
  31578. * following (optional) properties: precision, width, height. If a single number is passed,
  31579. * it will be used for both width and height. If an object is passed, the screenshot size
  31580. * will be derived from the parameters. The precision property is a multiplier allowing
  31581. * rendering at a higher or lower resolution
  31582. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31583. * Check your browser for supported MIME types
  31584. * @param samples Texture samples (default: 1)
  31585. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31586. * @param fileName A name for for the downloaded file.
  31587. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31588. * to the src parameter of an <img> to display it
  31589. */
  31590. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31591. /**
  31592. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31593. * Be aware Math.random() could cause collisions, but:
  31594. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  31595. * @returns a pseudo random id
  31596. */
  31597. static RandomId(): string;
  31598. /**
  31599. * Test if the given uri is a base64 string
  31600. * @param uri The uri to test
  31601. * @return True if the uri is a base64 string or false otherwise
  31602. */
  31603. static IsBase64(uri: string): boolean;
  31604. /**
  31605. * Decode the given base64 uri.
  31606. * @param uri The uri to decode
  31607. * @return The decoded base64 data.
  31608. */
  31609. static DecodeBase64(uri: string): ArrayBuffer;
  31610. /**
  31611. * Gets the absolute url.
  31612. * @param url the input url
  31613. * @return the absolute url
  31614. */
  31615. static GetAbsoluteUrl(url: string): string;
  31616. /**
  31617. * No log
  31618. */
  31619. static readonly NoneLogLevel: number;
  31620. /**
  31621. * Only message logs
  31622. */
  31623. static readonly MessageLogLevel: number;
  31624. /**
  31625. * Only warning logs
  31626. */
  31627. static readonly WarningLogLevel: number;
  31628. /**
  31629. * Only error logs
  31630. */
  31631. static readonly ErrorLogLevel: number;
  31632. /**
  31633. * All logs
  31634. */
  31635. static readonly AllLogLevel: number;
  31636. /**
  31637. * Gets a value indicating the number of loading errors
  31638. * @ignorenaming
  31639. */
  31640. static readonly errorsCount: number;
  31641. /**
  31642. * Callback called when a new log is added
  31643. */
  31644. static OnNewCacheEntry: (entry: string) => void;
  31645. /**
  31646. * Log a message to the console
  31647. * @param message defines the message to log
  31648. */
  31649. static Log(message: string): void;
  31650. /**
  31651. * Write a warning message to the console
  31652. * @param message defines the message to log
  31653. */
  31654. static Warn(message: string): void;
  31655. /**
  31656. * Write an error message to the console
  31657. * @param message defines the message to log
  31658. */
  31659. static Error(message: string): void;
  31660. /**
  31661. * Gets current log cache (list of logs)
  31662. */
  31663. static readonly LogCache: string;
  31664. /**
  31665. * Clears the log cache
  31666. */
  31667. static ClearLogCache(): void;
  31668. /**
  31669. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31670. */
  31671. static LogLevels: number;
  31672. /**
  31673. * Checks if the window object exists
  31674. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31675. */
  31676. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31677. /**
  31678. * No performance log
  31679. */
  31680. static readonly PerformanceNoneLogLevel: number;
  31681. /**
  31682. * Use user marks to log performance
  31683. */
  31684. static readonly PerformanceUserMarkLogLevel: number;
  31685. /**
  31686. * Log performance to the console
  31687. */
  31688. static readonly PerformanceConsoleLogLevel: number;
  31689. private static _performance;
  31690. /**
  31691. * Sets the current performance log level
  31692. */
  31693. static PerformanceLogLevel: number;
  31694. private static _StartPerformanceCounterDisabled;
  31695. private static _EndPerformanceCounterDisabled;
  31696. private static _StartUserMark;
  31697. private static _EndUserMark;
  31698. private static _StartPerformanceConsole;
  31699. private static _EndPerformanceConsole;
  31700. /**
  31701. * Starts a performance counter
  31702. */
  31703. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31704. /**
  31705. * Ends a specific performance coutner
  31706. */
  31707. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31708. /**
  31709. * Gets either window.performance.now() if supported or Date.now() else
  31710. */
  31711. static readonly Now: number;
  31712. /**
  31713. * This method will return the name of the class used to create the instance of the given object.
  31714. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31715. * @param object the object to get the class name from
  31716. * @param isType defines if the object is actually a type
  31717. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31718. */
  31719. static GetClassName(object: any, isType?: boolean): string;
  31720. /**
  31721. * Gets the first element of an array satisfying a given predicate
  31722. * @param array defines the array to browse
  31723. * @param predicate defines the predicate to use
  31724. * @returns null if not found or the element
  31725. */
  31726. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31727. /**
  31728. * This method will return the name of the full name of the class, including its owning module (if any).
  31729. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  31730. * @param object the object to get the class name from
  31731. * @param isType defines if the object is actually a type
  31732. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  31733. * @ignorenaming
  31734. */
  31735. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31736. /**
  31737. * Returns a promise that resolves after the given amount of time.
  31738. * @param delay Number of milliseconds to delay
  31739. * @returns Promise that resolves after the given amount of time
  31740. */
  31741. static DelayAsync(delay: number): Promise<void>;
  31742. }
  31743. /**
  31744. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31745. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31746. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31747. * @param name The name of the class, case should be preserved
  31748. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31749. */
  31750. export function className(name: string, module?: string): (target: Object) => void;
  31751. /**
  31752. * An implementation of a loop for asynchronous functions.
  31753. */
  31754. export class AsyncLoop {
  31755. /**
  31756. * Defines the number of iterations for the loop
  31757. */
  31758. iterations: number;
  31759. /**
  31760. * Defines the current index of the loop.
  31761. */
  31762. index: number;
  31763. private _done;
  31764. private _fn;
  31765. private _successCallback;
  31766. /**
  31767. * Constructor.
  31768. * @param iterations the number of iterations.
  31769. * @param func the function to run each iteration
  31770. * @param successCallback the callback that will be called upon succesful execution
  31771. * @param offset starting offset.
  31772. */
  31773. constructor(
  31774. /**
  31775. * Defines the number of iterations for the loop
  31776. */
  31777. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31778. /**
  31779. * Execute the next iteration. Must be called after the last iteration was finished.
  31780. */
  31781. executeNext(): void;
  31782. /**
  31783. * Break the loop and run the success callback.
  31784. */
  31785. breakLoop(): void;
  31786. /**
  31787. * Create and run an async loop.
  31788. * @param iterations the number of iterations.
  31789. * @param fn the function to run each iteration
  31790. * @param successCallback the callback that will be called upon succesful execution
  31791. * @param offset starting offset.
  31792. * @returns the created async loop object
  31793. */
  31794. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31795. /**
  31796. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31797. * @param iterations total number of iterations
  31798. * @param syncedIterations number of synchronous iterations in each async iteration.
  31799. * @param fn the function to call each iteration.
  31800. * @param callback a success call back that will be called when iterating stops.
  31801. * @param breakFunction a break condition (optional)
  31802. * @param timeout timeout settings for the setTimeout function. default - 0.
  31803. * @returns the created async loop object
  31804. */
  31805. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31806. }
  31807. }
  31808. declare module BABYLON {
  31809. /**
  31810. * This class implement a typical dictionary using a string as key and the generic type T as value.
  31811. * The underlying implementation relies on an associative array to ensure the best performances.
  31812. * The value can be anything including 'null' but except 'undefined'
  31813. */
  31814. export class StringDictionary<T> {
  31815. /**
  31816. * This will clear this dictionary and copy the content from the 'source' one.
  31817. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  31818. * @param source the dictionary to take the content from and copy to this dictionary
  31819. */
  31820. copyFrom(source: StringDictionary<T>): void;
  31821. /**
  31822. * Get a value based from its key
  31823. * @param key the given key to get the matching value from
  31824. * @return the value if found, otherwise undefined is returned
  31825. */
  31826. get(key: string): T | undefined;
  31827. /**
  31828. * Get a value from its key or add it if it doesn't exist.
  31829. * This method will ensure you that a given key/data will be present in the dictionary.
  31830. * @param key the given key to get the matching value from
  31831. * @param factory the factory that will create the value if the key is not present in the dictionary.
  31832. * The factory will only be invoked if there's no data for the given key.
  31833. * @return the value corresponding to the key.
  31834. */
  31835. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  31836. /**
  31837. * Get a value from its key if present in the dictionary otherwise add it
  31838. * @param key the key to get the value from
  31839. * @param val if there's no such key/value pair in the dictionary add it with this value
  31840. * @return the value corresponding to the key
  31841. */
  31842. getOrAdd(key: string, val: T): T;
  31843. /**
  31844. * Check if there's a given key in the dictionary
  31845. * @param key the key to check for
  31846. * @return true if the key is present, false otherwise
  31847. */
  31848. contains(key: string): boolean;
  31849. /**
  31850. * Add a new key and its corresponding value
  31851. * @param key the key to add
  31852. * @param value the value corresponding to the key
  31853. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  31854. */
  31855. add(key: string, value: T): boolean;
  31856. /**
  31857. * Update a specific value associated to a key
  31858. * @param key defines the key to use
  31859. * @param value defines the value to store
  31860. * @returns true if the value was updated (or false if the key was not found)
  31861. */
  31862. set(key: string, value: T): boolean;
  31863. /**
  31864. * Get the element of the given key and remove it from the dictionary
  31865. * @param key defines the key to search
  31866. * @returns the value associated with the key or null if not found
  31867. */
  31868. getAndRemove(key: string): Nullable<T>;
  31869. /**
  31870. * Remove a key/value from the dictionary.
  31871. * @param key the key to remove
  31872. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  31873. */
  31874. remove(key: string): boolean;
  31875. /**
  31876. * Clear the whole content of the dictionary
  31877. */
  31878. clear(): void;
  31879. /**
  31880. * Gets the current count
  31881. */
  31882. readonly count: number;
  31883. /**
  31884. * Execute a callback on each key/val of the dictionary.
  31885. * Note that you can remove any element in this dictionary in the callback implementation
  31886. * @param callback the callback to execute on a given key/value pair
  31887. */
  31888. forEach(callback: (key: string, val: T) => void): void;
  31889. /**
  31890. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  31891. * If the callback returns null or undefined the method will iterate to the next key/value pair
  31892. * Note that you can remove any element in this dictionary in the callback implementation
  31893. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  31894. * @returns the first item
  31895. */
  31896. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  31897. private _count;
  31898. private _data;
  31899. }
  31900. }
  31901. declare module BABYLON {
  31902. /** @hidden */
  31903. export interface ICollisionCoordinator {
  31904. createCollider(): Collider;
  31905. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31906. init(scene: Scene): void;
  31907. }
  31908. /** @hidden */
  31909. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31910. private _scene;
  31911. private _scaledPosition;
  31912. private _scaledVelocity;
  31913. private _finalPosition;
  31914. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31915. createCollider(): Collider;
  31916. init(scene: Scene): void;
  31917. private _collideWithWorld;
  31918. }
  31919. }
  31920. declare module BABYLON {
  31921. /**
  31922. * Class used to manage all inputs for the scene.
  31923. */
  31924. export class InputManager {
  31925. /** The distance in pixel that you have to move to prevent some events */
  31926. static DragMovementThreshold: number;
  31927. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31928. static LongPressDelay: number;
  31929. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31930. static DoubleClickDelay: number;
  31931. /** If you need to check double click without raising a single click at first click, enable this flag */
  31932. static ExclusiveDoubleClickMode: boolean;
  31933. private _wheelEventName;
  31934. private _onPointerMove;
  31935. private _onPointerDown;
  31936. private _onPointerUp;
  31937. private _initClickEvent;
  31938. private _initActionManager;
  31939. private _delayedSimpleClick;
  31940. private _delayedSimpleClickTimeout;
  31941. private _previousDelayedSimpleClickTimeout;
  31942. private _meshPickProceed;
  31943. private _previousButtonPressed;
  31944. private _currentPickResult;
  31945. private _previousPickResult;
  31946. private _totalPointersPressed;
  31947. private _doubleClickOccured;
  31948. private _pointerOverMesh;
  31949. private _pickedDownMesh;
  31950. private _pickedUpMesh;
  31951. private _pointerX;
  31952. private _pointerY;
  31953. private _unTranslatedPointerX;
  31954. private _unTranslatedPointerY;
  31955. private _startingPointerPosition;
  31956. private _previousStartingPointerPosition;
  31957. private _startingPointerTime;
  31958. private _previousStartingPointerTime;
  31959. private _pointerCaptures;
  31960. private _onKeyDown;
  31961. private _onKeyUp;
  31962. private _onCanvasFocusObserver;
  31963. private _onCanvasBlurObserver;
  31964. private _scene;
  31965. /**
  31966. * Creates a new InputManager
  31967. * @param scene defines the hosting scene
  31968. */
  31969. constructor(scene: Scene);
  31970. /**
  31971. * Gets the mesh that is currently under the pointer
  31972. */
  31973. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31974. /**
  31975. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31976. */
  31977. readonly unTranslatedPointer: Vector2;
  31978. /**
  31979. * Gets or sets the current on-screen X position of the pointer
  31980. */
  31981. pointerX: number;
  31982. /**
  31983. * Gets or sets the current on-screen Y position of the pointer
  31984. */
  31985. pointerY: number;
  31986. private _updatePointerPosition;
  31987. private _processPointerMove;
  31988. private _setRayOnPointerInfo;
  31989. private _checkPrePointerObservable;
  31990. /**
  31991. * Use this method to simulate a pointer move on a mesh
  31992. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31993. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31994. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31995. */
  31996. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31997. /**
  31998. * Use this method to simulate a pointer down on a mesh
  31999. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32000. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32001. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32002. */
  32003. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32004. private _processPointerDown;
  32005. /** @hidden */ private _isPointerSwiping(): boolean;
  32006. /**
  32007. * Use this method to simulate a pointer up on a mesh
  32008. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32009. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32010. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32011. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32012. */
  32013. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32014. private _processPointerUp;
  32015. /**
  32016. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32017. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32018. * @returns true if the pointer was captured
  32019. */
  32020. isPointerCaptured(pointerId?: number): boolean;
  32021. /**
  32022. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32023. * @param attachUp defines if you want to attach events to pointerup
  32024. * @param attachDown defines if you want to attach events to pointerdown
  32025. * @param attachMove defines if you want to attach events to pointermove
  32026. */
  32027. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32028. /**
  32029. * Detaches all event handlers
  32030. */
  32031. detachControl(): void;
  32032. /**
  32033. * Force the value of meshUnderPointer
  32034. * @param mesh defines the mesh to use
  32035. */
  32036. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32037. /**
  32038. * Gets the mesh under the pointer
  32039. * @returns a Mesh or null if no mesh is under the pointer
  32040. */
  32041. getPointerOverMesh(): Nullable<AbstractMesh>;
  32042. }
  32043. }
  32044. declare module BABYLON {
  32045. /**
  32046. * Helper class used to generate session unique ID
  32047. */
  32048. export class UniqueIdGenerator {
  32049. private static _UniqueIdCounter;
  32050. /**
  32051. * Gets an unique (relatively to the current scene) Id
  32052. */
  32053. static readonly UniqueId: number;
  32054. }
  32055. }
  32056. declare module BABYLON {
  32057. /**
  32058. * This class defines the direct association between an animation and a target
  32059. */
  32060. export class TargetedAnimation {
  32061. /**
  32062. * Animation to perform
  32063. */
  32064. animation: Animation;
  32065. /**
  32066. * Target to animate
  32067. */
  32068. target: any;
  32069. /**
  32070. * Serialize the object
  32071. * @returns the JSON object representing the current entity
  32072. */
  32073. serialize(): any;
  32074. }
  32075. /**
  32076. * Use this class to create coordinated animations on multiple targets
  32077. */
  32078. export class AnimationGroup implements IDisposable {
  32079. /** The name of the animation group */
  32080. name: string;
  32081. private _scene;
  32082. private _targetedAnimations;
  32083. private _animatables;
  32084. private _from;
  32085. private _to;
  32086. private _isStarted;
  32087. private _isPaused;
  32088. private _speedRatio;
  32089. private _loopAnimation;
  32090. /**
  32091. * Gets or sets the unique id of the node
  32092. */
  32093. uniqueId: number;
  32094. /**
  32095. * This observable will notify when one animation have ended
  32096. */
  32097. onAnimationEndObservable: Observable<TargetedAnimation>;
  32098. /**
  32099. * Observer raised when one animation loops
  32100. */
  32101. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32102. /**
  32103. * This observable will notify when all animations have ended.
  32104. */
  32105. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32106. /**
  32107. * This observable will notify when all animations have paused.
  32108. */
  32109. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32110. /**
  32111. * This observable will notify when all animations are playing.
  32112. */
  32113. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32114. /**
  32115. * Gets the first frame
  32116. */
  32117. readonly from: number;
  32118. /**
  32119. * Gets the last frame
  32120. */
  32121. readonly to: number;
  32122. /**
  32123. * Define if the animations are started
  32124. */
  32125. readonly isStarted: boolean;
  32126. /**
  32127. * Gets a value indicating that the current group is playing
  32128. */
  32129. readonly isPlaying: boolean;
  32130. /**
  32131. * Gets or sets the speed ratio to use for all animations
  32132. */
  32133. /**
  32134. * Gets or sets the speed ratio to use for all animations
  32135. */
  32136. speedRatio: number;
  32137. /**
  32138. * Gets or sets if all animations should loop or not
  32139. */
  32140. loopAnimation: boolean;
  32141. /**
  32142. * Gets the targeted animations for this animation group
  32143. */
  32144. readonly targetedAnimations: Array<TargetedAnimation>;
  32145. /**
  32146. * returning the list of animatables controlled by this animation group.
  32147. */
  32148. readonly animatables: Array<Animatable>;
  32149. /**
  32150. * Instantiates a new Animation Group.
  32151. * This helps managing several animations at once.
  32152. * @see http://doc.babylonjs.com/how_to/group
  32153. * @param name Defines the name of the group
  32154. * @param scene Defines the scene the group belongs to
  32155. */
  32156. constructor(
  32157. /** The name of the animation group */
  32158. name: string, scene?: Nullable<Scene>);
  32159. /**
  32160. * Add an animation (with its target) in the group
  32161. * @param animation defines the animation we want to add
  32162. * @param target defines the target of the animation
  32163. * @returns the TargetedAnimation object
  32164. */
  32165. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32166. /**
  32167. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32168. * It can add constant keys at begin or end
  32169. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32170. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32171. * @returns the animation group
  32172. */
  32173. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32174. /**
  32175. * Start all animations on given targets
  32176. * @param loop defines if animations must loop
  32177. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32178. * @param from defines the from key (optional)
  32179. * @param to defines the to key (optional)
  32180. * @returns the current animation group
  32181. */
  32182. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32183. /**
  32184. * Pause all animations
  32185. * @returns the animation group
  32186. */
  32187. pause(): AnimationGroup;
  32188. /**
  32189. * Play all animations to initial state
  32190. * This function will start() the animations if they were not started or will restart() them if they were paused
  32191. * @param loop defines if animations must loop
  32192. * @returns the animation group
  32193. */
  32194. play(loop?: boolean): AnimationGroup;
  32195. /**
  32196. * Reset all animations to initial state
  32197. * @returns the animation group
  32198. */
  32199. reset(): AnimationGroup;
  32200. /**
  32201. * Restart animations from key 0
  32202. * @returns the animation group
  32203. */
  32204. restart(): AnimationGroup;
  32205. /**
  32206. * Stop all animations
  32207. * @returns the animation group
  32208. */
  32209. stop(): AnimationGroup;
  32210. /**
  32211. * Set animation weight for all animatables
  32212. * @param weight defines the weight to use
  32213. * @return the animationGroup
  32214. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32215. */
  32216. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32217. /**
  32218. * Synchronize and normalize all animatables with a source animatable
  32219. * @param root defines the root animatable to synchronize with
  32220. * @return the animationGroup
  32221. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32222. */
  32223. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32224. /**
  32225. * Goes to a specific frame in this animation group
  32226. * @param frame the frame number to go to
  32227. * @return the animationGroup
  32228. */
  32229. goToFrame(frame: number): AnimationGroup;
  32230. /**
  32231. * Dispose all associated resources
  32232. */
  32233. dispose(): void;
  32234. private _checkAnimationGroupEnded;
  32235. /**
  32236. * Clone the current animation group and returns a copy
  32237. * @param newName defines the name of the new group
  32238. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32239. * @returns the new aniamtion group
  32240. */
  32241. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32242. /**
  32243. * Serializes the animationGroup to an object
  32244. * @returns Serialized object
  32245. */
  32246. serialize(): any;
  32247. /**
  32248. * Returns a new AnimationGroup object parsed from the source provided.
  32249. * @param parsedAnimationGroup defines the source
  32250. * @param scene defines the scene that will receive the animationGroup
  32251. * @returns a new AnimationGroup
  32252. */
  32253. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32254. /**
  32255. * Returns the string "AnimationGroup"
  32256. * @returns "AnimationGroup"
  32257. */
  32258. getClassName(): string;
  32259. /**
  32260. * Creates a detailled string about the object
  32261. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32262. * @returns a string representing the object
  32263. */
  32264. toString(fullDetails?: boolean): string;
  32265. }
  32266. }
  32267. declare module BABYLON {
  32268. /**
  32269. * Define an interface for all classes that will hold resources
  32270. */
  32271. export interface IDisposable {
  32272. /**
  32273. * Releases all held resources
  32274. */
  32275. dispose(): void;
  32276. }
  32277. /** Interface defining initialization parameters for Scene class */
  32278. export interface SceneOptions {
  32279. /**
  32280. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32281. * It will improve performance when the number of geometries becomes important.
  32282. */
  32283. useGeometryUniqueIdsMap?: boolean;
  32284. /**
  32285. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32286. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32287. */
  32288. useMaterialMeshMap?: boolean;
  32289. /**
  32290. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32291. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32292. */
  32293. useClonedMeshhMap?: boolean;
  32294. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32295. virtual?: boolean;
  32296. }
  32297. /**
  32298. * Represents a scene to be rendered by the engine.
  32299. * @see http://doc.babylonjs.com/features/scene
  32300. */
  32301. export class Scene extends AbstractScene implements IAnimatable {
  32302. /** The fog is deactivated */
  32303. static readonly FOGMODE_NONE: number;
  32304. /** The fog density is following an exponential function */
  32305. static readonly FOGMODE_EXP: number;
  32306. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32307. static readonly FOGMODE_EXP2: number;
  32308. /** The fog density is following a linear function. */
  32309. static readonly FOGMODE_LINEAR: number;
  32310. /**
  32311. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32312. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32313. */
  32314. static MinDeltaTime: number;
  32315. /**
  32316. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32317. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32318. */
  32319. static MaxDeltaTime: number;
  32320. /**
  32321. * Factory used to create the default material.
  32322. * @param name The name of the material to create
  32323. * @param scene The scene to create the material for
  32324. * @returns The default material
  32325. */
  32326. static DefaultMaterialFactory(scene: Scene): Material;
  32327. /**
  32328. * Factory used to create the a collision coordinator.
  32329. * @returns The collision coordinator
  32330. */
  32331. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32332. /** @hidden */ private _inputManager: InputManager;
  32333. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32334. cameraToUseForPointers: Nullable<Camera>;
  32335. /** @hidden */ protected readonly _isScene: boolean;
  32336. /**
  32337. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32338. */
  32339. autoClear: boolean;
  32340. /**
  32341. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32342. */
  32343. autoClearDepthAndStencil: boolean;
  32344. /**
  32345. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32346. */
  32347. clearColor: Color4;
  32348. /**
  32349. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32350. */
  32351. ambientColor: Color3;
  32352. /**
  32353. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32354. * It should only be one of the following (if not the default embedded one):
  32355. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32356. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32357. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32358. * The material properties need to be setup according to the type of texture in use.
  32359. */
  32360. environmentBRDFTexture: BaseTexture;
  32361. /** @hidden */
  32362. protected _environmentTexture: Nullable<BaseTexture>;
  32363. /**
  32364. * Texture used in all pbr material as the reflection texture.
  32365. * As in the majority of the scene they are the same (exception for multi room and so on),
  32366. * this is easier to reference from here than from all the materials.
  32367. */
  32368. /**
  32369. * Texture used in all pbr material as the reflection texture.
  32370. * As in the majority of the scene they are the same (exception for multi room and so on),
  32371. * this is easier to set here than in all the materials.
  32372. */
  32373. environmentTexture: Nullable<BaseTexture>;
  32374. /** @hidden */
  32375. protected _environmentIntensity: number;
  32376. /**
  32377. * Intensity of the environment in all pbr material.
  32378. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32379. * As in the majority of the scene they are the same (exception for multi room and so on),
  32380. * this is easier to reference from here than from all the materials.
  32381. */
  32382. /**
  32383. * Intensity of the environment in all pbr material.
  32384. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32385. * As in the majority of the scene they are the same (exception for multi room and so on),
  32386. * this is easier to set here than in all the materials.
  32387. */
  32388. environmentIntensity: number;
  32389. /** @hidden */
  32390. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32391. /**
  32392. * Default image processing configuration used either in the rendering
  32393. * Forward main pass or through the imageProcessingPostProcess if present.
  32394. * As in the majority of the scene they are the same (exception for multi camera),
  32395. * this is easier to reference from here than from all the materials and post process.
  32396. *
  32397. * No setter as we it is a shared configuration, you can set the values instead.
  32398. */
  32399. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32400. private _forceWireframe;
  32401. /**
  32402. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32403. */
  32404. forceWireframe: boolean;
  32405. private _forcePointsCloud;
  32406. /**
  32407. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32408. */
  32409. forcePointsCloud: boolean;
  32410. /**
  32411. * Gets or sets the active clipplane 1
  32412. */
  32413. clipPlane: Nullable<Plane>;
  32414. /**
  32415. * Gets or sets the active clipplane 2
  32416. */
  32417. clipPlane2: Nullable<Plane>;
  32418. /**
  32419. * Gets or sets the active clipplane 3
  32420. */
  32421. clipPlane3: Nullable<Plane>;
  32422. /**
  32423. * Gets or sets the active clipplane 4
  32424. */
  32425. clipPlane4: Nullable<Plane>;
  32426. /**
  32427. * Gets or sets a boolean indicating if animations are enabled
  32428. */
  32429. animationsEnabled: boolean;
  32430. private _animationPropertiesOverride;
  32431. /**
  32432. * Gets or sets the animation properties override
  32433. */
  32434. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32435. /**
  32436. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32437. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32438. */
  32439. useConstantAnimationDeltaTime: boolean;
  32440. /**
  32441. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32442. * Please note that it requires to run a ray cast through the scene on every frame
  32443. */
  32444. constantlyUpdateMeshUnderPointer: boolean;
  32445. /**
  32446. * Defines the HTML cursor to use when hovering over interactive elements
  32447. */
  32448. hoverCursor: string;
  32449. /**
  32450. * Defines the HTML default cursor to use (empty by default)
  32451. */
  32452. defaultCursor: string;
  32453. /**
  32454. * This is used to call preventDefault() on pointer down
  32455. * in order to block unwanted artifacts like system double clicks
  32456. */
  32457. preventDefaultOnPointerDown: boolean;
  32458. /**
  32459. * This is used to call preventDefault() on pointer up
  32460. * in order to block unwanted artifacts like system double clicks
  32461. */
  32462. preventDefaultOnPointerUp: boolean;
  32463. /**
  32464. * Gets or sets user defined metadata
  32465. */
  32466. metadata: any;
  32467. /**
  32468. * For internal use only. Please do not use.
  32469. */
  32470. reservedDataStore: any;
  32471. /**
  32472. * Gets the name of the plugin used to load this scene (null by default)
  32473. */
  32474. loadingPluginName: string;
  32475. /**
  32476. * Use this array to add regular expressions used to disable offline support for specific urls
  32477. */
  32478. disableOfflineSupportExceptionRules: RegExp[];
  32479. /**
  32480. * An event triggered when the scene is disposed.
  32481. */
  32482. onDisposeObservable: Observable<Scene>;
  32483. private _onDisposeObserver;
  32484. /** Sets a function to be executed when this scene is disposed. */
  32485. onDispose: () => void;
  32486. /**
  32487. * An event triggered before rendering the scene (right after animations and physics)
  32488. */
  32489. onBeforeRenderObservable: Observable<Scene>;
  32490. private _onBeforeRenderObserver;
  32491. /** Sets a function to be executed before rendering this scene */
  32492. beforeRender: Nullable<() => void>;
  32493. /**
  32494. * An event triggered after rendering the scene
  32495. */
  32496. onAfterRenderObservable: Observable<Scene>;
  32497. /**
  32498. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32499. */
  32500. onAfterRenderCameraObservable: Observable<Camera>;
  32501. private _onAfterRenderObserver;
  32502. /** Sets a function to be executed after rendering this scene */
  32503. afterRender: Nullable<() => void>;
  32504. /**
  32505. * An event triggered before animating the scene
  32506. */
  32507. onBeforeAnimationsObservable: Observable<Scene>;
  32508. /**
  32509. * An event triggered after animations processing
  32510. */
  32511. onAfterAnimationsObservable: Observable<Scene>;
  32512. /**
  32513. * An event triggered before draw calls are ready to be sent
  32514. */
  32515. onBeforeDrawPhaseObservable: Observable<Scene>;
  32516. /**
  32517. * An event triggered after draw calls have been sent
  32518. */
  32519. onAfterDrawPhaseObservable: Observable<Scene>;
  32520. /**
  32521. * An event triggered when the scene is ready
  32522. */
  32523. onReadyObservable: Observable<Scene>;
  32524. /**
  32525. * An event triggered before rendering a camera
  32526. */
  32527. onBeforeCameraRenderObservable: Observable<Camera>;
  32528. private _onBeforeCameraRenderObserver;
  32529. /** Sets a function to be executed before rendering a camera*/
  32530. beforeCameraRender: () => void;
  32531. /**
  32532. * An event triggered after rendering a camera
  32533. */
  32534. onAfterCameraRenderObservable: Observable<Camera>;
  32535. private _onAfterCameraRenderObserver;
  32536. /** Sets a function to be executed after rendering a camera*/
  32537. afterCameraRender: () => void;
  32538. /**
  32539. * An event triggered when active meshes evaluation is about to start
  32540. */
  32541. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32542. /**
  32543. * An event triggered when active meshes evaluation is done
  32544. */
  32545. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32546. /**
  32547. * An event triggered when particles rendering is about to start
  32548. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32549. */
  32550. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32551. /**
  32552. * An event triggered when particles rendering is done
  32553. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32554. */
  32555. onAfterParticlesRenderingObservable: Observable<Scene>;
  32556. /**
  32557. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32558. */
  32559. onDataLoadedObservable: Observable<Scene>;
  32560. /**
  32561. * An event triggered when a camera is created
  32562. */
  32563. onNewCameraAddedObservable: Observable<Camera>;
  32564. /**
  32565. * An event triggered when a camera is removed
  32566. */
  32567. onCameraRemovedObservable: Observable<Camera>;
  32568. /**
  32569. * An event triggered when a light is created
  32570. */
  32571. onNewLightAddedObservable: Observable<Light>;
  32572. /**
  32573. * An event triggered when a light is removed
  32574. */
  32575. onLightRemovedObservable: Observable<Light>;
  32576. /**
  32577. * An event triggered when a geometry is created
  32578. */
  32579. onNewGeometryAddedObservable: Observable<Geometry>;
  32580. /**
  32581. * An event triggered when a geometry is removed
  32582. */
  32583. onGeometryRemovedObservable: Observable<Geometry>;
  32584. /**
  32585. * An event triggered when a transform node is created
  32586. */
  32587. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32588. /**
  32589. * An event triggered when a transform node is removed
  32590. */
  32591. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32592. /**
  32593. * An event triggered when a mesh is created
  32594. */
  32595. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32596. /**
  32597. * An event triggered when a mesh is removed
  32598. */
  32599. onMeshRemovedObservable: Observable<AbstractMesh>;
  32600. /**
  32601. * An event triggered when a skeleton is created
  32602. */
  32603. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32604. /**
  32605. * An event triggered when a skeleton is removed
  32606. */
  32607. onSkeletonRemovedObservable: Observable<Skeleton>;
  32608. /**
  32609. * An event triggered when a material is created
  32610. */
  32611. onNewMaterialAddedObservable: Observable<Material>;
  32612. /**
  32613. * An event triggered when a material is removed
  32614. */
  32615. onMaterialRemovedObservable: Observable<Material>;
  32616. /**
  32617. * An event triggered when a texture is created
  32618. */
  32619. onNewTextureAddedObservable: Observable<BaseTexture>;
  32620. /**
  32621. * An event triggered when a texture is removed
  32622. */
  32623. onTextureRemovedObservable: Observable<BaseTexture>;
  32624. /**
  32625. * An event triggered when render targets are about to be rendered
  32626. * Can happen multiple times per frame.
  32627. */
  32628. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32629. /**
  32630. * An event triggered when render targets were rendered.
  32631. * Can happen multiple times per frame.
  32632. */
  32633. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32634. /**
  32635. * An event triggered before calculating deterministic simulation step
  32636. */
  32637. onBeforeStepObservable: Observable<Scene>;
  32638. /**
  32639. * An event triggered after calculating deterministic simulation step
  32640. */
  32641. onAfterStepObservable: Observable<Scene>;
  32642. /**
  32643. * An event triggered when the activeCamera property is updated
  32644. */
  32645. onActiveCameraChanged: Observable<Scene>;
  32646. /**
  32647. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32648. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32649. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  32650. */
  32651. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32652. /**
  32653. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32654. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32655. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  32656. */
  32657. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32658. /**
  32659. * This Observable will when a mesh has been imported into the scene.
  32660. */
  32661. onMeshImportedObservable: Observable<AbstractMesh>;
  32662. /**
  32663. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32664. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32665. */
  32666. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32667. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32668. /**
  32669. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32670. */
  32671. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32672. /**
  32673. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32674. */
  32675. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32676. /**
  32677. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32678. */
  32679. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32680. /** Callback called when a pointer move is detected */
  32681. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32682. /** Callback called when a pointer down is detected */
  32683. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32684. /** Callback called when a pointer up is detected */
  32685. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32686. /** Callback called when a pointer pick is detected */
  32687. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32688. /**
  32689. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  32690. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32691. */
  32692. onPrePointerObservable: Observable<PointerInfoPre>;
  32693. /**
  32694. * Observable event triggered each time an input event is received from the rendering canvas
  32695. */
  32696. onPointerObservable: Observable<PointerInfo>;
  32697. /**
  32698. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32699. */
  32700. readonly unTranslatedPointer: Vector2;
  32701. /**
  32702. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32703. */
  32704. static DragMovementThreshold: number;
  32705. /**
  32706. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32707. */
  32708. static LongPressDelay: number;
  32709. /**
  32710. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32711. */
  32712. static DoubleClickDelay: number;
  32713. /** If you need to check double click without raising a single click at first click, enable this flag */
  32714. static ExclusiveDoubleClickMode: boolean;
  32715. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32716. /**
  32717. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32718. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32719. */
  32720. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32721. /**
  32722. * Observable event triggered each time an keyboard event is received from the hosting window
  32723. */
  32724. onKeyboardObservable: Observable<KeyboardInfo>;
  32725. private _useRightHandedSystem;
  32726. /**
  32727. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32728. */
  32729. useRightHandedSystem: boolean;
  32730. private _timeAccumulator;
  32731. private _currentStepId;
  32732. private _currentInternalStep;
  32733. /**
  32734. * Sets the step Id used by deterministic lock step
  32735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32736. * @param newStepId defines the step Id
  32737. */
  32738. setStepId(newStepId: number): void;
  32739. /**
  32740. * Gets the step Id used by deterministic lock step
  32741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32742. * @returns the step Id
  32743. */
  32744. getStepId(): number;
  32745. /**
  32746. * Gets the internal step used by deterministic lock step
  32747. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32748. * @returns the internal step
  32749. */
  32750. getInternalStep(): number;
  32751. private _fogEnabled;
  32752. /**
  32753. * Gets or sets a boolean indicating if fog is enabled on this scene
  32754. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32755. * (Default is true)
  32756. */
  32757. fogEnabled: boolean;
  32758. private _fogMode;
  32759. /**
  32760. * Gets or sets the fog mode to use
  32761. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32762. * | mode | value |
  32763. * | --- | --- |
  32764. * | FOGMODE_NONE | 0 |
  32765. * | FOGMODE_EXP | 1 |
  32766. * | FOGMODE_EXP2 | 2 |
  32767. * | FOGMODE_LINEAR | 3 |
  32768. */
  32769. fogMode: number;
  32770. /**
  32771. * Gets or sets the fog color to use
  32772. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32773. * (Default is Color3(0.2, 0.2, 0.3))
  32774. */
  32775. fogColor: Color3;
  32776. /**
  32777. * Gets or sets the fog density to use
  32778. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32779. * (Default is 0.1)
  32780. */
  32781. fogDensity: number;
  32782. /**
  32783. * Gets or sets the fog start distance to use
  32784. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32785. * (Default is 0)
  32786. */
  32787. fogStart: number;
  32788. /**
  32789. * Gets or sets the fog end distance to use
  32790. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32791. * (Default is 1000)
  32792. */
  32793. fogEnd: number;
  32794. private _shadowsEnabled;
  32795. /**
  32796. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32797. */
  32798. shadowsEnabled: boolean;
  32799. private _lightsEnabled;
  32800. /**
  32801. * Gets or sets a boolean indicating if lights are enabled on this scene
  32802. */
  32803. lightsEnabled: boolean;
  32804. /** All of the active cameras added to this scene. */
  32805. activeCameras: Camera[];
  32806. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32807. /** Gets or sets the current active camera */
  32808. activeCamera: Nullable<Camera>;
  32809. private _defaultMaterial;
  32810. /** The default material used on meshes when no material is affected */
  32811. /** The default material used on meshes when no material is affected */
  32812. defaultMaterial: Material;
  32813. private _texturesEnabled;
  32814. /**
  32815. * Gets or sets a boolean indicating if textures are enabled on this scene
  32816. */
  32817. texturesEnabled: boolean;
  32818. /**
  32819. * Gets or sets a boolean indicating if particles are enabled on this scene
  32820. */
  32821. particlesEnabled: boolean;
  32822. /**
  32823. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32824. */
  32825. spritesEnabled: boolean;
  32826. private _skeletonsEnabled;
  32827. /**
  32828. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32829. */
  32830. skeletonsEnabled: boolean;
  32831. /**
  32832. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32833. */
  32834. lensFlaresEnabled: boolean;
  32835. /**
  32836. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32837. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32838. */
  32839. collisionsEnabled: boolean;
  32840. private _collisionCoordinator;
  32841. /** @hidden */
  32842. readonly collisionCoordinator: ICollisionCoordinator;
  32843. /**
  32844. * Defines the gravity applied to this scene (used only for collisions)
  32845. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32846. */
  32847. gravity: Vector3;
  32848. /**
  32849. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32850. */
  32851. postProcessesEnabled: boolean;
  32852. /**
  32853. * The list of postprocesses added to the scene
  32854. */
  32855. postProcesses: PostProcess[];
  32856. /**
  32857. * Gets the current postprocess manager
  32858. */
  32859. postProcessManager: PostProcessManager;
  32860. /**
  32861. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32862. */
  32863. renderTargetsEnabled: boolean;
  32864. /**
  32865. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32866. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32867. */
  32868. dumpNextRenderTargets: boolean;
  32869. /**
  32870. * The list of user defined render targets added to the scene
  32871. */
  32872. customRenderTargets: RenderTargetTexture[];
  32873. /**
  32874. * Defines if texture loading must be delayed
  32875. * If true, textures will only be loaded when they need to be rendered
  32876. */
  32877. useDelayedTextureLoading: boolean;
  32878. /**
  32879. * Gets the list of meshes imported to the scene through SceneLoader
  32880. */
  32881. importedMeshesFiles: String[];
  32882. /**
  32883. * Gets or sets a boolean indicating if probes are enabled on this scene
  32884. */
  32885. probesEnabled: boolean;
  32886. /**
  32887. * Gets or sets the current offline provider to use to store scene data
  32888. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32889. */
  32890. offlineProvider: IOfflineProvider;
  32891. /**
  32892. * Gets or sets the action manager associated with the scene
  32893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32894. */
  32895. actionManager: AbstractActionManager;
  32896. private _meshesForIntersections;
  32897. /**
  32898. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32899. */
  32900. proceduralTexturesEnabled: boolean;
  32901. private _engine;
  32902. private _totalVertices;
  32903. /** @hidden */ private _activeIndices: PerfCounter;
  32904. /** @hidden */ private _activeParticles: PerfCounter;
  32905. /** @hidden */ private _activeBones: PerfCounter;
  32906. private _animationRatio;
  32907. /** @hidden */ private _animationTimeLast: number;
  32908. /** @hidden */ private _animationTime: number;
  32909. /**
  32910. * Gets or sets a general scale for animation speed
  32911. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32912. */
  32913. animationTimeScale: number;
  32914. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32915. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32916. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32917. private _renderId;
  32918. private _frameId;
  32919. private _executeWhenReadyTimeoutId;
  32920. private _intermediateRendering;
  32921. private _viewUpdateFlag;
  32922. private _projectionUpdateFlag;
  32923. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32924. private _activeRequests;
  32925. /** @hidden */ private _pendingData: any[];
  32926. private _isDisposed;
  32927. /**
  32928. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32929. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32930. */
  32931. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32932. private _activeMeshes;
  32933. private _processedMaterials;
  32934. private _renderTargets;
  32935. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  32936. private _activeSkeletons;
  32937. private _softwareSkinnedMeshes;
  32938. private _renderingManager;
  32939. /** @hidden */ private _activeAnimatables: Animatable[];
  32940. private _transformMatrix;
  32941. private _sceneUbo;
  32942. /** @hidden */ private _viewMatrix: Matrix;
  32943. private _projectionMatrix;
  32944. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  32945. /** @hidden */ private _frustumPlanes: Plane[];
  32946. /**
  32947. * Gets the list of frustum planes (built from the active camera)
  32948. */
  32949. readonly frustumPlanes: Plane[];
  32950. /**
  32951. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32952. * This is useful if there are more lights that the maximum simulteanous authorized
  32953. */
  32954. requireLightSorting: boolean;
  32955. /** @hidden */
  32956. readonly useMaterialMeshMap: boolean;
  32957. /** @hidden */
  32958. readonly useClonedMeshhMap: boolean;
  32959. private _externalData;
  32960. private _uid;
  32961. /**
  32962. * @hidden
  32963. * Backing store of defined scene components.
  32964. */ private _components: ISceneComponent[];
  32965. /**
  32966. * @hidden
  32967. * Backing store of defined scene components.
  32968. */ private _serializableComponents: ISceneSerializableComponent[];
  32969. /**
  32970. * List of components to register on the next registration step.
  32971. */
  32972. private _transientComponents;
  32973. /**
  32974. * Registers the transient components if needed.
  32975. */
  32976. private _registerTransientComponents;
  32977. /**
  32978. * @hidden
  32979. * Add a component to the scene.
  32980. * Note that the ccomponent could be registered on th next frame if this is called after
  32981. * the register component stage.
  32982. * @param component Defines the component to add to the scene
  32983. */ private _addComponent(component: ISceneComponent): void;
  32984. /**
  32985. * @hidden
  32986. * Gets a component from the scene.
  32987. * @param name defines the name of the component to retrieve
  32988. * @returns the component or null if not present
  32989. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32990. /**
  32991. * @hidden
  32992. * Defines the actions happening before camera updates.
  32993. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32994. /**
  32995. * @hidden
  32996. * Defines the actions happening before clear the canvas.
  32997. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32998. /**
  32999. * @hidden
  33000. * Defines the actions when collecting render targets for the frame.
  33001. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33002. /**
  33003. * @hidden
  33004. * Defines the actions happening for one camera in the frame.
  33005. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33006. /**
  33007. * @hidden
  33008. * Defines the actions happening during the per mesh ready checks.
  33009. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  33010. /**
  33011. * @hidden
  33012. * Defines the actions happening before evaluate active mesh checks.
  33013. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33014. /**
  33015. * @hidden
  33016. * Defines the actions happening during the evaluate sub mesh checks.
  33017. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33018. /**
  33019. * @hidden
  33020. * Defines the actions happening during the active mesh stage.
  33021. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  33022. /**
  33023. * @hidden
  33024. * Defines the actions happening during the per camera render target step.
  33025. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33026. /**
  33027. * @hidden
  33028. * Defines the actions happening just before the active camera is drawing.
  33029. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  33030. /**
  33031. * @hidden
  33032. * Defines the actions happening just before a render target is drawing.
  33033. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33034. /**
  33035. * @hidden
  33036. * Defines the actions happening just before a rendering group is drawing.
  33037. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33038. /**
  33039. * @hidden
  33040. * Defines the actions happening just before a mesh is drawing.
  33041. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33042. /**
  33043. * @hidden
  33044. * Defines the actions happening just after a mesh has been drawn.
  33045. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33046. /**
  33047. * @hidden
  33048. * Defines the actions happening just after a rendering group has been drawn.
  33049. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33050. /**
  33051. * @hidden
  33052. * Defines the actions happening just after the active camera has been drawn.
  33053. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  33054. /**
  33055. * @hidden
  33056. * Defines the actions happening just after a render target has been drawn.
  33057. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33058. /**
  33059. * @hidden
  33060. * Defines the actions happening just after rendering all cameras and computing intersections.
  33061. */ private _afterRenderStage: Stage<SimpleStageAction>;
  33062. /**
  33063. * @hidden
  33064. * Defines the actions happening when a pointer move event happens.
  33065. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  33066. /**
  33067. * @hidden
  33068. * Defines the actions happening when a pointer down event happens.
  33069. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  33070. /**
  33071. * @hidden
  33072. * Defines the actions happening when a pointer up event happens.
  33073. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  33074. /**
  33075. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33076. */
  33077. private geometriesByUniqueId;
  33078. /**
  33079. * Creates a new Scene
  33080. * @param engine defines the engine to use to render this scene
  33081. * @param options defines the scene options
  33082. */
  33083. constructor(engine: Engine, options?: SceneOptions);
  33084. /**
  33085. * Gets a string idenfifying the name of the class
  33086. * @returns "Scene" string
  33087. */
  33088. getClassName(): string;
  33089. private _defaultMeshCandidates;
  33090. /**
  33091. * @hidden
  33092. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33093. private _defaultSubMeshCandidates;
  33094. /**
  33095. * @hidden
  33096. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33097. /**
  33098. * Sets the default candidate providers for the scene.
  33099. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33100. * and getCollidingSubMeshCandidates to their default function
  33101. */
  33102. setDefaultCandidateProviders(): void;
  33103. /**
  33104. * Gets the mesh that is currently under the pointer
  33105. */
  33106. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33107. /**
  33108. * Gets or sets the current on-screen X position of the pointer
  33109. */
  33110. pointerX: number;
  33111. /**
  33112. * Gets or sets the current on-screen Y position of the pointer
  33113. */
  33114. pointerY: number;
  33115. /**
  33116. * Gets the cached material (ie. the latest rendered one)
  33117. * @returns the cached material
  33118. */
  33119. getCachedMaterial(): Nullable<Material>;
  33120. /**
  33121. * Gets the cached effect (ie. the latest rendered one)
  33122. * @returns the cached effect
  33123. */
  33124. getCachedEffect(): Nullable<Effect>;
  33125. /**
  33126. * Gets the cached visibility state (ie. the latest rendered one)
  33127. * @returns the cached visibility state
  33128. */
  33129. getCachedVisibility(): Nullable<number>;
  33130. /**
  33131. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33132. * @param material defines the current material
  33133. * @param effect defines the current effect
  33134. * @param visibility defines the current visibility state
  33135. * @returns true if one parameter is not cached
  33136. */
  33137. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33138. /**
  33139. * Gets the engine associated with the scene
  33140. * @returns an Engine
  33141. */
  33142. getEngine(): Engine;
  33143. /**
  33144. * Gets the total number of vertices rendered per frame
  33145. * @returns the total number of vertices rendered per frame
  33146. */
  33147. getTotalVertices(): number;
  33148. /**
  33149. * Gets the performance counter for total vertices
  33150. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33151. */
  33152. readonly totalVerticesPerfCounter: PerfCounter;
  33153. /**
  33154. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33155. * @returns the total number of active indices rendered per frame
  33156. */
  33157. getActiveIndices(): number;
  33158. /**
  33159. * Gets the performance counter for active indices
  33160. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33161. */
  33162. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33163. /**
  33164. * Gets the total number of active particles rendered per frame
  33165. * @returns the total number of active particles rendered per frame
  33166. */
  33167. getActiveParticles(): number;
  33168. /**
  33169. * Gets the performance counter for active particles
  33170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33171. */
  33172. readonly activeParticlesPerfCounter: PerfCounter;
  33173. /**
  33174. * Gets the total number of active bones rendered per frame
  33175. * @returns the total number of active bones rendered per frame
  33176. */
  33177. getActiveBones(): number;
  33178. /**
  33179. * Gets the performance counter for active bones
  33180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33181. */
  33182. readonly activeBonesPerfCounter: PerfCounter;
  33183. /**
  33184. * Gets the array of active meshes
  33185. * @returns an array of AbstractMesh
  33186. */
  33187. getActiveMeshes(): SmartArray<AbstractMesh>;
  33188. /**
  33189. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33190. * @returns a number
  33191. */
  33192. getAnimationRatio(): number;
  33193. /**
  33194. * Gets an unique Id for the current render phase
  33195. * @returns a number
  33196. */
  33197. getRenderId(): number;
  33198. /**
  33199. * Gets an unique Id for the current frame
  33200. * @returns a number
  33201. */
  33202. getFrameId(): number;
  33203. /** Call this function if you want to manually increment the render Id*/
  33204. incrementRenderId(): void;
  33205. private _createUbo;
  33206. /**
  33207. * Use this method to simulate a pointer move on a mesh
  33208. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33209. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33210. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33211. * @returns the current scene
  33212. */
  33213. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33214. /**
  33215. * Use this method to simulate a pointer down on a mesh
  33216. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33217. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33218. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33219. * @returns the current scene
  33220. */
  33221. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33222. /**
  33223. * Use this method to simulate a pointer up on a mesh
  33224. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33225. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33226. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33227. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33228. * @returns the current scene
  33229. */
  33230. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33231. /**
  33232. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33233. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33234. * @returns true if the pointer was captured
  33235. */
  33236. isPointerCaptured(pointerId?: number): boolean;
  33237. /**
  33238. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33239. * @param attachUp defines if you want to attach events to pointerup
  33240. * @param attachDown defines if you want to attach events to pointerdown
  33241. * @param attachMove defines if you want to attach events to pointermove
  33242. */
  33243. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33244. /** Detaches all event handlers*/
  33245. detachControl(): void;
  33246. /**
  33247. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33248. * Delay loaded resources are not taking in account
  33249. * @return true if all required resources are ready
  33250. */
  33251. isReady(): boolean;
  33252. /** Resets all cached information relative to material (including effect and visibility) */
  33253. resetCachedMaterial(): void;
  33254. /**
  33255. * Registers a function to be called before every frame render
  33256. * @param func defines the function to register
  33257. */
  33258. registerBeforeRender(func: () => void): void;
  33259. /**
  33260. * Unregisters a function called before every frame render
  33261. * @param func defines the function to unregister
  33262. */
  33263. unregisterBeforeRender(func: () => void): void;
  33264. /**
  33265. * Registers a function to be called after every frame render
  33266. * @param func defines the function to register
  33267. */
  33268. registerAfterRender(func: () => void): void;
  33269. /**
  33270. * Unregisters a function called after every frame render
  33271. * @param func defines the function to unregister
  33272. */
  33273. unregisterAfterRender(func: () => void): void;
  33274. private _executeOnceBeforeRender;
  33275. /**
  33276. * The provided function will run before render once and will be disposed afterwards.
  33277. * A timeout delay can be provided so that the function will be executed in N ms.
  33278. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33279. * @param func The function to be executed.
  33280. * @param timeout optional delay in ms
  33281. */
  33282. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33283. /** @hidden */ private _addPendingData(data: any): void;
  33284. /** @hidden */ private _removePendingData(data: any): void;
  33285. /**
  33286. * Returns the number of items waiting to be loaded
  33287. * @returns the number of items waiting to be loaded
  33288. */
  33289. getWaitingItemsCount(): number;
  33290. /**
  33291. * Returns a boolean indicating if the scene is still loading data
  33292. */
  33293. readonly isLoading: boolean;
  33294. /**
  33295. * Registers a function to be executed when the scene is ready
  33296. * @param {Function} func - the function to be executed
  33297. */
  33298. executeWhenReady(func: () => void): void;
  33299. /**
  33300. * Returns a promise that resolves when the scene is ready
  33301. * @returns A promise that resolves when the scene is ready
  33302. */
  33303. whenReadyAsync(): Promise<void>;
  33304. /** @hidden */ private _checkIsReady(): void;
  33305. /**
  33306. * Gets all animatable attached to the scene
  33307. */
  33308. readonly animatables: Animatable[];
  33309. /**
  33310. * Resets the last animation time frame.
  33311. * Useful to override when animations start running when loading a scene for the first time.
  33312. */
  33313. resetLastAnimationTimeFrame(): void;
  33314. /**
  33315. * Gets the current view matrix
  33316. * @returns a Matrix
  33317. */
  33318. getViewMatrix(): Matrix;
  33319. /**
  33320. * Gets the current projection matrix
  33321. * @returns a Matrix
  33322. */
  33323. getProjectionMatrix(): Matrix;
  33324. /**
  33325. * Gets the current transform matrix
  33326. * @returns a Matrix made of View * Projection
  33327. */
  33328. getTransformMatrix(): Matrix;
  33329. /**
  33330. * Sets the current transform matrix
  33331. * @param viewL defines the View matrix to use
  33332. * @param projectionL defines the Projection matrix to use
  33333. * @param viewR defines the right View matrix to use (if provided)
  33334. * @param projectionR defines the right Projection matrix to use (if provided)
  33335. */
  33336. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33337. /**
  33338. * Gets the uniform buffer used to store scene data
  33339. * @returns a UniformBuffer
  33340. */
  33341. getSceneUniformBuffer(): UniformBuffer;
  33342. /**
  33343. * Gets an unique (relatively to the current scene) Id
  33344. * @returns an unique number for the scene
  33345. */
  33346. getUniqueId(): number;
  33347. /**
  33348. * Add a mesh to the list of scene's meshes
  33349. * @param newMesh defines the mesh to add
  33350. * @param recursive if all child meshes should also be added to the scene
  33351. */
  33352. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33353. /**
  33354. * Remove a mesh for the list of scene's meshes
  33355. * @param toRemove defines the mesh to remove
  33356. * @param recursive if all child meshes should also be removed from the scene
  33357. * @returns the index where the mesh was in the mesh list
  33358. */
  33359. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33360. /**
  33361. * Add a transform node to the list of scene's transform nodes
  33362. * @param newTransformNode defines the transform node to add
  33363. */
  33364. addTransformNode(newTransformNode: TransformNode): void;
  33365. /**
  33366. * Remove a transform node for the list of scene's transform nodes
  33367. * @param toRemove defines the transform node to remove
  33368. * @returns the index where the transform node was in the transform node list
  33369. */
  33370. removeTransformNode(toRemove: TransformNode): number;
  33371. /**
  33372. * Remove a skeleton for the list of scene's skeletons
  33373. * @param toRemove defines the skeleton to remove
  33374. * @returns the index where the skeleton was in the skeleton list
  33375. */
  33376. removeSkeleton(toRemove: Skeleton): number;
  33377. /**
  33378. * Remove a morph target for the list of scene's morph targets
  33379. * @param toRemove defines the morph target to remove
  33380. * @returns the index where the morph target was in the morph target list
  33381. */
  33382. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33383. /**
  33384. * Remove a light for the list of scene's lights
  33385. * @param toRemove defines the light to remove
  33386. * @returns the index where the light was in the light list
  33387. */
  33388. removeLight(toRemove: Light): number;
  33389. /**
  33390. * Remove a camera for the list of scene's cameras
  33391. * @param toRemove defines the camera to remove
  33392. * @returns the index where the camera was in the camera list
  33393. */
  33394. removeCamera(toRemove: Camera): number;
  33395. /**
  33396. * Remove a particle system for the list of scene's particle systems
  33397. * @param toRemove defines the particle system to remove
  33398. * @returns the index where the particle system was in the particle system list
  33399. */
  33400. removeParticleSystem(toRemove: IParticleSystem): number;
  33401. /**
  33402. * Remove a animation for the list of scene's animations
  33403. * @param toRemove defines the animation to remove
  33404. * @returns the index where the animation was in the animation list
  33405. */
  33406. removeAnimation(toRemove: Animation): number;
  33407. /**
  33408. * Will stop the animation of the given target
  33409. * @param target - the target
  33410. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33411. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  33412. */
  33413. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33414. /**
  33415. * Removes the given animation group from this scene.
  33416. * @param toRemove The animation group to remove
  33417. * @returns The index of the removed animation group
  33418. */
  33419. removeAnimationGroup(toRemove: AnimationGroup): number;
  33420. /**
  33421. * Removes the given multi-material from this scene.
  33422. * @param toRemove The multi-material to remove
  33423. * @returns The index of the removed multi-material
  33424. */
  33425. removeMultiMaterial(toRemove: MultiMaterial): number;
  33426. /**
  33427. * Removes the given material from this scene.
  33428. * @param toRemove The material to remove
  33429. * @returns The index of the removed material
  33430. */
  33431. removeMaterial(toRemove: Material): number;
  33432. /**
  33433. * Removes the given action manager from this scene.
  33434. * @param toRemove The action manager to remove
  33435. * @returns The index of the removed action manager
  33436. */
  33437. removeActionManager(toRemove: AbstractActionManager): number;
  33438. /**
  33439. * Removes the given texture from this scene.
  33440. * @param toRemove The texture to remove
  33441. * @returns The index of the removed texture
  33442. */
  33443. removeTexture(toRemove: BaseTexture): number;
  33444. /**
  33445. * Adds the given light to this scene
  33446. * @param newLight The light to add
  33447. */
  33448. addLight(newLight: Light): void;
  33449. /**
  33450. * Sorts the list list based on light priorities
  33451. */
  33452. sortLightsByPriority(): void;
  33453. /**
  33454. * Adds the given camera to this scene
  33455. * @param newCamera The camera to add
  33456. */
  33457. addCamera(newCamera: Camera): void;
  33458. /**
  33459. * Adds the given skeleton to this scene
  33460. * @param newSkeleton The skeleton to add
  33461. */
  33462. addSkeleton(newSkeleton: Skeleton): void;
  33463. /**
  33464. * Adds the given particle system to this scene
  33465. * @param newParticleSystem The particle system to add
  33466. */
  33467. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33468. /**
  33469. * Adds the given animation to this scene
  33470. * @param newAnimation The animation to add
  33471. */
  33472. addAnimation(newAnimation: Animation): void;
  33473. /**
  33474. * Adds the given animation group to this scene.
  33475. * @param newAnimationGroup The animation group to add
  33476. */
  33477. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33478. /**
  33479. * Adds the given multi-material to this scene
  33480. * @param newMultiMaterial The multi-material to add
  33481. */
  33482. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33483. /**
  33484. * Adds the given material to this scene
  33485. * @param newMaterial The material to add
  33486. */
  33487. addMaterial(newMaterial: Material): void;
  33488. /**
  33489. * Adds the given morph target to this scene
  33490. * @param newMorphTargetManager The morph target to add
  33491. */
  33492. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33493. /**
  33494. * Adds the given geometry to this scene
  33495. * @param newGeometry The geometry to add
  33496. */
  33497. addGeometry(newGeometry: Geometry): void;
  33498. /**
  33499. * Adds the given action manager to this scene
  33500. * @param newActionManager The action manager to add
  33501. */
  33502. addActionManager(newActionManager: AbstractActionManager): void;
  33503. /**
  33504. * Adds the given texture to this scene.
  33505. * @param newTexture The texture to add
  33506. */
  33507. addTexture(newTexture: BaseTexture): void;
  33508. /**
  33509. * Switch active camera
  33510. * @param newCamera defines the new active camera
  33511. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33512. */
  33513. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33514. /**
  33515. * sets the active camera of the scene using its ID
  33516. * @param id defines the camera's ID
  33517. * @return the new active camera or null if none found.
  33518. */
  33519. setActiveCameraByID(id: string): Nullable<Camera>;
  33520. /**
  33521. * sets the active camera of the scene using its name
  33522. * @param name defines the camera's name
  33523. * @returns the new active camera or null if none found.
  33524. */
  33525. setActiveCameraByName(name: string): Nullable<Camera>;
  33526. /**
  33527. * get an animation group using its name
  33528. * @param name defines the material's name
  33529. * @return the animation group or null if none found.
  33530. */
  33531. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33532. /**
  33533. * Get a material using its unique id
  33534. * @param uniqueId defines the material's unique id
  33535. * @return the material or null if none found.
  33536. */
  33537. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33538. /**
  33539. * get a material using its id
  33540. * @param id defines the material's ID
  33541. * @return the material or null if none found.
  33542. */
  33543. getMaterialByID(id: string): Nullable<Material>;
  33544. /**
  33545. * Gets a the last added material using a given id
  33546. * @param id defines the material's ID
  33547. * @return the last material with the given id or null if none found.
  33548. */
  33549. getLastMaterialByID(id: string): Nullable<Material>;
  33550. /**
  33551. * Gets a material using its name
  33552. * @param name defines the material's name
  33553. * @return the material or null if none found.
  33554. */
  33555. getMaterialByName(name: string): Nullable<Material>;
  33556. /**
  33557. * Get a texture using its unique id
  33558. * @param uniqueId defines the texture's unique id
  33559. * @return the texture or null if none found.
  33560. */
  33561. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33562. /**
  33563. * Gets a camera using its id
  33564. * @param id defines the id to look for
  33565. * @returns the camera or null if not found
  33566. */
  33567. getCameraByID(id: string): Nullable<Camera>;
  33568. /**
  33569. * Gets a camera using its unique id
  33570. * @param uniqueId defines the unique id to look for
  33571. * @returns the camera or null if not found
  33572. */
  33573. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33574. /**
  33575. * Gets a camera using its name
  33576. * @param name defines the camera's name
  33577. * @return the camera or null if none found.
  33578. */
  33579. getCameraByName(name: string): Nullable<Camera>;
  33580. /**
  33581. * Gets a bone using its id
  33582. * @param id defines the bone's id
  33583. * @return the bone or null if not found
  33584. */
  33585. getBoneByID(id: string): Nullable<Bone>;
  33586. /**
  33587. * Gets a bone using its id
  33588. * @param name defines the bone's name
  33589. * @return the bone or null if not found
  33590. */
  33591. getBoneByName(name: string): Nullable<Bone>;
  33592. /**
  33593. * Gets a light node using its name
  33594. * @param name defines the the light's name
  33595. * @return the light or null if none found.
  33596. */
  33597. getLightByName(name: string): Nullable<Light>;
  33598. /**
  33599. * Gets a light node using its id
  33600. * @param id defines the light's id
  33601. * @return the light or null if none found.
  33602. */
  33603. getLightByID(id: string): Nullable<Light>;
  33604. /**
  33605. * Gets a light node using its scene-generated unique ID
  33606. * @param uniqueId defines the light's unique id
  33607. * @return the light or null if none found.
  33608. */
  33609. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33610. /**
  33611. * Gets a particle system by id
  33612. * @param id defines the particle system id
  33613. * @return the corresponding system or null if none found
  33614. */
  33615. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33616. /**
  33617. * Gets a geometry using its ID
  33618. * @param id defines the geometry's id
  33619. * @return the geometry or null if none found.
  33620. */
  33621. getGeometryByID(id: string): Nullable<Geometry>;
  33622. private _getGeometryByUniqueID;
  33623. /**
  33624. * Add a new geometry to this scene
  33625. * @param geometry defines the geometry to be added to the scene.
  33626. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33627. * @return a boolean defining if the geometry was added or not
  33628. */
  33629. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33630. /**
  33631. * Removes an existing geometry
  33632. * @param geometry defines the geometry to be removed from the scene
  33633. * @return a boolean defining if the geometry was removed or not
  33634. */
  33635. removeGeometry(geometry: Geometry): boolean;
  33636. /**
  33637. * Gets the list of geometries attached to the scene
  33638. * @returns an array of Geometry
  33639. */
  33640. getGeometries(): Geometry[];
  33641. /**
  33642. * Gets the first added mesh found of a given ID
  33643. * @param id defines the id to search for
  33644. * @return the mesh found or null if not found at all
  33645. */
  33646. getMeshByID(id: string): Nullable<AbstractMesh>;
  33647. /**
  33648. * Gets a list of meshes using their id
  33649. * @param id defines the id to search for
  33650. * @returns a list of meshes
  33651. */
  33652. getMeshesByID(id: string): Array<AbstractMesh>;
  33653. /**
  33654. * Gets the first added transform node found of a given ID
  33655. * @param id defines the id to search for
  33656. * @return the found transform node or null if not found at all.
  33657. */
  33658. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33659. /**
  33660. * Gets a transform node with its auto-generated unique id
  33661. * @param uniqueId efines the unique id to search for
  33662. * @return the found transform node or null if not found at all.
  33663. */
  33664. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33665. /**
  33666. * Gets a list of transform nodes using their id
  33667. * @param id defines the id to search for
  33668. * @returns a list of transform nodes
  33669. */
  33670. getTransformNodesByID(id: string): Array<TransformNode>;
  33671. /**
  33672. * Gets a mesh with its auto-generated unique id
  33673. * @param uniqueId defines the unique id to search for
  33674. * @return the found mesh or null if not found at all.
  33675. */
  33676. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33677. /**
  33678. * Gets a the last added mesh using a given id
  33679. * @param id defines the id to search for
  33680. * @return the found mesh or null if not found at all.
  33681. */
  33682. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33683. /**
  33684. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33685. * @param id defines the id to search for
  33686. * @return the found node or null if not found at all
  33687. */
  33688. getLastEntryByID(id: string): Nullable<Node>;
  33689. /**
  33690. * Gets a node (Mesh, Camera, Light) using a given id
  33691. * @param id defines the id to search for
  33692. * @return the found node or null if not found at all
  33693. */
  33694. getNodeByID(id: string): Nullable<Node>;
  33695. /**
  33696. * Gets a node (Mesh, Camera, Light) using a given name
  33697. * @param name defines the name to search for
  33698. * @return the found node or null if not found at all.
  33699. */
  33700. getNodeByName(name: string): Nullable<Node>;
  33701. /**
  33702. * Gets a mesh using a given name
  33703. * @param name defines the name to search for
  33704. * @return the found mesh or null if not found at all.
  33705. */
  33706. getMeshByName(name: string): Nullable<AbstractMesh>;
  33707. /**
  33708. * Gets a transform node using a given name
  33709. * @param name defines the name to search for
  33710. * @return the found transform node or null if not found at all.
  33711. */
  33712. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33713. /**
  33714. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33715. * @param id defines the id to search for
  33716. * @return the found skeleton or null if not found at all.
  33717. */
  33718. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33719. /**
  33720. * Gets a skeleton using a given auto generated unique id
  33721. * @param uniqueId defines the unique id to search for
  33722. * @return the found skeleton or null if not found at all.
  33723. */
  33724. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33725. /**
  33726. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33727. * @param id defines the id to search for
  33728. * @return the found skeleton or null if not found at all.
  33729. */
  33730. getSkeletonById(id: string): Nullable<Skeleton>;
  33731. /**
  33732. * Gets a skeleton using a given name
  33733. * @param name defines the name to search for
  33734. * @return the found skeleton or null if not found at all.
  33735. */
  33736. getSkeletonByName(name: string): Nullable<Skeleton>;
  33737. /**
  33738. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33739. * @param id defines the id to search for
  33740. * @return the found morph target manager or null if not found at all.
  33741. */
  33742. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33743. /**
  33744. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33745. * @param id defines the id to search for
  33746. * @return the found morph target or null if not found at all.
  33747. */
  33748. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33749. /**
  33750. * Gets a boolean indicating if the given mesh is active
  33751. * @param mesh defines the mesh to look for
  33752. * @returns true if the mesh is in the active list
  33753. */
  33754. isActiveMesh(mesh: AbstractMesh): boolean;
  33755. /**
  33756. * Return a unique id as a string which can serve as an identifier for the scene
  33757. */
  33758. readonly uid: string;
  33759. /**
  33760. * Add an externaly attached data from its key.
  33761. * This method call will fail and return false, if such key already exists.
  33762. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33763. * @param key the unique key that identifies the data
  33764. * @param data the data object to associate to the key for this Engine instance
  33765. * @return true if no such key were already present and the data was added successfully, false otherwise
  33766. */
  33767. addExternalData<T>(key: string, data: T): boolean;
  33768. /**
  33769. * Get an externaly attached data from its key
  33770. * @param key the unique key that identifies the data
  33771. * @return the associated data, if present (can be null), or undefined if not present
  33772. */
  33773. getExternalData<T>(key: string): Nullable<T>;
  33774. /**
  33775. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33776. * @param key the unique key that identifies the data
  33777. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33778. * @return the associated data, can be null if the factory returned null.
  33779. */
  33780. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33781. /**
  33782. * Remove an externaly attached data from the Engine instance
  33783. * @param key the unique key that identifies the data
  33784. * @return true if the data was successfully removed, false if it doesn't exist
  33785. */
  33786. removeExternalData(key: string): boolean;
  33787. private _evaluateSubMesh;
  33788. /**
  33789. * Clear the processed materials smart array preventing retention point in material dispose.
  33790. */
  33791. freeProcessedMaterials(): void;
  33792. private _preventFreeActiveMeshesAndRenderingGroups;
  33793. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33794. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33795. * when disposing several meshes in a row or a hierarchy of meshes.
  33796. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33797. */
  33798. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33799. /**
  33800. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33801. */
  33802. freeActiveMeshes(): void;
  33803. /**
  33804. * Clear the info related to rendering groups preventing retention points during dispose.
  33805. */
  33806. freeRenderingGroups(): void;
  33807. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33808. /**
  33809. * Lambda returning the list of potentially active meshes.
  33810. */
  33811. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33812. /**
  33813. * Lambda returning the list of potentially active sub meshes.
  33814. */
  33815. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33816. /**
  33817. * Lambda returning the list of potentially intersecting sub meshes.
  33818. */
  33819. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33820. /**
  33821. * Lambda returning the list of potentially colliding sub meshes.
  33822. */
  33823. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33824. private _activeMeshesFrozen;
  33825. /**
  33826. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33827. * @returns the current scene
  33828. */
  33829. freezeActiveMeshes(): Scene;
  33830. /**
  33831. * Use this function to restart evaluating active meshes on every frame
  33832. * @returns the current scene
  33833. */
  33834. unfreezeActiveMeshes(): Scene;
  33835. private _evaluateActiveMeshes;
  33836. private _activeMesh;
  33837. /**
  33838. * Update the transform matrix to update from the current active camera
  33839. * @param force defines a boolean used to force the update even if cache is up to date
  33840. */
  33841. updateTransformMatrix(force?: boolean): void;
  33842. private _bindFrameBuffer;
  33843. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33844. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33845. private _processSubCameras;
  33846. private _checkIntersections;
  33847. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33848. /**
  33849. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33850. */
  33851. getDeterministicFrameTime: () => number;
  33852. /** @hidden */ private _animate(): void;
  33853. /** Execute all animations (for a frame) */
  33854. animate(): void;
  33855. /**
  33856. * Render the scene
  33857. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33858. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33859. */
  33860. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33861. /**
  33862. * Freeze all materials
  33863. * A frozen material will not be updatable but should be faster to render
  33864. */
  33865. freezeMaterials(): void;
  33866. /**
  33867. * Unfreeze all materials
  33868. * A frozen material will not be updatable but should be faster to render
  33869. */
  33870. unfreezeMaterials(): void;
  33871. /**
  33872. * Releases all held ressources
  33873. */
  33874. dispose(): void;
  33875. /**
  33876. * Gets if the scene is already disposed
  33877. */
  33878. readonly isDisposed: boolean;
  33879. /**
  33880. * Call this function to reduce memory footprint of the scene.
  33881. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33882. */
  33883. clearCachedVertexData(): void;
  33884. /**
  33885. * This function will remove the local cached buffer data from texture.
  33886. * It will save memory but will prevent the texture from being rebuilt
  33887. */
  33888. cleanCachedTextureBuffer(): void;
  33889. /**
  33890. * Get the world extend vectors with an optional filter
  33891. *
  33892. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33893. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33894. */
  33895. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33896. min: Vector3;
  33897. max: Vector3;
  33898. };
  33899. /**
  33900. * Creates a ray that can be used to pick in the scene
  33901. * @param x defines the x coordinate of the origin (on-screen)
  33902. * @param y defines the y coordinate of the origin (on-screen)
  33903. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33904. * @param camera defines the camera to use for the picking
  33905. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33906. * @returns a Ray
  33907. */
  33908. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33909. /**
  33910. * Creates a ray that can be used to pick in the scene
  33911. * @param x defines the x coordinate of the origin (on-screen)
  33912. * @param y defines the y coordinate of the origin (on-screen)
  33913. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33914. * @param result defines the ray where to store the picking ray
  33915. * @param camera defines the camera to use for the picking
  33916. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33917. * @returns the current scene
  33918. */
  33919. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33920. /**
  33921. * Creates a ray that can be used to pick in the scene
  33922. * @param x defines the x coordinate of the origin (on-screen)
  33923. * @param y defines the y coordinate of the origin (on-screen)
  33924. * @param camera defines the camera to use for the picking
  33925. * @returns a Ray
  33926. */
  33927. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33928. /**
  33929. * Creates a ray that can be used to pick in the scene
  33930. * @param x defines the x coordinate of the origin (on-screen)
  33931. * @param y defines the y coordinate of the origin (on-screen)
  33932. * @param result defines the ray where to store the picking ray
  33933. * @param camera defines the camera to use for the picking
  33934. * @returns the current scene
  33935. */
  33936. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33937. /** Launch a ray to try to pick a mesh in the scene
  33938. * @param x position on screen
  33939. * @param y position on screen
  33940. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  33941. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33942. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33943. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33944. * @returns a PickingInfo
  33945. */
  33946. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33947. /** Use the given ray to pick a mesh in the scene
  33948. * @param ray The ray to use to pick meshes
  33949. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  33950. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33951. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33952. * @returns a PickingInfo
  33953. */
  33954. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33955. /**
  33956. * Launch a ray to try to pick a mesh in the scene
  33957. * @param x X position on screen
  33958. * @param y Y position on screen
  33959. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  33960. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33961. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33962. * @returns an array of PickingInfo
  33963. */
  33964. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33965. /**
  33966. * Launch a ray to try to pick a mesh in the scene
  33967. * @param ray Ray to use
  33968. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  33969. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33970. * @returns an array of PickingInfo
  33971. */
  33972. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33973. /**
  33974. * Force the value of meshUnderPointer
  33975. * @param mesh defines the mesh to use
  33976. */
  33977. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33978. /**
  33979. * Gets the mesh under the pointer
  33980. * @returns a Mesh or null if no mesh is under the pointer
  33981. */
  33982. getPointerOverMesh(): Nullable<AbstractMesh>;
  33983. /** @hidden */ private _rebuildGeometries(): void;
  33984. /** @hidden */ private _rebuildTextures(): void;
  33985. private _getByTags;
  33986. /**
  33987. * Get a list of meshes by tags
  33988. * @param tagsQuery defines the tags query to use
  33989. * @param forEach defines a predicate used to filter results
  33990. * @returns an array of Mesh
  33991. */
  33992. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33993. /**
  33994. * Get a list of cameras by tags
  33995. * @param tagsQuery defines the tags query to use
  33996. * @param forEach defines a predicate used to filter results
  33997. * @returns an array of Camera
  33998. */
  33999. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34000. /**
  34001. * Get a list of lights by tags
  34002. * @param tagsQuery defines the tags query to use
  34003. * @param forEach defines a predicate used to filter results
  34004. * @returns an array of Light
  34005. */
  34006. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34007. /**
  34008. * Get a list of materials by tags
  34009. * @param tagsQuery defines the tags query to use
  34010. * @param forEach defines a predicate used to filter results
  34011. * @returns an array of Material
  34012. */
  34013. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34014. /**
  34015. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34016. * This allowed control for front to back rendering or reversly depending of the special needs.
  34017. *
  34018. * @param renderingGroupId The rendering group id corresponding to its index
  34019. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34020. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34021. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34022. */
  34023. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  34024. /**
  34025. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34026. *
  34027. * @param renderingGroupId The rendering group id corresponding to its index
  34028. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34029. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34030. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34031. */
  34032. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34033. /**
  34034. * Gets the current auto clear configuration for one rendering group of the rendering
  34035. * manager.
  34036. * @param index the rendering group index to get the information for
  34037. * @returns The auto clear setup for the requested rendering group
  34038. */
  34039. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34040. private _blockMaterialDirtyMechanism;
  34041. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34042. blockMaterialDirtyMechanism: boolean;
  34043. /**
  34044. * Will flag all materials as dirty to trigger new shader compilation
  34045. * @param flag defines the flag used to specify which material part must be marked as dirty
  34046. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34047. */
  34048. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34049. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  34050. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34051. }
  34052. }
  34053. declare module BABYLON {
  34054. /**
  34055. * Set of assets to keep when moving a scene into an asset container.
  34056. */
  34057. export class KeepAssets extends AbstractScene {
  34058. }
  34059. /**
  34060. * Container with a set of assets that can be added or removed from a scene.
  34061. */
  34062. export class AssetContainer extends AbstractScene {
  34063. /**
  34064. * The scene the AssetContainer belongs to.
  34065. */
  34066. scene: Scene;
  34067. /**
  34068. * Instantiates an AssetContainer.
  34069. * @param scene The scene the AssetContainer belongs to.
  34070. */
  34071. constructor(scene: Scene);
  34072. /**
  34073. * Adds all the assets from the container to the scene.
  34074. */
  34075. addAllToScene(): void;
  34076. /**
  34077. * Removes all the assets in the container from the scene
  34078. */
  34079. removeAllFromScene(): void;
  34080. /**
  34081. * Disposes all the assets in the container
  34082. */
  34083. dispose(): void;
  34084. private _moveAssets;
  34085. /**
  34086. * Removes all the assets contained in the scene and adds them to the container.
  34087. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34088. */
  34089. moveAllFromScene(keepAssets?: KeepAssets): void;
  34090. /**
  34091. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  34092. * @returns the root mesh
  34093. */
  34094. createRootMesh(): Mesh;
  34095. }
  34096. }
  34097. declare module BABYLON {
  34098. /**
  34099. * Defines how the parser contract is defined.
  34100. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34101. */
  34102. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34103. /**
  34104. * Defines how the individual parser contract is defined.
  34105. * These parser can parse an individual asset
  34106. */
  34107. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34108. /**
  34109. * Base class of the scene acting as a container for the different elements composing a scene.
  34110. * This class is dynamically extended by the different components of the scene increasing
  34111. * flexibility and reducing coupling
  34112. */
  34113. export abstract class AbstractScene {
  34114. /**
  34115. * Stores the list of available parsers in the application.
  34116. */
  34117. private static _BabylonFileParsers;
  34118. /**
  34119. * Stores the list of available individual parsers in the application.
  34120. */
  34121. private static _IndividualBabylonFileParsers;
  34122. /**
  34123. * Adds a parser in the list of available ones
  34124. * @param name Defines the name of the parser
  34125. * @param parser Defines the parser to add
  34126. */
  34127. static AddParser(name: string, parser: BabylonFileParser): void;
  34128. /**
  34129. * Gets a general parser from the list of avaialble ones
  34130. * @param name Defines the name of the parser
  34131. * @returns the requested parser or null
  34132. */
  34133. static GetParser(name: string): Nullable<BabylonFileParser>;
  34134. /**
  34135. * Adds n individual parser in the list of available ones
  34136. * @param name Defines the name of the parser
  34137. * @param parser Defines the parser to add
  34138. */
  34139. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34140. /**
  34141. * Gets an individual parser from the list of avaialble ones
  34142. * @param name Defines the name of the parser
  34143. * @returns the requested parser or null
  34144. */
  34145. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34146. /**
  34147. * Parser json data and populate both a scene and its associated container object
  34148. * @param jsonData Defines the data to parse
  34149. * @param scene Defines the scene to parse the data for
  34150. * @param container Defines the container attached to the parsing sequence
  34151. * @param rootUrl Defines the root url of the data
  34152. */
  34153. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34154. /**
  34155. * Gets the list of root nodes (ie. nodes with no parent)
  34156. */
  34157. rootNodes: Node[];
  34158. /** All of the cameras added to this scene
  34159. * @see http://doc.babylonjs.com/babylon101/cameras
  34160. */
  34161. cameras: Camera[];
  34162. /**
  34163. * All of the lights added to this scene
  34164. * @see http://doc.babylonjs.com/babylon101/lights
  34165. */
  34166. lights: Light[];
  34167. /**
  34168. * All of the (abstract) meshes added to this scene
  34169. */
  34170. meshes: AbstractMesh[];
  34171. /**
  34172. * The list of skeletons added to the scene
  34173. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34174. */
  34175. skeletons: Skeleton[];
  34176. /**
  34177. * All of the particle systems added to this scene
  34178. * @see http://doc.babylonjs.com/babylon101/particles
  34179. */
  34180. particleSystems: IParticleSystem[];
  34181. /**
  34182. * Gets a list of Animations associated with the scene
  34183. */
  34184. animations: Animation[];
  34185. /**
  34186. * All of the animation groups added to this scene
  34187. * @see http://doc.babylonjs.com/how_to/group
  34188. */
  34189. animationGroups: AnimationGroup[];
  34190. /**
  34191. * All of the multi-materials added to this scene
  34192. * @see http://doc.babylonjs.com/how_to/multi_materials
  34193. */
  34194. multiMaterials: MultiMaterial[];
  34195. /**
  34196. * All of the materials added to this scene
  34197. * In the context of a Scene, it is not supposed to be modified manually.
  34198. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34199. * Note also that the order of the Material wihin the array is not significant and might change.
  34200. * @see http://doc.babylonjs.com/babylon101/materials
  34201. */
  34202. materials: Material[];
  34203. /**
  34204. * The list of morph target managers added to the scene
  34205. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34206. */
  34207. morphTargetManagers: MorphTargetManager[];
  34208. /**
  34209. * The list of geometries used in the scene.
  34210. */
  34211. geometries: Geometry[];
  34212. /**
  34213. * All of the tranform nodes added to this scene
  34214. * In the context of a Scene, it is not supposed to be modified manually.
  34215. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34216. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34217. * @see http://doc.babylonjs.com/how_to/transformnode
  34218. */
  34219. transformNodes: TransformNode[];
  34220. /**
  34221. * ActionManagers available on the scene.
  34222. */
  34223. actionManagers: AbstractActionManager[];
  34224. /**
  34225. * Textures to keep.
  34226. */
  34227. textures: BaseTexture[];
  34228. /**
  34229. * Environment texture for the scene
  34230. */
  34231. environmentTexture: Nullable<BaseTexture>;
  34232. }
  34233. }
  34234. declare module BABYLON {
  34235. /**
  34236. * Interface used to define options for Sound class
  34237. */
  34238. export interface ISoundOptions {
  34239. /**
  34240. * Does the sound autoplay once loaded.
  34241. */
  34242. autoplay?: boolean;
  34243. /**
  34244. * Does the sound loop after it finishes playing once.
  34245. */
  34246. loop?: boolean;
  34247. /**
  34248. * Sound's volume
  34249. */
  34250. volume?: number;
  34251. /**
  34252. * Is it a spatial sound?
  34253. */
  34254. spatialSound?: boolean;
  34255. /**
  34256. * Maximum distance to hear that sound
  34257. */
  34258. maxDistance?: number;
  34259. /**
  34260. * Uses user defined attenuation function
  34261. */
  34262. useCustomAttenuation?: boolean;
  34263. /**
  34264. * Define the roll off factor of spatial sounds.
  34265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34266. */
  34267. rolloffFactor?: number;
  34268. /**
  34269. * Define the reference distance the sound should be heard perfectly.
  34270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34271. */
  34272. refDistance?: number;
  34273. /**
  34274. * Define the distance attenuation model the sound will follow.
  34275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34276. */
  34277. distanceModel?: string;
  34278. /**
  34279. * Defines the playback speed (1 by default)
  34280. */
  34281. playbackRate?: number;
  34282. /**
  34283. * Defines if the sound is from a streaming source
  34284. */
  34285. streaming?: boolean;
  34286. /**
  34287. * Defines an optional length (in seconds) inside the sound file
  34288. */
  34289. length?: number;
  34290. /**
  34291. * Defines an optional offset (in seconds) inside the sound file
  34292. */
  34293. offset?: number;
  34294. /**
  34295. * If true, URLs will not be required to state the audio file codec to use.
  34296. */
  34297. skipCodecCheck?: boolean;
  34298. }
  34299. /**
  34300. * Defines a sound that can be played in the application.
  34301. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34302. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34303. */
  34304. export class Sound {
  34305. /**
  34306. * The name of the sound in the scene.
  34307. */
  34308. name: string;
  34309. /**
  34310. * Does the sound autoplay once loaded.
  34311. */
  34312. autoplay: boolean;
  34313. /**
  34314. * Does the sound loop after it finishes playing once.
  34315. */
  34316. loop: boolean;
  34317. /**
  34318. * Does the sound use a custom attenuation curve to simulate the falloff
  34319. * happening when the source gets further away from the camera.
  34320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34321. */
  34322. useCustomAttenuation: boolean;
  34323. /**
  34324. * The sound track id this sound belongs to.
  34325. */
  34326. soundTrackId: number;
  34327. /**
  34328. * Is this sound currently played.
  34329. */
  34330. isPlaying: boolean;
  34331. /**
  34332. * Is this sound currently paused.
  34333. */
  34334. isPaused: boolean;
  34335. /**
  34336. * Does this sound enables spatial sound.
  34337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34338. */
  34339. spatialSound: boolean;
  34340. /**
  34341. * Define the reference distance the sound should be heard perfectly.
  34342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34343. */
  34344. refDistance: number;
  34345. /**
  34346. * Define the roll off factor of spatial sounds.
  34347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34348. */
  34349. rolloffFactor: number;
  34350. /**
  34351. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34353. */
  34354. maxDistance: number;
  34355. /**
  34356. * Define the distance attenuation model the sound will follow.
  34357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34358. */
  34359. distanceModel: string;
  34360. /**
  34361. * @hidden
  34362. * Back Compat
  34363. **/
  34364. onended: () => any;
  34365. /**
  34366. * Observable event when the current playing sound finishes.
  34367. */
  34368. onEndedObservable: Observable<Sound>;
  34369. private _panningModel;
  34370. private _playbackRate;
  34371. private _streaming;
  34372. private _startTime;
  34373. private _startOffset;
  34374. private _position;
  34375. /** @hidden */ private _positionInEmitterSpace: boolean;
  34376. private _localDirection;
  34377. private _volume;
  34378. private _isReadyToPlay;
  34379. private _isDirectional;
  34380. private _readyToPlayCallback;
  34381. private _audioBuffer;
  34382. private _soundSource;
  34383. private _streamingSource;
  34384. private _soundPanner;
  34385. private _soundGain;
  34386. private _inputAudioNode;
  34387. private _outputAudioNode;
  34388. private _coneInnerAngle;
  34389. private _coneOuterAngle;
  34390. private _coneOuterGain;
  34391. private _scene;
  34392. private _connectedTransformNode;
  34393. private _customAttenuationFunction;
  34394. private _registerFunc;
  34395. private _isOutputConnected;
  34396. private _htmlAudioElement;
  34397. private _urlType;
  34398. private _length?;
  34399. private _offset?;
  34400. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34401. /**
  34402. * Create a sound and attach it to a scene
  34403. * @param name Name of your sound
  34404. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34405. * @param scene defines the scene the sound belongs to
  34406. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34407. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34408. */
  34409. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34410. /**
  34411. * Release the sound and its associated resources
  34412. */
  34413. dispose(): void;
  34414. /**
  34415. * Gets if the sounds is ready to be played or not.
  34416. * @returns true if ready, otherwise false
  34417. */
  34418. isReady(): boolean;
  34419. private _soundLoaded;
  34420. /**
  34421. * Sets the data of the sound from an audiobuffer
  34422. * @param audioBuffer The audioBuffer containing the data
  34423. */
  34424. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34425. /**
  34426. * Updates the current sounds options such as maxdistance, loop...
  34427. * @param options A JSON object containing values named as the object properties
  34428. */
  34429. updateOptions(options: ISoundOptions): void;
  34430. private _createSpatialParameters;
  34431. private _updateSpatialParameters;
  34432. /**
  34433. * Switch the panning model to HRTF:
  34434. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34436. */
  34437. switchPanningModelToHRTF(): void;
  34438. /**
  34439. * Switch the panning model to Equal Power:
  34440. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34441. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34442. */
  34443. switchPanningModelToEqualPower(): void;
  34444. private _switchPanningModel;
  34445. /**
  34446. * Connect this sound to a sound track audio node like gain...
  34447. * @param soundTrackAudioNode the sound track audio node to connect to
  34448. */
  34449. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34450. /**
  34451. * Transform this sound into a directional source
  34452. * @param coneInnerAngle Size of the inner cone in degree
  34453. * @param coneOuterAngle Size of the outer cone in degree
  34454. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34455. */
  34456. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34457. /**
  34458. * Gets or sets the inner angle for the directional cone.
  34459. */
  34460. /**
  34461. * Gets or sets the inner angle for the directional cone.
  34462. */
  34463. directionalConeInnerAngle: number;
  34464. /**
  34465. * Gets or sets the outer angle for the directional cone.
  34466. */
  34467. /**
  34468. * Gets or sets the outer angle for the directional cone.
  34469. */
  34470. directionalConeOuterAngle: number;
  34471. /**
  34472. * Sets the position of the emitter if spatial sound is enabled
  34473. * @param newPosition Defines the new posisiton
  34474. */
  34475. setPosition(newPosition: Vector3): void;
  34476. /**
  34477. * Sets the local direction of the emitter if spatial sound is enabled
  34478. * @param newLocalDirection Defines the new local direction
  34479. */
  34480. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34481. private _updateDirection;
  34482. /** @hidden */
  34483. updateDistanceFromListener(): void;
  34484. /**
  34485. * Sets a new custom attenuation function for the sound.
  34486. * @param callback Defines the function used for the attenuation
  34487. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34488. */
  34489. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34490. /**
  34491. * Play the sound
  34492. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34493. * @param offset (optional) Start the sound at a specific time in seconds
  34494. * @param length (optional) Sound duration (in seconds)
  34495. */
  34496. play(time?: number, offset?: number, length?: number): void;
  34497. private _onended;
  34498. /**
  34499. * Stop the sound
  34500. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34501. */
  34502. stop(time?: number): void;
  34503. /**
  34504. * Put the sound in pause
  34505. */
  34506. pause(): void;
  34507. /**
  34508. * Sets a dedicated volume for this sounds
  34509. * @param newVolume Define the new volume of the sound
  34510. * @param time Define time for gradual change to new volume
  34511. */
  34512. setVolume(newVolume: number, time?: number): void;
  34513. /**
  34514. * Set the sound play back rate
  34515. * @param newPlaybackRate Define the playback rate the sound should be played at
  34516. */
  34517. setPlaybackRate(newPlaybackRate: number): void;
  34518. /**
  34519. * Gets the volume of the sound.
  34520. * @returns the volume of the sound
  34521. */
  34522. getVolume(): number;
  34523. /**
  34524. * Attach the sound to a dedicated mesh
  34525. * @param transformNode The transform node to connect the sound with
  34526. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34527. */
  34528. attachToMesh(transformNode: TransformNode): void;
  34529. /**
  34530. * Detach the sound from the previously attached mesh
  34531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34532. */
  34533. detachFromMesh(): void;
  34534. private _onRegisterAfterWorldMatrixUpdate;
  34535. /**
  34536. * Clone the current sound in the scene.
  34537. * @returns the new sound clone
  34538. */
  34539. clone(): Nullable<Sound>;
  34540. /**
  34541. * Gets the current underlying audio buffer containing the data
  34542. * @returns the audio buffer
  34543. */
  34544. getAudioBuffer(): Nullable<AudioBuffer>;
  34545. /**
  34546. * Serializes the Sound in a JSON representation
  34547. * @returns the JSON representation of the sound
  34548. */
  34549. serialize(): any;
  34550. /**
  34551. * Parse a JSON representation of a sound to innstantiate in a given scene
  34552. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34553. * @param scene Define the scene the new parsed sound should be created in
  34554. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34555. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34556. * @returns the newly parsed sound
  34557. */
  34558. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34559. }
  34560. }
  34561. declare module BABYLON {
  34562. /**
  34563. * This defines an action helpful to play a defined sound on a triggered action.
  34564. */
  34565. export class PlaySoundAction extends Action {
  34566. private _sound;
  34567. /**
  34568. * Instantiate the action
  34569. * @param triggerOptions defines the trigger options
  34570. * @param sound defines the sound to play
  34571. * @param condition defines the trigger related conditions
  34572. */
  34573. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34574. /** @hidden */ private _prepare(): void;
  34575. /**
  34576. * Execute the action and play the sound.
  34577. */
  34578. execute(): void;
  34579. /**
  34580. * Serializes the actions and its related information.
  34581. * @param parent defines the object to serialize in
  34582. * @returns the serialized object
  34583. */
  34584. serialize(parent: any): any;
  34585. }
  34586. /**
  34587. * This defines an action helpful to stop a defined sound on a triggered action.
  34588. */
  34589. export class StopSoundAction extends Action {
  34590. private _sound;
  34591. /**
  34592. * Instantiate the action
  34593. * @param triggerOptions defines the trigger options
  34594. * @param sound defines the sound to stop
  34595. * @param condition defines the trigger related conditions
  34596. */
  34597. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34598. /** @hidden */ private _prepare(): void;
  34599. /**
  34600. * Execute the action and stop the sound.
  34601. */
  34602. execute(): void;
  34603. /**
  34604. * Serializes the actions and its related information.
  34605. * @param parent defines the object to serialize in
  34606. * @returns the serialized object
  34607. */
  34608. serialize(parent: any): any;
  34609. }
  34610. }
  34611. declare module BABYLON {
  34612. /**
  34613. * This defines an action responsible to change the value of a property
  34614. * by interpolating between its current value and the newly set one once triggered.
  34615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34616. */
  34617. export class InterpolateValueAction extends Action {
  34618. /**
  34619. * Defines the path of the property where the value should be interpolated
  34620. */
  34621. propertyPath: string;
  34622. /**
  34623. * Defines the target value at the end of the interpolation.
  34624. */
  34625. value: any;
  34626. /**
  34627. * Defines the time it will take for the property to interpolate to the value.
  34628. */
  34629. duration: number;
  34630. /**
  34631. * Defines if the other scene animations should be stopped when the action has been triggered
  34632. */
  34633. stopOtherAnimations?: boolean;
  34634. /**
  34635. * Defines a callback raised once the interpolation animation has been done.
  34636. */
  34637. onInterpolationDone?: () => void;
  34638. /**
  34639. * Observable triggered once the interpolation animation has been done.
  34640. */
  34641. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34642. private _target;
  34643. private _effectiveTarget;
  34644. private _property;
  34645. /**
  34646. * Instantiate the action
  34647. * @param triggerOptions defines the trigger options
  34648. * @param target defines the object containing the value to interpolate
  34649. * @param propertyPath defines the path to the property in the target object
  34650. * @param value defines the target value at the end of the interpolation
  34651. * @param duration deines the time it will take for the property to interpolate to the value.
  34652. * @param condition defines the trigger related conditions
  34653. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34654. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34655. */
  34656. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34657. /** @hidden */ private _prepare(): void;
  34658. /**
  34659. * Execute the action starts the value interpolation.
  34660. */
  34661. execute(): void;
  34662. /**
  34663. * Serializes the actions and its related information.
  34664. * @param parent defines the object to serialize in
  34665. * @returns the serialized object
  34666. */
  34667. serialize(parent: any): any;
  34668. }
  34669. }
  34670. declare module BABYLON {
  34671. /**
  34672. * Options allowed during the creation of a sound track.
  34673. */
  34674. export interface ISoundTrackOptions {
  34675. /**
  34676. * The volume the sound track should take during creation
  34677. */
  34678. volume?: number;
  34679. /**
  34680. * Define if the sound track is the main sound track of the scene
  34681. */
  34682. mainTrack?: boolean;
  34683. }
  34684. /**
  34685. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34686. * It will be also used in a future release to apply effects on a specific track.
  34687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34688. */
  34689. export class SoundTrack {
  34690. /**
  34691. * The unique identifier of the sound track in the scene.
  34692. */
  34693. id: number;
  34694. /**
  34695. * The list of sounds included in the sound track.
  34696. */
  34697. soundCollection: Array<Sound>;
  34698. private _outputAudioNode;
  34699. private _scene;
  34700. private _isMainTrack;
  34701. private _connectedAnalyser;
  34702. private _options;
  34703. private _isInitialized;
  34704. /**
  34705. * Creates a new sound track.
  34706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34707. * @param scene Define the scene the sound track belongs to
  34708. * @param options
  34709. */
  34710. constructor(scene: Scene, options?: ISoundTrackOptions);
  34711. private _initializeSoundTrackAudioGraph;
  34712. /**
  34713. * Release the sound track and its associated resources
  34714. */
  34715. dispose(): void;
  34716. /**
  34717. * Adds a sound to this sound track
  34718. * @param sound define the cound to add
  34719. * @ignoreNaming
  34720. */
  34721. AddSound(sound: Sound): void;
  34722. /**
  34723. * Removes a sound to this sound track
  34724. * @param sound define the cound to remove
  34725. * @ignoreNaming
  34726. */
  34727. RemoveSound(sound: Sound): void;
  34728. /**
  34729. * Set a global volume for the full sound track.
  34730. * @param newVolume Define the new volume of the sound track
  34731. */
  34732. setVolume(newVolume: number): void;
  34733. /**
  34734. * Switch the panning model to HRTF:
  34735. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34737. */
  34738. switchPanningModelToHRTF(): void;
  34739. /**
  34740. * Switch the panning model to Equal Power:
  34741. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34742. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34743. */
  34744. switchPanningModelToEqualPower(): void;
  34745. /**
  34746. * Connect the sound track to an audio analyser allowing some amazing
  34747. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34749. * @param analyser The analyser to connect to the engine
  34750. */
  34751. connectToAnalyser(analyser: Analyser): void;
  34752. }
  34753. }
  34754. declare module BABYLON {
  34755. interface AbstractScene {
  34756. /**
  34757. * The list of sounds used in the scene.
  34758. */
  34759. sounds: Nullable<Array<Sound>>;
  34760. }
  34761. interface Scene {
  34762. /**
  34763. * @hidden
  34764. * Backing field
  34765. */ private _mainSoundTrack: SoundTrack;
  34766. /**
  34767. * The main sound track played by the scene.
  34768. * It cotains your primary collection of sounds.
  34769. */
  34770. mainSoundTrack: SoundTrack;
  34771. /**
  34772. * The list of sound tracks added to the scene
  34773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34774. */
  34775. soundTracks: Nullable<Array<SoundTrack>>;
  34776. /**
  34777. * Gets a sound using a given name
  34778. * @param name defines the name to search for
  34779. * @return the found sound or null if not found at all.
  34780. */
  34781. getSoundByName(name: string): Nullable<Sound>;
  34782. /**
  34783. * Gets or sets if audio support is enabled
  34784. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34785. */
  34786. audioEnabled: boolean;
  34787. /**
  34788. * Gets or sets if audio will be output to headphones
  34789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34790. */
  34791. headphone: boolean;
  34792. /**
  34793. * Gets or sets custom audio listener position provider
  34794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34795. */
  34796. audioListenerPositionProvider: Nullable<() => Vector3>;
  34797. }
  34798. /**
  34799. * Defines the sound scene component responsible to manage any sounds
  34800. * in a given scene.
  34801. */
  34802. export class AudioSceneComponent implements ISceneSerializableComponent {
  34803. /**
  34804. * The component name helpfull to identify the component in the list of scene components.
  34805. */
  34806. readonly name: string;
  34807. /**
  34808. * The scene the component belongs to.
  34809. */
  34810. scene: Scene;
  34811. private _audioEnabled;
  34812. /**
  34813. * Gets whether audio is enabled or not.
  34814. * Please use related enable/disable method to switch state.
  34815. */
  34816. readonly audioEnabled: boolean;
  34817. private _headphone;
  34818. /**
  34819. * Gets whether audio is outputing to headphone or not.
  34820. * Please use the according Switch methods to change output.
  34821. */
  34822. readonly headphone: boolean;
  34823. private _audioListenerPositionProvider;
  34824. /**
  34825. * Gets the current audio listener position provider
  34826. */
  34827. /**
  34828. * Sets a custom listener position for all sounds in the scene
  34829. * By default, this is the position of the first active camera
  34830. */
  34831. audioListenerPositionProvider: Nullable<() => Vector3>;
  34832. /**
  34833. * Creates a new instance of the component for the given scene
  34834. * @param scene Defines the scene to register the component in
  34835. */
  34836. constructor(scene: Scene);
  34837. /**
  34838. * Registers the component in a given scene
  34839. */
  34840. register(): void;
  34841. /**
  34842. * Rebuilds the elements related to this component in case of
  34843. * context lost for instance.
  34844. */
  34845. rebuild(): void;
  34846. /**
  34847. * Serializes the component data to the specified json object
  34848. * @param serializationObject The object to serialize to
  34849. */
  34850. serialize(serializationObject: any): void;
  34851. /**
  34852. * Adds all the elements from the container to the scene
  34853. * @param container the container holding the elements
  34854. */
  34855. addFromContainer(container: AbstractScene): void;
  34856. /**
  34857. * Removes all the elements in the container from the scene
  34858. * @param container contains the elements to remove
  34859. * @param dispose if the removed element should be disposed (default: false)
  34860. */
  34861. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34862. /**
  34863. * Disposes the component and the associated ressources.
  34864. */
  34865. dispose(): void;
  34866. /**
  34867. * Disables audio in the associated scene.
  34868. */
  34869. disableAudio(): void;
  34870. /**
  34871. * Enables audio in the associated scene.
  34872. */
  34873. enableAudio(): void;
  34874. /**
  34875. * Switch audio to headphone output.
  34876. */
  34877. switchAudioModeForHeadphones(): void;
  34878. /**
  34879. * Switch audio to normal speakers.
  34880. */
  34881. switchAudioModeForNormalSpeakers(): void;
  34882. private _afterRender;
  34883. }
  34884. }
  34885. declare module BABYLON {
  34886. /**
  34887. * Wraps one or more Sound objects and selects one with random weight for playback.
  34888. */
  34889. export class WeightedSound {
  34890. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34891. loop: boolean;
  34892. private _coneInnerAngle;
  34893. private _coneOuterAngle;
  34894. private _volume;
  34895. /** A Sound is currently playing. */
  34896. isPlaying: boolean;
  34897. /** A Sound is currently paused. */
  34898. isPaused: boolean;
  34899. private _sounds;
  34900. private _weights;
  34901. private _currentIndex?;
  34902. /**
  34903. * Creates a new WeightedSound from the list of sounds given.
  34904. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34905. * @param sounds Array of Sounds that will be selected from.
  34906. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34907. */
  34908. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34909. /**
  34910. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34911. */
  34912. /**
  34913. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34914. */
  34915. directionalConeInnerAngle: number;
  34916. /**
  34917. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34918. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34919. */
  34920. /**
  34921. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34922. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34923. */
  34924. directionalConeOuterAngle: number;
  34925. /**
  34926. * Playback volume.
  34927. */
  34928. /**
  34929. * Playback volume.
  34930. */
  34931. volume: number;
  34932. private _onended;
  34933. /**
  34934. * Suspend playback
  34935. */
  34936. pause(): void;
  34937. /**
  34938. * Stop playback
  34939. */
  34940. stop(): void;
  34941. /**
  34942. * Start playback.
  34943. * @param startOffset Position the clip head at a specific time in seconds.
  34944. */
  34945. play(startOffset?: number): void;
  34946. }
  34947. }
  34948. declare module BABYLON {
  34949. /**
  34950. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34951. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34952. */
  34953. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34954. /**
  34955. * Gets the name of the behavior.
  34956. */
  34957. readonly name: string;
  34958. /**
  34959. * The easing function used by animations
  34960. */
  34961. static EasingFunction: BackEase;
  34962. /**
  34963. * The easing mode used by animations
  34964. */
  34965. static EasingMode: number;
  34966. /**
  34967. * The duration of the animation, in milliseconds
  34968. */
  34969. transitionDuration: number;
  34970. /**
  34971. * Length of the distance animated by the transition when lower radius is reached
  34972. */
  34973. lowerRadiusTransitionRange: number;
  34974. /**
  34975. * Length of the distance animated by the transition when upper radius is reached
  34976. */
  34977. upperRadiusTransitionRange: number;
  34978. private _autoTransitionRange;
  34979. /**
  34980. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34981. */
  34982. /**
  34983. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34984. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34985. */
  34986. autoTransitionRange: boolean;
  34987. private _attachedCamera;
  34988. private _onAfterCheckInputsObserver;
  34989. private _onMeshTargetChangedObserver;
  34990. /**
  34991. * Initializes the behavior.
  34992. */
  34993. init(): void;
  34994. /**
  34995. * Attaches the behavior to its arc rotate camera.
  34996. * @param camera Defines the camera to attach the behavior to
  34997. */
  34998. attach(camera: ArcRotateCamera): void;
  34999. /**
  35000. * Detaches the behavior from its current arc rotate camera.
  35001. */
  35002. detach(): void;
  35003. private _radiusIsAnimating;
  35004. private _radiusBounceTransition;
  35005. private _animatables;
  35006. private _cachedWheelPrecision;
  35007. /**
  35008. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35009. * @param radiusLimit The limit to check against.
  35010. * @return Bool to indicate if at limit.
  35011. */
  35012. private _isRadiusAtLimit;
  35013. /**
  35014. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35015. * @param radiusDelta The delta by which to animate to. Can be negative.
  35016. */
  35017. private _applyBoundRadiusAnimation;
  35018. /**
  35019. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35020. */
  35021. protected _clearAnimationLocks(): void;
  35022. /**
  35023. * Stops and removes all animations that have been applied to the camera
  35024. */
  35025. stopAllAnimations(): void;
  35026. }
  35027. }
  35028. declare module BABYLON {
  35029. /**
  35030. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  35031. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35032. */
  35033. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35034. /**
  35035. * Gets the name of the behavior.
  35036. */
  35037. readonly name: string;
  35038. private _mode;
  35039. private _radiusScale;
  35040. private _positionScale;
  35041. private _defaultElevation;
  35042. private _elevationReturnTime;
  35043. private _elevationReturnWaitTime;
  35044. private _zoomStopsAnimation;
  35045. private _framingTime;
  35046. /**
  35047. * The easing function used by animations
  35048. */
  35049. static EasingFunction: ExponentialEase;
  35050. /**
  35051. * The easing mode used by animations
  35052. */
  35053. static EasingMode: number;
  35054. /**
  35055. * Sets the current mode used by the behavior
  35056. */
  35057. /**
  35058. * Gets current mode used by the behavior.
  35059. */
  35060. mode: number;
  35061. /**
  35062. * Sets the scale applied to the radius (1 by default)
  35063. */
  35064. /**
  35065. * Gets the scale applied to the radius
  35066. */
  35067. radiusScale: number;
  35068. /**
  35069. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35070. */
  35071. /**
  35072. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35073. */
  35074. positionScale: number;
  35075. /**
  35076. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35077. * behaviour is triggered, in radians.
  35078. */
  35079. /**
  35080. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35081. * behaviour is triggered, in radians.
  35082. */
  35083. defaultElevation: number;
  35084. /**
  35085. * Sets the time (in milliseconds) taken to return to the default beta position.
  35086. * Negative value indicates camera should not return to default.
  35087. */
  35088. /**
  35089. * Gets the time (in milliseconds) taken to return to the default beta position.
  35090. * Negative value indicates camera should not return to default.
  35091. */
  35092. elevationReturnTime: number;
  35093. /**
  35094. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35095. */
  35096. /**
  35097. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35098. */
  35099. elevationReturnWaitTime: number;
  35100. /**
  35101. * Sets the flag that indicates if user zooming should stop animation.
  35102. */
  35103. /**
  35104. * Gets the flag that indicates if user zooming should stop animation.
  35105. */
  35106. zoomStopsAnimation: boolean;
  35107. /**
  35108. * Sets the transition time when framing the mesh, in milliseconds
  35109. */
  35110. /**
  35111. * Gets the transition time when framing the mesh, in milliseconds
  35112. */
  35113. framingTime: number;
  35114. /**
  35115. * Define if the behavior should automatically change the configured
  35116. * camera limits and sensibilities.
  35117. */
  35118. autoCorrectCameraLimitsAndSensibility: boolean;
  35119. private _onPrePointerObservableObserver;
  35120. private _onAfterCheckInputsObserver;
  35121. private _onMeshTargetChangedObserver;
  35122. private _attachedCamera;
  35123. private _isPointerDown;
  35124. private _lastInteractionTime;
  35125. /**
  35126. * Initializes the behavior.
  35127. */
  35128. init(): void;
  35129. /**
  35130. * Attaches the behavior to its arc rotate camera.
  35131. * @param camera Defines the camera to attach the behavior to
  35132. */
  35133. attach(camera: ArcRotateCamera): void;
  35134. /**
  35135. * Detaches the behavior from its current arc rotate camera.
  35136. */
  35137. detach(): void;
  35138. private _animatables;
  35139. private _betaIsAnimating;
  35140. private _betaTransition;
  35141. private _radiusTransition;
  35142. private _vectorTransition;
  35143. /**
  35144. * Targets the given mesh and updates zoom level accordingly.
  35145. * @param mesh The mesh to target.
  35146. * @param radius Optional. If a cached radius position already exists, overrides default.
  35147. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35148. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35149. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35150. */
  35151. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35152. /**
  35153. * Targets the given mesh with its children and updates zoom level accordingly.
  35154. * @param mesh The mesh to target.
  35155. * @param radius Optional. If a cached radius position already exists, overrides default.
  35156. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35157. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35158. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35159. */
  35160. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35161. /**
  35162. * Targets the given meshes with their children and updates zoom level accordingly.
  35163. * @param meshes The mesh to target.
  35164. * @param radius Optional. If a cached radius position already exists, overrides default.
  35165. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35166. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35167. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35168. */
  35169. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35170. /**
  35171. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35172. * @param minimumWorld Determines the smaller position of the bounding box extend
  35173. * @param maximumWorld Determines the bigger position of the bounding box extend
  35174. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35175. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35176. */
  35177. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35178. /**
  35179. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35180. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35181. * frustum width.
  35182. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35183. * to fully enclose the mesh in the viewing frustum.
  35184. */
  35185. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35186. /**
  35187. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35188. * is automatically returned to its default position (expected to be above ground plane).
  35189. */
  35190. private _maintainCameraAboveGround;
  35191. /**
  35192. * Returns the frustum slope based on the canvas ratio and camera FOV
  35193. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35194. */
  35195. private _getFrustumSlope;
  35196. /**
  35197. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35198. */
  35199. private _clearAnimationLocks;
  35200. /**
  35201. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35202. */
  35203. private _applyUserInteraction;
  35204. /**
  35205. * Stops and removes all animations that have been applied to the camera
  35206. */
  35207. stopAllAnimations(): void;
  35208. /**
  35209. * Gets a value indicating if the user is moving the camera
  35210. */
  35211. readonly isUserIsMoving: boolean;
  35212. /**
  35213. * The camera can move all the way towards the mesh.
  35214. */
  35215. static IgnoreBoundsSizeMode: number;
  35216. /**
  35217. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35218. */
  35219. static FitFrustumSidesMode: number;
  35220. }
  35221. }
  35222. declare module BABYLON {
  35223. /**
  35224. * Base class for Camera Pointer Inputs.
  35225. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35226. * for example usage.
  35227. */
  35228. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35229. /**
  35230. * Defines the camera the input is attached to.
  35231. */
  35232. abstract camera: Camera;
  35233. /**
  35234. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35235. */
  35236. protected _altKey: boolean;
  35237. protected _ctrlKey: boolean;
  35238. protected _metaKey: boolean;
  35239. protected _shiftKey: boolean;
  35240. /**
  35241. * Which mouse buttons were pressed at time of last mouse event.
  35242. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35243. */
  35244. protected _buttonsPressed: number;
  35245. /**
  35246. * Defines the buttons associated with the input to handle camera move.
  35247. */
  35248. buttons: number[];
  35249. /**
  35250. * Attach the input controls to a specific dom element to get the input from.
  35251. * @param element Defines the element the controls should be listened from
  35252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35253. */
  35254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35255. /**
  35256. * Detach the current controls from the specified dom element.
  35257. * @param element Defines the element to stop listening the inputs from
  35258. */
  35259. detachControl(element: Nullable<HTMLElement>): void;
  35260. /**
  35261. * Gets the class name of the current input.
  35262. * @returns the class name
  35263. */
  35264. getClassName(): string;
  35265. /**
  35266. * Get the friendly name associated with the input class.
  35267. * @returns the input friendly name
  35268. */
  35269. getSimpleName(): string;
  35270. /**
  35271. * Called on pointer POINTERDOUBLETAP event.
  35272. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35273. */
  35274. protected onDoubleTap(type: string): void;
  35275. /**
  35276. * Called on pointer POINTERMOVE event if only a single touch is active.
  35277. * Override this method to provide functionality.
  35278. */
  35279. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35280. /**
  35281. * Called on pointer POINTERMOVE event if multiple touches are active.
  35282. * Override this method to provide functionality.
  35283. */
  35284. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35285. /**
  35286. * Called on JS contextmenu event.
  35287. * Override this method to provide functionality.
  35288. */
  35289. protected onContextMenu(evt: PointerEvent): void;
  35290. /**
  35291. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35292. * press.
  35293. * Override this method to provide functionality.
  35294. */
  35295. protected onButtonDown(evt: PointerEvent): void;
  35296. /**
  35297. * Called each time a new POINTERUP event occurs. Ie, for each button
  35298. * release.
  35299. * Override this method to provide functionality.
  35300. */
  35301. protected onButtonUp(evt: PointerEvent): void;
  35302. /**
  35303. * Called when window becomes inactive.
  35304. * Override this method to provide functionality.
  35305. */
  35306. protected onLostFocus(): void;
  35307. private _pointerInput;
  35308. private _observer;
  35309. private _onLostFocus;
  35310. private pointA;
  35311. private pointB;
  35312. }
  35313. }
  35314. declare module BABYLON {
  35315. /**
  35316. * Manage the pointers inputs to control an arc rotate camera.
  35317. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35318. */
  35319. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35320. /**
  35321. * Defines the camera the input is attached to.
  35322. */
  35323. camera: ArcRotateCamera;
  35324. /**
  35325. * Gets the class name of the current input.
  35326. * @returns the class name
  35327. */
  35328. getClassName(): string;
  35329. /**
  35330. * Defines the buttons associated with the input to handle camera move.
  35331. */
  35332. buttons: number[];
  35333. /**
  35334. * Defines the pointer angular sensibility along the X axis or how fast is
  35335. * the camera rotating.
  35336. */
  35337. angularSensibilityX: number;
  35338. /**
  35339. * Defines the pointer angular sensibility along the Y axis or how fast is
  35340. * the camera rotating.
  35341. */
  35342. angularSensibilityY: number;
  35343. /**
  35344. * Defines the pointer pinch precision or how fast is the camera zooming.
  35345. */
  35346. pinchPrecision: number;
  35347. /**
  35348. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35349. * from 0.
  35350. * It defines the percentage of current camera.radius to use as delta when
  35351. * pinch zoom is used.
  35352. */
  35353. pinchDeltaPercentage: number;
  35354. /**
  35355. * Defines the pointer panning sensibility or how fast is the camera moving.
  35356. */
  35357. panningSensibility: number;
  35358. /**
  35359. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35360. */
  35361. multiTouchPanning: boolean;
  35362. /**
  35363. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35364. * zoom (pinch) through multitouch.
  35365. */
  35366. multiTouchPanAndZoom: boolean;
  35367. /**
  35368. * Revers pinch action direction.
  35369. */
  35370. pinchInwards: boolean;
  35371. private _isPanClick;
  35372. private _twoFingerActivityCount;
  35373. private _isPinching;
  35374. /**
  35375. * Called on pointer POINTERMOVE event if only a single touch is active.
  35376. */
  35377. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35378. /**
  35379. * Called on pointer POINTERDOUBLETAP event.
  35380. */
  35381. protected onDoubleTap(type: string): void;
  35382. /**
  35383. * Called on pointer POINTERMOVE event if multiple touches are active.
  35384. */
  35385. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35386. /**
  35387. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35388. * press.
  35389. */
  35390. protected onButtonDown(evt: PointerEvent): void;
  35391. /**
  35392. * Called each time a new POINTERUP event occurs. Ie, for each button
  35393. * release.
  35394. */
  35395. protected onButtonUp(evt: PointerEvent): void;
  35396. /**
  35397. * Called when window becomes inactive.
  35398. */
  35399. protected onLostFocus(): void;
  35400. }
  35401. }
  35402. declare module BABYLON {
  35403. /**
  35404. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35405. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35406. */
  35407. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35408. /**
  35409. * Defines the camera the input is attached to.
  35410. */
  35411. camera: ArcRotateCamera;
  35412. /**
  35413. * Defines the list of key codes associated with the up action (increase alpha)
  35414. */
  35415. keysUp: number[];
  35416. /**
  35417. * Defines the list of key codes associated with the down action (decrease alpha)
  35418. */
  35419. keysDown: number[];
  35420. /**
  35421. * Defines the list of key codes associated with the left action (increase beta)
  35422. */
  35423. keysLeft: number[];
  35424. /**
  35425. * Defines the list of key codes associated with the right action (decrease beta)
  35426. */
  35427. keysRight: number[];
  35428. /**
  35429. * Defines the list of key codes associated with the reset action.
  35430. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35431. */
  35432. keysReset: number[];
  35433. /**
  35434. * Defines the panning sensibility of the inputs.
  35435. * (How fast is the camera paning)
  35436. */
  35437. panningSensibility: number;
  35438. /**
  35439. * Defines the zooming sensibility of the inputs.
  35440. * (How fast is the camera zooming)
  35441. */
  35442. zoomingSensibility: number;
  35443. /**
  35444. * Defines wether maintaining the alt key down switch the movement mode from
  35445. * orientation to zoom.
  35446. */
  35447. useAltToZoom: boolean;
  35448. /**
  35449. * Rotation speed of the camera
  35450. */
  35451. angularSpeed: number;
  35452. private _keys;
  35453. private _ctrlPressed;
  35454. private _altPressed;
  35455. private _onCanvasBlurObserver;
  35456. private _onKeyboardObserver;
  35457. private _engine;
  35458. private _scene;
  35459. /**
  35460. * Attach the input controls to a specific dom element to get the input from.
  35461. * @param element Defines the element the controls should be listened from
  35462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35463. */
  35464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35465. /**
  35466. * Detach the current controls from the specified dom element.
  35467. * @param element Defines the element to stop listening the inputs from
  35468. */
  35469. detachControl(element: Nullable<HTMLElement>): void;
  35470. /**
  35471. * Update the current camera state depending on the inputs that have been used this frame.
  35472. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35473. */
  35474. checkInputs(): void;
  35475. /**
  35476. * Gets the class name of the current intput.
  35477. * @returns the class name
  35478. */
  35479. getClassName(): string;
  35480. /**
  35481. * Get the friendly name associated with the input class.
  35482. * @returns the input friendly name
  35483. */
  35484. getSimpleName(): string;
  35485. }
  35486. }
  35487. declare module BABYLON {
  35488. /**
  35489. * Manage the mouse wheel inputs to control an arc rotate camera.
  35490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35491. */
  35492. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35493. /**
  35494. * Defines the camera the input is attached to.
  35495. */
  35496. camera: ArcRotateCamera;
  35497. /**
  35498. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35499. */
  35500. wheelPrecision: number;
  35501. /**
  35502. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35503. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35504. */
  35505. wheelDeltaPercentage: number;
  35506. private _wheel;
  35507. private _observer;
  35508. private computeDeltaFromMouseWheelLegacyEvent;
  35509. /**
  35510. * Attach the input controls to a specific dom element to get the input from.
  35511. * @param element Defines the element the controls should be listened from
  35512. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35513. */
  35514. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35515. /**
  35516. * Detach the current controls from the specified dom element.
  35517. * @param element Defines the element to stop listening the inputs from
  35518. */
  35519. detachControl(element: Nullable<HTMLElement>): void;
  35520. /**
  35521. * Gets the class name of the current intput.
  35522. * @returns the class name
  35523. */
  35524. getClassName(): string;
  35525. /**
  35526. * Get the friendly name associated with the input class.
  35527. * @returns the input friendly name
  35528. */
  35529. getSimpleName(): string;
  35530. }
  35531. }
  35532. declare module BABYLON {
  35533. /**
  35534. * Default Inputs manager for the ArcRotateCamera.
  35535. * It groups all the default supported inputs for ease of use.
  35536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35537. */
  35538. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35539. /**
  35540. * Instantiates a new ArcRotateCameraInputsManager.
  35541. * @param camera Defines the camera the inputs belong to
  35542. */
  35543. constructor(camera: ArcRotateCamera);
  35544. /**
  35545. * Add mouse wheel input support to the input manager.
  35546. * @returns the current input manager
  35547. */
  35548. addMouseWheel(): ArcRotateCameraInputsManager;
  35549. /**
  35550. * Add pointers input support to the input manager.
  35551. * @returns the current input manager
  35552. */
  35553. addPointers(): ArcRotateCameraInputsManager;
  35554. /**
  35555. * Add keyboard input support to the input manager.
  35556. * @returns the current input manager
  35557. */
  35558. addKeyboard(): ArcRotateCameraInputsManager;
  35559. }
  35560. }
  35561. declare module BABYLON {
  35562. /**
  35563. * This represents an orbital type of camera.
  35564. *
  35565. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  35566. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  35567. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35568. */
  35569. export class ArcRotateCamera extends TargetCamera {
  35570. /**
  35571. * Defines the rotation angle of the camera along the longitudinal axis.
  35572. */
  35573. alpha: number;
  35574. /**
  35575. * Defines the rotation angle of the camera along the latitudinal axis.
  35576. */
  35577. beta: number;
  35578. /**
  35579. * Defines the radius of the camera from it s target point.
  35580. */
  35581. radius: number;
  35582. protected _target: Vector3;
  35583. protected _targetHost: Nullable<AbstractMesh>;
  35584. /**
  35585. * Defines the target point of the camera.
  35586. * The camera looks towards it form the radius distance.
  35587. */
  35588. target: Vector3;
  35589. /**
  35590. * Define the current local position of the camera in the scene
  35591. */
  35592. position: Vector3;
  35593. protected _upVector: Vector3;
  35594. protected _upToYMatrix: Matrix;
  35595. protected _YToUpMatrix: Matrix;
  35596. /**
  35597. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35598. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35599. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35600. */
  35601. upVector: Vector3;
  35602. /**
  35603. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35604. */
  35605. setMatUp(): void;
  35606. /**
  35607. * Current inertia value on the longitudinal axis.
  35608. * The bigger this number the longer it will take for the camera to stop.
  35609. */
  35610. inertialAlphaOffset: number;
  35611. /**
  35612. * Current inertia value on the latitudinal axis.
  35613. * The bigger this number the longer it will take for the camera to stop.
  35614. */
  35615. inertialBetaOffset: number;
  35616. /**
  35617. * Current inertia value on the radius axis.
  35618. * The bigger this number the longer it will take for the camera to stop.
  35619. */
  35620. inertialRadiusOffset: number;
  35621. /**
  35622. * Minimum allowed angle on the longitudinal axis.
  35623. * This can help limiting how the Camera is able to move in the scene.
  35624. */
  35625. lowerAlphaLimit: Nullable<number>;
  35626. /**
  35627. * Maximum allowed angle on the longitudinal axis.
  35628. * This can help limiting how the Camera is able to move in the scene.
  35629. */
  35630. upperAlphaLimit: Nullable<number>;
  35631. /**
  35632. * Minimum allowed angle on the latitudinal axis.
  35633. * This can help limiting how the Camera is able to move in the scene.
  35634. */
  35635. lowerBetaLimit: number;
  35636. /**
  35637. * Maximum allowed angle on the latitudinal axis.
  35638. * This can help limiting how the Camera is able to move in the scene.
  35639. */
  35640. upperBetaLimit: number;
  35641. /**
  35642. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35643. * This can help limiting how the Camera is able to move in the scene.
  35644. */
  35645. lowerRadiusLimit: Nullable<number>;
  35646. /**
  35647. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35648. * This can help limiting how the Camera is able to move in the scene.
  35649. */
  35650. upperRadiusLimit: Nullable<number>;
  35651. /**
  35652. * Defines the current inertia value used during panning of the camera along the X axis.
  35653. */
  35654. inertialPanningX: number;
  35655. /**
  35656. * Defines the current inertia value used during panning of the camera along the Y axis.
  35657. */
  35658. inertialPanningY: number;
  35659. /**
  35660. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35661. * Basically if your fingers moves away from more than this distance you will be considered
  35662. * in pinch mode.
  35663. */
  35664. pinchToPanMaxDistance: number;
  35665. /**
  35666. * Defines the maximum distance the camera can pan.
  35667. * This could help keeping the cammera always in your scene.
  35668. */
  35669. panningDistanceLimit: Nullable<number>;
  35670. /**
  35671. * Defines the target of the camera before paning.
  35672. */
  35673. panningOriginTarget: Vector3;
  35674. /**
  35675. * Defines the value of the inertia used during panning.
  35676. * 0 would mean stop inertia and one would mean no decelleration at all.
  35677. */
  35678. panningInertia: number;
  35679. /**
  35680. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35681. */
  35682. angularSensibilityX: number;
  35683. /**
  35684. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35685. */
  35686. angularSensibilityY: number;
  35687. /**
  35688. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35689. */
  35690. pinchPrecision: number;
  35691. /**
  35692. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35693. * It will be used instead of pinchDeltaPrecision if different from 0.
  35694. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35695. */
  35696. pinchDeltaPercentage: number;
  35697. /**
  35698. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35699. */
  35700. panningSensibility: number;
  35701. /**
  35702. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35703. */
  35704. keysUp: number[];
  35705. /**
  35706. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35707. */
  35708. keysDown: number[];
  35709. /**
  35710. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35711. */
  35712. keysLeft: number[];
  35713. /**
  35714. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35715. */
  35716. keysRight: number[];
  35717. /**
  35718. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35719. */
  35720. wheelPrecision: number;
  35721. /**
  35722. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35723. * It will be used instead of pinchDeltaPrecision if different from 0.
  35724. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35725. */
  35726. wheelDeltaPercentage: number;
  35727. /**
  35728. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35729. */
  35730. zoomOnFactor: number;
  35731. /**
  35732. * Defines a screen offset for the camera position.
  35733. */
  35734. targetScreenOffset: Vector2;
  35735. /**
  35736. * Allows the camera to be completely reversed.
  35737. * If false the camera can not arrive upside down.
  35738. */
  35739. allowUpsideDown: boolean;
  35740. /**
  35741. * Define if double tap/click is used to restore the previously saved state of the camera.
  35742. */
  35743. useInputToRestoreState: boolean;
  35744. /** @hidden */ private _viewMatrix: Matrix;
  35745. /** @hidden */ private _useCtrlForPanning: boolean;
  35746. /** @hidden */ private _panningMouseButton: number;
  35747. /**
  35748. * Defines the input associated to the camera.
  35749. */
  35750. inputs: ArcRotateCameraInputsManager;
  35751. /** @hidden */ private _reset: () => void;
  35752. /**
  35753. * Defines the allowed panning axis.
  35754. */
  35755. panningAxis: Vector3;
  35756. protected _localDirection: Vector3;
  35757. protected _transformedDirection: Vector3;
  35758. private _bouncingBehavior;
  35759. /**
  35760. * Gets the bouncing behavior of the camera if it has been enabled.
  35761. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35762. */
  35763. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35764. /**
  35765. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35766. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35767. */
  35768. useBouncingBehavior: boolean;
  35769. private _framingBehavior;
  35770. /**
  35771. * Gets the framing behavior of the camera if it has been enabled.
  35772. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35773. */
  35774. readonly framingBehavior: Nullable<FramingBehavior>;
  35775. /**
  35776. * Defines if the framing behavior of the camera is enabled on the camera.
  35777. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35778. */
  35779. useFramingBehavior: boolean;
  35780. private _autoRotationBehavior;
  35781. /**
  35782. * Gets the auto rotation behavior of the camera if it has been enabled.
  35783. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35784. */
  35785. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35786. /**
  35787. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35788. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35789. */
  35790. useAutoRotationBehavior: boolean;
  35791. /**
  35792. * Observable triggered when the mesh target has been changed on the camera.
  35793. */
  35794. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35795. /**
  35796. * Event raised when the camera is colliding with a mesh.
  35797. */
  35798. onCollide: (collidedMesh: AbstractMesh) => void;
  35799. /**
  35800. * Defines whether the camera should check collision with the objects oh the scene.
  35801. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35802. */
  35803. checkCollisions: boolean;
  35804. /**
  35805. * Defines the collision radius of the camera.
  35806. * This simulates a sphere around the camera.
  35807. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35808. */
  35809. collisionRadius: Vector3;
  35810. protected _collider: Collider;
  35811. protected _previousPosition: Vector3;
  35812. protected _collisionVelocity: Vector3;
  35813. protected _newPosition: Vector3;
  35814. protected _previousAlpha: number;
  35815. protected _previousBeta: number;
  35816. protected _previousRadius: number;
  35817. protected _collisionTriggered: boolean;
  35818. protected _targetBoundingCenter: Nullable<Vector3>;
  35819. private _computationVector;
  35820. /**
  35821. * Instantiates a new ArcRotateCamera in a given scene
  35822. * @param name Defines the name of the camera
  35823. * @param alpha Defines the camera rotation along the logitudinal axis
  35824. * @param beta Defines the camera rotation along the latitudinal axis
  35825. * @param radius Defines the camera distance from its target
  35826. * @param target Defines the camera target
  35827. * @param scene Defines the scene the camera belongs to
  35828. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35829. */
  35830. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35831. /** @hidden */ private _initCache(): void;
  35832. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35833. protected _getTargetPosition(): Vector3;
  35834. private _storedAlpha;
  35835. private _storedBeta;
  35836. private _storedRadius;
  35837. private _storedTarget;
  35838. private _storedTargetScreenOffset;
  35839. /**
  35840. * Stores the current state of the camera (alpha, beta, radius and target)
  35841. * @returns the camera itself
  35842. */
  35843. storeState(): Camera;
  35844. /**
  35845. * @hidden
  35846. * Restored camera state. You must call storeState() first
  35847. */ private _restoreStateValues(): boolean;
  35848. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35849. /**
  35850. * Attached controls to the current camera.
  35851. * @param element Defines the element the controls should be listened from
  35852. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35853. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35854. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35855. */
  35856. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35857. /**
  35858. * Detach the current controls from the camera.
  35859. * The camera will stop reacting to inputs.
  35860. * @param element Defines the element to stop listening the inputs from
  35861. */
  35862. detachControl(element: HTMLElement): void;
  35863. /** @hidden */ private _checkInputs(): void;
  35864. protected _checkLimits(): void;
  35865. /**
  35866. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35867. */
  35868. rebuildAnglesAndRadius(): void;
  35869. /**
  35870. * Use a position to define the current camera related information like alpha, beta and radius
  35871. * @param position Defines the position to set the camera at
  35872. */
  35873. setPosition(position: Vector3): void;
  35874. /**
  35875. * Defines the target the camera should look at.
  35876. * This will automatically adapt alpha beta and radius to fit within the new target.
  35877. * @param target Defines the new target as a Vector or a mesh
  35878. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35879. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35880. */
  35881. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35882. /** @hidden */ private _getViewMatrix(): Matrix;
  35883. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35884. /**
  35885. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35886. * @param meshes Defines the mesh to zoom on
  35887. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  35888. */
  35889. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35890. /**
  35891. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35892. * The target will be changed but the radius
  35893. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35894. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  35895. */
  35896. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35897. min: Vector3;
  35898. max: Vector3;
  35899. distance: number;
  35900. }, doNotUpdateMaxZ?: boolean): void;
  35901. /**
  35902. * @override
  35903. * Override Camera.createRigCamera
  35904. */
  35905. createRigCamera(name: string, cameraIndex: number): Camera;
  35906. /**
  35907. * @hidden
  35908. * @override
  35909. * Override Camera._updateRigCameras
  35910. */ private _updateRigCameras(): void;
  35911. /**
  35912. * Destroy the camera and release the current resources hold by it.
  35913. */
  35914. dispose(): void;
  35915. /**
  35916. * Gets the current object class name.
  35917. * @return the class name
  35918. */
  35919. getClassName(): string;
  35920. }
  35921. }
  35922. declare module BABYLON {
  35923. /**
  35924. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35925. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35926. */
  35927. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35928. /**
  35929. * Gets the name of the behavior.
  35930. */
  35931. readonly name: string;
  35932. private _zoomStopsAnimation;
  35933. private _idleRotationSpeed;
  35934. private _idleRotationWaitTime;
  35935. private _idleRotationSpinupTime;
  35936. /**
  35937. * Sets the flag that indicates if user zooming should stop animation.
  35938. */
  35939. /**
  35940. * Gets the flag that indicates if user zooming should stop animation.
  35941. */
  35942. zoomStopsAnimation: boolean;
  35943. /**
  35944. * Sets the default speed at which the camera rotates around the model.
  35945. */
  35946. /**
  35947. * Gets the default speed at which the camera rotates around the model.
  35948. */
  35949. idleRotationSpeed: number;
  35950. /**
  35951. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35952. */
  35953. /**
  35954. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35955. */
  35956. idleRotationWaitTime: number;
  35957. /**
  35958. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35959. */
  35960. /**
  35961. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35962. */
  35963. idleRotationSpinupTime: number;
  35964. /**
  35965. * Gets a value indicating if the camera is currently rotating because of this behavior
  35966. */
  35967. readonly rotationInProgress: boolean;
  35968. private _onPrePointerObservableObserver;
  35969. private _onAfterCheckInputsObserver;
  35970. private _attachedCamera;
  35971. private _isPointerDown;
  35972. private _lastFrameTime;
  35973. private _lastInteractionTime;
  35974. private _cameraRotationSpeed;
  35975. /**
  35976. * Initializes the behavior.
  35977. */
  35978. init(): void;
  35979. /**
  35980. * Attaches the behavior to its arc rotate camera.
  35981. * @param camera Defines the camera to attach the behavior to
  35982. */
  35983. attach(camera: ArcRotateCamera): void;
  35984. /**
  35985. * Detaches the behavior from its current arc rotate camera.
  35986. */
  35987. detach(): void;
  35988. /**
  35989. * Returns true if user is scrolling.
  35990. * @return true if user is scrolling.
  35991. */
  35992. private _userIsZooming;
  35993. private _lastFrameRadius;
  35994. private _shouldAnimationStopForInteraction;
  35995. /**
  35996. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35997. */
  35998. private _applyUserInteraction;
  35999. private _userIsMoving;
  36000. }
  36001. }
  36002. declare module BABYLON {
  36003. /**
  36004. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36005. */
  36006. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36007. private ui;
  36008. /**
  36009. * The name of the behavior
  36010. */
  36011. name: string;
  36012. /**
  36013. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36014. */
  36015. distanceAwayFromFace: number;
  36016. /**
  36017. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36018. */
  36019. distanceAwayFromBottomOfFace: number;
  36020. private _faceVectors;
  36021. private _target;
  36022. private _scene;
  36023. private _onRenderObserver;
  36024. private _tmpMatrix;
  36025. private _tmpVector;
  36026. /**
  36027. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36028. * @param ui The transform node that should be attched to the mesh
  36029. */
  36030. constructor(ui: TransformNode);
  36031. /**
  36032. * Initializes the behavior
  36033. */
  36034. init(): void;
  36035. private _closestFace;
  36036. private _zeroVector;
  36037. private _lookAtTmpMatrix;
  36038. private _lookAtToRef;
  36039. /**
  36040. * Attaches the AttachToBoxBehavior to the passed in mesh
  36041. * @param target The mesh that the specified node will be attached to
  36042. */
  36043. attach(target: Mesh): void;
  36044. /**
  36045. * Detaches the behavior from the mesh
  36046. */
  36047. detach(): void;
  36048. }
  36049. }
  36050. declare module BABYLON {
  36051. /**
  36052. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36053. */
  36054. export class FadeInOutBehavior implements Behavior<Mesh> {
  36055. /**
  36056. * Time in milliseconds to delay before fading in (Default: 0)
  36057. */
  36058. delay: number;
  36059. /**
  36060. * Time in milliseconds for the mesh to fade in (Default: 300)
  36061. */
  36062. fadeInTime: number;
  36063. private _millisecondsPerFrame;
  36064. private _hovered;
  36065. private _hoverValue;
  36066. private _ownerNode;
  36067. /**
  36068. * Instatiates the FadeInOutBehavior
  36069. */
  36070. constructor();
  36071. /**
  36072. * The name of the behavior
  36073. */
  36074. readonly name: string;
  36075. /**
  36076. * Initializes the behavior
  36077. */
  36078. init(): void;
  36079. /**
  36080. * Attaches the fade behavior on the passed in mesh
  36081. * @param ownerNode The mesh that will be faded in/out once attached
  36082. */
  36083. attach(ownerNode: Mesh): void;
  36084. /**
  36085. * Detaches the behavior from the mesh
  36086. */
  36087. detach(): void;
  36088. /**
  36089. * Triggers the mesh to begin fading in or out
  36090. * @param value if the object should fade in or out (true to fade in)
  36091. */
  36092. fadeIn(value: boolean): void;
  36093. private _update;
  36094. private _setAllVisibility;
  36095. }
  36096. }
  36097. declare module BABYLON {
  36098. /**
  36099. * Class containing a set of static utilities functions for managing Pivots
  36100. * @hidden
  36101. */
  36102. export class PivotTools {
  36103. private static _PivotCached;
  36104. private static _OldPivotPoint;
  36105. private static _PivotTranslation;
  36106. private static _PivotTmpVector;
  36107. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36108. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  36109. }
  36110. }
  36111. declare module BABYLON {
  36112. /**
  36113. * Class containing static functions to help procedurally build meshes
  36114. */
  36115. export class PlaneBuilder {
  36116. /**
  36117. * Creates a plane mesh
  36118. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36119. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36120. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36122. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36124. * @param name defines the name of the mesh
  36125. * @param options defines the options used to create the mesh
  36126. * @param scene defines the hosting scene
  36127. * @returns the plane mesh
  36128. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36129. */
  36130. static CreatePlane(name: string, options: {
  36131. size?: number;
  36132. width?: number;
  36133. height?: number;
  36134. sideOrientation?: number;
  36135. frontUVs?: Vector4;
  36136. backUVs?: Vector4;
  36137. updatable?: boolean;
  36138. sourcePlane?: Plane;
  36139. }, scene?: Nullable<Scene>): Mesh;
  36140. }
  36141. }
  36142. declare module BABYLON {
  36143. /**
  36144. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36145. */
  36146. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36147. private static _AnyMouseID;
  36148. /**
  36149. * Abstract mesh the behavior is set on
  36150. */
  36151. attachedNode: AbstractMesh;
  36152. private _dragPlane;
  36153. private _scene;
  36154. private _pointerObserver;
  36155. private _beforeRenderObserver;
  36156. private static _planeScene;
  36157. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36158. /**
  36159. * The maximum tolerated angle between the drag plane and dragging pointer rays to trigger pointer events. Set to 0 to allow any angle (default: 0)
  36160. */
  36161. maxDragAngle: number;
  36162. /**
  36163. * @hidden
  36164. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36165. /**
  36166. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36167. */
  36168. currentDraggingPointerID: number;
  36169. /**
  36170. * The last position where the pointer hit the drag plane in world space
  36171. */
  36172. lastDragPosition: Vector3;
  36173. /**
  36174. * If the behavior is currently in a dragging state
  36175. */
  36176. dragging: boolean;
  36177. /**
  36178. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  36179. */
  36180. dragDeltaRatio: number;
  36181. /**
  36182. * If the drag plane orientation should be updated during the dragging (Default: true)
  36183. */
  36184. updateDragPlane: boolean;
  36185. private _debugMode;
  36186. private _moving;
  36187. /**
  36188. * Fires each time the attached mesh is dragged with the pointer
  36189. * * delta between last drag position and current drag position in world space
  36190. * * dragDistance along the drag axis
  36191. * * dragPlaneNormal normal of the current drag plane used during the drag
  36192. * * dragPlanePoint in world space where the drag intersects the drag plane
  36193. */
  36194. onDragObservable: Observable<{
  36195. delta: Vector3;
  36196. dragPlanePoint: Vector3;
  36197. dragPlaneNormal: Vector3;
  36198. dragDistance: number;
  36199. pointerId: number;
  36200. }>;
  36201. /**
  36202. * Fires each time a drag begins (eg. mouse down on mesh)
  36203. */
  36204. onDragStartObservable: Observable<{
  36205. dragPlanePoint: Vector3;
  36206. pointerId: number;
  36207. }>;
  36208. /**
  36209. * Fires each time a drag ends (eg. mouse release after drag)
  36210. */
  36211. onDragEndObservable: Observable<{
  36212. dragPlanePoint: Vector3;
  36213. pointerId: number;
  36214. }>;
  36215. /**
  36216. * If the attached mesh should be moved when dragged
  36217. */
  36218. moveAttached: boolean;
  36219. /**
  36220. * If the drag behavior will react to drag events (Default: true)
  36221. */
  36222. enabled: boolean;
  36223. /**
  36224. * If pointer events should start and release the drag (Default: true)
  36225. */
  36226. startAndReleaseDragOnPointerEvents: boolean;
  36227. /**
  36228. * If camera controls should be detached during the drag
  36229. */
  36230. detachCameraControls: boolean;
  36231. /**
  36232. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36233. */
  36234. useObjectOrienationForDragging: boolean;
  36235. private _options;
  36236. /**
  36237. * Creates a pointer drag behavior that can be attached to a mesh
  36238. * @param options The drag axis or normal of the plane that will be dragged across. If no options are specified the drag plane will always face the ray's origin (eg. camera)
  36239. */
  36240. constructor(options?: {
  36241. dragAxis?: Vector3;
  36242. dragPlaneNormal?: Vector3;
  36243. });
  36244. /**
  36245. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36246. */
  36247. validateDrag: (targetPosition: Vector3) => boolean;
  36248. /**
  36249. * The name of the behavior
  36250. */
  36251. readonly name: string;
  36252. /**
  36253. * Initializes the behavior
  36254. */
  36255. init(): void;
  36256. private _tmpVector;
  36257. private _alternatePickedPoint;
  36258. private _worldDragAxis;
  36259. private _targetPosition;
  36260. private _attachedElement;
  36261. /**
  36262. * Attaches the drag behavior the passed in mesh
  36263. * @param ownerNode The mesh that will be dragged around once attached
  36264. * @param predicate Predicate to use for pick filtering
  36265. */
  36266. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  36267. /**
  36268. * Force relase the drag action by code.
  36269. */
  36270. releaseDrag(): void;
  36271. private _startDragRay;
  36272. private _lastPointerRay;
  36273. /**
  36274. * Simulates the start of a pointer drag event on the behavior
  36275. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36276. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36277. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36278. */
  36279. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36280. private _startDrag;
  36281. private _dragDelta;
  36282. private _moveDrag;
  36283. private _pickWithRayOnDragPlane;
  36284. private _pointA;
  36285. private _pointB;
  36286. private _pointC;
  36287. private _lineA;
  36288. private _lineB;
  36289. private _localAxis;
  36290. private _lookAt;
  36291. private _updateDragPlanePosition;
  36292. /**
  36293. * Detaches the behavior from the mesh
  36294. */
  36295. detach(): void;
  36296. }
  36297. }
  36298. declare module BABYLON {
  36299. /**
  36300. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36301. */
  36302. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36303. private _dragBehaviorA;
  36304. private _dragBehaviorB;
  36305. private _startDistance;
  36306. private _initialScale;
  36307. private _targetScale;
  36308. private _ownerNode;
  36309. private _sceneRenderObserver;
  36310. /**
  36311. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36312. */
  36313. constructor();
  36314. /**
  36315. * The name of the behavior
  36316. */
  36317. readonly name: string;
  36318. /**
  36319. * Initializes the behavior
  36320. */
  36321. init(): void;
  36322. private _getCurrentDistance;
  36323. /**
  36324. * Attaches the scale behavior the passed in mesh
  36325. * @param ownerNode The mesh that will be scaled around once attached
  36326. */
  36327. attach(ownerNode: Mesh): void;
  36328. /**
  36329. * Detaches the behavior from the mesh
  36330. */
  36331. detach(): void;
  36332. }
  36333. }
  36334. declare module BABYLON {
  36335. /**
  36336. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  36337. */
  36338. export class SixDofDragBehavior implements Behavior<Mesh> {
  36339. private static _virtualScene;
  36340. private _ownerNode;
  36341. private _sceneRenderObserver;
  36342. private _scene;
  36343. private _targetPosition;
  36344. private _virtualOriginMesh;
  36345. private _virtualDragMesh;
  36346. private _pointerObserver;
  36347. private _moving;
  36348. private _startingOrientation;
  36349. /**
  36350. * How much faster the object should move when the controller is moving towards it. This is useful to bring objects that are far away from the user to them faster. Set this to 0 to avoid any speed increase. (Default: 3)
  36351. */
  36352. private zDragFactor;
  36353. /**
  36354. * If the object should rotate to face the drag origin
  36355. */
  36356. rotateDraggedObject: boolean;
  36357. /**
  36358. * If the behavior is currently in a dragging state
  36359. */
  36360. dragging: boolean;
  36361. /**
  36362. * The distance towards the target drag position to move each frame. This can be useful to avoid jitter. Set this to 1 for no delay. (Default: 0.2)
  36363. */
  36364. dragDeltaRatio: number;
  36365. /**
  36366. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36367. */
  36368. currentDraggingPointerID: number;
  36369. /**
  36370. * If camera controls should be detached during the drag
  36371. */
  36372. detachCameraControls: boolean;
  36373. /**
  36374. * Fires each time a drag starts
  36375. */
  36376. onDragStartObservable: Observable<{}>;
  36377. /**
  36378. * Fires each time a drag ends (eg. mouse release after drag)
  36379. */
  36380. onDragEndObservable: Observable<{}>;
  36381. /**
  36382. * Instantiates a behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  36383. */
  36384. constructor();
  36385. /**
  36386. * The name of the behavior
  36387. */
  36388. readonly name: string;
  36389. /**
  36390. * Initializes the behavior
  36391. */
  36392. init(): void;
  36393. /**
  36394. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36395. */
  36396. private readonly _pointerCamera;
  36397. /**
  36398. * Attaches the scale behavior the passed in mesh
  36399. * @param ownerNode The mesh that will be scaled around once attached
  36400. */
  36401. attach(ownerNode: Mesh): void;
  36402. /**
  36403. * Detaches the behavior from the mesh
  36404. */
  36405. detach(): void;
  36406. }
  36407. }
  36408. declare module BABYLON {
  36409. /**
  36410. * Class used to apply inverse kinematics to bones
  36411. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36412. */
  36413. export class BoneIKController {
  36414. private static _tmpVecs;
  36415. private static _tmpQuat;
  36416. private static _tmpMats;
  36417. /**
  36418. * Gets or sets the target mesh
  36419. */
  36420. targetMesh: AbstractMesh;
  36421. /** Gets or sets the mesh used as pole */
  36422. poleTargetMesh: AbstractMesh;
  36423. /**
  36424. * Gets or sets the bone used as pole
  36425. */
  36426. poleTargetBone: Nullable<Bone>;
  36427. /**
  36428. * Gets or sets the target position
  36429. */
  36430. targetPosition: Vector3;
  36431. /**
  36432. * Gets or sets the pole target position
  36433. */
  36434. poleTargetPosition: Vector3;
  36435. /**
  36436. * Gets or sets the pole target local offset
  36437. */
  36438. poleTargetLocalOffset: Vector3;
  36439. /**
  36440. * Gets or sets the pole angle
  36441. */
  36442. poleAngle: number;
  36443. /**
  36444. * Gets or sets the mesh associated with the controller
  36445. */
  36446. mesh: AbstractMesh;
  36447. /**
  36448. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  36449. */
  36450. slerpAmount: number;
  36451. private _bone1Quat;
  36452. private _bone1Mat;
  36453. private _bone2Ang;
  36454. private _bone1;
  36455. private _bone2;
  36456. private _bone1Length;
  36457. private _bone2Length;
  36458. private _maxAngle;
  36459. private _maxReach;
  36460. private _rightHandedSystem;
  36461. private _bendAxis;
  36462. private _slerping;
  36463. private _adjustRoll;
  36464. /**
  36465. * Gets or sets maximum allowed angle
  36466. */
  36467. maxAngle: number;
  36468. /**
  36469. * Creates a new BoneIKController
  36470. * @param mesh defines the mesh to control
  36471. * @param bone defines the bone to control
  36472. * @param options defines options to set up the controller
  36473. */
  36474. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36475. targetMesh?: AbstractMesh;
  36476. poleTargetMesh?: AbstractMesh;
  36477. poleTargetBone?: Bone;
  36478. poleTargetLocalOffset?: Vector3;
  36479. poleAngle?: number;
  36480. bendAxis?: Vector3;
  36481. maxAngle?: number;
  36482. slerpAmount?: number;
  36483. });
  36484. private _setMaxAngle;
  36485. /**
  36486. * Force the controller to update the bones
  36487. */
  36488. update(): void;
  36489. }
  36490. }
  36491. declare module BABYLON {
  36492. /**
  36493. * Class used to make a bone look toward a point in space
  36494. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36495. */
  36496. export class BoneLookController {
  36497. private static _tmpVecs;
  36498. private static _tmpQuat;
  36499. private static _tmpMats;
  36500. /**
  36501. * The target Vector3 that the bone will look at
  36502. */
  36503. target: Vector3;
  36504. /**
  36505. * The mesh that the bone is attached to
  36506. */
  36507. mesh: AbstractMesh;
  36508. /**
  36509. * The bone that will be looking to the target
  36510. */
  36511. bone: Bone;
  36512. /**
  36513. * The up axis of the coordinate system that is used when the bone is rotated
  36514. */
  36515. upAxis: Vector3;
  36516. /**
  36517. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36518. */
  36519. upAxisSpace: Space;
  36520. /**
  36521. * Used to make an adjustment to the yaw of the bone
  36522. */
  36523. adjustYaw: number;
  36524. /**
  36525. * Used to make an adjustment to the pitch of the bone
  36526. */
  36527. adjustPitch: number;
  36528. /**
  36529. * Used to make an adjustment to the roll of the bone
  36530. */
  36531. adjustRoll: number;
  36532. /**
  36533. * The amount to slerp (spherical linear interpolation) to the target. Set this to a value between 0 and 1 (a value of 1 disables slerp)
  36534. */
  36535. slerpAmount: number;
  36536. private _minYaw;
  36537. private _maxYaw;
  36538. private _minPitch;
  36539. private _maxPitch;
  36540. private _minYawSin;
  36541. private _minYawCos;
  36542. private _maxYawSin;
  36543. private _maxYawCos;
  36544. private _midYawConstraint;
  36545. private _minPitchTan;
  36546. private _maxPitchTan;
  36547. private _boneQuat;
  36548. private _slerping;
  36549. private _transformYawPitch;
  36550. private _transformYawPitchInv;
  36551. private _firstFrameSkipped;
  36552. private _yawRange;
  36553. private _fowardAxis;
  36554. /**
  36555. * Gets or sets the minimum yaw angle that the bone can look to
  36556. */
  36557. minYaw: number;
  36558. /**
  36559. * Gets or sets the maximum yaw angle that the bone can look to
  36560. */
  36561. maxYaw: number;
  36562. /**
  36563. * Gets or sets the minimum pitch angle that the bone can look to
  36564. */
  36565. minPitch: number;
  36566. /**
  36567. * Gets or sets the maximum pitch angle that the bone can look to
  36568. */
  36569. maxPitch: number;
  36570. /**
  36571. * Create a BoneLookController
  36572. * @param mesh the mesh that the bone belongs to
  36573. * @param bone the bone that will be looking to the target
  36574. * @param target the target Vector3 to look at
  36575. * @param options optional settings:
  36576. * * maxYaw: the maximum angle the bone will yaw to
  36577. * * minYaw: the minimum angle the bone will yaw to
  36578. * * maxPitch: the maximum angle the bone will pitch to
  36579. * * minPitch: the minimum angle the bone will yaw to
  36580. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36581. * * upAxis: the up axis of the coordinate system
  36582. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36583. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36584. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36585. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36586. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36587. * * adjustRoll: used to make an adjustment to the roll of the bone
  36588. **/
  36589. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36590. maxYaw?: number;
  36591. minYaw?: number;
  36592. maxPitch?: number;
  36593. minPitch?: number;
  36594. slerpAmount?: number;
  36595. upAxis?: Vector3;
  36596. upAxisSpace?: Space;
  36597. yawAxis?: Vector3;
  36598. pitchAxis?: Vector3;
  36599. adjustYaw?: number;
  36600. adjustPitch?: number;
  36601. adjustRoll?: number;
  36602. });
  36603. /**
  36604. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36605. */
  36606. update(): void;
  36607. private _getAngleDiff;
  36608. private _getAngleBetween;
  36609. private _isAngleBetween;
  36610. }
  36611. }
  36612. declare module BABYLON {
  36613. /**
  36614. * Manage the gamepad inputs to control an arc rotate camera.
  36615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36616. */
  36617. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36618. /**
  36619. * Defines the camera the input is attached to.
  36620. */
  36621. camera: ArcRotateCamera;
  36622. /**
  36623. * Defines the gamepad the input is gathering event from.
  36624. */
  36625. gamepad: Nullable<Gamepad>;
  36626. /**
  36627. * Defines the gamepad rotation sensiblity.
  36628. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36629. */
  36630. gamepadRotationSensibility: number;
  36631. /**
  36632. * Defines the gamepad move sensiblity.
  36633. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36634. */
  36635. gamepadMoveSensibility: number;
  36636. private _yAxisScale;
  36637. /**
  36638. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  36639. */
  36640. invertYAxis: boolean;
  36641. private _onGamepadConnectedObserver;
  36642. private _onGamepadDisconnectedObserver;
  36643. /**
  36644. * Attach the input controls to a specific dom element to get the input from.
  36645. * @param element Defines the element the controls should be listened from
  36646. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36647. */
  36648. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36649. /**
  36650. * Detach the current controls from the specified dom element.
  36651. * @param element Defines the element to stop listening the inputs from
  36652. */
  36653. detachControl(element: Nullable<HTMLElement>): void;
  36654. /**
  36655. * Update the current camera state depending on the inputs that have been used this frame.
  36656. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36657. */
  36658. checkInputs(): void;
  36659. /**
  36660. * Gets the class name of the current intput.
  36661. * @returns the class name
  36662. */
  36663. getClassName(): string;
  36664. /**
  36665. * Get the friendly name associated with the input class.
  36666. * @returns the input friendly name
  36667. */
  36668. getSimpleName(): string;
  36669. }
  36670. }
  36671. declare module BABYLON {
  36672. interface ArcRotateCameraInputsManager {
  36673. /**
  36674. * Add orientation input support to the input manager.
  36675. * @returns the current input manager
  36676. */
  36677. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36678. }
  36679. /**
  36680. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36682. */
  36683. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36684. /**
  36685. * Defines the camera the input is attached to.
  36686. */
  36687. camera: ArcRotateCamera;
  36688. /**
  36689. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36690. */
  36691. alphaCorrection: number;
  36692. /**
  36693. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36694. */
  36695. gammaCorrection: number;
  36696. private _alpha;
  36697. private _gamma;
  36698. private _dirty;
  36699. private _deviceOrientationHandler;
  36700. /**
  36701. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36702. */
  36703. constructor();
  36704. /**
  36705. * Attach the input controls to a specific dom element to get the input from.
  36706. * @param element Defines the element the controls should be listened from
  36707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36708. */
  36709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36710. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36711. /**
  36712. * Update the current camera state depending on the inputs that have been used this frame.
  36713. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36714. */
  36715. checkInputs(): void;
  36716. /**
  36717. * Detach the current controls from the specified dom element.
  36718. * @param element Defines the element to stop listening the inputs from
  36719. */
  36720. detachControl(element: Nullable<HTMLElement>): void;
  36721. /**
  36722. * Gets the class name of the current intput.
  36723. * @returns the class name
  36724. */
  36725. getClassName(): string;
  36726. /**
  36727. * Get the friendly name associated with the input class.
  36728. * @returns the input friendly name
  36729. */
  36730. getSimpleName(): string;
  36731. }
  36732. }
  36733. declare module BABYLON {
  36734. /**
  36735. * Listen to mouse events to control the camera.
  36736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36737. */
  36738. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36739. /**
  36740. * Defines the camera the input is attached to.
  36741. */
  36742. camera: FlyCamera;
  36743. /**
  36744. * Defines if touch is enabled. (Default is true.)
  36745. */
  36746. touchEnabled: boolean;
  36747. /**
  36748. * Defines the buttons associated with the input to handle camera rotation.
  36749. */
  36750. buttons: number[];
  36751. /**
  36752. * Assign buttons for Yaw control.
  36753. */
  36754. buttonsYaw: number[];
  36755. /**
  36756. * Assign buttons for Pitch control.
  36757. */
  36758. buttonsPitch: number[];
  36759. /**
  36760. * Assign buttons for Roll control.
  36761. */
  36762. buttonsRoll: number[];
  36763. /**
  36764. * Detect if any button is being pressed while mouse is moved.
  36765. * -1 = Mouse locked.
  36766. * 0 = Left button.
  36767. * 1 = Middle Button.
  36768. * 2 = Right Button.
  36769. */
  36770. activeButton: number;
  36771. /**
  36772. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36773. * Higher values reduce its sensitivity.
  36774. */
  36775. angularSensibility: number;
  36776. private _mousemoveCallback;
  36777. private _observer;
  36778. private _rollObserver;
  36779. private previousPosition;
  36780. private noPreventDefault;
  36781. private element;
  36782. /**
  36783. * Listen to mouse events to control the camera.
  36784. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36785. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36786. */
  36787. constructor(touchEnabled?: boolean);
  36788. /**
  36789. * Attach the mouse control to the HTML DOM element.
  36790. * @param element Defines the element that listens to the input events.
  36791. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36792. */
  36793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36794. /**
  36795. * Detach the current controls from the specified dom element.
  36796. * @param element Defines the element to stop listening the inputs from
  36797. */
  36798. detachControl(element: Nullable<HTMLElement>): void;
  36799. /**
  36800. * Gets the class name of the current input.
  36801. * @returns the class name.
  36802. */
  36803. getClassName(): string;
  36804. /**
  36805. * Get the friendly name associated with the input class.
  36806. * @returns the input's friendly name.
  36807. */
  36808. getSimpleName(): string;
  36809. private _pointerInput;
  36810. private _onMouseMove;
  36811. /**
  36812. * Rotate camera by mouse offset.
  36813. */
  36814. private rotateCamera;
  36815. }
  36816. }
  36817. declare module BABYLON {
  36818. /**
  36819. * Default Inputs manager for the FlyCamera.
  36820. * It groups all the default supported inputs for ease of use.
  36821. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36822. */
  36823. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36824. /**
  36825. * Instantiates a new FlyCameraInputsManager.
  36826. * @param camera Defines the camera the inputs belong to.
  36827. */
  36828. constructor(camera: FlyCamera);
  36829. /**
  36830. * Add keyboard input support to the input manager.
  36831. * @returns the new FlyCameraKeyboardMoveInput().
  36832. */
  36833. addKeyboard(): FlyCameraInputsManager;
  36834. /**
  36835. * Add mouse input support to the input manager.
  36836. * @param touchEnabled Enable touch screen support.
  36837. * @returns the new FlyCameraMouseInput().
  36838. */
  36839. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36840. }
  36841. }
  36842. declare module BABYLON {
  36843. /**
  36844. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36845. * such as in a 3D Space Shooter or a Flight Simulator.
  36846. */
  36847. export class FlyCamera extends TargetCamera {
  36848. /**
  36849. * Define the collision ellipsoid of the camera.
  36850. * This is helpful for simulating a camera body, like a player's body.
  36851. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36852. */
  36853. ellipsoid: Vector3;
  36854. /**
  36855. * Define an offset for the position of the ellipsoid around the camera.
  36856. * This can be helpful if the camera is attached away from the player's body center,
  36857. * such as at its head.
  36858. */
  36859. ellipsoidOffset: Vector3;
  36860. /**
  36861. * Enable or disable collisions of the camera with the rest of the scene objects.
  36862. */
  36863. checkCollisions: boolean;
  36864. /**
  36865. * Enable or disable gravity on the camera.
  36866. */
  36867. applyGravity: boolean;
  36868. /**
  36869. * Define the current direction the camera is moving to.
  36870. */
  36871. cameraDirection: Vector3;
  36872. /**
  36873. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36874. * This overrides and empties cameraRotation.
  36875. */
  36876. rotationQuaternion: Quaternion;
  36877. /**
  36878. * Track Roll to maintain the wanted Rolling when looking around.
  36879. */ private _trackRoll: number;
  36880. /**
  36881. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36882. */
  36883. rollCorrect: number;
  36884. /**
  36885. * Mimic a banked turn, Rolling the camera when Yawing.
  36886. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36887. */
  36888. bankedTurn: boolean;
  36889. /**
  36890. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36891. */
  36892. bankedTurnLimit: number;
  36893. /**
  36894. * Value of 0 disables the banked Roll.
  36895. * Value of 1 is equal to the Yaw angle in radians.
  36896. */
  36897. bankedTurnMultiplier: number;
  36898. /**
  36899. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36900. */
  36901. inputs: FlyCameraInputsManager;
  36902. /**
  36903. * Gets the input sensibility for mouse input.
  36904. * Higher values reduce sensitivity.
  36905. */
  36906. /**
  36907. * Sets the input sensibility for a mouse input.
  36908. * Higher values reduce sensitivity.
  36909. */
  36910. angularSensibility: number;
  36911. /**
  36912. * Get the keys for camera movement forward.
  36913. */
  36914. /**
  36915. * Set the keys for camera movement forward.
  36916. */
  36917. keysForward: number[];
  36918. /**
  36919. * Get the keys for camera movement backward.
  36920. */
  36921. keysBackward: number[];
  36922. /**
  36923. * Get the keys for camera movement up.
  36924. */
  36925. /**
  36926. * Set the keys for camera movement up.
  36927. */
  36928. keysUp: number[];
  36929. /**
  36930. * Get the keys for camera movement down.
  36931. */
  36932. /**
  36933. * Set the keys for camera movement down.
  36934. */
  36935. keysDown: number[];
  36936. /**
  36937. * Get the keys for camera movement left.
  36938. */
  36939. /**
  36940. * Set the keys for camera movement left.
  36941. */
  36942. keysLeft: number[];
  36943. /**
  36944. * Set the keys for camera movement right.
  36945. */
  36946. /**
  36947. * Set the keys for camera movement right.
  36948. */
  36949. keysRight: number[];
  36950. /**
  36951. * Event raised when the camera collides with a mesh in the scene.
  36952. */
  36953. onCollide: (collidedMesh: AbstractMesh) => void;
  36954. private _collider;
  36955. private _needMoveForGravity;
  36956. private _oldPosition;
  36957. private _diffPosition;
  36958. private _newPosition;
  36959. /** @hidden */ private _localDirection: Vector3;
  36960. /** @hidden */ private _transformedDirection: Vector3;
  36961. /**
  36962. * Instantiates a FlyCamera.
  36963. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36964. * such as in a 3D Space Shooter or a Flight Simulator.
  36965. * @param name Define the name of the camera in the scene.
  36966. * @param position Define the starting position of the camera in the scene.
  36967. * @param scene Define the scene the camera belongs to.
  36968. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36969. */
  36970. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36971. /**
  36972. * Attach a control to the HTML DOM element.
  36973. * @param element Defines the element that listens to the input events.
  36974. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36975. */
  36976. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36977. /**
  36978. * Detach a control from the HTML DOM element.
  36979. * The camera will stop reacting to that input.
  36980. * @param element Defines the element that listens to the input events.
  36981. */
  36982. detachControl(element: HTMLElement): void;
  36983. private _collisionMask;
  36984. /**
  36985. * Get the mask that the camera ignores in collision events.
  36986. */
  36987. /**
  36988. * Set the mask that the camera ignores in collision events.
  36989. */
  36990. collisionMask: number;
  36991. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  36992. /** @hidden */
  36993. private _onCollisionPositionChange;
  36994. /** @hidden */ private _checkInputs(): void;
  36995. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  36996. /** @hidden */ private _updatePosition(): void;
  36997. /**
  36998. * Restore the Roll to its target value at the rate specified.
  36999. * @param rate - Higher means slower restoring.
  37000. * @hidden
  37001. */
  37002. restoreRoll(rate: number): void;
  37003. /**
  37004. * Destroy the camera and release the current resources held by it.
  37005. */
  37006. dispose(): void;
  37007. /**
  37008. * Get the current object class name.
  37009. * @returns the class name.
  37010. */
  37011. getClassName(): string;
  37012. }
  37013. }
  37014. declare module BABYLON {
  37015. /**
  37016. * Listen to keyboard events to control the camera.
  37017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37018. */
  37019. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37020. /**
  37021. * Defines the camera the input is attached to.
  37022. */
  37023. camera: FlyCamera;
  37024. /**
  37025. * The list of keyboard keys used to control the forward move of the camera.
  37026. */
  37027. keysForward: number[];
  37028. /**
  37029. * The list of keyboard keys used to control the backward move of the camera.
  37030. */
  37031. keysBackward: number[];
  37032. /**
  37033. * The list of keyboard keys used to control the forward move of the camera.
  37034. */
  37035. keysUp: number[];
  37036. /**
  37037. * The list of keyboard keys used to control the backward move of the camera.
  37038. */
  37039. keysDown: number[];
  37040. /**
  37041. * The list of keyboard keys used to control the right strafe move of the camera.
  37042. */
  37043. keysRight: number[];
  37044. /**
  37045. * The list of keyboard keys used to control the left strafe move of the camera.
  37046. */
  37047. keysLeft: number[];
  37048. private _keys;
  37049. private _onCanvasBlurObserver;
  37050. private _onKeyboardObserver;
  37051. private _engine;
  37052. private _scene;
  37053. /**
  37054. * Attach the input controls to a specific dom element to get the input from.
  37055. * @param element Defines the element the controls should be listened from
  37056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37057. */
  37058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37059. /**
  37060. * Detach the current controls from the specified dom element.
  37061. * @param element Defines the element to stop listening the inputs from
  37062. */
  37063. detachControl(element: Nullable<HTMLElement>): void;
  37064. /**
  37065. * Gets the class name of the current intput.
  37066. * @returns the class name
  37067. */
  37068. getClassName(): string;
  37069. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  37070. /**
  37071. * Get the friendly name associated with the input class.
  37072. * @returns the input friendly name
  37073. */
  37074. getSimpleName(): string;
  37075. /**
  37076. * Update the current camera state depending on the inputs that have been used this frame.
  37077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37078. */
  37079. checkInputs(): void;
  37080. }
  37081. }
  37082. declare module BABYLON {
  37083. /**
  37084. * Manage the mouse wheel inputs to control a follow camera.
  37085. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37086. */
  37087. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37088. /**
  37089. * Defines the camera the input is attached to.
  37090. */
  37091. camera: FollowCamera;
  37092. /**
  37093. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37094. */
  37095. axisControlRadius: boolean;
  37096. /**
  37097. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37098. */
  37099. axisControlHeight: boolean;
  37100. /**
  37101. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37102. */
  37103. axisControlRotation: boolean;
  37104. /**
  37105. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37106. * relation to mouseWheel events.
  37107. */
  37108. wheelPrecision: number;
  37109. /**
  37110. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37111. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37112. */
  37113. wheelDeltaPercentage: number;
  37114. private _wheel;
  37115. private _observer;
  37116. /**
  37117. * Attach the input controls to a specific dom element to get the input from.
  37118. * @param element Defines the element the controls should be listened from
  37119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37120. */
  37121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37122. /**
  37123. * Detach the current controls from the specified dom element.
  37124. * @param element Defines the element to stop listening the inputs from
  37125. */
  37126. detachControl(element: Nullable<HTMLElement>): void;
  37127. /**
  37128. * Gets the class name of the current intput.
  37129. * @returns the class name
  37130. */
  37131. getClassName(): string;
  37132. /**
  37133. * Get the friendly name associated with the input class.
  37134. * @returns the input friendly name
  37135. */
  37136. getSimpleName(): string;
  37137. }
  37138. }
  37139. declare module BABYLON {
  37140. /**
  37141. * Manage the pointers inputs to control an follow camera.
  37142. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37143. */
  37144. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37145. /**
  37146. * Defines the camera the input is attached to.
  37147. */
  37148. camera: FollowCamera;
  37149. /**
  37150. * Gets the class name of the current input.
  37151. * @returns the class name
  37152. */
  37153. getClassName(): string;
  37154. /**
  37155. * Defines the pointer angular sensibility along the X axis or how fast is
  37156. * the camera rotating.
  37157. * A negative number will reverse the axis direction.
  37158. */
  37159. angularSensibilityX: number;
  37160. /**
  37161. * Defines the pointer angular sensibility along the Y axis or how fast is
  37162. * the camera rotating.
  37163. * A negative number will reverse the axis direction.
  37164. */
  37165. angularSensibilityY: number;
  37166. /**
  37167. * Defines the pointer pinch precision or how fast is the camera zooming.
  37168. * A negative number will reverse the axis direction.
  37169. */
  37170. pinchPrecision: number;
  37171. /**
  37172. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37173. * from 0.
  37174. * It defines the percentage of current camera.radius to use as delta when
  37175. * pinch zoom is used.
  37176. */
  37177. pinchDeltaPercentage: number;
  37178. /**
  37179. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37180. */
  37181. axisXControlRadius: boolean;
  37182. /**
  37183. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37184. */
  37185. axisXControlHeight: boolean;
  37186. /**
  37187. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37188. */
  37189. axisXControlRotation: boolean;
  37190. /**
  37191. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37192. */
  37193. axisYControlRadius: boolean;
  37194. /**
  37195. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37196. */
  37197. axisYControlHeight: boolean;
  37198. /**
  37199. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37200. */
  37201. axisYControlRotation: boolean;
  37202. /**
  37203. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37204. */
  37205. axisPinchControlRadius: boolean;
  37206. /**
  37207. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37208. */
  37209. axisPinchControlHeight: boolean;
  37210. /**
  37211. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37212. */
  37213. axisPinchControlRotation: boolean;
  37214. /**
  37215. * Log error messages if basic misconfiguration has occurred.
  37216. */
  37217. warningEnable: boolean;
  37218. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37219. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37220. private _warningCounter;
  37221. private _warning;
  37222. }
  37223. }
  37224. declare module BABYLON {
  37225. /**
  37226. * Default Inputs manager for the FollowCamera.
  37227. * It groups all the default supported inputs for ease of use.
  37228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37229. */
  37230. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37231. /**
  37232. * Instantiates a new FollowCameraInputsManager.
  37233. * @param camera Defines the camera the inputs belong to
  37234. */
  37235. constructor(camera: FollowCamera);
  37236. /**
  37237. * Add keyboard input support to the input manager.
  37238. * @returns the current input manager
  37239. */
  37240. addKeyboard(): FollowCameraInputsManager;
  37241. /**
  37242. * Add mouse wheel input support to the input manager.
  37243. * @returns the current input manager
  37244. */
  37245. addMouseWheel(): FollowCameraInputsManager;
  37246. /**
  37247. * Add pointers input support to the input manager.
  37248. * @returns the current input manager
  37249. */
  37250. addPointers(): FollowCameraInputsManager;
  37251. /**
  37252. * Add orientation input support to the input manager.
  37253. * @returns the current input manager
  37254. */
  37255. addVRDeviceOrientation(): FollowCameraInputsManager;
  37256. }
  37257. }
  37258. declare module BABYLON {
  37259. /**
  37260. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37261. * an arc rotate version arcFollowCamera are available.
  37262. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37263. */
  37264. export class FollowCamera extends TargetCamera {
  37265. /**
  37266. * Distance the follow camera should follow an object at
  37267. */
  37268. radius: number;
  37269. /**
  37270. * Minimum allowed distance of the camera to the axis of rotation
  37271. * (The camera can not get closer).
  37272. * This can help limiting how the Camera is able to move in the scene.
  37273. */
  37274. lowerRadiusLimit: Nullable<number>;
  37275. /**
  37276. * Maximum allowed distance of the camera to the axis of rotation
  37277. * (The camera can not get further).
  37278. * This can help limiting how the Camera is able to move in the scene.
  37279. */
  37280. upperRadiusLimit: Nullable<number>;
  37281. /**
  37282. * Define a rotation offset between the camera and the object it follows
  37283. */
  37284. rotationOffset: number;
  37285. /**
  37286. * Minimum allowed angle to camera position relative to target object.
  37287. * This can help limiting how the Camera is able to move in the scene.
  37288. */
  37289. lowerRotationOffsetLimit: Nullable<number>;
  37290. /**
  37291. * Maximum allowed angle to camera position relative to target object.
  37292. * This can help limiting how the Camera is able to move in the scene.
  37293. */
  37294. upperRotationOffsetLimit: Nullable<number>;
  37295. /**
  37296. * Define a height offset between the camera and the object it follows.
  37297. * It can help following an object from the top (like a car chaing a plane)
  37298. */
  37299. heightOffset: number;
  37300. /**
  37301. * Minimum allowed height of camera position relative to target object.
  37302. * This can help limiting how the Camera is able to move in the scene.
  37303. */
  37304. lowerHeightOffsetLimit: Nullable<number>;
  37305. /**
  37306. * Maximum allowed height of camera position relative to target object.
  37307. * This can help limiting how the Camera is able to move in the scene.
  37308. */
  37309. upperHeightOffsetLimit: Nullable<number>;
  37310. /**
  37311. * Define how fast the camera can accelerate to follow it s target.
  37312. */
  37313. cameraAcceleration: number;
  37314. /**
  37315. * Define the speed limit of the camera following an object.
  37316. */
  37317. maxCameraSpeed: number;
  37318. /**
  37319. * Define the target of the camera.
  37320. */
  37321. lockedTarget: Nullable<AbstractMesh>;
  37322. /**
  37323. * Defines the input associated with the camera.
  37324. */
  37325. inputs: FollowCameraInputsManager;
  37326. /**
  37327. * Instantiates the follow camera.
  37328. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37329. * @param name Define the name of the camera in the scene
  37330. * @param position Define the position of the camera
  37331. * @param scene Define the scene the camera belong to
  37332. * @param lockedTarget Define the target of the camera
  37333. */
  37334. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37335. private _follow;
  37336. /**
  37337. * Attached controls to the current camera.
  37338. * @param element Defines the element the controls should be listened from
  37339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37340. */
  37341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37342. /**
  37343. * Detach the current controls from the camera.
  37344. * The camera will stop reacting to inputs.
  37345. * @param element Defines the element to stop listening the inputs from
  37346. */
  37347. detachControl(element: HTMLElement): void;
  37348. /** @hidden */ private _checkInputs(): void;
  37349. private _checkLimits;
  37350. /**
  37351. * Gets the camera class name.
  37352. * @returns the class name
  37353. */
  37354. getClassName(): string;
  37355. }
  37356. /**
  37357. * Arc Rotate version of the follow camera.
  37358. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37359. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37360. */
  37361. export class ArcFollowCamera extends TargetCamera {
  37362. /** The longitudinal angle of the camera */
  37363. alpha: number;
  37364. /** The latitudinal angle of the camera */
  37365. beta: number;
  37366. /** The radius of the camera from its target */
  37367. radius: number;
  37368. /** Define the camera target (the messh it should follow) */
  37369. target: Nullable<AbstractMesh>;
  37370. private _cartesianCoordinates;
  37371. /**
  37372. * Instantiates a new ArcFollowCamera
  37373. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37374. * @param name Define the name of the camera
  37375. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37376. * @param beta Define the rotation angle of the camera around the elevation axis
  37377. * @param radius Define the radius of the camera from its target point
  37378. * @param target Define the target of the camera
  37379. * @param scene Define the scene the camera belongs to
  37380. */
  37381. constructor(name: string,
  37382. /** The longitudinal angle of the camera */
  37383. alpha: number,
  37384. /** The latitudinal angle of the camera */
  37385. beta: number,
  37386. /** The radius of the camera from its target */
  37387. radius: number,
  37388. /** Define the camera target (the messh it should follow) */
  37389. target: Nullable<AbstractMesh>, scene: Scene);
  37390. private _follow;
  37391. /** @hidden */ private _checkInputs(): void;
  37392. /**
  37393. * Returns the class name of the object.
  37394. * It is mostly used internally for serialization purposes.
  37395. */
  37396. getClassName(): string;
  37397. }
  37398. }
  37399. declare module BABYLON {
  37400. /**
  37401. * Manage the keyboard inputs to control the movement of a follow camera.
  37402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37403. */
  37404. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37405. /**
  37406. * Defines the camera the input is attached to.
  37407. */
  37408. camera: FollowCamera;
  37409. /**
  37410. * Defines the list of key codes associated with the up action (increase heightOffset)
  37411. */
  37412. keysHeightOffsetIncr: number[];
  37413. /**
  37414. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37415. */
  37416. keysHeightOffsetDecr: number[];
  37417. /**
  37418. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37419. */
  37420. keysHeightOffsetModifierAlt: boolean;
  37421. /**
  37422. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37423. */
  37424. keysHeightOffsetModifierCtrl: boolean;
  37425. /**
  37426. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37427. */
  37428. keysHeightOffsetModifierShift: boolean;
  37429. /**
  37430. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37431. */
  37432. keysRotationOffsetIncr: number[];
  37433. /**
  37434. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37435. */
  37436. keysRotationOffsetDecr: number[];
  37437. /**
  37438. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37439. */
  37440. keysRotationOffsetModifierAlt: boolean;
  37441. /**
  37442. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37443. */
  37444. keysRotationOffsetModifierCtrl: boolean;
  37445. /**
  37446. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37447. */
  37448. keysRotationOffsetModifierShift: boolean;
  37449. /**
  37450. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37451. */
  37452. keysRadiusIncr: number[];
  37453. /**
  37454. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37455. */
  37456. keysRadiusDecr: number[];
  37457. /**
  37458. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37459. */
  37460. keysRadiusModifierAlt: boolean;
  37461. /**
  37462. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37463. */
  37464. keysRadiusModifierCtrl: boolean;
  37465. /**
  37466. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37467. */
  37468. keysRadiusModifierShift: boolean;
  37469. /**
  37470. * Defines the rate of change of heightOffset.
  37471. */
  37472. heightSensibility: number;
  37473. /**
  37474. * Defines the rate of change of rotationOffset.
  37475. */
  37476. rotationSensibility: number;
  37477. /**
  37478. * Defines the rate of change of radius.
  37479. */
  37480. radiusSensibility: number;
  37481. private _keys;
  37482. private _ctrlPressed;
  37483. private _altPressed;
  37484. private _shiftPressed;
  37485. private _onCanvasBlurObserver;
  37486. private _onKeyboardObserver;
  37487. private _engine;
  37488. private _scene;
  37489. /**
  37490. * Attach the input controls to a specific dom element to get the input from.
  37491. * @param element Defines the element the controls should be listened from
  37492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37493. */
  37494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37495. /**
  37496. * Detach the current controls from the specified dom element.
  37497. * @param element Defines the element to stop listening the inputs from
  37498. */
  37499. detachControl(element: Nullable<HTMLElement>): void;
  37500. /**
  37501. * Update the current camera state depending on the inputs that have been used this frame.
  37502. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37503. */
  37504. checkInputs(): void;
  37505. /**
  37506. * Gets the class name of the current input.
  37507. * @returns the class name
  37508. */
  37509. getClassName(): string;
  37510. /**
  37511. * Get the friendly name associated with the input class.
  37512. * @returns the input friendly name
  37513. */
  37514. getSimpleName(): string;
  37515. /**
  37516. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37517. * allow modification of the heightOffset value.
  37518. */
  37519. private _modifierHeightOffset;
  37520. /**
  37521. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37522. * allow modification of the rotationOffset value.
  37523. */
  37524. private _modifierRotationOffset;
  37525. /**
  37526. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37527. * allow modification of the radius value.
  37528. */
  37529. private _modifierRadius;
  37530. }
  37531. }
  37532. declare module BABYLON {
  37533. interface FreeCameraInputsManager {
  37534. /**
  37535. * @hidden
  37536. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37537. /**
  37538. * Add orientation input support to the input manager.
  37539. * @returns the current input manager
  37540. */
  37541. addDeviceOrientation(): FreeCameraInputsManager;
  37542. }
  37543. /**
  37544. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37545. * Screen rotation is taken into account.
  37546. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37547. */
  37548. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37549. private _camera;
  37550. private _screenOrientationAngle;
  37551. private _constantTranform;
  37552. private _screenQuaternion;
  37553. private _alpha;
  37554. private _beta;
  37555. private _gamma;
  37556. /**
  37557. * Can be used to detect if a device orientation sensor is availible on a device
  37558. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37559. * @returns a promise that will resolve on orientation change
  37560. */
  37561. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37562. /**
  37563. * @hidden
  37564. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37565. /**
  37566. * Instantiates a new input
  37567. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37568. */
  37569. constructor();
  37570. /**
  37571. * Define the camera controlled by the input.
  37572. */
  37573. camera: FreeCamera;
  37574. /**
  37575. * Attach the input controls to a specific dom element to get the input from.
  37576. * @param element Defines the element the controls should be listened from
  37577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37578. */
  37579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37580. private _orientationChanged;
  37581. private _deviceOrientation;
  37582. /**
  37583. * Detach the current controls from the specified dom element.
  37584. * @param element Defines the element to stop listening the inputs from
  37585. */
  37586. detachControl(element: Nullable<HTMLElement>): void;
  37587. /**
  37588. * Update the current camera state depending on the inputs that have been used this frame.
  37589. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37590. */
  37591. checkInputs(): void;
  37592. /**
  37593. * Gets the class name of the current intput.
  37594. * @returns the class name
  37595. */
  37596. getClassName(): string;
  37597. /**
  37598. * Get the friendly name associated with the input class.
  37599. * @returns the input friendly name
  37600. */
  37601. getSimpleName(): string;
  37602. }
  37603. }
  37604. declare module BABYLON {
  37605. /**
  37606. * Manage the gamepad inputs to control a free camera.
  37607. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37608. */
  37609. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37610. /**
  37611. * Define the camera the input is attached to.
  37612. */
  37613. camera: FreeCamera;
  37614. /**
  37615. * Define the Gamepad controlling the input
  37616. */
  37617. gamepad: Nullable<Gamepad>;
  37618. /**
  37619. * Defines the gamepad rotation sensiblity.
  37620. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37621. */
  37622. gamepadAngularSensibility: number;
  37623. /**
  37624. * Defines the gamepad move sensiblity.
  37625. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37626. */
  37627. gamepadMoveSensibility: number;
  37628. private _yAxisScale;
  37629. /**
  37630. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  37631. */
  37632. invertYAxis: boolean;
  37633. private _onGamepadConnectedObserver;
  37634. private _onGamepadDisconnectedObserver;
  37635. private _cameraTransform;
  37636. private _deltaTransform;
  37637. private _vector3;
  37638. private _vector2;
  37639. /**
  37640. * Attach the input controls to a specific dom element to get the input from.
  37641. * @param element Defines the element the controls should be listened from
  37642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37643. */
  37644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37645. /**
  37646. * Detach the current controls from the specified dom element.
  37647. * @param element Defines the element to stop listening the inputs from
  37648. */
  37649. detachControl(element: Nullable<HTMLElement>): void;
  37650. /**
  37651. * Update the current camera state depending on the inputs that have been used this frame.
  37652. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37653. */
  37654. checkInputs(): void;
  37655. /**
  37656. * Gets the class name of the current intput.
  37657. * @returns the class name
  37658. */
  37659. getClassName(): string;
  37660. /**
  37661. * Get the friendly name associated with the input class.
  37662. * @returns the input friendly name
  37663. */
  37664. getSimpleName(): string;
  37665. }
  37666. }
  37667. declare module BABYLON {
  37668. /**
  37669. * Defines the potential axis of a Joystick
  37670. */
  37671. export enum JoystickAxis {
  37672. /** X axis */
  37673. X = 0,
  37674. /** Y axis */
  37675. Y = 1,
  37676. /** Z axis */
  37677. Z = 2
  37678. }
  37679. /**
  37680. * Class used to define virtual joystick (used in touch mode)
  37681. */
  37682. export class VirtualJoystick {
  37683. /**
  37684. * Gets or sets a boolean indicating that left and right values must be inverted
  37685. */
  37686. reverseLeftRight: boolean;
  37687. /**
  37688. * Gets or sets a boolean indicating that up and down values must be inverted
  37689. */
  37690. reverseUpDown: boolean;
  37691. /**
  37692. * Gets the offset value for the position (ie. the change of the position value)
  37693. */
  37694. deltaPosition: Vector3;
  37695. /**
  37696. * Gets a boolean indicating if the virtual joystick was pressed
  37697. */
  37698. pressed: boolean;
  37699. /**
  37700. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37701. */
  37702. static Canvas: Nullable<HTMLCanvasElement>;
  37703. private static _globalJoystickIndex;
  37704. private static vjCanvasContext;
  37705. private static vjCanvasWidth;
  37706. private static vjCanvasHeight;
  37707. private static halfWidth;
  37708. private _action;
  37709. private _axisTargetedByLeftAndRight;
  37710. private _axisTargetedByUpAndDown;
  37711. private _joystickSensibility;
  37712. private _inversedSensibility;
  37713. private _joystickPointerID;
  37714. private _joystickColor;
  37715. private _joystickPointerPos;
  37716. private _joystickPreviousPointerPos;
  37717. private _joystickPointerStartPos;
  37718. private _deltaJoystickVector;
  37719. private _leftJoystick;
  37720. private _touches;
  37721. private _onPointerDownHandlerRef;
  37722. private _onPointerMoveHandlerRef;
  37723. private _onPointerUpHandlerRef;
  37724. private _onResize;
  37725. /**
  37726. * Creates a new virtual joystick
  37727. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37728. */
  37729. constructor(leftJoystick?: boolean);
  37730. /**
  37731. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37732. * @param newJoystickSensibility defines the new sensibility
  37733. */
  37734. setJoystickSensibility(newJoystickSensibility: number): void;
  37735. private _onPointerDown;
  37736. private _onPointerMove;
  37737. private _onPointerUp;
  37738. /**
  37739. * Change the color of the virtual joystick
  37740. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37741. */
  37742. setJoystickColor(newColor: string): void;
  37743. /**
  37744. * Defines a callback to call when the joystick is touched
  37745. * @param action defines the callback
  37746. */
  37747. setActionOnTouch(action: () => any): void;
  37748. /**
  37749. * Defines which axis you'd like to control for left & right
  37750. * @param axis defines the axis to use
  37751. */
  37752. setAxisForLeftRight(axis: JoystickAxis): void;
  37753. /**
  37754. * Defines which axis you'd like to control for up & down
  37755. * @param axis defines the axis to use
  37756. */
  37757. setAxisForUpDown(axis: JoystickAxis): void;
  37758. private _drawVirtualJoystick;
  37759. /**
  37760. * Release internal HTML canvas
  37761. */
  37762. releaseCanvas(): void;
  37763. }
  37764. }
  37765. declare module BABYLON {
  37766. interface FreeCameraInputsManager {
  37767. /**
  37768. * Add virtual joystick input support to the input manager.
  37769. * @returns the current input manager
  37770. */
  37771. addVirtualJoystick(): FreeCameraInputsManager;
  37772. }
  37773. /**
  37774. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37775. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37776. */
  37777. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37778. /**
  37779. * Defines the camera the input is attached to.
  37780. */
  37781. camera: FreeCamera;
  37782. private _leftjoystick;
  37783. private _rightjoystick;
  37784. /**
  37785. * Gets the left stick of the virtual joystick.
  37786. * @returns The virtual Joystick
  37787. */
  37788. getLeftJoystick(): VirtualJoystick;
  37789. /**
  37790. * Gets the right stick of the virtual joystick.
  37791. * @returns The virtual Joystick
  37792. */
  37793. getRightJoystick(): VirtualJoystick;
  37794. /**
  37795. * Update the current camera state depending on the inputs that have been used this frame.
  37796. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37797. */
  37798. checkInputs(): void;
  37799. /**
  37800. * Attach the input controls to a specific dom element to get the input from.
  37801. * @param element Defines the element the controls should be listened from
  37802. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37803. */
  37804. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37805. /**
  37806. * Detach the current controls from the specified dom element.
  37807. * @param element Defines the element to stop listening the inputs from
  37808. */
  37809. detachControl(element: Nullable<HTMLElement>): void;
  37810. /**
  37811. * Gets the class name of the current intput.
  37812. * @returns the class name
  37813. */
  37814. getClassName(): string;
  37815. /**
  37816. * Get the friendly name associated with the input class.
  37817. * @returns the input friendly name
  37818. */
  37819. getSimpleName(): string;
  37820. }
  37821. }
  37822. declare module BABYLON {
  37823. /**
  37824. * This represents a FPS type of camera controlled by touch.
  37825. * This is like a universal camera minus the Gamepad controls.
  37826. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37827. */
  37828. export class TouchCamera extends FreeCamera {
  37829. /**
  37830. * Defines the touch sensibility for rotation.
  37831. * The higher the faster.
  37832. */
  37833. touchAngularSensibility: number;
  37834. /**
  37835. * Defines the touch sensibility for move.
  37836. * The higher the faster.
  37837. */
  37838. touchMoveSensibility: number;
  37839. /**
  37840. * Instantiates a new touch camera.
  37841. * This represents a FPS type of camera controlled by touch.
  37842. * This is like a universal camera minus the Gamepad controls.
  37843. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37844. * @param name Define the name of the camera in the scene
  37845. * @param position Define the start position of the camera in the scene
  37846. * @param scene Define the scene the camera belongs to
  37847. */
  37848. constructor(name: string, position: Vector3, scene: Scene);
  37849. /**
  37850. * Gets the current object class name.
  37851. * @return the class name
  37852. */
  37853. getClassName(): string;
  37854. /** @hidden */ private _setupInputs(): void;
  37855. }
  37856. }
  37857. declare module BABYLON {
  37858. /**
  37859. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37860. * being tilted forward or back and left or right.
  37861. */
  37862. export class DeviceOrientationCamera extends FreeCamera {
  37863. private _initialQuaternion;
  37864. private _quaternionCache;
  37865. private _tmpDragQuaternion;
  37866. private _disablePointerInputWhenUsingDeviceOrientation;
  37867. /**
  37868. * Creates a new device orientation camera
  37869. * @param name The name of the camera
  37870. * @param position The start position camera
  37871. * @param scene The scene the camera belongs to
  37872. */
  37873. constructor(name: string, position: Vector3, scene: Scene);
  37874. /**
  37875. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  37876. */
  37877. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37878. private _dragFactor;
  37879. /**
  37880. * Enabled turning on the y axis when the orientation sensor is active
  37881. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37882. */
  37883. enableHorizontalDragging(dragFactor?: number): void;
  37884. /**
  37885. * Gets the current instance class name ("DeviceOrientationCamera").
  37886. * This helps avoiding instanceof at run time.
  37887. * @returns the class name
  37888. */
  37889. getClassName(): string;
  37890. /**
  37891. * @hidden
  37892. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37893. */ private _checkInputs(): void;
  37894. /**
  37895. * Reset the camera to its default orientation on the specified axis only.
  37896. * @param axis The axis to reset
  37897. */
  37898. resetToCurrentRotation(axis?: Axis): void;
  37899. }
  37900. }
  37901. declare module BABYLON {
  37902. /**
  37903. * Defines supported buttons for XBox360 compatible gamepads
  37904. */
  37905. export enum Xbox360Button {
  37906. /** A */
  37907. A = 0,
  37908. /** B */
  37909. B = 1,
  37910. /** X */
  37911. X = 2,
  37912. /** Y */
  37913. Y = 3,
  37914. /** Start */
  37915. Start = 4,
  37916. /** Back */
  37917. Back = 5,
  37918. /** Left button */
  37919. LB = 6,
  37920. /** Right button */
  37921. RB = 7,
  37922. /** Left stick */
  37923. LeftStick = 8,
  37924. /** Right stick */
  37925. RightStick = 9
  37926. }
  37927. /** Defines values for XBox360 DPad */
  37928. export enum Xbox360Dpad {
  37929. /** Up */
  37930. Up = 0,
  37931. /** Down */
  37932. Down = 1,
  37933. /** Left */
  37934. Left = 2,
  37935. /** Right */
  37936. Right = 3
  37937. }
  37938. /**
  37939. * Defines a XBox360 gamepad
  37940. */
  37941. export class Xbox360Pad extends Gamepad {
  37942. private _leftTrigger;
  37943. private _rightTrigger;
  37944. private _onlefttriggerchanged;
  37945. private _onrighttriggerchanged;
  37946. private _onbuttondown;
  37947. private _onbuttonup;
  37948. private _ondpaddown;
  37949. private _ondpadup;
  37950. /** Observable raised when a button is pressed */
  37951. onButtonDownObservable: Observable<Xbox360Button>;
  37952. /** Observable raised when a button is released */
  37953. onButtonUpObservable: Observable<Xbox360Button>;
  37954. /** Observable raised when a pad is pressed */
  37955. onPadDownObservable: Observable<Xbox360Dpad>;
  37956. /** Observable raised when a pad is released */
  37957. onPadUpObservable: Observable<Xbox360Dpad>;
  37958. private _buttonA;
  37959. private _buttonB;
  37960. private _buttonX;
  37961. private _buttonY;
  37962. private _buttonBack;
  37963. private _buttonStart;
  37964. private _buttonLB;
  37965. private _buttonRB;
  37966. private _buttonLeftStick;
  37967. private _buttonRightStick;
  37968. private _dPadUp;
  37969. private _dPadDown;
  37970. private _dPadLeft;
  37971. private _dPadRight;
  37972. private _isXboxOnePad;
  37973. /**
  37974. * Creates a new XBox360 gamepad object
  37975. * @param id defines the id of this gamepad
  37976. * @param index defines its index
  37977. * @param gamepad defines the internal HTML gamepad object
  37978. * @param xboxOne defines if it is a XBox One gamepad
  37979. */
  37980. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37981. /**
  37982. * Defines the callback to call when left trigger is pressed
  37983. * @param callback defines the callback to use
  37984. */
  37985. onlefttriggerchanged(callback: (value: number) => void): void;
  37986. /**
  37987. * Defines the callback to call when right trigger is pressed
  37988. * @param callback defines the callback to use
  37989. */
  37990. onrighttriggerchanged(callback: (value: number) => void): void;
  37991. /**
  37992. * Gets the left trigger value
  37993. */
  37994. /**
  37995. * Sets the left trigger value
  37996. */
  37997. leftTrigger: number;
  37998. /**
  37999. * Gets the right trigger value
  38000. */
  38001. /**
  38002. * Sets the right trigger value
  38003. */
  38004. rightTrigger: number;
  38005. /**
  38006. * Defines the callback to call when a button is pressed
  38007. * @param callback defines the callback to use
  38008. */
  38009. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38010. /**
  38011. * Defines the callback to call when a button is released
  38012. * @param callback defines the callback to use
  38013. */
  38014. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38015. /**
  38016. * Defines the callback to call when a pad is pressed
  38017. * @param callback defines the callback to use
  38018. */
  38019. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38020. /**
  38021. * Defines the callback to call when a pad is released
  38022. * @param callback defines the callback to use
  38023. */
  38024. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38025. private _setButtonValue;
  38026. private _setDPadValue;
  38027. /**
  38028. * Gets the value of the `A` button
  38029. */
  38030. /**
  38031. * Sets the value of the `A` button
  38032. */
  38033. buttonA: number;
  38034. /**
  38035. * Gets the value of the `B` button
  38036. */
  38037. /**
  38038. * Sets the value of the `B` button
  38039. */
  38040. buttonB: number;
  38041. /**
  38042. * Gets the value of the `X` button
  38043. */
  38044. /**
  38045. * Sets the value of the `X` button
  38046. */
  38047. buttonX: number;
  38048. /**
  38049. * Gets the value of the `Y` button
  38050. */
  38051. /**
  38052. * Sets the value of the `Y` button
  38053. */
  38054. buttonY: number;
  38055. /**
  38056. * Gets the value of the `Start` button
  38057. */
  38058. /**
  38059. * Sets the value of the `Start` button
  38060. */
  38061. buttonStart: number;
  38062. /**
  38063. * Gets the value of the `Back` button
  38064. */
  38065. /**
  38066. * Sets the value of the `Back` button
  38067. */
  38068. buttonBack: number;
  38069. /**
  38070. * Gets the value of the `Left` button
  38071. */
  38072. /**
  38073. * Sets the value of the `Left` button
  38074. */
  38075. buttonLB: number;
  38076. /**
  38077. * Gets the value of the `Right` button
  38078. */
  38079. /**
  38080. * Sets the value of the `Right` button
  38081. */
  38082. buttonRB: number;
  38083. /**
  38084. * Gets the value of the Left joystick
  38085. */
  38086. /**
  38087. * Sets the value of the Left joystick
  38088. */
  38089. buttonLeftStick: number;
  38090. /**
  38091. * Gets the value of the Right joystick
  38092. */
  38093. /**
  38094. * Sets the value of the Right joystick
  38095. */
  38096. buttonRightStick: number;
  38097. /**
  38098. * Gets the value of D-pad up
  38099. */
  38100. /**
  38101. * Sets the value of D-pad up
  38102. */
  38103. dPadUp: number;
  38104. /**
  38105. * Gets the value of D-pad down
  38106. */
  38107. /**
  38108. * Sets the value of D-pad down
  38109. */
  38110. dPadDown: number;
  38111. /**
  38112. * Gets the value of D-pad left
  38113. */
  38114. /**
  38115. * Sets the value of D-pad left
  38116. */
  38117. dPadLeft: number;
  38118. /**
  38119. * Gets the value of D-pad right
  38120. */
  38121. /**
  38122. * Sets the value of D-pad right
  38123. */
  38124. dPadRight: number;
  38125. /**
  38126. * Force the gamepad to synchronize with device values
  38127. */
  38128. update(): void;
  38129. /**
  38130. * Disposes the gamepad
  38131. */
  38132. dispose(): void;
  38133. }
  38134. }
  38135. declare module BABYLON {
  38136. /**
  38137. * Defines supported buttons for DualShock compatible gamepads
  38138. */
  38139. export enum DualShockButton {
  38140. /** Cross */
  38141. Cross = 0,
  38142. /** Circle */
  38143. Circle = 1,
  38144. /** Square */
  38145. Square = 2,
  38146. /** Triangle */
  38147. Triangle = 3,
  38148. /** Options */
  38149. Options = 4,
  38150. /** Share */
  38151. Share = 5,
  38152. /** L1 */
  38153. L1 = 6,
  38154. /** R1 */
  38155. R1 = 7,
  38156. /** Left stick */
  38157. LeftStick = 8,
  38158. /** Right stick */
  38159. RightStick = 9
  38160. }
  38161. /** Defines values for DualShock DPad */
  38162. export enum DualShockDpad {
  38163. /** Up */
  38164. Up = 0,
  38165. /** Down */
  38166. Down = 1,
  38167. /** Left */
  38168. Left = 2,
  38169. /** Right */
  38170. Right = 3
  38171. }
  38172. /**
  38173. * Defines a DualShock gamepad
  38174. */
  38175. export class DualShockPad extends Gamepad {
  38176. private _leftTrigger;
  38177. private _rightTrigger;
  38178. private _onlefttriggerchanged;
  38179. private _onrighttriggerchanged;
  38180. private _onbuttondown;
  38181. private _onbuttonup;
  38182. private _ondpaddown;
  38183. private _ondpadup;
  38184. /** Observable raised when a button is pressed */
  38185. onButtonDownObservable: Observable<DualShockButton>;
  38186. /** Observable raised when a button is released */
  38187. onButtonUpObservable: Observable<DualShockButton>;
  38188. /** Observable raised when a pad is pressed */
  38189. onPadDownObservable: Observable<DualShockDpad>;
  38190. /** Observable raised when a pad is released */
  38191. onPadUpObservable: Observable<DualShockDpad>;
  38192. private _buttonCross;
  38193. private _buttonCircle;
  38194. private _buttonSquare;
  38195. private _buttonTriangle;
  38196. private _buttonShare;
  38197. private _buttonOptions;
  38198. private _buttonL1;
  38199. private _buttonR1;
  38200. private _buttonLeftStick;
  38201. private _buttonRightStick;
  38202. private _dPadUp;
  38203. private _dPadDown;
  38204. private _dPadLeft;
  38205. private _dPadRight;
  38206. /**
  38207. * Creates a new DualShock gamepad object
  38208. * @param id defines the id of this gamepad
  38209. * @param index defines its index
  38210. * @param gamepad defines the internal HTML gamepad object
  38211. */
  38212. constructor(id: string, index: number, gamepad: any);
  38213. /**
  38214. * Defines the callback to call when left trigger is pressed
  38215. * @param callback defines the callback to use
  38216. */
  38217. onlefttriggerchanged(callback: (value: number) => void): void;
  38218. /**
  38219. * Defines the callback to call when right trigger is pressed
  38220. * @param callback defines the callback to use
  38221. */
  38222. onrighttriggerchanged(callback: (value: number) => void): void;
  38223. /**
  38224. * Gets the left trigger value
  38225. */
  38226. /**
  38227. * Sets the left trigger value
  38228. */
  38229. leftTrigger: number;
  38230. /**
  38231. * Gets the right trigger value
  38232. */
  38233. /**
  38234. * Sets the right trigger value
  38235. */
  38236. rightTrigger: number;
  38237. /**
  38238. * Defines the callback to call when a button is pressed
  38239. * @param callback defines the callback to use
  38240. */
  38241. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  38242. /**
  38243. * Defines the callback to call when a button is released
  38244. * @param callback defines the callback to use
  38245. */
  38246. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  38247. /**
  38248. * Defines the callback to call when a pad is pressed
  38249. * @param callback defines the callback to use
  38250. */
  38251. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  38252. /**
  38253. * Defines the callback to call when a pad is released
  38254. * @param callback defines the callback to use
  38255. */
  38256. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  38257. private _setButtonValue;
  38258. private _setDPadValue;
  38259. /**
  38260. * Gets the value of the `Cross` button
  38261. */
  38262. /**
  38263. * Sets the value of the `Cross` button
  38264. */
  38265. buttonCross: number;
  38266. /**
  38267. * Gets the value of the `Circle` button
  38268. */
  38269. /**
  38270. * Sets the value of the `Circle` button
  38271. */
  38272. buttonCircle: number;
  38273. /**
  38274. * Gets the value of the `Square` button
  38275. */
  38276. /**
  38277. * Sets the value of the `Square` button
  38278. */
  38279. buttonSquare: number;
  38280. /**
  38281. * Gets the value of the `Triangle` button
  38282. */
  38283. /**
  38284. * Sets the value of the `Triangle` button
  38285. */
  38286. buttonTriangle: number;
  38287. /**
  38288. * Gets the value of the `Options` button
  38289. */
  38290. /**
  38291. * Sets the value of the `Options` button
  38292. */
  38293. buttonOptions: number;
  38294. /**
  38295. * Gets the value of the `Share` button
  38296. */
  38297. /**
  38298. * Sets the value of the `Share` button
  38299. */
  38300. buttonShare: number;
  38301. /**
  38302. * Gets the value of the `L1` button
  38303. */
  38304. /**
  38305. * Sets the value of the `L1` button
  38306. */
  38307. buttonL1: number;
  38308. /**
  38309. * Gets the value of the `R1` button
  38310. */
  38311. /**
  38312. * Sets the value of the `R1` button
  38313. */
  38314. buttonR1: number;
  38315. /**
  38316. * Gets the value of the Left joystick
  38317. */
  38318. /**
  38319. * Sets the value of the Left joystick
  38320. */
  38321. buttonLeftStick: number;
  38322. /**
  38323. * Gets the value of the Right joystick
  38324. */
  38325. /**
  38326. * Sets the value of the Right joystick
  38327. */
  38328. buttonRightStick: number;
  38329. /**
  38330. * Gets the value of D-pad up
  38331. */
  38332. /**
  38333. * Sets the value of D-pad up
  38334. */
  38335. dPadUp: number;
  38336. /**
  38337. * Gets the value of D-pad down
  38338. */
  38339. /**
  38340. * Sets the value of D-pad down
  38341. */
  38342. dPadDown: number;
  38343. /**
  38344. * Gets the value of D-pad left
  38345. */
  38346. /**
  38347. * Sets the value of D-pad left
  38348. */
  38349. dPadLeft: number;
  38350. /**
  38351. * Gets the value of D-pad right
  38352. */
  38353. /**
  38354. * Sets the value of D-pad right
  38355. */
  38356. dPadRight: number;
  38357. /**
  38358. * Force the gamepad to synchronize with device values
  38359. */
  38360. update(): void;
  38361. /**
  38362. * Disposes the gamepad
  38363. */
  38364. dispose(): void;
  38365. }
  38366. }
  38367. declare module BABYLON {
  38368. /**
  38369. * Manager for handling gamepads
  38370. */
  38371. export class GamepadManager {
  38372. private _scene?;
  38373. private _babylonGamepads;
  38374. private _oneGamepadConnected;
  38375. /** @hidden */ private _isMonitoring: boolean;
  38376. private _gamepadEventSupported;
  38377. private _gamepadSupport;
  38378. /**
  38379. * observable to be triggered when the gamepad controller has been connected
  38380. */
  38381. onGamepadConnectedObservable: Observable<Gamepad>;
  38382. /**
  38383. * observable to be triggered when the gamepad controller has been disconnected
  38384. */
  38385. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38386. private _onGamepadConnectedEvent;
  38387. private _onGamepadDisconnectedEvent;
  38388. /**
  38389. * Initializes the gamepad manager
  38390. * @param _scene BabylonJS scene
  38391. */
  38392. constructor(_scene?: Scene | undefined);
  38393. /**
  38394. * The gamepads in the game pad manager
  38395. */
  38396. readonly gamepads: Gamepad[];
  38397. /**
  38398. * Get the gamepad controllers based on type
  38399. * @param type The type of gamepad controller
  38400. * @returns Nullable gamepad
  38401. */
  38402. getGamepadByType(type?: number): Nullable<Gamepad>;
  38403. /**
  38404. * Disposes the gamepad manager
  38405. */
  38406. dispose(): void;
  38407. private _addNewGamepad;
  38408. private _startMonitoringGamepads;
  38409. private _stopMonitoringGamepads;
  38410. /** @hidden */ private _checkGamepadsStatus(): void;
  38411. private _updateGamepadObjects;
  38412. }
  38413. }
  38414. declare module BABYLON {
  38415. interface Scene {
  38416. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38417. /**
  38418. * Gets the gamepad manager associated with the scene
  38419. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38420. */
  38421. gamepadManager: GamepadManager;
  38422. }
  38423. /**
  38424. * Interface representing a free camera inputs manager
  38425. */
  38426. interface FreeCameraInputsManager {
  38427. /**
  38428. * Adds gamepad input support to the FreeCameraInputsManager.
  38429. * @returns the FreeCameraInputsManager
  38430. */
  38431. addGamepad(): FreeCameraInputsManager;
  38432. }
  38433. /**
  38434. * Interface representing an arc rotate camera inputs manager
  38435. */
  38436. interface ArcRotateCameraInputsManager {
  38437. /**
  38438. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38439. * @returns the camera inputs manager
  38440. */
  38441. addGamepad(): ArcRotateCameraInputsManager;
  38442. }
  38443. /**
  38444. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38445. */
  38446. export class GamepadSystemSceneComponent implements ISceneComponent {
  38447. /**
  38448. * The component name helpfull to identify the component in the list of scene components.
  38449. */
  38450. readonly name: string;
  38451. /**
  38452. * The scene the component belongs to.
  38453. */
  38454. scene: Scene;
  38455. /**
  38456. * Creates a new instance of the component for the given scene
  38457. * @param scene Defines the scene to register the component in
  38458. */
  38459. constructor(scene: Scene);
  38460. /**
  38461. * Registers the component in a given scene
  38462. */
  38463. register(): void;
  38464. /**
  38465. * Rebuilds the elements related to this component in case of
  38466. * context lost for instance.
  38467. */
  38468. rebuild(): void;
  38469. /**
  38470. * Disposes the component and the associated ressources
  38471. */
  38472. dispose(): void;
  38473. private _beforeCameraUpdate;
  38474. }
  38475. }
  38476. declare module BABYLON {
  38477. /**
  38478. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  38479. * which still works and will still be found in many Playgrounds.
  38480. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38481. */
  38482. export class UniversalCamera extends TouchCamera {
  38483. /**
  38484. * Defines the gamepad rotation sensiblity.
  38485. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38486. */
  38487. gamepadAngularSensibility: number;
  38488. /**
  38489. * Defines the gamepad move sensiblity.
  38490. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38491. */
  38492. gamepadMoveSensibility: number;
  38493. /**
  38494. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  38495. * which still works and will still be found in many Playgrounds.
  38496. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38497. * @param name Define the name of the camera in the scene
  38498. * @param position Define the start position of the camera in the scene
  38499. * @param scene Define the scene the camera belongs to
  38500. */
  38501. constructor(name: string, position: Vector3, scene: Scene);
  38502. /**
  38503. * Gets the current object class name.
  38504. * @return the class name
  38505. */
  38506. getClassName(): string;
  38507. }
  38508. }
  38509. declare module BABYLON {
  38510. /**
  38511. * This represents a FPS type of camera. This is only here for back compat purpose.
  38512. * Please use the UniversalCamera instead as both are identical.
  38513. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38514. */
  38515. export class GamepadCamera extends UniversalCamera {
  38516. /**
  38517. * Instantiates a new Gamepad Camera
  38518. * This represents a FPS type of camera. This is only here for back compat purpose.
  38519. * Please use the UniversalCamera instead as both are identical.
  38520. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38521. * @param name Define the name of the camera in the scene
  38522. * @param position Define the start position of the camera in the scene
  38523. * @param scene Define the scene the camera belongs to
  38524. */
  38525. constructor(name: string, position: Vector3, scene: Scene);
  38526. /**
  38527. * Gets the current object class name.
  38528. * @return the class name
  38529. */
  38530. getClassName(): string;
  38531. }
  38532. }
  38533. declare module BABYLON {
  38534. /** @hidden */
  38535. export var passPixelShader: {
  38536. name: string;
  38537. shader: string;
  38538. };
  38539. }
  38540. declare module BABYLON {
  38541. /** @hidden */
  38542. export var passCubePixelShader: {
  38543. name: string;
  38544. shader: string;
  38545. };
  38546. }
  38547. declare module BABYLON {
  38548. /**
  38549. * PassPostProcess which produces an output the same as it's input
  38550. */
  38551. export class PassPostProcess extends PostProcess {
  38552. /**
  38553. * Creates the PassPostProcess
  38554. * @param name The name of the effect.
  38555. * @param options The required width/height ratio to downsize to before computing the render pass.
  38556. * @param camera The camera to apply the render pass to.
  38557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38558. * @param engine The engine which the post process will be applied. (default: current engine)
  38559. * @param reusable If the post process can be reused on the same frame. (default: false)
  38560. * @param textureType The type of texture to be used when performing the post processing.
  38561. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  38562. */
  38563. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38564. }
  38565. /**
  38566. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38567. */
  38568. export class PassCubePostProcess extends PostProcess {
  38569. private _face;
  38570. /**
  38571. * Gets or sets the cube face to display.
  38572. * * 0 is +X
  38573. * * 1 is -X
  38574. * * 2 is +Y
  38575. * * 3 is -Y
  38576. * * 4 is +Z
  38577. * * 5 is -Z
  38578. */
  38579. face: number;
  38580. /**
  38581. * Creates the PassCubePostProcess
  38582. * @param name The name of the effect.
  38583. * @param options The required width/height ratio to downsize to before computing the render pass.
  38584. * @param camera The camera to apply the render pass to.
  38585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38586. * @param engine The engine which the post process will be applied. (default: current engine)
  38587. * @param reusable If the post process can be reused on the same frame. (default: false)
  38588. * @param textureType The type of texture to be used when performing the post processing.
  38589. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  38590. */
  38591. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38592. }
  38593. }
  38594. declare module BABYLON {
  38595. /** @hidden */
  38596. export var anaglyphPixelShader: {
  38597. name: string;
  38598. shader: string;
  38599. };
  38600. }
  38601. declare module BABYLON {
  38602. /**
  38603. * Postprocess used to generate anaglyphic rendering
  38604. */
  38605. export class AnaglyphPostProcess extends PostProcess {
  38606. private _passedProcess;
  38607. /**
  38608. * Creates a new AnaglyphPostProcess
  38609. * @param name defines postprocess name
  38610. * @param options defines creation options or target ratio scale
  38611. * @param rigCameras defines cameras using this postprocess
  38612. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38613. * @param engine defines hosting engine
  38614. * @param reusable defines if the postprocess will be reused multiple times per frame
  38615. */
  38616. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38617. }
  38618. }
  38619. declare module BABYLON {
  38620. /**
  38621. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38622. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38623. */
  38624. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38625. /**
  38626. * Creates a new AnaglyphArcRotateCamera
  38627. * @param name defines camera name
  38628. * @param alpha defines alpha angle (in radians)
  38629. * @param beta defines beta angle (in radians)
  38630. * @param radius defines radius
  38631. * @param target defines camera target
  38632. * @param interaxialDistance defines distance between each color axis
  38633. * @param scene defines the hosting scene
  38634. */
  38635. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38636. /**
  38637. * Gets camera class name
  38638. * @returns AnaglyphArcRotateCamera
  38639. */
  38640. getClassName(): string;
  38641. }
  38642. }
  38643. declare module BABYLON {
  38644. /**
  38645. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38646. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38647. */
  38648. export class AnaglyphFreeCamera extends FreeCamera {
  38649. /**
  38650. * Creates a new AnaglyphFreeCamera
  38651. * @param name defines camera name
  38652. * @param position defines initial position
  38653. * @param interaxialDistance defines distance between each color axis
  38654. * @param scene defines the hosting scene
  38655. */
  38656. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38657. /**
  38658. * Gets camera class name
  38659. * @returns AnaglyphFreeCamera
  38660. */
  38661. getClassName(): string;
  38662. }
  38663. }
  38664. declare module BABYLON {
  38665. /**
  38666. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38667. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38668. */
  38669. export class AnaglyphGamepadCamera extends GamepadCamera {
  38670. /**
  38671. * Creates a new AnaglyphGamepadCamera
  38672. * @param name defines camera name
  38673. * @param position defines initial position
  38674. * @param interaxialDistance defines distance between each color axis
  38675. * @param scene defines the hosting scene
  38676. */
  38677. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38678. /**
  38679. * Gets camera class name
  38680. * @returns AnaglyphGamepadCamera
  38681. */
  38682. getClassName(): string;
  38683. }
  38684. }
  38685. declare module BABYLON {
  38686. /**
  38687. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38688. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38689. */
  38690. export class AnaglyphUniversalCamera extends UniversalCamera {
  38691. /**
  38692. * Creates a new AnaglyphUniversalCamera
  38693. * @param name defines camera name
  38694. * @param position defines initial position
  38695. * @param interaxialDistance defines distance between each color axis
  38696. * @param scene defines the hosting scene
  38697. */
  38698. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38699. /**
  38700. * Gets camera class name
  38701. * @returns AnaglyphUniversalCamera
  38702. */
  38703. getClassName(): string;
  38704. }
  38705. }
  38706. declare module BABYLON {
  38707. /** @hidden */
  38708. export var stereoscopicInterlacePixelShader: {
  38709. name: string;
  38710. shader: string;
  38711. };
  38712. }
  38713. declare module BABYLON {
  38714. /**
  38715. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38716. */
  38717. export class StereoscopicInterlacePostProcess extends PostProcess {
  38718. private _stepSize;
  38719. private _passedProcess;
  38720. /**
  38721. * Initializes a StereoscopicInterlacePostProcess
  38722. * @param name The name of the effect.
  38723. * @param rigCameras The rig cameras to be appled to the post process
  38724. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38726. * @param engine The engine which the post process will be applied. (default: current engine)
  38727. * @param reusable If the post process can be reused on the same frame. (default: false)
  38728. */
  38729. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38730. }
  38731. }
  38732. declare module BABYLON {
  38733. /**
  38734. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38735. * @see http://doc.babylonjs.com/features/cameras
  38736. */
  38737. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38738. /**
  38739. * Creates a new StereoscopicArcRotateCamera
  38740. * @param name defines camera name
  38741. * @param alpha defines alpha angle (in radians)
  38742. * @param beta defines beta angle (in radians)
  38743. * @param radius defines radius
  38744. * @param target defines camera target
  38745. * @param interaxialDistance defines distance between each color axis
  38746. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38747. * @param scene defines the hosting scene
  38748. */
  38749. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38750. /**
  38751. * Gets camera class name
  38752. * @returns StereoscopicArcRotateCamera
  38753. */
  38754. getClassName(): string;
  38755. }
  38756. }
  38757. declare module BABYLON {
  38758. /**
  38759. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38760. * @see http://doc.babylonjs.com/features/cameras
  38761. */
  38762. export class StereoscopicFreeCamera extends FreeCamera {
  38763. /**
  38764. * Creates a new StereoscopicFreeCamera
  38765. * @param name defines camera name
  38766. * @param position defines initial position
  38767. * @param interaxialDistance defines distance between each color axis
  38768. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38769. * @param scene defines the hosting scene
  38770. */
  38771. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38772. /**
  38773. * Gets camera class name
  38774. * @returns StereoscopicFreeCamera
  38775. */
  38776. getClassName(): string;
  38777. }
  38778. }
  38779. declare module BABYLON {
  38780. /**
  38781. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38782. * @see http://doc.babylonjs.com/features/cameras
  38783. */
  38784. export class StereoscopicGamepadCamera extends GamepadCamera {
  38785. /**
  38786. * Creates a new StereoscopicGamepadCamera
  38787. * @param name defines camera name
  38788. * @param position defines initial position
  38789. * @param interaxialDistance defines distance between each color axis
  38790. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38791. * @param scene defines the hosting scene
  38792. */
  38793. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38794. /**
  38795. * Gets camera class name
  38796. * @returns StereoscopicGamepadCamera
  38797. */
  38798. getClassName(): string;
  38799. }
  38800. }
  38801. declare module BABYLON {
  38802. /**
  38803. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38804. * @see http://doc.babylonjs.com/features/cameras
  38805. */
  38806. export class StereoscopicUniversalCamera extends UniversalCamera {
  38807. /**
  38808. * Creates a new StereoscopicUniversalCamera
  38809. * @param name defines camera name
  38810. * @param position defines initial position
  38811. * @param interaxialDistance defines distance between each color axis
  38812. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38813. * @param scene defines the hosting scene
  38814. */
  38815. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38816. /**
  38817. * Gets camera class name
  38818. * @returns StereoscopicUniversalCamera
  38819. */
  38820. getClassName(): string;
  38821. }
  38822. }
  38823. declare module BABYLON {
  38824. /**
  38825. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38826. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38827. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38828. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38829. */
  38830. export class VirtualJoysticksCamera extends FreeCamera {
  38831. /**
  38832. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38833. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38834. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38835. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38836. * @param name Define the name of the camera in the scene
  38837. * @param position Define the start position of the camera in the scene
  38838. * @param scene Define the scene the camera belongs to
  38839. */
  38840. constructor(name: string, position: Vector3, scene: Scene);
  38841. /**
  38842. * Gets the current object class name.
  38843. * @return the class name
  38844. */
  38845. getClassName(): string;
  38846. }
  38847. }
  38848. declare module BABYLON {
  38849. /**
  38850. * This represents all the required metrics to create a VR camera.
  38851. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38852. */
  38853. export class VRCameraMetrics {
  38854. /**
  38855. * Define the horizontal resolution off the screen.
  38856. */
  38857. hResolution: number;
  38858. /**
  38859. * Define the vertical resolution off the screen.
  38860. */
  38861. vResolution: number;
  38862. /**
  38863. * Define the horizontal screen size.
  38864. */
  38865. hScreenSize: number;
  38866. /**
  38867. * Define the vertical screen size.
  38868. */
  38869. vScreenSize: number;
  38870. /**
  38871. * Define the vertical screen center position.
  38872. */
  38873. vScreenCenter: number;
  38874. /**
  38875. * Define the distance of the eyes to the screen.
  38876. */
  38877. eyeToScreenDistance: number;
  38878. /**
  38879. * Define the distance between both lenses
  38880. */
  38881. lensSeparationDistance: number;
  38882. /**
  38883. * Define the distance between both viewer's eyes.
  38884. */
  38885. interpupillaryDistance: number;
  38886. /**
  38887. * Define the distortion factor of the VR postprocess.
  38888. * Please, touch with care.
  38889. */
  38890. distortionK: number[];
  38891. /**
  38892. * Define the chromatic aberration correction factors for the VR post process.
  38893. */
  38894. chromaAbCorrection: number[];
  38895. /**
  38896. * Define the scale factor of the post process.
  38897. * The smaller the better but the slower.
  38898. */
  38899. postProcessScaleFactor: number;
  38900. /**
  38901. * Define an offset for the lens center.
  38902. */
  38903. lensCenterOffset: number;
  38904. /**
  38905. * Define if the current vr camera should compensate the distortion of the lense or not.
  38906. */
  38907. compensateDistortion: boolean;
  38908. /**
  38909. * Defines if multiview should be enabled when rendering (Default: false)
  38910. */
  38911. multiviewEnabled: boolean;
  38912. /**
  38913. * Gets the rendering aspect ratio based on the provided resolutions.
  38914. */
  38915. readonly aspectRatio: number;
  38916. /**
  38917. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38918. */
  38919. readonly aspectRatioFov: number;
  38920. /**
  38921. * @hidden
  38922. */
  38923. readonly leftHMatrix: Matrix;
  38924. /**
  38925. * @hidden
  38926. */
  38927. readonly rightHMatrix: Matrix;
  38928. /**
  38929. * @hidden
  38930. */
  38931. readonly leftPreViewMatrix: Matrix;
  38932. /**
  38933. * @hidden
  38934. */
  38935. readonly rightPreViewMatrix: Matrix;
  38936. /**
  38937. * Get the default VRMetrics based on the most generic setup.
  38938. * @returns the default vr metrics
  38939. */
  38940. static GetDefault(): VRCameraMetrics;
  38941. }
  38942. }
  38943. declare module BABYLON {
  38944. /** @hidden */
  38945. export var vrDistortionCorrectionPixelShader: {
  38946. name: string;
  38947. shader: string;
  38948. };
  38949. }
  38950. declare module BABYLON {
  38951. /**
  38952. * VRDistortionCorrectionPostProcess used for mobile VR
  38953. */
  38954. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38955. private _isRightEye;
  38956. private _distortionFactors;
  38957. private _postProcessScaleFactor;
  38958. private _lensCenterOffset;
  38959. private _scaleIn;
  38960. private _scaleFactor;
  38961. private _lensCenter;
  38962. /**
  38963. * Initializes the VRDistortionCorrectionPostProcess
  38964. * @param name The name of the effect.
  38965. * @param camera The camera to apply the render pass to.
  38966. * @param isRightEye If this is for the right eye distortion
  38967. * @param vrMetrics All the required metrics for the VR camera
  38968. */
  38969. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38970. }
  38971. }
  38972. declare module BABYLON {
  38973. /**
  38974. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38975. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38976. */
  38977. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38978. /**
  38979. * Creates a new VRDeviceOrientationArcRotateCamera
  38980. * @param name defines camera name
  38981. * @param alpha defines the camera rotation along the logitudinal axis
  38982. * @param beta defines the camera rotation along the latitudinal axis
  38983. * @param radius defines the camera distance from its target
  38984. * @param target defines the camera target
  38985. * @param scene defines the scene the camera belongs to
  38986. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38987. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38988. */
  38989. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38990. /**
  38991. * Gets camera class name
  38992. * @returns VRDeviceOrientationArcRotateCamera
  38993. */
  38994. getClassName(): string;
  38995. }
  38996. }
  38997. declare module BABYLON {
  38998. /**
  38999. * Camera used to simulate VR rendering (based on FreeCamera)
  39000. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39001. */
  39002. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39003. /**
  39004. * Creates a new VRDeviceOrientationFreeCamera
  39005. * @param name defines camera name
  39006. * @param position defines the start position of the camera
  39007. * @param scene defines the scene the camera belongs to
  39008. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39009. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39010. */
  39011. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39012. /**
  39013. * Gets camera class name
  39014. * @returns VRDeviceOrientationFreeCamera
  39015. */
  39016. getClassName(): string;
  39017. }
  39018. }
  39019. declare module BABYLON {
  39020. /**
  39021. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39022. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39023. */
  39024. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39025. /**
  39026. * Creates a new VRDeviceOrientationGamepadCamera
  39027. * @param name defines camera name
  39028. * @param position defines the start position of the camera
  39029. * @param scene defines the scene the camera belongs to
  39030. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39031. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39032. */
  39033. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39034. /**
  39035. * Gets camera class name
  39036. * @returns VRDeviceOrientationGamepadCamera
  39037. */
  39038. getClassName(): string;
  39039. }
  39040. }
  39041. declare module BABYLON {
  39042. /**
  39043. * Base class of materials working in push mode in babylon JS
  39044. * @hidden
  39045. */
  39046. export class PushMaterial extends Material {
  39047. protected _activeEffect: Effect;
  39048. protected _normalMatrix: Matrix;
  39049. /**
  39050. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39051. * This means that the material can keep using a previous shader while a new one is being compiled.
  39052. * This is mostly used when shader parallel compilation is supported (true by default)
  39053. */
  39054. allowShaderHotSwapping: boolean;
  39055. constructor(name: string, scene: Scene);
  39056. getEffect(): Effect;
  39057. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39058. /**
  39059. * Binds the given world matrix to the active effect
  39060. *
  39061. * @param world the matrix to bind
  39062. */
  39063. bindOnlyWorldMatrix(world: Matrix): void;
  39064. /**
  39065. * Binds the given normal matrix to the active effect
  39066. *
  39067. * @param normalMatrix the matrix to bind
  39068. */
  39069. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39070. bind(world: Matrix, mesh?: Mesh): void;
  39071. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39072. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39073. }
  39074. }
  39075. declare module BABYLON {
  39076. /**
  39077. * This groups all the flags used to control the materials channel.
  39078. */
  39079. export class MaterialFlags {
  39080. private static _DiffuseTextureEnabled;
  39081. /**
  39082. * Are diffuse textures enabled in the application.
  39083. */
  39084. static DiffuseTextureEnabled: boolean;
  39085. private static _AmbientTextureEnabled;
  39086. /**
  39087. * Are ambient textures enabled in the application.
  39088. */
  39089. static AmbientTextureEnabled: boolean;
  39090. private static _OpacityTextureEnabled;
  39091. /**
  39092. * Are opacity textures enabled in the application.
  39093. */
  39094. static OpacityTextureEnabled: boolean;
  39095. private static _ReflectionTextureEnabled;
  39096. /**
  39097. * Are reflection textures enabled in the application.
  39098. */
  39099. static ReflectionTextureEnabled: boolean;
  39100. private static _EmissiveTextureEnabled;
  39101. /**
  39102. * Are emissive textures enabled in the application.
  39103. */
  39104. static EmissiveTextureEnabled: boolean;
  39105. private static _SpecularTextureEnabled;
  39106. /**
  39107. * Are specular textures enabled in the application.
  39108. */
  39109. static SpecularTextureEnabled: boolean;
  39110. private static _BumpTextureEnabled;
  39111. /**
  39112. * Are bump textures enabled in the application.
  39113. */
  39114. static BumpTextureEnabled: boolean;
  39115. private static _LightmapTextureEnabled;
  39116. /**
  39117. * Are lightmap textures enabled in the application.
  39118. */
  39119. static LightmapTextureEnabled: boolean;
  39120. private static _RefractionTextureEnabled;
  39121. /**
  39122. * Are refraction textures enabled in the application.
  39123. */
  39124. static RefractionTextureEnabled: boolean;
  39125. private static _ColorGradingTextureEnabled;
  39126. /**
  39127. * Are color grading textures enabled in the application.
  39128. */
  39129. static ColorGradingTextureEnabled: boolean;
  39130. private static _FresnelEnabled;
  39131. /**
  39132. * Are fresnels enabled in the application.
  39133. */
  39134. static FresnelEnabled: boolean;
  39135. private static _ClearCoatTextureEnabled;
  39136. /**
  39137. * Are clear coat textures enabled in the application.
  39138. */
  39139. static ClearCoatTextureEnabled: boolean;
  39140. private static _ClearCoatBumpTextureEnabled;
  39141. /**
  39142. * Are clear coat bump textures enabled in the application.
  39143. */
  39144. static ClearCoatBumpTextureEnabled: boolean;
  39145. private static _ClearCoatTintTextureEnabled;
  39146. /**
  39147. * Are clear coat tint textures enabled in the application.
  39148. */
  39149. static ClearCoatTintTextureEnabled: boolean;
  39150. private static _SheenTextureEnabled;
  39151. /**
  39152. * Are sheen textures enabled in the application.
  39153. */
  39154. static SheenTextureEnabled: boolean;
  39155. private static _AnisotropicTextureEnabled;
  39156. /**
  39157. * Are anisotropic textures enabled in the application.
  39158. */
  39159. static AnisotropicTextureEnabled: boolean;
  39160. private static _ThicknessTextureEnabled;
  39161. /**
  39162. * Are thickness textures enabled in the application.
  39163. */
  39164. static ThicknessTextureEnabled: boolean;
  39165. }
  39166. }
  39167. declare module BABYLON {
  39168. /** @hidden */
  39169. export var defaultFragmentDeclaration: {
  39170. name: string;
  39171. shader: string;
  39172. };
  39173. }
  39174. declare module BABYLON {
  39175. /** @hidden */
  39176. export var defaultUboDeclaration: {
  39177. name: string;
  39178. shader: string;
  39179. };
  39180. }
  39181. declare module BABYLON {
  39182. /** @hidden */
  39183. export var lightFragmentDeclaration: {
  39184. name: string;
  39185. shader: string;
  39186. };
  39187. }
  39188. declare module BABYLON {
  39189. /** @hidden */
  39190. export var lightUboDeclaration: {
  39191. name: string;
  39192. shader: string;
  39193. };
  39194. }
  39195. declare module BABYLON {
  39196. /** @hidden */
  39197. export var lightsFragmentFunctions: {
  39198. name: string;
  39199. shader: string;
  39200. };
  39201. }
  39202. declare module BABYLON {
  39203. /** @hidden */
  39204. export var shadowsFragmentFunctions: {
  39205. name: string;
  39206. shader: string;
  39207. };
  39208. }
  39209. declare module BABYLON {
  39210. /** @hidden */
  39211. export var fresnelFunction: {
  39212. name: string;
  39213. shader: string;
  39214. };
  39215. }
  39216. declare module BABYLON {
  39217. /** @hidden */
  39218. export var reflectionFunction: {
  39219. name: string;
  39220. shader: string;
  39221. };
  39222. }
  39223. declare module BABYLON {
  39224. /** @hidden */
  39225. export var bumpFragmentFunctions: {
  39226. name: string;
  39227. shader: string;
  39228. };
  39229. }
  39230. declare module BABYLON {
  39231. /** @hidden */
  39232. export var logDepthDeclaration: {
  39233. name: string;
  39234. shader: string;
  39235. };
  39236. }
  39237. declare module BABYLON {
  39238. /** @hidden */
  39239. export var bumpFragment: {
  39240. name: string;
  39241. shader: string;
  39242. };
  39243. }
  39244. declare module BABYLON {
  39245. /** @hidden */
  39246. export var depthPrePass: {
  39247. name: string;
  39248. shader: string;
  39249. };
  39250. }
  39251. declare module BABYLON {
  39252. /** @hidden */
  39253. export var lightFragment: {
  39254. name: string;
  39255. shader: string;
  39256. };
  39257. }
  39258. declare module BABYLON {
  39259. /** @hidden */
  39260. export var logDepthFragment: {
  39261. name: string;
  39262. shader: string;
  39263. };
  39264. }
  39265. declare module BABYLON {
  39266. /** @hidden */
  39267. export var defaultPixelShader: {
  39268. name: string;
  39269. shader: string;
  39270. };
  39271. }
  39272. declare module BABYLON {
  39273. /** @hidden */
  39274. export var defaultVertexDeclaration: {
  39275. name: string;
  39276. shader: string;
  39277. };
  39278. }
  39279. declare module BABYLON {
  39280. /** @hidden */
  39281. export var bumpVertexDeclaration: {
  39282. name: string;
  39283. shader: string;
  39284. };
  39285. }
  39286. declare module BABYLON {
  39287. /** @hidden */
  39288. export var bumpVertex: {
  39289. name: string;
  39290. shader: string;
  39291. };
  39292. }
  39293. declare module BABYLON {
  39294. /** @hidden */
  39295. export var fogVertex: {
  39296. name: string;
  39297. shader: string;
  39298. };
  39299. }
  39300. declare module BABYLON {
  39301. /** @hidden */
  39302. export var shadowsVertex: {
  39303. name: string;
  39304. shader: string;
  39305. };
  39306. }
  39307. declare module BABYLON {
  39308. /** @hidden */
  39309. export var pointCloudVertex: {
  39310. name: string;
  39311. shader: string;
  39312. };
  39313. }
  39314. declare module BABYLON {
  39315. /** @hidden */
  39316. export var logDepthVertex: {
  39317. name: string;
  39318. shader: string;
  39319. };
  39320. }
  39321. declare module BABYLON {
  39322. /** @hidden */
  39323. export var defaultVertexShader: {
  39324. name: string;
  39325. shader: string;
  39326. };
  39327. }
  39328. declare module BABYLON {
  39329. /** @hidden */
  39330. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39331. MAINUV1: boolean;
  39332. MAINUV2: boolean;
  39333. DIFFUSE: boolean;
  39334. DIFFUSEDIRECTUV: number;
  39335. AMBIENT: boolean;
  39336. AMBIENTDIRECTUV: number;
  39337. OPACITY: boolean;
  39338. OPACITYDIRECTUV: number;
  39339. OPACITYRGB: boolean;
  39340. REFLECTION: boolean;
  39341. EMISSIVE: boolean;
  39342. EMISSIVEDIRECTUV: number;
  39343. SPECULAR: boolean;
  39344. SPECULARDIRECTUV: number;
  39345. BUMP: boolean;
  39346. BUMPDIRECTUV: number;
  39347. PARALLAX: boolean;
  39348. PARALLAXOCCLUSION: boolean;
  39349. SPECULAROVERALPHA: boolean;
  39350. CLIPPLANE: boolean;
  39351. CLIPPLANE2: boolean;
  39352. CLIPPLANE3: boolean;
  39353. CLIPPLANE4: boolean;
  39354. ALPHATEST: boolean;
  39355. DEPTHPREPASS: boolean;
  39356. ALPHAFROMDIFFUSE: boolean;
  39357. POINTSIZE: boolean;
  39358. FOG: boolean;
  39359. SPECULARTERM: boolean;
  39360. DIFFUSEFRESNEL: boolean;
  39361. OPACITYFRESNEL: boolean;
  39362. REFLECTIONFRESNEL: boolean;
  39363. REFRACTIONFRESNEL: boolean;
  39364. EMISSIVEFRESNEL: boolean;
  39365. FRESNEL: boolean;
  39366. NORMAL: boolean;
  39367. UV1: boolean;
  39368. UV2: boolean;
  39369. VERTEXCOLOR: boolean;
  39370. VERTEXALPHA: boolean;
  39371. NUM_BONE_INFLUENCERS: number;
  39372. BonesPerMesh: number;
  39373. BONETEXTURE: boolean;
  39374. INSTANCES: boolean;
  39375. GLOSSINESS: boolean;
  39376. ROUGHNESS: boolean;
  39377. EMISSIVEASILLUMINATION: boolean;
  39378. LINKEMISSIVEWITHDIFFUSE: boolean;
  39379. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39380. LIGHTMAP: boolean;
  39381. LIGHTMAPDIRECTUV: number;
  39382. OBJECTSPACE_NORMALMAP: boolean;
  39383. USELIGHTMAPASSHADOWMAP: boolean;
  39384. REFLECTIONMAP_3D: boolean;
  39385. REFLECTIONMAP_SPHERICAL: boolean;
  39386. REFLECTIONMAP_PLANAR: boolean;
  39387. REFLECTIONMAP_CUBIC: boolean;
  39388. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39389. REFLECTIONMAP_PROJECTION: boolean;
  39390. REFLECTIONMAP_SKYBOX: boolean;
  39391. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39392. REFLECTIONMAP_EXPLICIT: boolean;
  39393. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39394. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39395. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39396. INVERTCUBICMAP: boolean;
  39397. LOGARITHMICDEPTH: boolean;
  39398. REFRACTION: boolean;
  39399. REFRACTIONMAP_3D: boolean;
  39400. REFLECTIONOVERALPHA: boolean;
  39401. TWOSIDEDLIGHTING: boolean;
  39402. SHADOWFLOAT: boolean;
  39403. MORPHTARGETS: boolean;
  39404. MORPHTARGETS_NORMAL: boolean;
  39405. MORPHTARGETS_TANGENT: boolean;
  39406. MORPHTARGETS_UV: boolean;
  39407. NUM_MORPH_INFLUENCERS: number;
  39408. NONUNIFORMSCALING: boolean;
  39409. PREMULTIPLYALPHA: boolean;
  39410. IMAGEPROCESSING: boolean;
  39411. VIGNETTE: boolean;
  39412. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39413. VIGNETTEBLENDMODEOPAQUE: boolean;
  39414. TONEMAPPING: boolean;
  39415. TONEMAPPING_ACES: boolean;
  39416. CONTRAST: boolean;
  39417. COLORCURVES: boolean;
  39418. COLORGRADING: boolean;
  39419. COLORGRADING3D: boolean;
  39420. SAMPLER3DGREENDEPTH: boolean;
  39421. SAMPLER3DBGRMAP: boolean;
  39422. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39423. MULTIVIEW: boolean;
  39424. /**
  39425. * If the reflection texture on this material is in linear color space
  39426. * @hidden
  39427. */
  39428. IS_REFLECTION_LINEAR: boolean;
  39429. /**
  39430. * If the refraction texture on this material is in linear color space
  39431. * @hidden
  39432. */
  39433. IS_REFRACTION_LINEAR: boolean;
  39434. EXPOSURE: boolean;
  39435. constructor();
  39436. setReflectionMode(modeToEnable: string): void;
  39437. }
  39438. /**
  39439. * This is the default material used in Babylon. It is the best trade off between quality
  39440. * and performances.
  39441. * @see http://doc.babylonjs.com/babylon101/materials
  39442. */
  39443. export class StandardMaterial extends PushMaterial {
  39444. private _diffuseTexture;
  39445. /**
  39446. * The basic texture of the material as viewed under a light.
  39447. */
  39448. diffuseTexture: Nullable<BaseTexture>;
  39449. private _ambientTexture;
  39450. /**
  39451. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39452. */
  39453. ambientTexture: Nullable<BaseTexture>;
  39454. private _opacityTexture;
  39455. /**
  39456. * Define the transparency of the material from a texture.
  39457. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39458. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39459. */
  39460. opacityTexture: Nullable<BaseTexture>;
  39461. private _reflectionTexture;
  39462. /**
  39463. * Define the texture used to display the reflection.
  39464. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39465. */
  39466. reflectionTexture: Nullable<BaseTexture>;
  39467. private _emissiveTexture;
  39468. /**
  39469. * Define texture of the material as if self lit.
  39470. * This will be mixed in the final result even in the absence of light.
  39471. */
  39472. emissiveTexture: Nullable<BaseTexture>;
  39473. private _specularTexture;
  39474. /**
  39475. * Define how the color and intensity of the highlight given by the light in the material.
  39476. */
  39477. specularTexture: Nullable<BaseTexture>;
  39478. private _bumpTexture;
  39479. /**
  39480. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39481. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  39482. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39483. */
  39484. bumpTexture: Nullable<BaseTexture>;
  39485. private _lightmapTexture;
  39486. /**
  39487. * Complex lighting can be computationally expensive to compute at runtime.
  39488. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39489. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39490. */
  39491. lightmapTexture: Nullable<BaseTexture>;
  39492. private _refractionTexture;
  39493. /**
  39494. * Define the texture used to display the refraction.
  39495. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39496. */
  39497. refractionTexture: Nullable<BaseTexture>;
  39498. /**
  39499. * The color of the material lit by the environmental background lighting.
  39500. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39501. */
  39502. ambientColor: Color3;
  39503. /**
  39504. * The basic color of the material as viewed under a light.
  39505. */
  39506. diffuseColor: Color3;
  39507. /**
  39508. * Define how the color and intensity of the highlight given by the light in the material.
  39509. */
  39510. specularColor: Color3;
  39511. /**
  39512. * Define the color of the material as if self lit.
  39513. * This will be mixed in the final result even in the absence of light.
  39514. */
  39515. emissiveColor: Color3;
  39516. /**
  39517. * Defines how sharp are the highlights in the material.
  39518. * The bigger the value the sharper giving a more glossy feeling to the result.
  39519. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39520. */
  39521. specularPower: number;
  39522. private _useAlphaFromDiffuseTexture;
  39523. /**
  39524. * Does the transparency come from the diffuse texture alpha channel.
  39525. */
  39526. useAlphaFromDiffuseTexture: boolean;
  39527. private _useEmissiveAsIllumination;
  39528. /**
  39529. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39530. */
  39531. useEmissiveAsIllumination: boolean;
  39532. private _linkEmissiveWithDiffuse;
  39533. /**
  39534. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39535. * the emissive level when the final color is close to one.
  39536. */
  39537. linkEmissiveWithDiffuse: boolean;
  39538. private _useSpecularOverAlpha;
  39539. /**
  39540. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39541. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39542. */
  39543. useSpecularOverAlpha: boolean;
  39544. private _useReflectionOverAlpha;
  39545. /**
  39546. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39547. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39548. */
  39549. useReflectionOverAlpha: boolean;
  39550. private _disableLighting;
  39551. /**
  39552. * Does lights from the scene impacts this material.
  39553. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39554. */
  39555. disableLighting: boolean;
  39556. private _useObjectSpaceNormalMap;
  39557. /**
  39558. * Allows using an object space normal map (instead of tangent space).
  39559. */
  39560. useObjectSpaceNormalMap: boolean;
  39561. private _useParallax;
  39562. /**
  39563. * Is parallax enabled or not.
  39564. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39565. */
  39566. useParallax: boolean;
  39567. private _useParallaxOcclusion;
  39568. /**
  39569. * Is parallax occlusion enabled or not.
  39570. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39571. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39572. */
  39573. useParallaxOcclusion: boolean;
  39574. /**
  39575. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  39576. */
  39577. parallaxScaleBias: number;
  39578. private _roughness;
  39579. /**
  39580. * Helps to define how blurry the reflections should appears in the material.
  39581. */
  39582. roughness: number;
  39583. /**
  39584. * In case of refraction, define the value of the index of refraction.
  39585. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39586. */
  39587. indexOfRefraction: number;
  39588. /**
  39589. * Invert the refraction texture alongside the y axis.
  39590. * It can be useful with procedural textures or probe for instance.
  39591. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39592. */
  39593. invertRefractionY: boolean;
  39594. /**
  39595. * Defines the alpha limits in alpha test mode.
  39596. */
  39597. alphaCutOff: number;
  39598. private _useLightmapAsShadowmap;
  39599. /**
  39600. * In case of light mapping, define whether the map contains light or shadow informations.
  39601. */
  39602. useLightmapAsShadowmap: boolean;
  39603. private _diffuseFresnelParameters;
  39604. /**
  39605. * Define the diffuse fresnel parameters of the material.
  39606. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39607. */
  39608. diffuseFresnelParameters: FresnelParameters;
  39609. private _opacityFresnelParameters;
  39610. /**
  39611. * Define the opacity fresnel parameters of the material.
  39612. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39613. */
  39614. opacityFresnelParameters: FresnelParameters;
  39615. private _reflectionFresnelParameters;
  39616. /**
  39617. * Define the reflection fresnel parameters of the material.
  39618. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39619. */
  39620. reflectionFresnelParameters: FresnelParameters;
  39621. private _refractionFresnelParameters;
  39622. /**
  39623. * Define the refraction fresnel parameters of the material.
  39624. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39625. */
  39626. refractionFresnelParameters: FresnelParameters;
  39627. private _emissiveFresnelParameters;
  39628. /**
  39629. * Define the emissive fresnel parameters of the material.
  39630. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39631. */
  39632. emissiveFresnelParameters: FresnelParameters;
  39633. private _useReflectionFresnelFromSpecular;
  39634. /**
  39635. * If true automatically deducts the fresnels values from the material specularity.
  39636. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39637. */
  39638. useReflectionFresnelFromSpecular: boolean;
  39639. private _useGlossinessFromSpecularMapAlpha;
  39640. /**
  39641. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39642. */
  39643. useGlossinessFromSpecularMapAlpha: boolean;
  39644. private _maxSimultaneousLights;
  39645. /**
  39646. * Defines the maximum number of lights that can be used in the material
  39647. */
  39648. maxSimultaneousLights: number;
  39649. private _invertNormalMapX;
  39650. /**
  39651. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39652. */
  39653. invertNormalMapX: boolean;
  39654. private _invertNormalMapY;
  39655. /**
  39656. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39657. */
  39658. invertNormalMapY: boolean;
  39659. private _twoSidedLighting;
  39660. /**
  39661. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39662. */
  39663. twoSidedLighting: boolean;
  39664. /**
  39665. * Default configuration related to image processing available in the standard Material.
  39666. */
  39667. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39668. /**
  39669. * Gets the image processing configuration used either in this material.
  39670. */
  39671. /**
  39672. * Sets the Default image processing configuration used either in the this material.
  39673. *
  39674. * If sets to null, the scene one is in use.
  39675. */
  39676. imageProcessingConfiguration: ImageProcessingConfiguration;
  39677. /**
  39678. * Keep track of the image processing observer to allow dispose and replace.
  39679. */
  39680. private _imageProcessingObserver;
  39681. /**
  39682. * Attaches a new image processing configuration to the Standard Material.
  39683. * @param configuration
  39684. */
  39685. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39686. /**
  39687. * Gets wether the color curves effect is enabled.
  39688. */
  39689. /**
  39690. * Sets wether the color curves effect is enabled.
  39691. */
  39692. cameraColorCurvesEnabled: boolean;
  39693. /**
  39694. * Gets wether the color grading effect is enabled.
  39695. */
  39696. /**
  39697. * Gets wether the color grading effect is enabled.
  39698. */
  39699. cameraColorGradingEnabled: boolean;
  39700. /**
  39701. * Gets wether tonemapping is enabled or not.
  39702. */
  39703. /**
  39704. * Sets wether tonemapping is enabled or not
  39705. */
  39706. cameraToneMappingEnabled: boolean;
  39707. /**
  39708. * The camera exposure used on this material.
  39709. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39710. * This corresponds to a photographic exposure.
  39711. */
  39712. /**
  39713. * The camera exposure used on this material.
  39714. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39715. * This corresponds to a photographic exposure.
  39716. */
  39717. cameraExposure: number;
  39718. /**
  39719. * Gets The camera contrast used on this material.
  39720. */
  39721. /**
  39722. * Sets The camera contrast used on this material.
  39723. */
  39724. cameraContrast: number;
  39725. /**
  39726. * Gets the Color Grading 2D Lookup Texture.
  39727. */
  39728. /**
  39729. * Sets the Color Grading 2D Lookup Texture.
  39730. */
  39731. cameraColorGradingTexture: Nullable<BaseTexture>;
  39732. /**
  39733. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39734. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39735. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  39736. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39737. */
  39738. /**
  39739. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39740. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39741. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  39742. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39743. */
  39744. cameraColorCurves: Nullable<ColorCurves>;
  39745. /**
  39746. * Custom callback helping to override the default shader used in the material.
  39747. */
  39748. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39749. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39750. protected _worldViewProjectionMatrix: Matrix;
  39751. protected _globalAmbientColor: Color3;
  39752. protected _useLogarithmicDepth: boolean;
  39753. protected _rebuildInParallel: boolean;
  39754. /**
  39755. * Instantiates a new standard material.
  39756. * This is the default material used in Babylon. It is the best trade off between quality
  39757. * and performances.
  39758. * @see http://doc.babylonjs.com/babylon101/materials
  39759. * @param name Define the name of the material in the scene
  39760. * @param scene Define the scene the material belong to
  39761. */
  39762. constructor(name: string, scene: Scene);
  39763. /**
  39764. * Gets a boolean indicating that current material needs to register RTT
  39765. */
  39766. readonly hasRenderTargetTextures: boolean;
  39767. /**
  39768. * Gets the current class name of the material e.g. "StandardMaterial"
  39769. * Mainly use in serialization.
  39770. * @returns the class name
  39771. */
  39772. getClassName(): string;
  39773. /**
  39774. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39775. * You can try switching to logarithmic depth.
  39776. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39777. */
  39778. useLogarithmicDepth: boolean;
  39779. /**
  39780. * Specifies if the material will require alpha blending
  39781. * @returns a boolean specifying if alpha blending is needed
  39782. */
  39783. needAlphaBlending(): boolean;
  39784. /**
  39785. * Specifies if this material should be rendered in alpha test mode
  39786. * @returns a boolean specifying if an alpha test is needed.
  39787. */
  39788. needAlphaTesting(): boolean;
  39789. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39790. /**
  39791. * Get the texture used for alpha test purpose.
  39792. * @returns the diffuse texture in case of the standard material.
  39793. */
  39794. getAlphaTestTexture(): Nullable<BaseTexture>;
  39795. /**
  39796. * Get if the submesh is ready to be used and all its information available.
  39797. * Child classes can use it to update shaders
  39798. * @param mesh defines the mesh to check
  39799. * @param subMesh defines which submesh to check
  39800. * @param useInstances specifies that instances should be used
  39801. * @returns a boolean indicating that the submesh is ready or not
  39802. */
  39803. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39804. /**
  39805. * Builds the material UBO layouts.
  39806. * Used internally during the effect preparation.
  39807. */
  39808. buildUniformLayout(): void;
  39809. /**
  39810. * Unbinds the material from the mesh
  39811. */
  39812. unbind(): void;
  39813. /**
  39814. * Binds the submesh to this material by preparing the effect and shader to draw
  39815. * @param world defines the world transformation matrix
  39816. * @param mesh defines the mesh containing the submesh
  39817. * @param subMesh defines the submesh to bind the material to
  39818. */
  39819. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39820. /**
  39821. * Get the list of animatables in the material.
  39822. * @returns the list of animatables object used in the material
  39823. */
  39824. getAnimatables(): IAnimatable[];
  39825. /**
  39826. * Gets the active textures from the material
  39827. * @returns an array of textures
  39828. */
  39829. getActiveTextures(): BaseTexture[];
  39830. /**
  39831. * Specifies if the material uses a texture
  39832. * @param texture defines the texture to check against the material
  39833. * @returns a boolean specifying if the material uses the texture
  39834. */
  39835. hasTexture(texture: BaseTexture): boolean;
  39836. /**
  39837. * Disposes the material
  39838. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39839. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39840. */
  39841. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39842. /**
  39843. * Makes a duplicate of the material, and gives it a new name
  39844. * @param name defines the new name for the duplicated material
  39845. * @returns the cloned material
  39846. */
  39847. clone(name: string): StandardMaterial;
  39848. /**
  39849. * Serializes this material in a JSON representation
  39850. * @returns the serialized material object
  39851. */
  39852. serialize(): any;
  39853. /**
  39854. * Creates a standard material from parsed material data
  39855. * @param source defines the JSON representation of the material
  39856. * @param scene defines the hosting scene
  39857. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39858. * @returns a new standard material
  39859. */
  39860. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39861. /**
  39862. * Are diffuse textures enabled in the application.
  39863. */
  39864. static DiffuseTextureEnabled: boolean;
  39865. /**
  39866. * Are ambient textures enabled in the application.
  39867. */
  39868. static AmbientTextureEnabled: boolean;
  39869. /**
  39870. * Are opacity textures enabled in the application.
  39871. */
  39872. static OpacityTextureEnabled: boolean;
  39873. /**
  39874. * Are reflection textures enabled in the application.
  39875. */
  39876. static ReflectionTextureEnabled: boolean;
  39877. /**
  39878. * Are emissive textures enabled in the application.
  39879. */
  39880. static EmissiveTextureEnabled: boolean;
  39881. /**
  39882. * Are specular textures enabled in the application.
  39883. */
  39884. static SpecularTextureEnabled: boolean;
  39885. /**
  39886. * Are bump textures enabled in the application.
  39887. */
  39888. static BumpTextureEnabled: boolean;
  39889. /**
  39890. * Are lightmap textures enabled in the application.
  39891. */
  39892. static LightmapTextureEnabled: boolean;
  39893. /**
  39894. * Are refraction textures enabled in the application.
  39895. */
  39896. static RefractionTextureEnabled: boolean;
  39897. /**
  39898. * Are color grading textures enabled in the application.
  39899. */
  39900. static ColorGradingTextureEnabled: boolean;
  39901. /**
  39902. * Are fresnels enabled in the application.
  39903. */
  39904. static FresnelEnabled: boolean;
  39905. }
  39906. }
  39907. declare module BABYLON {
  39908. /** @hidden */
  39909. export var imageProcessingPixelShader: {
  39910. name: string;
  39911. shader: string;
  39912. };
  39913. }
  39914. declare module BABYLON {
  39915. /**
  39916. * ImageProcessingPostProcess
  39917. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39918. */
  39919. export class ImageProcessingPostProcess extends PostProcess {
  39920. /**
  39921. * Default configuration related to image processing available in the PBR Material.
  39922. */
  39923. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39924. /**
  39925. * Gets the image processing configuration used either in this material.
  39926. */
  39927. /**
  39928. * Sets the Default image processing configuration used either in the this material.
  39929. *
  39930. * If sets to null, the scene one is in use.
  39931. */
  39932. imageProcessingConfiguration: ImageProcessingConfiguration;
  39933. /**
  39934. * Keep track of the image processing observer to allow dispose and replace.
  39935. */
  39936. private _imageProcessingObserver;
  39937. /**
  39938. * Attaches a new image processing configuration to the PBR Material.
  39939. * @param configuration
  39940. */
  39941. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39942. /**
  39943. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39944. */
  39945. /**
  39946. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39947. */
  39948. colorCurves: Nullable<ColorCurves>;
  39949. /**
  39950. * Gets wether the color curves effect is enabled.
  39951. */
  39952. /**
  39953. * Sets wether the color curves effect is enabled.
  39954. */
  39955. colorCurvesEnabled: boolean;
  39956. /**
  39957. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39958. */
  39959. /**
  39960. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39961. */
  39962. colorGradingTexture: Nullable<BaseTexture>;
  39963. /**
  39964. * Gets wether the color grading effect is enabled.
  39965. */
  39966. /**
  39967. * Gets wether the color grading effect is enabled.
  39968. */
  39969. colorGradingEnabled: boolean;
  39970. /**
  39971. * Gets exposure used in the effect.
  39972. */
  39973. /**
  39974. * Sets exposure used in the effect.
  39975. */
  39976. exposure: number;
  39977. /**
  39978. * Gets wether tonemapping is enabled or not.
  39979. */
  39980. /**
  39981. * Sets wether tonemapping is enabled or not
  39982. */
  39983. toneMappingEnabled: boolean;
  39984. /**
  39985. * Gets the type of tone mapping effect.
  39986. */
  39987. /**
  39988. * Sets the type of tone mapping effect.
  39989. */
  39990. toneMappingType: number;
  39991. /**
  39992. * Gets contrast used in the effect.
  39993. */
  39994. /**
  39995. * Sets contrast used in the effect.
  39996. */
  39997. contrast: number;
  39998. /**
  39999. * Gets Vignette stretch size.
  40000. */
  40001. /**
  40002. * Sets Vignette stretch size.
  40003. */
  40004. vignetteStretch: number;
  40005. /**
  40006. * Gets Vignette centre X Offset.
  40007. */
  40008. /**
  40009. * Sets Vignette centre X Offset.
  40010. */
  40011. vignetteCentreX: number;
  40012. /**
  40013. * Gets Vignette centre Y Offset.
  40014. */
  40015. /**
  40016. * Sets Vignette centre Y Offset.
  40017. */
  40018. vignetteCentreY: number;
  40019. /**
  40020. * Gets Vignette weight or intensity of the vignette effect.
  40021. */
  40022. /**
  40023. * Sets Vignette weight or intensity of the vignette effect.
  40024. */
  40025. vignetteWeight: number;
  40026. /**
  40027. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40028. * if vignetteEnabled is set to true.
  40029. */
  40030. /**
  40031. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40032. * if vignetteEnabled is set to true.
  40033. */
  40034. vignetteColor: Color4;
  40035. /**
  40036. * Gets Camera field of view used by the Vignette effect.
  40037. */
  40038. /**
  40039. * Sets Camera field of view used by the Vignette effect.
  40040. */
  40041. vignetteCameraFov: number;
  40042. /**
  40043. * Gets the vignette blend mode allowing different kind of effect.
  40044. */
  40045. /**
  40046. * Sets the vignette blend mode allowing different kind of effect.
  40047. */
  40048. vignetteBlendMode: number;
  40049. /**
  40050. * Gets wether the vignette effect is enabled.
  40051. */
  40052. /**
  40053. * Sets wether the vignette effect is enabled.
  40054. */
  40055. vignetteEnabled: boolean;
  40056. private _fromLinearSpace;
  40057. /**
  40058. * Gets wether the input of the processing is in Gamma or Linear Space.
  40059. */
  40060. /**
  40061. * Sets wether the input of the processing is in Gamma or Linear Space.
  40062. */
  40063. fromLinearSpace: boolean;
  40064. /**
  40065. * Defines cache preventing GC.
  40066. */
  40067. private _defines;
  40068. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40069. /**
  40070. * "ImageProcessingPostProcess"
  40071. * @returns "ImageProcessingPostProcess"
  40072. */
  40073. getClassName(): string;
  40074. protected _updateParameters(): void;
  40075. dispose(camera?: Camera): void;
  40076. }
  40077. }
  40078. declare module BABYLON {
  40079. /**
  40080. * Class containing static functions to help procedurally build meshes
  40081. */
  40082. export class GroundBuilder {
  40083. /**
  40084. * Creates a ground mesh
  40085. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40086. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40088. * @param name defines the name of the mesh
  40089. * @param options defines the options used to create the mesh
  40090. * @param scene defines the hosting scene
  40091. * @returns the ground mesh
  40092. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40093. */
  40094. static CreateGround(name: string, options: {
  40095. width?: number;
  40096. height?: number;
  40097. subdivisions?: number;
  40098. subdivisionsX?: number;
  40099. subdivisionsY?: number;
  40100. updatable?: boolean;
  40101. }, scene: any): Mesh;
  40102. /**
  40103. * Creates a tiled ground mesh
  40104. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40105. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40106. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  40107. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  40108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40109. * @param name defines the name of the mesh
  40110. * @param options defines the options used to create the mesh
  40111. * @param scene defines the hosting scene
  40112. * @returns the tiled ground mesh
  40113. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40114. */
  40115. static CreateTiledGround(name: string, options: {
  40116. xmin: number;
  40117. zmin: number;
  40118. xmax: number;
  40119. zmax: number;
  40120. subdivisions?: {
  40121. w: number;
  40122. h: number;
  40123. };
  40124. precision?: {
  40125. w: number;
  40126. h: number;
  40127. };
  40128. updatable?: boolean;
  40129. }, scene?: Nullable<Scene>): Mesh;
  40130. /**
  40131. * Creates a ground mesh from a height map
  40132. * * The parameter `url` sets the URL of the height map image resource.
  40133. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40134. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40135. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40136. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40137. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  40138. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  40139. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40141. * @param name defines the name of the mesh
  40142. * @param url defines the url to the height map
  40143. * @param options defines the options used to create the mesh
  40144. * @param scene defines the hosting scene
  40145. * @returns the ground mesh
  40146. * @see https://doc.babylonjs.com/babylon101/height_map
  40147. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40148. */
  40149. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40150. width?: number;
  40151. height?: number;
  40152. subdivisions?: number;
  40153. minHeight?: number;
  40154. maxHeight?: number;
  40155. colorFilter?: Color3;
  40156. alphaFilter?: number;
  40157. updatable?: boolean;
  40158. onReady?: (mesh: GroundMesh) => void;
  40159. }, scene?: Nullable<Scene>): GroundMesh;
  40160. }
  40161. }
  40162. declare module BABYLON {
  40163. /**
  40164. * Class containing static functions to help procedurally build meshes
  40165. */
  40166. export class TorusBuilder {
  40167. /**
  40168. * Creates a torus mesh
  40169. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40170. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40171. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40175. * @param name defines the name of the mesh
  40176. * @param options defines the options used to create the mesh
  40177. * @param scene defines the hosting scene
  40178. * @returns the torus mesh
  40179. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40180. */
  40181. static CreateTorus(name: string, options: {
  40182. diameter?: number;
  40183. thickness?: number;
  40184. tessellation?: number;
  40185. updatable?: boolean;
  40186. sideOrientation?: number;
  40187. frontUVs?: Vector4;
  40188. backUVs?: Vector4;
  40189. }, scene: any): Mesh;
  40190. }
  40191. }
  40192. declare module BABYLON {
  40193. /**
  40194. * Class containing static functions to help procedurally build meshes
  40195. */
  40196. export class CylinderBuilder {
  40197. /**
  40198. * Creates a cylinder or a cone mesh
  40199. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40200. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40201. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  40202. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40203. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40204. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40205. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40206. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  40207. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40208. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  40209. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  40210. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40211. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  40212. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  40213. * * If `enclose` is false, a ring surface is one element.
  40214. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40215. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  40216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40219. * @param name defines the name of the mesh
  40220. * @param options defines the options used to create the mesh
  40221. * @param scene defines the hosting scene
  40222. * @returns the cylinder mesh
  40223. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40224. */
  40225. static CreateCylinder(name: string, options: {
  40226. height?: number;
  40227. diameterTop?: number;
  40228. diameterBottom?: number;
  40229. diameter?: number;
  40230. tessellation?: number;
  40231. subdivisions?: number;
  40232. arc?: number;
  40233. faceColors?: Color4[];
  40234. faceUV?: Vector4[];
  40235. updatable?: boolean;
  40236. hasRings?: boolean;
  40237. enclose?: boolean;
  40238. cap?: number;
  40239. sideOrientation?: number;
  40240. frontUVs?: Vector4;
  40241. backUVs?: Vector4;
  40242. }, scene: any): Mesh;
  40243. }
  40244. }
  40245. declare module BABYLON {
  40246. /**
  40247. * Options to modify the vr teleportation behavior.
  40248. */
  40249. export interface VRTeleportationOptions {
  40250. /**
  40251. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40252. */
  40253. floorMeshName?: string;
  40254. /**
  40255. * A list of meshes to be used as the teleportation floor. (default: empty)
  40256. */
  40257. floorMeshes?: Mesh[];
  40258. }
  40259. /**
  40260. * Options to modify the vr experience helper's behavior.
  40261. */
  40262. export interface VRExperienceHelperOptions extends WebVROptions {
  40263. /**
  40264. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40265. */
  40266. createDeviceOrientationCamera?: boolean;
  40267. /**
  40268. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40269. */
  40270. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40271. /**
  40272. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40273. */
  40274. laserToggle?: boolean;
  40275. /**
  40276. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40277. */
  40278. floorMeshes?: Mesh[];
  40279. /**
  40280. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40281. */
  40282. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40283. }
  40284. /**
  40285. * Event containing information after VR has been entered
  40286. */
  40287. export class OnAfterEnteringVRObservableEvent {
  40288. /**
  40289. * If entering vr was successful
  40290. */
  40291. success: boolean;
  40292. }
  40293. /**
  40294. * Helps to quickly add VR support to an existing scene.
  40295. * See http://doc.babylonjs.com/how_to/webvr_helper
  40296. */
  40297. export class VRExperienceHelper {
  40298. /** Options to modify the vr experience helper's behavior. */
  40299. webVROptions: VRExperienceHelperOptions;
  40300. private _scene;
  40301. private _position;
  40302. private _btnVR;
  40303. private _btnVRDisplayed;
  40304. private _webVRsupported;
  40305. private _webVRready;
  40306. private _webVRrequesting;
  40307. private _webVRpresenting;
  40308. private _hasEnteredVR;
  40309. private _fullscreenVRpresenting;
  40310. private _canvas;
  40311. private _webVRCamera;
  40312. private _vrDeviceOrientationCamera;
  40313. private _deviceOrientationCamera;
  40314. private _existingCamera;
  40315. private _onKeyDown;
  40316. private _onVrDisplayPresentChange;
  40317. private _onVRDisplayChanged;
  40318. private _onVRRequestPresentStart;
  40319. private _onVRRequestPresentComplete;
  40320. /**
  40321. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  40322. */
  40323. enableGazeEvenWhenNoPointerLock: boolean;
  40324. /**
  40325. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40326. */
  40327. exitVROnDoubleTap: boolean;
  40328. /**
  40329. * Observable raised right before entering VR.
  40330. */
  40331. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40332. /**
  40333. * Observable raised when entering VR has completed.
  40334. */
  40335. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40336. /**
  40337. * Observable raised when exiting VR.
  40338. */
  40339. onExitingVRObservable: Observable<VRExperienceHelper>;
  40340. /**
  40341. * Observable raised when controller mesh is loaded.
  40342. */
  40343. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40344. /** Return this.onEnteringVRObservable
  40345. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40346. */
  40347. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40348. /** Return this.onExitingVRObservable
  40349. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40350. */
  40351. readonly onExitingVR: Observable<VRExperienceHelper>;
  40352. /** Return this.onControllerMeshLoadedObservable
  40353. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40354. */
  40355. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40356. private _rayLength;
  40357. private _useCustomVRButton;
  40358. private _teleportationRequested;
  40359. private _teleportActive;
  40360. private _floorMeshName;
  40361. private _floorMeshesCollection;
  40362. private _rotationAllowed;
  40363. private _teleportBackwardsVector;
  40364. private _teleportationTarget;
  40365. private _isDefaultTeleportationTarget;
  40366. private _postProcessMove;
  40367. private _teleportationFillColor;
  40368. private _teleportationBorderColor;
  40369. private _rotationAngle;
  40370. private _haloCenter;
  40371. private _cameraGazer;
  40372. private _padSensibilityUp;
  40373. private _padSensibilityDown;
  40374. private _leftController;
  40375. private _rightController;
  40376. /**
  40377. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40378. */
  40379. onNewMeshSelected: Observable<AbstractMesh>;
  40380. /**
  40381. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  40382. * This observable will provide the mesh and the controller used to select the mesh
  40383. */
  40384. onMeshSelectedWithController: Observable<{
  40385. mesh: AbstractMesh;
  40386. controller: WebVRController;
  40387. }>;
  40388. /**
  40389. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40390. */
  40391. onNewMeshPicked: Observable<PickingInfo>;
  40392. private _circleEase;
  40393. /**
  40394. * Observable raised before camera teleportation
  40395. */
  40396. onBeforeCameraTeleport: Observable<Vector3>;
  40397. /**
  40398. * Observable raised after camera teleportation
  40399. */
  40400. onAfterCameraTeleport: Observable<Vector3>;
  40401. /**
  40402. * Observable raised when current selected mesh gets unselected
  40403. */
  40404. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40405. private _raySelectionPredicate;
  40406. /**
  40407. * To be optionaly changed by user to define custom ray selection
  40408. */
  40409. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40410. /**
  40411. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40412. */
  40413. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40414. /**
  40415. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40416. */
  40417. teleportationEnabled: boolean;
  40418. private _defaultHeight;
  40419. private _teleportationInitialized;
  40420. private _interactionsEnabled;
  40421. private _interactionsRequested;
  40422. private _displayGaze;
  40423. private _displayLaserPointer;
  40424. /**
  40425. * The mesh used to display where the user is going to teleport.
  40426. */
  40427. /**
  40428. * Sets the mesh to be used to display where the user is going to teleport.
  40429. */
  40430. teleportationTarget: Mesh;
  40431. /**
  40432. * The mesh used to display where the user is selecting, this mesh will be cloned and set as the gazeTracker for the left and right controller
  40433. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40434. * See http://doc.babylonjs.com/resources/baking_transformations
  40435. */
  40436. gazeTrackerMesh: Mesh;
  40437. /**
  40438. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40439. */
  40440. updateGazeTrackerScale: boolean;
  40441. /**
  40442. * If the gaze trackers color should be updated when selecting meshes
  40443. */
  40444. updateGazeTrackerColor: boolean;
  40445. /**
  40446. * If the controller laser color should be updated when selecting meshes
  40447. */
  40448. updateControllerLaserColor: boolean;
  40449. /**
  40450. * The gaze tracking mesh corresponding to the left controller
  40451. */
  40452. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40453. /**
  40454. * The gaze tracking mesh corresponding to the right controller
  40455. */
  40456. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40457. /**
  40458. * If the ray of the gaze should be displayed.
  40459. */
  40460. /**
  40461. * Sets if the ray of the gaze should be displayed.
  40462. */
  40463. displayGaze: boolean;
  40464. /**
  40465. * If the ray of the LaserPointer should be displayed.
  40466. */
  40467. /**
  40468. * Sets if the ray of the LaserPointer should be displayed.
  40469. */
  40470. displayLaserPointer: boolean;
  40471. /**
  40472. * The deviceOrientationCamera used as the camera when not in VR.
  40473. */
  40474. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40475. /**
  40476. * Based on the current WebVR support, returns the current VR camera used.
  40477. */
  40478. readonly currentVRCamera: Nullable<Camera>;
  40479. /**
  40480. * The webVRCamera which is used when in VR.
  40481. */
  40482. readonly webVRCamera: WebVRFreeCamera;
  40483. /**
  40484. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40485. */
  40486. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40487. /**
  40488. * The html button that is used to trigger entering into VR.
  40489. */
  40490. readonly vrButton: Nullable<HTMLButtonElement>;
  40491. private readonly _teleportationRequestInitiated;
  40492. /**
  40493. * Defines wether or not Pointer lock should be requested when switching to
  40494. * full screen.
  40495. */
  40496. requestPointerLockOnFullScreen: boolean;
  40497. /**
  40498. * Instantiates a VRExperienceHelper.
  40499. * Helps to quickly add VR support to an existing scene.
  40500. * @param scene The scene the VRExperienceHelper belongs to.
  40501. * @param webVROptions Options to modify the vr experience helper's behavior.
  40502. */
  40503. constructor(scene: Scene,
  40504. /** Options to modify the vr experience helper's behavior. */
  40505. webVROptions?: VRExperienceHelperOptions);
  40506. private _onDefaultMeshLoaded;
  40507. private _onResize;
  40508. private _onFullscreenChange;
  40509. /**
  40510. * Gets a value indicating if we are currently in VR mode.
  40511. */
  40512. readonly isInVRMode: boolean;
  40513. private onVrDisplayPresentChange;
  40514. private onVRDisplayChanged;
  40515. private moveButtonToBottomRight;
  40516. private displayVRButton;
  40517. private updateButtonVisibility;
  40518. private _cachedAngularSensibility;
  40519. /**
  40520. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40521. * Otherwise, will use the fullscreen API.
  40522. */
  40523. enterVR(): void;
  40524. /**
  40525. * Attempt to exit VR, or fullscreen.
  40526. */
  40527. exitVR(): void;
  40528. /**
  40529. * The position of the vr experience helper.
  40530. */
  40531. /**
  40532. * Sets the position of the vr experience helper.
  40533. */
  40534. position: Vector3;
  40535. /**
  40536. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40537. */
  40538. enableInteractions(): void;
  40539. private readonly _noControllerIsActive;
  40540. private beforeRender;
  40541. private _isTeleportationFloor;
  40542. /**
  40543. * Adds a floor mesh to be used for teleportation.
  40544. * @param floorMesh the mesh to be used for teleportation.
  40545. */
  40546. addFloorMesh(floorMesh: Mesh): void;
  40547. /**
  40548. * Removes a floor mesh from being used for teleportation.
  40549. * @param floorMesh the mesh to be removed.
  40550. */
  40551. removeFloorMesh(floorMesh: Mesh): void;
  40552. /**
  40553. * Enables interactions and teleportation using the VR controllers and gaze.
  40554. * @param vrTeleportationOptions options to modify teleportation behavior.
  40555. */
  40556. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40557. private _onNewGamepadConnected;
  40558. private _tryEnableInteractionOnController;
  40559. private _onNewGamepadDisconnected;
  40560. private _enableInteractionOnController;
  40561. private _checkTeleportWithRay;
  40562. private _checkRotate;
  40563. private _checkTeleportBackwards;
  40564. private _enableTeleportationOnController;
  40565. private _createTeleportationCircles;
  40566. private _displayTeleportationTarget;
  40567. private _hideTeleportationTarget;
  40568. private _rotateCamera;
  40569. private _moveTeleportationSelectorTo;
  40570. private _workingVector;
  40571. private _workingQuaternion;
  40572. private _workingMatrix;
  40573. /**
  40574. * Teleports the users feet to the desired location
  40575. * @param location The location where the user's feet should be placed
  40576. */
  40577. teleportCamera(location: Vector3): void;
  40578. private _convertNormalToDirectionOfRay;
  40579. private _castRayAndSelectObject;
  40580. private _notifySelectedMeshUnselected;
  40581. /**
  40582. * Sets the color of the laser ray from the vr controllers.
  40583. * @param color new color for the ray.
  40584. */
  40585. changeLaserColor(color: Color3): void;
  40586. /**
  40587. * Sets the color of the ray from the vr headsets gaze.
  40588. * @param color new color for the ray.
  40589. */
  40590. changeGazeColor(color: Color3): void;
  40591. /**
  40592. * Exits VR and disposes of the vr experience helper
  40593. */
  40594. dispose(): void;
  40595. /**
  40596. * Gets the name of the VRExperienceHelper class
  40597. * @returns "VRExperienceHelper"
  40598. */
  40599. getClassName(): string;
  40600. }
  40601. }
  40602. declare module BABYLON {
  40603. /**
  40604. * Manages an XRSession to work with Babylon's engine
  40605. * @see https://doc.babylonjs.com/how_to/webxr
  40606. */
  40607. export class WebXRSessionManager implements IDisposable {
  40608. private scene;
  40609. /**
  40610. * Fires every time a new xrFrame arrives which can be used to update the camera
  40611. */
  40612. onXRFrameObservable: Observable<any>;
  40613. /**
  40614. * Fires when the xr session is ended either by the device or manually done
  40615. */
  40616. onXRSessionEnded: Observable<any>;
  40617. /**
  40618. * Underlying xr session
  40619. */
  40620. session: XRSession;
  40621. /**
  40622. * Type of reference space used when creating the session
  40623. */
  40624. referenceSpace: XRReferenceSpace;
  40625. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40626. /**
  40627. * Current XR frame
  40628. */
  40629. currentFrame: Nullable<XRFrame>;
  40630. private _xrNavigator;
  40631. private baseLayer;
  40632. /**
  40633. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40634. * @param scene The scene which the session should be created for
  40635. */
  40636. constructor(scene: Scene);
  40637. /**
  40638. * Initializes the manager
  40639. * After initialization enterXR can be called to start an XR session
  40640. * @returns Promise which resolves after it is initialized
  40641. */
  40642. initializeAsync(): Promise<void>;
  40643. /**
  40644. * Initializes an xr session
  40645. * @param xrSessionMode mode to initialize
  40646. * @returns a promise which will resolve once the session has been initialized
  40647. */
  40648. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40649. /**
  40650. * Sets the reference space on the xr session
  40651. * @param referenceSpace space to set
  40652. * @returns a promise that will resolve once the reference space has been set
  40653. */
  40654. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40655. /**
  40656. * Updates the render state of the session
  40657. * @param state state to set
  40658. * @returns a promise that resolves once the render state has been updated
  40659. */
  40660. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40661. /**
  40662. * Starts rendering to the xr layer
  40663. * @returns a promise that will resolve once rendering has started
  40664. */
  40665. startRenderingToXRAsync(): Promise<void>;
  40666. /**
  40667. * Stops the xrSession and restores the renderloop
  40668. * @returns Promise which resolves after it exits XR
  40669. */
  40670. exitXRAsync(): Promise<unknown>;
  40671. /**
  40672. * Checks if a session would be supported for the creation options specified
  40673. * @param sessionMode session mode to check if supported eg. immersive-vr
  40674. * @returns true if supported
  40675. */
  40676. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40677. /**
  40678. * @hidden
  40679. * Converts the render layer of xrSession to a render target
  40680. * @param session session to create render target for
  40681. * @param scene scene the new render target should be created for
  40682. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40683. /**
  40684. * Disposes of the session manager
  40685. */
  40686. dispose(): void;
  40687. }
  40688. }
  40689. declare module BABYLON {
  40690. /**
  40691. * WebXR Camera which holds the views for the xrSession
  40692. * @see https://doc.babylonjs.com/how_to/webxr
  40693. */
  40694. export class WebXRCamera extends FreeCamera {
  40695. private static _TmpMatrix;
  40696. /**
  40697. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40698. * @param name the name of the camera
  40699. * @param scene the scene to add the camera to
  40700. */
  40701. constructor(name: string, scene: Scene);
  40702. private _updateNumberOfRigCameras;
  40703. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  40704. /**
  40705. * Updates the cameras position from the current pose information of the XR session
  40706. * @param xrSessionManager the session containing pose information
  40707. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40708. */
  40709. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40710. }
  40711. }
  40712. declare module BABYLON {
  40713. /**
  40714. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40715. */
  40716. export class WebXRManagedOutputCanvas implements IDisposable {
  40717. private helper;
  40718. private _canvas;
  40719. /**
  40720. * xrpresent context of the canvas which can be used to display/mirror xr content
  40721. */
  40722. canvasContext: WebGLRenderingContext;
  40723. /**
  40724. * xr layer for the canvas
  40725. */
  40726. xrLayer: Nullable<XRWebGLLayer>;
  40727. /**
  40728. * Initializes the xr layer for the session
  40729. * @param xrSession xr session
  40730. * @returns a promise that will resolve once the XR Layer has been created
  40731. */
  40732. initializeXRLayerAsync(xrSession: any): any;
  40733. /**
  40734. * Initializes the canvas to be added/removed upon entering/exiting xr
  40735. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40736. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40737. */
  40738. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40739. /**
  40740. * Disposes of the object
  40741. */
  40742. dispose(): void;
  40743. private _setManagedOutputCanvas;
  40744. private _addCanvas;
  40745. private _removeCanvas;
  40746. }
  40747. }
  40748. declare module BABYLON {
  40749. /**
  40750. * States of the webXR experience
  40751. */
  40752. export enum WebXRState {
  40753. /**
  40754. * Transitioning to being in XR mode
  40755. */
  40756. ENTERING_XR = 0,
  40757. /**
  40758. * Transitioning to non XR mode
  40759. */
  40760. EXITING_XR = 1,
  40761. /**
  40762. * In XR mode and presenting
  40763. */
  40764. IN_XR = 2,
  40765. /**
  40766. * Not entered XR mode
  40767. */
  40768. NOT_IN_XR = 3
  40769. }
  40770. /**
  40771. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40772. * @see https://doc.babylonjs.com/how_to/webxr
  40773. */
  40774. export class WebXRExperienceHelper implements IDisposable {
  40775. private scene;
  40776. /**
  40777. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  40778. */
  40779. container: AbstractMesh;
  40780. /**
  40781. * Camera used to render xr content
  40782. */
  40783. camera: WebXRCamera;
  40784. /**
  40785. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40786. */
  40787. state: WebXRState;
  40788. private _setState;
  40789. private static _TmpVector;
  40790. /**
  40791. * Fires when the state of the experience helper has changed
  40792. */
  40793. onStateChangedObservable: Observable<WebXRState>;
  40794. /** Session manager used to keep track of xr session */
  40795. sessionManager: WebXRSessionManager;
  40796. private _nonVRCamera;
  40797. private _originalSceneAutoClear;
  40798. private _supported;
  40799. /**
  40800. * Creates the experience helper
  40801. * @param scene the scene to attach the experience helper to
  40802. * @returns a promise for the experience helper
  40803. */
  40804. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40805. /**
  40806. * Creates a WebXRExperienceHelper
  40807. * @param scene The scene the helper should be created in
  40808. */
  40809. private constructor();
  40810. /**
  40811. * Exits XR mode and returns the scene to its original state
  40812. * @returns promise that resolves after xr mode has exited
  40813. */
  40814. exitXRAsync(): Promise<unknown>;
  40815. /**
  40816. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40817. * @param sessionCreationOptions options for the XR session
  40818. * @param referenceSpaceType frame of reference of the XR session
  40819. * @param outputCanvas the output canvas that will be used to enter XR mode
  40820. * @returns promise that resolves after xr mode has entered
  40821. */
  40822. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40823. /**
  40824. * Updates the global position of the camera by moving the camera's container
  40825. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40826. * @param position The desired global position of the camera
  40827. */
  40828. setPositionOfCameraUsingContainer(position: Vector3): void;
  40829. /**
  40830. * Rotates the xr camera by rotating the camera's container around the camera's position
  40831. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40832. * @param rotation the desired quaternion rotation to apply to the camera
  40833. */
  40834. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40835. /**
  40836. * Disposes of the experience helper
  40837. */
  40838. dispose(): void;
  40839. }
  40840. }
  40841. declare module BABYLON {
  40842. /**
  40843. * Button which can be used to enter a different mode of XR
  40844. */
  40845. export class WebXREnterExitUIButton {
  40846. /** button element */
  40847. element: HTMLElement;
  40848. /** XR initialization options for the button */
  40849. sessionMode: XRSessionMode;
  40850. /** Reference space type */
  40851. referenceSpaceType: XRReferenceSpaceType;
  40852. /**
  40853. * Creates a WebXREnterExitUIButton
  40854. * @param element button element
  40855. * @param sessionMode XR initialization session mode
  40856. * @param referenceSpaceType the type of reference space to be used
  40857. */
  40858. constructor(
  40859. /** button element */
  40860. element: HTMLElement,
  40861. /** XR initialization options for the button */
  40862. sessionMode: XRSessionMode,
  40863. /** Reference space type */
  40864. referenceSpaceType: XRReferenceSpaceType);
  40865. /**
  40866. * Overwritable function which can be used to update the button's visuals when the state changes
  40867. * @param activeButton the current active button in the UI
  40868. */
  40869. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40870. }
  40871. /**
  40872. * Options to create the webXR UI
  40873. */
  40874. export class WebXREnterExitUIOptions {
  40875. /**
  40876. * Context to enter xr with
  40877. */
  40878. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40879. /**
  40880. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40881. */
  40882. customButtons?: Array<WebXREnterExitUIButton>;
  40883. }
  40884. /**
  40885. * UI to allow the user to enter/exit XR mode
  40886. */
  40887. export class WebXREnterExitUI implements IDisposable {
  40888. private scene;
  40889. private _overlay;
  40890. private _buttons;
  40891. private _activeButton;
  40892. /**
  40893. * Fired every time the active button is changed.
  40894. *
  40895. * When xr is entered via a button that launches xr that button will be the callback parameter
  40896. *
  40897. * When exiting xr the callback parameter will be null)
  40898. */
  40899. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40900. /**
  40901. * Creates UI to allow the user to enter/exit XR mode
  40902. * @param scene the scene to add the ui to
  40903. * @param helper the xr experience helper to enter/exit xr with
  40904. * @param options options to configure the UI
  40905. * @returns the created ui
  40906. */
  40907. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40908. private constructor();
  40909. private _updateButtons;
  40910. /**
  40911. * Disposes of the object
  40912. */
  40913. dispose(): void;
  40914. }
  40915. }
  40916. declare module BABYLON {
  40917. /**
  40918. * Represents an XR input
  40919. */
  40920. export class WebXRController {
  40921. private scene;
  40922. /** The underlying input source for the controller */
  40923. inputSource: XRInputSource;
  40924. private parentContainer;
  40925. /**
  40926. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  40927. */
  40928. grip?: AbstractMesh;
  40929. /**
  40930. * Pointer which can be used to select objects or attach a visible laser to
  40931. */
  40932. pointer: AbstractMesh;
  40933. /**
  40934. * Event that fires when the controller is removed/disposed
  40935. */
  40936. onDisposeObservable: Observable<{}>;
  40937. private _tmpMatrix;
  40938. private _tmpQuaternion;
  40939. private _tmpVector;
  40940. /**
  40941. * Creates the controller
  40942. * @see https://doc.babylonjs.com/how_to/webxr
  40943. * @param scene the scene which the controller should be associated to
  40944. * @param inputSource the underlying input source for the controller
  40945. * @param parentContainer parent that the controller meshes should be children of
  40946. */
  40947. constructor(scene: Scene,
  40948. /** The underlying input source for the controller */
  40949. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  40950. /**
  40951. * Updates the controller pose based on the given XRFrame
  40952. * @param xrFrame xr frame to update the pose with
  40953. * @param referenceSpace reference space to use
  40954. */
  40955. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  40956. /**
  40957. * Gets a world space ray coming from the controller
  40958. * @param result the resulting ray
  40959. */
  40960. getWorldPointerRayToRef(result: Ray): void;
  40961. /**
  40962. * Disposes of the object
  40963. */
  40964. dispose(): void;
  40965. }
  40966. }
  40967. declare module BABYLON {
  40968. /**
  40969. * XR input used to track XR inputs such as controllers/rays
  40970. */
  40971. export class WebXRInput implements IDisposable {
  40972. /**
  40973. * Base experience the input listens to
  40974. */
  40975. baseExperience: WebXRExperienceHelper;
  40976. /**
  40977. * XR controllers being tracked
  40978. */
  40979. controllers: Array<WebXRController>;
  40980. private _frameObserver;
  40981. private _stateObserver;
  40982. /**
  40983. * Event when a controller has been connected/added
  40984. */
  40985. onControllerAddedObservable: Observable<WebXRController>;
  40986. /**
  40987. * Event when a controller has been removed/disconnected
  40988. */
  40989. onControllerRemovedObservable: Observable<WebXRController>;
  40990. /**
  40991. * Initializes the WebXRInput
  40992. * @param baseExperience experience helper which the input should be created for
  40993. */
  40994. constructor(
  40995. /**
  40996. * Base experience the input listens to
  40997. */
  40998. baseExperience: WebXRExperienceHelper);
  40999. private _onInputSourcesChange;
  41000. private _addAndRemoveControllers;
  41001. /**
  41002. * Disposes of the object
  41003. */
  41004. dispose(): void;
  41005. }
  41006. }
  41007. declare module BABYLON {
  41008. /**
  41009. * Enables teleportation
  41010. */
  41011. export class WebXRControllerTeleportation {
  41012. private _teleportationFillColor;
  41013. private _teleportationBorderColor;
  41014. private _tmpRay;
  41015. private _tmpVector;
  41016. /**
  41017. * Creates a WebXRControllerTeleportation
  41018. * @param input input manager to add teleportation to
  41019. * @param floorMeshes floormeshes which can be teleported to
  41020. */
  41021. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  41022. }
  41023. }
  41024. declare module BABYLON {
  41025. /**
  41026. * Handles pointer input automatically for the pointer of XR controllers
  41027. */
  41028. export class WebXRControllerPointerSelection {
  41029. private static _idCounter;
  41030. private _tmpRay;
  41031. /**
  41032. * Creates a WebXRControllerPointerSelection
  41033. * @param input input manager to setup pointer selection
  41034. */
  41035. constructor(input: WebXRInput);
  41036. private _convertNormalToDirectionOfRay;
  41037. private _updatePointerDistance;
  41038. }
  41039. }
  41040. declare module BABYLON {
  41041. /**
  41042. * Class used to represent data loading progression
  41043. */
  41044. export class SceneLoaderProgressEvent {
  41045. /** defines if data length to load can be evaluated */
  41046. readonly lengthComputable: boolean;
  41047. /** defines the loaded data length */
  41048. readonly loaded: number;
  41049. /** defines the data length to load */
  41050. readonly total: number;
  41051. /**
  41052. * Create a new progress event
  41053. * @param lengthComputable defines if data length to load can be evaluated
  41054. * @param loaded defines the loaded data length
  41055. * @param total defines the data length to load
  41056. */
  41057. constructor(
  41058. /** defines if data length to load can be evaluated */
  41059. lengthComputable: boolean,
  41060. /** defines the loaded data length */
  41061. loaded: number,
  41062. /** defines the data length to load */
  41063. total: number);
  41064. /**
  41065. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41066. * @param event defines the source event
  41067. * @returns a new SceneLoaderProgressEvent
  41068. */
  41069. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41070. }
  41071. /**
  41072. * Interface used by SceneLoader plugins to define supported file extensions
  41073. */
  41074. export interface ISceneLoaderPluginExtensions {
  41075. /**
  41076. * Defines the list of supported extensions
  41077. */
  41078. [extension: string]: {
  41079. isBinary: boolean;
  41080. };
  41081. }
  41082. /**
  41083. * Interface used by SceneLoader plugin factory
  41084. */
  41085. export interface ISceneLoaderPluginFactory {
  41086. /**
  41087. * Defines the name of the factory
  41088. */
  41089. name: string;
  41090. /**
  41091. * Function called to create a new plugin
  41092. * @return the new plugin
  41093. */
  41094. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41095. /**
  41096. * Boolean indicating if the plugin can direct load specific data
  41097. */
  41098. canDirectLoad?: (data: string) => boolean;
  41099. }
  41100. /**
  41101. * Interface used to define a SceneLoader plugin
  41102. */
  41103. export interface ISceneLoaderPlugin {
  41104. /**
  41105. * The friendly name of this plugin.
  41106. */
  41107. name: string;
  41108. /**
  41109. * The file extensions supported by this plugin.
  41110. */
  41111. extensions: string | ISceneLoaderPluginExtensions;
  41112. /**
  41113. * Import meshes into a scene.
  41114. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41115. * @param scene The scene to import into
  41116. * @param data The data to import
  41117. * @param rootUrl The root url for scene and resources
  41118. * @param meshes The meshes array to import into
  41119. * @param particleSystems The particle systems array to import into
  41120. * @param skeletons The skeletons array to import into
  41121. * @param onError The callback when import fails
  41122. * @returns True if successful or false otherwise
  41123. */
  41124. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41125. /**
  41126. * Load into a scene.
  41127. * @param scene The scene to load into
  41128. * @param data The data to import
  41129. * @param rootUrl The root url for scene and resources
  41130. * @param onError The callback when import fails
  41131. * @returns true if successful or false otherwise
  41132. */
  41133. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41134. /**
  41135. * The callback that returns true if the data can be directly loaded.
  41136. */
  41137. canDirectLoad?: (data: string) => boolean;
  41138. /**
  41139. * The callback that allows custom handling of the root url based on the response url.
  41140. */
  41141. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41142. /**
  41143. * Load into an asset container.
  41144. * @param scene The scene to load into
  41145. * @param data The data to import
  41146. * @param rootUrl The root url for scene and resources
  41147. * @param onError The callback when import fails
  41148. * @returns The loaded asset container
  41149. */
  41150. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41151. }
  41152. /**
  41153. * Interface used to define an async SceneLoader plugin
  41154. */
  41155. export interface ISceneLoaderPluginAsync {
  41156. /**
  41157. * The friendly name of this plugin.
  41158. */
  41159. name: string;
  41160. /**
  41161. * The file extensions supported by this plugin.
  41162. */
  41163. extensions: string | ISceneLoaderPluginExtensions;
  41164. /**
  41165. * Import meshes into a scene.
  41166. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41167. * @param scene The scene to import into
  41168. * @param data The data to import
  41169. * @param rootUrl The root url for scene and resources
  41170. * @param onProgress The callback when the load progresses
  41171. * @param fileName Defines the name of the file to load
  41172. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41173. */
  41174. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41175. meshes: AbstractMesh[];
  41176. particleSystems: IParticleSystem[];
  41177. skeletons: Skeleton[];
  41178. animationGroups: AnimationGroup[];
  41179. }>;
  41180. /**
  41181. * Load into a scene.
  41182. * @param scene The scene to load into
  41183. * @param data The data to import
  41184. * @param rootUrl The root url for scene and resources
  41185. * @param onProgress The callback when the load progresses
  41186. * @param fileName Defines the name of the file to load
  41187. * @returns Nothing
  41188. */
  41189. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41190. /**
  41191. * The callback that returns true if the data can be directly loaded.
  41192. */
  41193. canDirectLoad?: (data: string) => boolean;
  41194. /**
  41195. * The callback that allows custom handling of the root url based on the response url.
  41196. */
  41197. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41198. /**
  41199. * Load into an asset container.
  41200. * @param scene The scene to load into
  41201. * @param data The data to import
  41202. * @param rootUrl The root url for scene and resources
  41203. * @param onProgress The callback when the load progresses
  41204. * @param fileName Defines the name of the file to load
  41205. * @returns The loaded asset container
  41206. */
  41207. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41208. }
  41209. /**
  41210. * Class used to load scene from various file formats using registered plugins
  41211. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41212. */
  41213. export class SceneLoader {
  41214. /**
  41215. * No logging while loading
  41216. */
  41217. static readonly NO_LOGGING: number;
  41218. /**
  41219. * Minimal logging while loading
  41220. */
  41221. static readonly MINIMAL_LOGGING: number;
  41222. /**
  41223. * Summary logging while loading
  41224. */
  41225. static readonly SUMMARY_LOGGING: number;
  41226. /**
  41227. * Detailled logging while loading
  41228. */
  41229. static readonly DETAILED_LOGGING: number;
  41230. /**
  41231. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41232. */
  41233. static ForceFullSceneLoadingForIncremental: boolean;
  41234. /**
  41235. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41236. */
  41237. static ShowLoadingScreen: boolean;
  41238. /**
  41239. * Defines the current logging level (while loading the scene)
  41240. * @ignorenaming
  41241. */
  41242. static loggingLevel: number;
  41243. /**
  41244. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41245. */
  41246. static CleanBoneMatrixWeights: boolean;
  41247. /**
  41248. * Event raised when a plugin is used to load a scene
  41249. */
  41250. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41251. private static _registeredPlugins;
  41252. private static _getDefaultPlugin;
  41253. private static _getPluginForExtension;
  41254. private static _getPluginForDirectLoad;
  41255. private static _getPluginForFilename;
  41256. private static _getDirectLoad;
  41257. private static _loadData;
  41258. private static _getFileInfo;
  41259. /**
  41260. * Gets a plugin that can load the given extension
  41261. * @param extension defines the extension to load
  41262. * @returns a plugin or null if none works
  41263. */
  41264. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41265. /**
  41266. * Gets a boolean indicating that the given extension can be loaded
  41267. * @param extension defines the extension to load
  41268. * @returns true if the extension is supported
  41269. */
  41270. static IsPluginForExtensionAvailable(extension: string): boolean;
  41271. /**
  41272. * Adds a new plugin to the list of registered plugins
  41273. * @param plugin defines the plugin to add
  41274. */
  41275. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41276. /**
  41277. * Import meshes into a scene
  41278. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41279. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41280. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41281. * @param scene the instance of BABYLON.Scene to append to
  41282. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41283. * @param onProgress a callback with a progress event for each file being loaded
  41284. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41285. * @param pluginExtension the extension used to determine the plugin
  41286. * @returns The loaded plugin
  41287. */
  41288. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41289. /**
  41290. * Import meshes into a scene
  41291. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41292. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41293. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41294. * @param scene the instance of BABYLON.Scene to append to
  41295. * @param onProgress a callback with a progress event for each file being loaded
  41296. * @param pluginExtension the extension used to determine the plugin
  41297. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41298. */
  41299. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41300. meshes: AbstractMesh[];
  41301. particleSystems: IParticleSystem[];
  41302. skeletons: Skeleton[];
  41303. animationGroups: AnimationGroup[];
  41304. }>;
  41305. /**
  41306. * Load a scene
  41307. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41308. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41309. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41310. * @param onSuccess a callback with the scene when import succeeds
  41311. * @param onProgress a callback with a progress event for each file being loaded
  41312. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41313. * @param pluginExtension the extension used to determine the plugin
  41314. * @returns The loaded plugin
  41315. */
  41316. static Load(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41317. /**
  41318. * Load a scene
  41319. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41320. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41321. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41322. * @param onProgress a callback with a progress event for each file being loaded
  41323. * @param pluginExtension the extension used to determine the plugin
  41324. * @returns The loaded scene
  41325. */
  41326. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41327. /**
  41328. * Append a scene
  41329. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41330. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41331. * @param scene is the instance of BABYLON.Scene to append to
  41332. * @param onSuccess a callback with the scene when import succeeds
  41333. * @param onProgress a callback with a progress event for each file being loaded
  41334. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41335. * @param pluginExtension the extension used to determine the plugin
  41336. * @returns The loaded plugin
  41337. */
  41338. static Append(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41339. /**
  41340. * Append a scene
  41341. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41342. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41343. * @param scene is the instance of BABYLON.Scene to append to
  41344. * @param onProgress a callback with a progress event for each file being loaded
  41345. * @param pluginExtension the extension used to determine the plugin
  41346. * @returns The given scene
  41347. */
  41348. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41349. /**
  41350. * Load a scene into an asset container
  41351. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41352. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41353. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41354. * @param onSuccess a callback with the scene when import succeeds
  41355. * @param onProgress a callback with a progress event for each file being loaded
  41356. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41357. * @param pluginExtension the extension used to determine the plugin
  41358. * @returns The loaded plugin
  41359. */
  41360. static LoadAssetContainer(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41361. /**
  41362. * Load a scene into an asset container
  41363. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41364. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  41365. * @param scene is the instance of Scene to append to
  41366. * @param onProgress a callback with a progress event for each file being loaded
  41367. * @param pluginExtension the extension used to determine the plugin
  41368. * @returns The loaded asset container
  41369. */
  41370. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41371. }
  41372. }
  41373. declare module BABYLON {
  41374. /**
  41375. * Generic Controller
  41376. */
  41377. export class GenericController extends WebVRController {
  41378. /**
  41379. * Base Url for the controller model.
  41380. */
  41381. static readonly MODEL_BASE_URL: string;
  41382. /**
  41383. * File name for the controller model.
  41384. */
  41385. static readonly MODEL_FILENAME: string;
  41386. /**
  41387. * Creates a new GenericController from a gamepad
  41388. * @param vrGamepad the gamepad that the controller should be created from
  41389. */
  41390. constructor(vrGamepad: any);
  41391. /**
  41392. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41393. * @param scene scene in which to add meshes
  41394. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41395. */
  41396. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41397. /**
  41398. * Called once for each button that changed state since the last frame
  41399. * @param buttonIdx Which button index changed
  41400. * @param state New state of the button
  41401. * @param changes Which properties on the state changed since last frame
  41402. */
  41403. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41404. }
  41405. }
  41406. declare module BABYLON {
  41407. /**
  41408. * Defines the WindowsMotionController object that the state of the windows motion controller
  41409. */
  41410. export class WindowsMotionController extends WebVRController {
  41411. /**
  41412. * The base url used to load the left and right controller models
  41413. */
  41414. static MODEL_BASE_URL: string;
  41415. /**
  41416. * The name of the left controller model file
  41417. */
  41418. static MODEL_LEFT_FILENAME: string;
  41419. /**
  41420. * The name of the right controller model file
  41421. */
  41422. static MODEL_RIGHT_FILENAME: string;
  41423. /**
  41424. * The controller name prefix for this controller type
  41425. */
  41426. static readonly GAMEPAD_ID_PREFIX: string;
  41427. /**
  41428. * The controller id pattern for this controller type
  41429. */
  41430. private static readonly GAMEPAD_ID_PATTERN;
  41431. private _loadedMeshInfo;
  41432. private readonly _mapping;
  41433. /**
  41434. * Fired when the trackpad on this controller is clicked
  41435. */
  41436. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41437. /**
  41438. * Fired when the trackpad on this controller is modified
  41439. */
  41440. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41441. /**
  41442. * The current x and y values of this controller's trackpad
  41443. */
  41444. trackpad: StickValues;
  41445. /**
  41446. * Creates a new WindowsMotionController from a gamepad
  41447. * @param vrGamepad the gamepad that the controller should be created from
  41448. */
  41449. constructor(vrGamepad: any);
  41450. /**
  41451. * Fired when the trigger on this controller is modified
  41452. */
  41453. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41454. /**
  41455. * Fired when the menu button on this controller is modified
  41456. */
  41457. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41458. /**
  41459. * Fired when the grip button on this controller is modified
  41460. */
  41461. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41462. /**
  41463. * Fired when the thumbstick button on this controller is modified
  41464. */
  41465. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41466. /**
  41467. * Fired when the touchpad button on this controller is modified
  41468. */
  41469. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41470. /**
  41471. * Fired when the touchpad values on this controller are modified
  41472. */
  41473. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41474. private _updateTrackpad;
  41475. /**
  41476. * Called once per frame by the engine.
  41477. */
  41478. update(): void;
  41479. /**
  41480. * Called once for each button that changed state since the last frame
  41481. * @param buttonIdx Which button index changed
  41482. * @param state New state of the button
  41483. * @param changes Which properties on the state changed since last frame
  41484. */
  41485. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41486. /**
  41487. * Moves the buttons on the controller mesh based on their current state
  41488. * @param buttonName the name of the button to move
  41489. * @param buttonValue the value of the button which determines the buttons new position
  41490. */
  41491. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41492. /**
  41493. * Moves the axis on the controller mesh based on its current state
  41494. * @param axis the index of the axis
  41495. * @param axisValue the value of the axis which determines the meshes new position
  41496. * @hidden
  41497. */
  41498. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41499. /**
  41500. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41501. * @param scene scene in which to add meshes
  41502. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41503. */
  41504. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41505. /**
  41506. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41507. * can be transformed by button presses and axes values, based on this._mapping.
  41508. *
  41509. * @param scene scene in which the meshes exist
  41510. * @param meshes list of meshes that make up the controller model to process
  41511. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41512. */
  41513. private processModel;
  41514. private createMeshInfo;
  41515. /**
  41516. * Gets the ray of the controller in the direction the controller is pointing
  41517. * @param length the length the resulting ray should be
  41518. * @returns a ray in the direction the controller is pointing
  41519. */
  41520. getForwardRay(length?: number): Ray;
  41521. /**
  41522. * Disposes of the controller
  41523. */
  41524. dispose(): void;
  41525. }
  41526. }
  41527. declare module BABYLON {
  41528. /**
  41529. * Oculus Touch Controller
  41530. */
  41531. export class OculusTouchController extends WebVRController {
  41532. /**
  41533. * Base Url for the controller model.
  41534. */
  41535. static MODEL_BASE_URL: string;
  41536. /**
  41537. * File name for the left controller model.
  41538. */
  41539. static MODEL_LEFT_FILENAME: string;
  41540. /**
  41541. * File name for the right controller model.
  41542. */
  41543. static MODEL_RIGHT_FILENAME: string;
  41544. /**
  41545. * Base Url for the Quest controller model.
  41546. */
  41547. static QUEST_MODEL_BASE_URL: string;
  41548. /**
  41549. * @hidden
  41550. * If the controllers are running on a device that needs the updated Quest controller models
  41551. */ private static _IsQuest: boolean;
  41552. /**
  41553. * Fired when the secondary trigger on this controller is modified
  41554. */
  41555. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41556. /**
  41557. * Fired when the thumb rest on this controller is modified
  41558. */
  41559. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41560. /**
  41561. * Creates a new OculusTouchController from a gamepad
  41562. * @param vrGamepad the gamepad that the controller should be created from
  41563. */
  41564. constructor(vrGamepad: any);
  41565. /**
  41566. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41567. * @param scene scene in which to add meshes
  41568. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41569. */
  41570. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41571. /**
  41572. * Fired when the A button on this controller is modified
  41573. */
  41574. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41575. /**
  41576. * Fired when the B button on this controller is modified
  41577. */
  41578. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41579. /**
  41580. * Fired when the X button on this controller is modified
  41581. */
  41582. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41583. /**
  41584. * Fired when the Y button on this controller is modified
  41585. */
  41586. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41587. /**
  41588. * Called once for each button that changed state since the last frame
  41589. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41590. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41591. * 2) secondary trigger (same)
  41592. * 3) A (right) X (left), touch, pressed = value
  41593. * 4) B / Y
  41594. * 5) thumb rest
  41595. * @param buttonIdx Which button index changed
  41596. * @param state New state of the button
  41597. * @param changes Which properties on the state changed since last frame
  41598. */
  41599. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41600. }
  41601. }
  41602. declare module BABYLON {
  41603. /**
  41604. * Vive Controller
  41605. */
  41606. export class ViveController extends WebVRController {
  41607. /**
  41608. * Base Url for the controller model.
  41609. */
  41610. static MODEL_BASE_URL: string;
  41611. /**
  41612. * File name for the controller model.
  41613. */
  41614. static MODEL_FILENAME: string;
  41615. /**
  41616. * Creates a new ViveController from a gamepad
  41617. * @param vrGamepad the gamepad that the controller should be created from
  41618. */
  41619. constructor(vrGamepad: any);
  41620. /**
  41621. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41622. * @param scene scene in which to add meshes
  41623. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41624. */
  41625. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41626. /**
  41627. * Fired when the left button on this controller is modified
  41628. */
  41629. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41630. /**
  41631. * Fired when the right button on this controller is modified
  41632. */
  41633. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41634. /**
  41635. * Fired when the menu button on this controller is modified
  41636. */
  41637. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41638. /**
  41639. * Called once for each button that changed state since the last frame
  41640. * Vive mapping:
  41641. * 0: touchpad
  41642. * 1: trigger
  41643. * 2: left AND right buttons
  41644. * 3: menu button
  41645. * @param buttonIdx Which button index changed
  41646. * @param state New state of the button
  41647. * @param changes Which properties on the state changed since last frame
  41648. */
  41649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41650. }
  41651. }
  41652. declare module BABYLON {
  41653. /**
  41654. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41655. */
  41656. export class WebXRControllerModelLoader {
  41657. /**
  41658. * Creates the WebXRControllerModelLoader
  41659. * @param input xr input that creates the controllers
  41660. */
  41661. constructor(input: WebXRInput);
  41662. }
  41663. }
  41664. declare module BABYLON {
  41665. /**
  41666. * Contains an array of blocks representing the octree
  41667. */
  41668. export interface IOctreeContainer<T> {
  41669. /**
  41670. * Blocks within the octree
  41671. */
  41672. blocks: Array<OctreeBlock<T>>;
  41673. }
  41674. /**
  41675. * Class used to store a cell in an octree
  41676. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41677. */
  41678. export class OctreeBlock<T> {
  41679. /**
  41680. * Gets the content of the current block
  41681. */
  41682. entries: T[];
  41683. /**
  41684. * Gets the list of block children
  41685. */
  41686. blocks: Array<OctreeBlock<T>>;
  41687. private _depth;
  41688. private _maxDepth;
  41689. private _capacity;
  41690. private _minPoint;
  41691. private _maxPoint;
  41692. private _boundingVectors;
  41693. private _creationFunc;
  41694. /**
  41695. * Creates a new block
  41696. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41697. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41698. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41699. * @param depth defines the current depth of this block in the octree
  41700. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41701. * @param creationFunc defines a callback to call when an element is added to the block
  41702. */
  41703. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41704. /**
  41705. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41706. */
  41707. readonly capacity: number;
  41708. /**
  41709. * Gets the minimum vector (in world space) of the block's bounding box
  41710. */
  41711. readonly minPoint: Vector3;
  41712. /**
  41713. * Gets the maximum vector (in world space) of the block's bounding box
  41714. */
  41715. readonly maxPoint: Vector3;
  41716. /**
  41717. * Add a new element to this block
  41718. * @param entry defines the element to add
  41719. */
  41720. addEntry(entry: T): void;
  41721. /**
  41722. * Remove an element from this block
  41723. * @param entry defines the element to remove
  41724. */
  41725. removeEntry(entry: T): void;
  41726. /**
  41727. * Add an array of elements to this block
  41728. * @param entries defines the array of elements to add
  41729. */
  41730. addEntries(entries: T[]): void;
  41731. /**
  41732. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41733. * @param frustumPlanes defines the frustum planes to test
  41734. * @param selection defines the array to store current content if selection is positive
  41735. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41736. */
  41737. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41738. /**
  41739. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41740. * @param sphereCenter defines the bounding sphere center
  41741. * @param sphereRadius defines the bounding sphere radius
  41742. * @param selection defines the array to store current content if selection is positive
  41743. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41744. */
  41745. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41746. /**
  41747. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41748. * @param ray defines the ray to test with
  41749. * @param selection defines the array to store current content if selection is positive
  41750. */
  41751. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41752. /**
  41753. * Subdivide the content into child blocks (this block will then be empty)
  41754. */
  41755. createInnerBlocks(): void;
  41756. /**
  41757. * @hidden
  41758. */ private static _CreateBlocks<T>(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer<T>, creationFunc: (entry: T, block: OctreeBlock<T>) => void): void;
  41759. }
  41760. }
  41761. declare module BABYLON {
  41762. /**
  41763. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41764. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41765. */
  41766. export class Octree<T> {
  41767. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  41768. maxDepth: number;
  41769. /**
  41770. * Blocks within the octree containing objects
  41771. */
  41772. blocks: Array<OctreeBlock<T>>;
  41773. /**
  41774. * Content stored in the octree
  41775. */
  41776. dynamicContent: T[];
  41777. private _maxBlockCapacity;
  41778. private _selectionContent;
  41779. private _creationFunc;
  41780. /**
  41781. * Creates a octree
  41782. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41783. * @param creationFunc function to be used to instatiate the octree
  41784. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41785. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  41786. */
  41787. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41788. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  41789. maxDepth?: number);
  41790. /**
  41791. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41792. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  41793. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  41794. * @param entries meshes to be added to the octree blocks
  41795. */
  41796. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41797. /**
  41798. * Adds a mesh to the octree
  41799. * @param entry Mesh to add to the octree
  41800. */
  41801. addMesh(entry: T): void;
  41802. /**
  41803. * Remove an element from the octree
  41804. * @param entry defines the element to remove
  41805. */
  41806. removeMesh(entry: T): void;
  41807. /**
  41808. * Selects an array of meshes within the frustum
  41809. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41810. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41811. * @returns array of meshes within the frustum
  41812. */
  41813. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41814. /**
  41815. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41816. * @param sphereCenter defines the bounding sphere center
  41817. * @param sphereRadius defines the bounding sphere radius
  41818. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41819. * @returns an array of objects that intersect the sphere
  41820. */
  41821. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41822. /**
  41823. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41824. * @param ray defines the ray to test with
  41825. * @returns array of intersected objects
  41826. */
  41827. intersectsRay(ray: Ray): SmartArray<T>;
  41828. /**
  41829. * Adds a mesh into the octree block if it intersects the block
  41830. */
  41831. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41832. /**
  41833. * Adds a submesh into the octree block if it intersects the block
  41834. */
  41835. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41836. }
  41837. }
  41838. declare module BABYLON {
  41839. interface Scene {
  41840. /**
  41841. * @hidden
  41842. * Backing Filed
  41843. */ private _selectionOctree: Octree<AbstractMesh>;
  41844. /**
  41845. * Gets the octree used to boost mesh selection (picking)
  41846. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41847. */
  41848. selectionOctree: Octree<AbstractMesh>;
  41849. /**
  41850. * Creates or updates the octree used to boost selection (picking)
  41851. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41852. * @param maxCapacity defines the maximum capacity per leaf
  41853. * @param maxDepth defines the maximum depth of the octree
  41854. * @returns an octree of AbstractMesh
  41855. */
  41856. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41857. }
  41858. interface AbstractMesh {
  41859. /**
  41860. * @hidden
  41861. * Backing Field
  41862. */ private _submeshesOctree: Octree<SubMesh>;
  41863. /**
  41864. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41865. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41866. * @param maxCapacity defines the maximum size of each block (64 by default)
  41867. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41868. * @returns the new octree
  41869. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41871. */
  41872. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41873. }
  41874. /**
  41875. * Defines the octree scene component responsible to manage any octrees
  41876. * in a given scene.
  41877. */
  41878. export class OctreeSceneComponent {
  41879. /**
  41880. * The component name help to identify the component in the list of scene components.
  41881. */
  41882. readonly name: string;
  41883. /**
  41884. * The scene the component belongs to.
  41885. */
  41886. scene: Scene;
  41887. /**
  41888. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41889. */
  41890. readonly checksIsEnabled: boolean;
  41891. /**
  41892. * Creates a new instance of the component for the given scene
  41893. * @param scene Defines the scene to register the component in
  41894. */
  41895. constructor(scene: Scene);
  41896. /**
  41897. * Registers the component in a given scene
  41898. */
  41899. register(): void;
  41900. /**
  41901. * Return the list of active meshes
  41902. * @returns the list of active meshes
  41903. */
  41904. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41905. /**
  41906. * Return the list of active sub meshes
  41907. * @param mesh The mesh to get the candidates sub meshes from
  41908. * @returns the list of active sub meshes
  41909. */
  41910. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41911. private _tempRay;
  41912. /**
  41913. * Return the list of sub meshes intersecting with a given local ray
  41914. * @param mesh defines the mesh to find the submesh for
  41915. * @param localRay defines the ray in local space
  41916. * @returns the list of intersecting sub meshes
  41917. */
  41918. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41919. /**
  41920. * Return the list of sub meshes colliding with a collider
  41921. * @param mesh defines the mesh to find the submesh for
  41922. * @param collider defines the collider to evaluate the collision against
  41923. * @returns the list of colliding sub meshes
  41924. */
  41925. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41926. /**
  41927. * Rebuilds the elements related to this component in case of
  41928. * context lost for instance.
  41929. */
  41930. rebuild(): void;
  41931. /**
  41932. * Disposes the component and the associated ressources.
  41933. */
  41934. dispose(): void;
  41935. }
  41936. }
  41937. declare module BABYLON {
  41938. /**
  41939. * Renders a layer on top of an existing scene
  41940. */
  41941. export class UtilityLayerRenderer implements IDisposable {
  41942. /** the original scene that will be rendered on top of */
  41943. originalScene: Scene;
  41944. private _pointerCaptures;
  41945. private _lastPointerEvents;
  41946. private static _DefaultUtilityLayer;
  41947. private static _DefaultKeepDepthUtilityLayer;
  41948. private _sharedGizmoLight;
  41949. private _renderCamera;
  41950. /**
  41951. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41952. * @returns the camera that is used when rendering the utility layer
  41953. */
  41954. getRenderCamera(): Nullable<Camera>;
  41955. /**
  41956. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41957. * @param cam the camera that should be used when rendering the utility layer
  41958. */
  41959. setRenderCamera(cam: Nullable<Camera>): void;
  41960. /**
  41961. * @hidden
  41962. * Light which used by gizmos to get light shading
  41963. */ private _getSharedGizmoLight(): HemisphericLight;
  41964. /**
  41965. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41966. */
  41967. pickUtilitySceneFirst: boolean;
  41968. /**
  41969. * A shared utility layer that can be used to overlay objects into a scene (Depth map of the previous scene is cleared before drawing on top of it)
  41970. */
  41971. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41972. /**
  41973. * A shared utility layer that can be used to embed objects into a scene (Depth map of the previous scene is not cleared before drawing on top of it)
  41974. */
  41975. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41976. /**
  41977. * The scene that is rendered on top of the original scene
  41978. */
  41979. utilityLayerScene: Scene;
  41980. /**
  41981. * If the utility layer should automatically be rendered on top of existing scene
  41982. */
  41983. shouldRender: boolean;
  41984. /**
  41985. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41986. */
  41987. onlyCheckPointerDownEvents: boolean;
  41988. /**
  41989. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41990. */
  41991. processAllEvents: boolean;
  41992. /**
  41993. * Observable raised when the pointer move from the utility layer scene to the main scene
  41994. */
  41995. onPointerOutObservable: Observable<number>;
  41996. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41997. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41998. private _afterRenderObserver;
  41999. private _sceneDisposeObserver;
  42000. private _originalPointerObserver;
  42001. /**
  42002. * Instantiates a UtilityLayerRenderer
  42003. * @param originalScene the original scene that will be rendered on top of
  42004. * @param handleEvents boolean indicating if the utility layer should handle events
  42005. */
  42006. constructor(
  42007. /** the original scene that will be rendered on top of */
  42008. originalScene: Scene, handleEvents?: boolean);
  42009. private _notifyObservers;
  42010. /**
  42011. * Renders the utility layers scene on top of the original scene
  42012. */
  42013. render(): void;
  42014. /**
  42015. * Disposes of the renderer
  42016. */
  42017. dispose(): void;
  42018. private _updateCamera;
  42019. }
  42020. }
  42021. declare module BABYLON {
  42022. /**
  42023. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42024. */
  42025. export class Gizmo implements IDisposable {
  42026. /** The utility layer the gizmo will be added to */
  42027. gizmoLayer: UtilityLayerRenderer;
  42028. /**
  42029. * The root mesh of the gizmo
  42030. */ private _rootMesh: Mesh;
  42031. private _attachedMesh;
  42032. /**
  42033. * Ratio for the scale of the gizmo (Default: 1)
  42034. */
  42035. scaleRatio: number;
  42036. /**
  42037. * If a custom mesh has been set (Default: false)
  42038. */
  42039. protected _customMeshSet: boolean;
  42040. /**
  42041. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42042. * * When set, interactions will be enabled
  42043. */
  42044. attachedMesh: Nullable<AbstractMesh>;
  42045. /**
  42046. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42047. * @param mesh The mesh to replace the default mesh of the gizmo
  42048. */
  42049. setCustomMesh(mesh: Mesh): void;
  42050. /**
  42051. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42052. */
  42053. updateGizmoRotationToMatchAttachedMesh: boolean;
  42054. /**
  42055. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42056. */
  42057. updateGizmoPositionToMatchAttachedMesh: boolean;
  42058. /**
  42059. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  42060. */
  42061. updateScale: boolean;
  42062. protected _interactionsEnabled: boolean;
  42063. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42064. private _beforeRenderObserver;
  42065. private _tempVector;
  42066. /**
  42067. * Creates a gizmo
  42068. * @param gizmoLayer The utility layer the gizmo will be added to
  42069. */
  42070. constructor(
  42071. /** The utility layer the gizmo will be added to */
  42072. gizmoLayer?: UtilityLayerRenderer);
  42073. /**
  42074. * Updates the gizmo to match the attached mesh's position/rotation
  42075. */
  42076. protected _update(): void;
  42077. /**
  42078. * Disposes of the gizmo
  42079. */
  42080. dispose(): void;
  42081. }
  42082. }
  42083. declare module BABYLON {
  42084. /**
  42085. * Single plane drag gizmo
  42086. */
  42087. export class PlaneDragGizmo extends Gizmo {
  42088. /**
  42089. * Drag behavior responsible for the gizmos dragging interactions
  42090. */
  42091. dragBehavior: PointerDragBehavior;
  42092. private _pointerObserver;
  42093. /**
  42094. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42095. */
  42096. snapDistance: number;
  42097. /**
  42098. * Event that fires each time the gizmo snaps to a new location.
  42099. * * snapDistance is the the change in distance
  42100. */
  42101. onSnapObservable: Observable<{
  42102. snapDistance: number;
  42103. }>;
  42104. private _plane;
  42105. private _coloredMaterial;
  42106. private _hoverMaterial;
  42107. private _isEnabled;
  42108. private _parent;
  42109. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42110. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42111. /**
  42112. * Creates a PlaneDragGizmo
  42113. * @param gizmoLayer The utility layer the gizmo will be added to
  42114. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42115. * @param color The color of the gizmo
  42116. */
  42117. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42118. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42119. /**
  42120. * If the gizmo is enabled
  42121. */
  42122. isEnabled: boolean;
  42123. /**
  42124. * Disposes of the gizmo
  42125. */
  42126. dispose(): void;
  42127. }
  42128. }
  42129. declare module BABYLON {
  42130. /**
  42131. * Gizmo that enables dragging a mesh along 3 axis
  42132. */
  42133. export class PositionGizmo extends Gizmo {
  42134. /**
  42135. * Internal gizmo used for interactions on the x axis
  42136. */
  42137. xGizmo: AxisDragGizmo;
  42138. /**
  42139. * Internal gizmo used for interactions on the y axis
  42140. */
  42141. yGizmo: AxisDragGizmo;
  42142. /**
  42143. * Internal gizmo used for interactions on the z axis
  42144. */
  42145. zGizmo: AxisDragGizmo;
  42146. /**
  42147. * Internal gizmo used for interactions on the yz plane
  42148. */
  42149. xPlaneGizmo: PlaneDragGizmo;
  42150. /**
  42151. * Internal gizmo used for interactions on the xz plane
  42152. */
  42153. yPlaneGizmo: PlaneDragGizmo;
  42154. /**
  42155. * Internal gizmo used for interactions on the xy plane
  42156. */
  42157. zPlaneGizmo: PlaneDragGizmo;
  42158. /**
  42159. * private variables
  42160. */
  42161. private _meshAttached;
  42162. private _updateGizmoRotationToMatchAttachedMesh;
  42163. private _snapDistance;
  42164. private _scaleRatio;
  42165. /** Fires an event when any of it's sub gizmos are dragged */
  42166. onDragStartObservable: Observable<unknown>;
  42167. /** Fires an event when any of it's sub gizmos are released from dragging */
  42168. onDragEndObservable: Observable<unknown>;
  42169. /**
  42170. * If set to true, planar drag is enabled
  42171. */
  42172. private _planarGizmoEnabled;
  42173. attachedMesh: Nullable<AbstractMesh>;
  42174. /**
  42175. * Creates a PositionGizmo
  42176. * @param gizmoLayer The utility layer the gizmo will be added to
  42177. */
  42178. constructor(gizmoLayer?: UtilityLayerRenderer);
  42179. /**
  42180. * If the planar drag gizmo is enabled
  42181. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42182. */
  42183. planarGizmoEnabled: boolean;
  42184. updateGizmoRotationToMatchAttachedMesh: boolean;
  42185. /**
  42186. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42187. */
  42188. snapDistance: number;
  42189. /**
  42190. * Ratio for the scale of the gizmo (Default: 1)
  42191. */
  42192. scaleRatio: number;
  42193. /**
  42194. * Disposes of the gizmo
  42195. */
  42196. dispose(): void;
  42197. /**
  42198. * CustomMeshes are not supported by this gizmo
  42199. * @param mesh The mesh to replace the default mesh of the gizmo
  42200. */
  42201. setCustomMesh(mesh: Mesh): void;
  42202. }
  42203. }
  42204. declare module BABYLON {
  42205. /**
  42206. * Single axis drag gizmo
  42207. */
  42208. export class AxisDragGizmo extends Gizmo {
  42209. /**
  42210. * Drag behavior responsible for the gizmos dragging interactions
  42211. */
  42212. dragBehavior: PointerDragBehavior;
  42213. private _pointerObserver;
  42214. /**
  42215. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42216. */
  42217. snapDistance: number;
  42218. /**
  42219. * Event that fires each time the gizmo snaps to a new location.
  42220. * * snapDistance is the the change in distance
  42221. */
  42222. onSnapObservable: Observable<{
  42223. snapDistance: number;
  42224. }>;
  42225. private _isEnabled;
  42226. private _parent;
  42227. private _arrow;
  42228. private _coloredMaterial;
  42229. private _hoverMaterial;
  42230. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42231. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42232. /**
  42233. * Creates an AxisDragGizmo
  42234. * @param gizmoLayer The utility layer the gizmo will be added to
  42235. * @param dragAxis The axis which the gizmo will be able to drag on
  42236. * @param color The color of the gizmo
  42237. */
  42238. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42239. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42240. /**
  42241. * If the gizmo is enabled
  42242. */
  42243. isEnabled: boolean;
  42244. /**
  42245. * Disposes of the gizmo
  42246. */
  42247. dispose(): void;
  42248. }
  42249. }
  42250. declare module BABYLON.Debug {
  42251. /**
  42252. * The Axes viewer will show 3 axes in a specific point in space
  42253. */
  42254. export class AxesViewer {
  42255. private _xAxis;
  42256. private _yAxis;
  42257. private _zAxis;
  42258. private _scaleLinesFactor;
  42259. private _instanced;
  42260. /**
  42261. * Gets the hosting scene
  42262. */
  42263. scene: Scene;
  42264. /**
  42265. * Gets or sets a number used to scale line length
  42266. */
  42267. scaleLines: number;
  42268. /** Gets the node hierarchy used to render x-axis */
  42269. readonly xAxis: TransformNode;
  42270. /** Gets the node hierarchy used to render y-axis */
  42271. readonly yAxis: TransformNode;
  42272. /** Gets the node hierarchy used to render z-axis */
  42273. readonly zAxis: TransformNode;
  42274. /**
  42275. * Creates a new AxesViewer
  42276. * @param scene defines the hosting scene
  42277. * @param scaleLines defines a number used to scale line length (1 by default)
  42278. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42279. * @param xAxis defines the node hierarchy used to render the x-axis
  42280. * @param yAxis defines the node hierarchy used to render the y-axis
  42281. * @param zAxis defines the node hierarchy used to render the z-axis
  42282. */
  42283. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42284. /**
  42285. * Force the viewer to update
  42286. * @param position defines the position of the viewer
  42287. * @param xaxis defines the x axis of the viewer
  42288. * @param yaxis defines the y axis of the viewer
  42289. * @param zaxis defines the z axis of the viewer
  42290. */
  42291. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42292. /**
  42293. * Creates an instance of this axes viewer.
  42294. * @returns a new axes viewer with instanced meshes
  42295. */
  42296. createInstance(): AxesViewer;
  42297. /** Releases resources */
  42298. dispose(): void;
  42299. private static _SetRenderingGroupId;
  42300. }
  42301. }
  42302. declare module BABYLON.Debug {
  42303. /**
  42304. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42305. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42306. */
  42307. export class BoneAxesViewer extends AxesViewer {
  42308. /**
  42309. * Gets or sets the target mesh where to display the axes viewer
  42310. */
  42311. mesh: Nullable<Mesh>;
  42312. /**
  42313. * Gets or sets the target bone where to display the axes viewer
  42314. */
  42315. bone: Nullable<Bone>;
  42316. /** Gets current position */
  42317. pos: Vector3;
  42318. /** Gets direction of X axis */
  42319. xaxis: Vector3;
  42320. /** Gets direction of Y axis */
  42321. yaxis: Vector3;
  42322. /** Gets direction of Z axis */
  42323. zaxis: Vector3;
  42324. /**
  42325. * Creates a new BoneAxesViewer
  42326. * @param scene defines the hosting scene
  42327. * @param bone defines the target bone
  42328. * @param mesh defines the target mesh
  42329. * @param scaleLines defines a scaling factor for line length (1 by default)
  42330. */
  42331. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42332. /**
  42333. * Force the viewer to update
  42334. */
  42335. update(): void;
  42336. /** Releases resources */
  42337. dispose(): void;
  42338. }
  42339. }
  42340. declare module BABYLON {
  42341. /**
  42342. * Interface used to define scene explorer extensibility option
  42343. */
  42344. export interface IExplorerExtensibilityOption {
  42345. /**
  42346. * Define the option label
  42347. */
  42348. label: string;
  42349. /**
  42350. * Defines the action to execute on click
  42351. */
  42352. action: (entity: any) => void;
  42353. }
  42354. /**
  42355. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42356. */
  42357. export interface IExplorerExtensibilityGroup {
  42358. /**
  42359. * Defines a predicate to test if a given type mut be extended
  42360. */
  42361. predicate: (entity: any) => boolean;
  42362. /**
  42363. * Gets the list of options added to a type
  42364. */
  42365. entries: IExplorerExtensibilityOption[];
  42366. }
  42367. /**
  42368. * Interface used to define the options to use to create the Inspector
  42369. */
  42370. export interface IInspectorOptions {
  42371. /**
  42372. * Display in overlay mode (default: false)
  42373. */
  42374. overlay?: boolean;
  42375. /**
  42376. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42377. */
  42378. globalRoot?: HTMLElement;
  42379. /**
  42380. * Display the Scene explorer
  42381. */
  42382. showExplorer?: boolean;
  42383. /**
  42384. * Display the property inspector
  42385. */
  42386. showInspector?: boolean;
  42387. /**
  42388. * Display in embed mode (both panes on the right)
  42389. */
  42390. embedMode?: boolean;
  42391. /**
  42392. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42393. */
  42394. handleResize?: boolean;
  42395. /**
  42396. * Allow the panes to popup (default: true)
  42397. */
  42398. enablePopup?: boolean;
  42399. /**
  42400. * Allow the panes to be closed by users (default: true)
  42401. */
  42402. enableClose?: boolean;
  42403. /**
  42404. * Optional list of extensibility entries
  42405. */
  42406. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42407. /**
  42408. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42409. */
  42410. inspectorURL?: string;
  42411. }
  42412. interface Scene {
  42413. /**
  42414. * @hidden
  42415. * Backing field
  42416. */ private _debugLayer: DebugLayer;
  42417. /**
  42418. * Gets the debug layer (aka Inspector) associated with the scene
  42419. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42420. */
  42421. debugLayer: DebugLayer;
  42422. }
  42423. /**
  42424. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42425. * what is happening in your scene
  42426. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42427. */
  42428. export class DebugLayer {
  42429. /**
  42430. * Define the url to get the inspector script from.
  42431. * By default it uses the babylonjs CDN.
  42432. * @ignoreNaming
  42433. */
  42434. static InspectorURL: string;
  42435. private _scene;
  42436. private BJSINSPECTOR;
  42437. private _onPropertyChangedObservable?;
  42438. /**
  42439. * Observable triggered when a property is changed through the inspector.
  42440. */
  42441. readonly onPropertyChangedObservable: any;
  42442. /**
  42443. * Instantiates a new debug layer.
  42444. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42445. * what is happening in your scene
  42446. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42447. * @param scene Defines the scene to inspect
  42448. */
  42449. constructor(scene: Scene);
  42450. /** Creates the inspector window. */
  42451. private _createInspector;
  42452. /**
  42453. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42454. * @param entity defines the entity to select
  42455. * @param lineContainerTitle defines the specific block to highlight
  42456. */
  42457. select(entity: any, lineContainerTitle?: string): void;
  42458. /** Get the inspector from bundle or global */
  42459. private _getGlobalInspector;
  42460. /**
  42461. * Get if the inspector is visible or not.
  42462. * @returns true if visible otherwise, false
  42463. */
  42464. isVisible(): boolean;
  42465. /**
  42466. * Hide the inspector and close its window.
  42467. */
  42468. hide(): void;
  42469. /**
  42470. * Launch the debugLayer.
  42471. * @param config Define the configuration of the inspector
  42472. * @return a promise fulfilled when the debug layer is visible
  42473. */
  42474. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42475. }
  42476. }
  42477. declare module BABYLON {
  42478. /**
  42479. * Class containing static functions to help procedurally build meshes
  42480. */
  42481. export class BoxBuilder {
  42482. /**
  42483. * Creates a box mesh
  42484. * * The parameter `size` sets the size (float) of each box side (default 1)
  42485. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42486. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  42487. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42491. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42492. * @param name defines the name of the mesh
  42493. * @param options defines the options used to create the mesh
  42494. * @param scene defines the hosting scene
  42495. * @returns the box mesh
  42496. */
  42497. static CreateBox(name: string, options: {
  42498. size?: number;
  42499. width?: number;
  42500. height?: number;
  42501. depth?: number;
  42502. faceUV?: Vector4[];
  42503. faceColors?: Color4[];
  42504. sideOrientation?: number;
  42505. frontUVs?: Vector4;
  42506. backUVs?: Vector4;
  42507. wrap?: boolean;
  42508. topBaseAt?: number;
  42509. bottomBaseAt?: number;
  42510. updatable?: boolean;
  42511. }, scene?: Nullable<Scene>): Mesh;
  42512. }
  42513. }
  42514. declare module BABYLON {
  42515. /**
  42516. * Class containing static functions to help procedurally build meshes
  42517. */
  42518. export class SphereBuilder {
  42519. /**
  42520. * Creates a sphere mesh
  42521. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42522. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  42523. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42524. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  42525. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  42526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42529. * @param name defines the name of the mesh
  42530. * @param options defines the options used to create the mesh
  42531. * @param scene defines the hosting scene
  42532. * @returns the sphere mesh
  42533. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42534. */
  42535. static CreateSphere(name: string, options: {
  42536. segments?: number;
  42537. diameter?: number;
  42538. diameterX?: number;
  42539. diameterY?: number;
  42540. diameterZ?: number;
  42541. arc?: number;
  42542. slice?: number;
  42543. sideOrientation?: number;
  42544. frontUVs?: Vector4;
  42545. backUVs?: Vector4;
  42546. updatable?: boolean;
  42547. }, scene?: Nullable<Scene>): Mesh;
  42548. }
  42549. }
  42550. declare module BABYLON.Debug {
  42551. /**
  42552. * Used to show the physics impostor around the specific mesh
  42553. */
  42554. export class PhysicsViewer {
  42555. /** @hidden */
  42556. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42557. /** @hidden */
  42558. protected _meshes: Array<Nullable<AbstractMesh>>;
  42559. /** @hidden */
  42560. protected _scene: Nullable<Scene>;
  42561. /** @hidden */
  42562. protected _numMeshes: number;
  42563. /** @hidden */
  42564. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42565. private _renderFunction;
  42566. private _utilityLayer;
  42567. private _debugBoxMesh;
  42568. private _debugSphereMesh;
  42569. private _debugCylinderMesh;
  42570. private _debugMaterial;
  42571. private _debugMeshMeshes;
  42572. /**
  42573. * Creates a new PhysicsViewer
  42574. * @param scene defines the hosting scene
  42575. */
  42576. constructor(scene: Scene);
  42577. /** @hidden */
  42578. protected _updateDebugMeshes(): void;
  42579. /**
  42580. * Renders a specified physic impostor
  42581. * @param impostor defines the impostor to render
  42582. * @param targetMesh defines the mesh represented by the impostor
  42583. * @returns the new debug mesh used to render the impostor
  42584. */
  42585. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42586. /**
  42587. * Hides a specified physic impostor
  42588. * @param impostor defines the impostor to hide
  42589. */
  42590. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42591. private _getDebugMaterial;
  42592. private _getDebugBoxMesh;
  42593. private _getDebugSphereMesh;
  42594. private _getDebugCylinderMesh;
  42595. private _getDebugMeshMesh;
  42596. private _getDebugMesh;
  42597. /** Releases all resources */
  42598. dispose(): void;
  42599. }
  42600. }
  42601. declare module BABYLON {
  42602. /**
  42603. * Class containing static functions to help procedurally build meshes
  42604. */
  42605. export class LinesBuilder {
  42606. /**
  42607. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42608. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  42609. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42610. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42611. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42612. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42613. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42614. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  42615. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42618. * @param name defines the name of the new line system
  42619. * @param options defines the options used to create the line system
  42620. * @param scene defines the hosting scene
  42621. * @returns a new line system mesh
  42622. */
  42623. static CreateLineSystem(name: string, options: {
  42624. lines: Vector3[][];
  42625. updatable?: boolean;
  42626. instance?: Nullable<LinesMesh>;
  42627. colors?: Nullable<Color4[][]>;
  42628. useVertexAlpha?: boolean;
  42629. }, scene: Nullable<Scene>): LinesMesh;
  42630. /**
  42631. * Creates a line mesh
  42632. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  42633. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42634. * * The parameter `points` is an array successive Vector3
  42635. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  42636. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42637. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42638. * * When updating an instance, remember that only point positions can change, not the number of points
  42639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42641. * @param name defines the name of the new line system
  42642. * @param options defines the options used to create the line system
  42643. * @param scene defines the hosting scene
  42644. * @returns a new line mesh
  42645. */
  42646. static CreateLines(name: string, options: {
  42647. points: Vector3[];
  42648. updatable?: boolean;
  42649. instance?: Nullable<LinesMesh>;
  42650. colors?: Color4[];
  42651. useVertexAlpha?: boolean;
  42652. }, scene?: Nullable<Scene>): LinesMesh;
  42653. /**
  42654. * Creates a dashed line mesh
  42655. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  42656. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42657. * * The parameter `points` is an array successive Vector3
  42658. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42659. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42660. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42661. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  42662. * * When updating an instance, remember that only point positions can change, not the number of points
  42663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42664. * @param name defines the name of the mesh
  42665. * @param options defines the options used to create the mesh
  42666. * @param scene defines the hosting scene
  42667. * @returns the dashed line mesh
  42668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42669. */
  42670. static CreateDashedLines(name: string, options: {
  42671. points: Vector3[];
  42672. dashSize?: number;
  42673. gapSize?: number;
  42674. dashNb?: number;
  42675. updatable?: boolean;
  42676. instance?: LinesMesh;
  42677. }, scene?: Nullable<Scene>): LinesMesh;
  42678. }
  42679. }
  42680. declare module BABYLON {
  42681. /**
  42682. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42683. * in order to better appreciate the issue one might have.
  42684. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42685. */
  42686. export class RayHelper {
  42687. /**
  42688. * Defines the ray we are currently tryin to visualize.
  42689. */
  42690. ray: Nullable<Ray>;
  42691. private _renderPoints;
  42692. private _renderLine;
  42693. private _renderFunction;
  42694. private _scene;
  42695. private _updateToMeshFunction;
  42696. private _attachedToMesh;
  42697. private _meshSpaceDirection;
  42698. private _meshSpaceOrigin;
  42699. /**
  42700. * Helper function to create a colored helper in a scene in one line.
  42701. * @param ray Defines the ray we are currently tryin to visualize
  42702. * @param scene Defines the scene the ray is used in
  42703. * @param color Defines the color we want to see the ray in
  42704. * @returns The newly created ray helper.
  42705. */
  42706. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42707. /**
  42708. * Instantiate a new ray helper.
  42709. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42710. * in order to better appreciate the issue one might have.
  42711. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42712. * @param ray Defines the ray we are currently tryin to visualize
  42713. */
  42714. constructor(ray: Ray);
  42715. /**
  42716. * Shows the ray we are willing to debug.
  42717. * @param scene Defines the scene the ray needs to be rendered in
  42718. * @param color Defines the color the ray needs to be rendered in
  42719. */
  42720. show(scene: Scene, color?: Color3): void;
  42721. /**
  42722. * Hides the ray we are debugging.
  42723. */
  42724. hide(): void;
  42725. private _render;
  42726. /**
  42727. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42728. * @param mesh Defines the mesh we want the helper attached to
  42729. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42730. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42731. * @param length Defines the length of the ray
  42732. */
  42733. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42734. /**
  42735. * Detach the ray helper from the mesh it has previously been attached to.
  42736. */
  42737. detachFromMesh(): void;
  42738. private _updateToMesh;
  42739. /**
  42740. * Dispose the helper and release its associated resources.
  42741. */
  42742. dispose(): void;
  42743. }
  42744. }
  42745. declare module BABYLON.Debug {
  42746. /**
  42747. * Class used to render a debug view of a given skeleton
  42748. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42749. */
  42750. export class SkeletonViewer {
  42751. /** defines the skeleton to render */
  42752. skeleton: Skeleton;
  42753. /** defines the mesh attached to the skeleton */
  42754. mesh: AbstractMesh;
  42755. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42756. autoUpdateBonesMatrices: boolean;
  42757. /** defines the rendering group id to use with the viewer */
  42758. renderingGroupId: number;
  42759. /** Gets or sets the color used to render the skeleton */
  42760. color: Color3;
  42761. private _scene;
  42762. private _debugLines;
  42763. private _debugMesh;
  42764. private _isEnabled;
  42765. private _renderFunction;
  42766. private _utilityLayer;
  42767. /**
  42768. * Returns the mesh used to render the bones
  42769. */
  42770. readonly debugMesh: Nullable<LinesMesh>;
  42771. /**
  42772. * Creates a new SkeletonViewer
  42773. * @param skeleton defines the skeleton to render
  42774. * @param mesh defines the mesh attached to the skeleton
  42775. * @param scene defines the hosting scene
  42776. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42777. * @param renderingGroupId defines the rendering group id to use with the viewer
  42778. */
  42779. constructor(
  42780. /** defines the skeleton to render */
  42781. skeleton: Skeleton,
  42782. /** defines the mesh attached to the skeleton */
  42783. mesh: AbstractMesh, scene: Scene,
  42784. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42785. autoUpdateBonesMatrices?: boolean,
  42786. /** defines the rendering group id to use with the viewer */
  42787. renderingGroupId?: number);
  42788. /** Gets or sets a boolean indicating if the viewer is enabled */
  42789. isEnabled: boolean;
  42790. private _getBonePosition;
  42791. private _getLinesForBonesWithLength;
  42792. private _getLinesForBonesNoLength;
  42793. /** Update the viewer to sync with current skeleton state */
  42794. update(): void;
  42795. /** Release associated resources */
  42796. dispose(): void;
  42797. }
  42798. }
  42799. declare module BABYLON {
  42800. /**
  42801. * Options to create the null engine
  42802. */
  42803. export class NullEngineOptions {
  42804. /**
  42805. * Render width (Default: 512)
  42806. */
  42807. renderWidth: number;
  42808. /**
  42809. * Render height (Default: 256)
  42810. */
  42811. renderHeight: number;
  42812. /**
  42813. * Texture size (Default: 512)
  42814. */
  42815. textureSize: number;
  42816. /**
  42817. * If delta time between frames should be constant
  42818. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42819. */
  42820. deterministicLockstep: boolean;
  42821. /**
  42822. * Maximum about of steps between frames (Default: 4)
  42823. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42824. */
  42825. lockstepMaxSteps: number;
  42826. }
  42827. /**
  42828. * The null engine class provides support for headless version of babylon.js.
  42829. * This can be used in server side scenario or for testing purposes
  42830. */
  42831. export class NullEngine extends Engine {
  42832. private _options;
  42833. /**
  42834. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42835. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42836. * @returns true if engine is in deterministic lock step mode
  42837. */
  42838. isDeterministicLockStep(): boolean;
  42839. /**
  42840. * Gets the max steps when engine is running in deterministic lock step
  42841. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42842. * @returns the max steps
  42843. */
  42844. getLockstepMaxSteps(): number;
  42845. /**
  42846. * Gets the current hardware scaling level.
  42847. * By default the hardware scaling level is computed from the window device ratio.
  42848. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  42849. * @returns a number indicating the current hardware scaling level
  42850. */
  42851. getHardwareScalingLevel(): number;
  42852. constructor(options?: NullEngineOptions);
  42853. /**
  42854. * Creates a vertex buffer
  42855. * @param vertices the data for the vertex buffer
  42856. * @returns the new WebGL static buffer
  42857. */
  42858. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42859. /**
  42860. * Creates a new index buffer
  42861. * @param indices defines the content of the index buffer
  42862. * @param updatable defines if the index buffer must be updatable
  42863. * @returns a new webGL buffer
  42864. */
  42865. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42866. /**
  42867. * Clear the current render buffer or the current render target (if any is set up)
  42868. * @param color defines the color to use
  42869. * @param backBuffer defines if the back buffer must be cleared
  42870. * @param depth defines if the depth buffer must be cleared
  42871. * @param stencil defines if the stencil buffer must be cleared
  42872. */
  42873. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42874. /**
  42875. * Gets the current render width
  42876. * @param useScreen defines if screen size must be used (or the current render target if any)
  42877. * @returns a number defining the current render width
  42878. */
  42879. getRenderWidth(useScreen?: boolean): number;
  42880. /**
  42881. * Gets the current render height
  42882. * @param useScreen defines if screen size must be used (or the current render target if any)
  42883. * @returns a number defining the current render height
  42884. */
  42885. getRenderHeight(useScreen?: boolean): number;
  42886. /**
  42887. * Set the WebGL's viewport
  42888. * @param viewport defines the viewport element to be used
  42889. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  42890. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  42891. */
  42892. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42893. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42894. /**
  42895. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  42896. * @param pipelineContext defines the pipeline context to use
  42897. * @param uniformsNames defines the list of uniform names
  42898. * @returns an array of webGL uniform locations
  42899. */
  42900. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42901. /**
  42902. * Gets the lsit of active attributes for a given webGL program
  42903. * @param pipelineContext defines the pipeline context to use
  42904. * @param attributesNames defines the list of attribute names to get
  42905. * @returns an array of indices indicating the offset of each attribute
  42906. */
  42907. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42908. /**
  42909. * Binds an effect to the webGL context
  42910. * @param effect defines the effect to bind
  42911. */
  42912. bindSamplers(effect: Effect): void;
  42913. /**
  42914. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  42915. * @param effect defines the effect to activate
  42916. */
  42917. enableEffect(effect: Effect): void;
  42918. /**
  42919. * Set various states to the webGL context
  42920. * @param culling defines backface culling state
  42921. * @param zOffset defines the value to apply to zOffset (0 by default)
  42922. * @param force defines if states must be applied even if cache is up to date
  42923. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42924. */
  42925. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42926. /**
  42927. * Set the value of an uniform to an array of int32
  42928. * @param uniform defines the webGL uniform location where to store the value
  42929. * @param array defines the array of int32 to store
  42930. */
  42931. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42932. /**
  42933. * Set the value of an uniform to an array of int32 (stored as vec2)
  42934. * @param uniform defines the webGL uniform location where to store the value
  42935. * @param array defines the array of int32 to store
  42936. */
  42937. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42938. /**
  42939. * Set the value of an uniform to an array of int32 (stored as vec3)
  42940. * @param uniform defines the webGL uniform location where to store the value
  42941. * @param array defines the array of int32 to store
  42942. */
  42943. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42944. /**
  42945. * Set the value of an uniform to an array of int32 (stored as vec4)
  42946. * @param uniform defines the webGL uniform location where to store the value
  42947. * @param array defines the array of int32 to store
  42948. */
  42949. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42950. /**
  42951. * Set the value of an uniform to an array of float32
  42952. * @param uniform defines the webGL uniform location where to store the value
  42953. * @param array defines the array of float32 to store
  42954. */
  42955. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42956. /**
  42957. * Set the value of an uniform to an array of float32 (stored as vec2)
  42958. * @param uniform defines the webGL uniform location where to store the value
  42959. * @param array defines the array of float32 to store
  42960. */
  42961. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42962. /**
  42963. * Set the value of an uniform to an array of float32 (stored as vec3)
  42964. * @param uniform defines the webGL uniform location where to store the value
  42965. * @param array defines the array of float32 to store
  42966. */
  42967. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42968. /**
  42969. * Set the value of an uniform to an array of float32 (stored as vec4)
  42970. * @param uniform defines the webGL uniform location where to store the value
  42971. * @param array defines the array of float32 to store
  42972. */
  42973. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42974. /**
  42975. * Set the value of an uniform to an array of number
  42976. * @param uniform defines the webGL uniform location where to store the value
  42977. * @param array defines the array of number to store
  42978. */
  42979. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42980. /**
  42981. * Set the value of an uniform to an array of number (stored as vec2)
  42982. * @param uniform defines the webGL uniform location where to store the value
  42983. * @param array defines the array of number to store
  42984. */
  42985. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42986. /**
  42987. * Set the value of an uniform to an array of number (stored as vec3)
  42988. * @param uniform defines the webGL uniform location where to store the value
  42989. * @param array defines the array of number to store
  42990. */
  42991. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42992. /**
  42993. * Set the value of an uniform to an array of number (stored as vec4)
  42994. * @param uniform defines the webGL uniform location where to store the value
  42995. * @param array defines the array of number to store
  42996. */
  42997. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42998. /**
  42999. * Set the value of an uniform to an array of float32 (stored as matrices)
  43000. * @param uniform defines the webGL uniform location where to store the value
  43001. * @param matrices defines the array of float32 to store
  43002. */
  43003. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43004. /**
  43005. * Set the value of an uniform to a matrix (3x3)
  43006. * @param uniform defines the webGL uniform location where to store the value
  43007. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  43008. */
  43009. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43010. /**
  43011. * Set the value of an uniform to a matrix (2x2)
  43012. * @param uniform defines the webGL uniform location where to store the value
  43013. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  43014. */
  43015. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43016. /**
  43017. * Set the value of an uniform to a number (float)
  43018. * @param uniform defines the webGL uniform location where to store the value
  43019. * @param value defines the float number to store
  43020. */
  43021. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43022. /**
  43023. * Set the value of an uniform to a vec2
  43024. * @param uniform defines the webGL uniform location where to store the value
  43025. * @param x defines the 1st component of the value
  43026. * @param y defines the 2nd component of the value
  43027. */
  43028. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43029. /**
  43030. * Set the value of an uniform to a vec3
  43031. * @param uniform defines the webGL uniform location where to store the value
  43032. * @param x defines the 1st component of the value
  43033. * @param y defines the 2nd component of the value
  43034. * @param z defines the 3rd component of the value
  43035. */
  43036. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43037. /**
  43038. * Set the value of an uniform to a boolean
  43039. * @param uniform defines the webGL uniform location where to store the value
  43040. * @param bool defines the boolean to store
  43041. */
  43042. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43043. /**
  43044. * Set the value of an uniform to a vec4
  43045. * @param uniform defines the webGL uniform location where to store the value
  43046. * @param x defines the 1st component of the value
  43047. * @param y defines the 2nd component of the value
  43048. * @param z defines the 3rd component of the value
  43049. * @param w defines the 4th component of the value
  43050. */
  43051. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43052. /**
  43053. * Sets the current alpha mode
  43054. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  43055. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43056. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43057. */
  43058. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43059. /**
  43060. * Bind webGl buffers directly to the webGL context
  43061. * @param vertexBuffers defines the vertex buffer to bind
  43062. * @param indexBuffer defines the index buffer to bind
  43063. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  43064. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  43065. * @param effect defines the effect associated with the vertex buffer
  43066. */
  43067. bindBuffers(vertexBuffers: {
  43068. [key: string]: VertexBuffer;
  43069. }, indexBuffer: DataBuffer, effect: Effect): void;
  43070. /**
  43071. * Force the entire cache to be cleared
  43072. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  43073. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  43074. */
  43075. wipeCaches(bruteForce?: boolean): void;
  43076. /**
  43077. * Send a draw order
  43078. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  43079. * @param indexStart defines the starting index
  43080. * @param indexCount defines the number of index to draw
  43081. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43082. */
  43083. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43084. /**
  43085. * Draw a list of indexed primitives
  43086. * @param fillMode defines the primitive to use
  43087. * @param indexStart defines the starting index
  43088. * @param indexCount defines the number of index to draw
  43089. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43090. */
  43091. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43092. /**
  43093. * Draw a list of unindexed primitives
  43094. * @param fillMode defines the primitive to use
  43095. * @param verticesStart defines the index of first vertex to draw
  43096. * @param verticesCount defines the count of vertices to draw
  43097. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43098. */
  43099. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43100. /** @hidden */ private _createTexture(): WebGLTexture;
  43101. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  43102. /**
  43103. * Usually called from Texture.ts.
  43104. * Passed information to create a WebGLTexture
  43105. * @param urlArg defines a value which contains one of the following:
  43106. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43107. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43108. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43109. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43110. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  43111. * @param scene needed for loading to the correct scene
  43112. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  43113. * @param onLoad optional callback to be called upon successful completion
  43114. * @param onError optional callback to be called upon failure
  43115. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  43116. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43117. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43118. * @param forcedExtension defines the extension to use to pick the right loader
  43119. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  43120. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43121. */
  43122. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  43123. /**
  43124. * Creates a new render target texture
  43125. * @param size defines the size of the texture
  43126. * @param options defines the options used to create the texture
  43127. * @returns a new render target texture stored in an InternalTexture
  43128. */
  43129. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43130. /**
  43131. * Update the sampling mode of a given texture
  43132. * @param samplingMode defines the required sampling mode
  43133. * @param texture defines the texture to update
  43134. */
  43135. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43136. /**
  43137. * Binds the frame buffer to the specified texture.
  43138. * @param texture The texture to render to or null for the default canvas
  43139. * @param faceIndex The face of the texture to render to in case of cube texture
  43140. * @param requiredWidth The width of the target to render to
  43141. * @param requiredHeight The height of the target to render to
  43142. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  43143. * @param depthStencilTexture The depth stencil texture to use to render
  43144. * @param lodLevel defines le lod level to bind to the frame buffer
  43145. */
  43146. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43147. /**
  43148. * Unbind the current render target texture from the webGL context
  43149. * @param texture defines the render target texture to unbind
  43150. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43151. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43152. */
  43153. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43154. /**
  43155. * Creates a dynamic vertex buffer
  43156. * @param vertices the data for the dynamic vertex buffer
  43157. * @returns the new WebGL dynamic buffer
  43158. */
  43159. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43160. /**
  43161. * Update the content of a dynamic texture
  43162. * @param texture defines the texture to update
  43163. * @param canvas defines the canvas containing the source
  43164. * @param invertY defines if data must be stored with Y axis inverted
  43165. * @param premulAlpha defines if alpha is stored as premultiplied
  43166. * @param format defines the format of the data
  43167. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  43168. */
  43169. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43170. /**
  43171. * Gets a boolean indicating if all created effects are ready
  43172. * @returns true if all effects are ready
  43173. */
  43174. areAllEffectsReady(): boolean;
  43175. /**
  43176. * @hidden
  43177. * Get the current error code of the webGL context
  43178. * @returns the error code
  43179. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43180. */
  43181. getError(): number;
  43182. /** @hidden */ private _getUnpackAlignement(): number;
  43183. /** @hidden */ private _unpackFlipY(value: boolean): void;
  43184. /**
  43185. * Update a dynamic index buffer
  43186. * @param indexBuffer defines the target index buffer
  43187. * @param indices defines the data to update
  43188. * @param offset defines the offset in the target index buffer where update should start
  43189. */
  43190. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43191. /**
  43192. * Updates a dynamic vertex buffer.
  43193. * @param vertexBuffer the vertex buffer to update
  43194. * @param vertices the data used to update the vertex buffer
  43195. * @param byteOffset the byte offset of the data (optional)
  43196. * @param byteLength the byte length of the data (optional)
  43197. */
  43198. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43199. /** @hidden */ private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43200. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  43201. protected _deleteBuffer(buffer: WebGLBuffer): void;
  43202. /**
  43203. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  43204. */
  43205. releaseEffects(): void;
  43206. displayLoadingUI(): void;
  43207. hideLoadingUI(): void;
  43208. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43209. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43210. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43211. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43212. }
  43213. }
  43214. declare module BABYLON {
  43215. /** @hidden */
  43216. export class _OcclusionDataStorage {
  43217. /** @hidden */
  43218. occlusionInternalRetryCounter: number;
  43219. /** @hidden */
  43220. isOcclusionQueryInProgress: boolean;
  43221. /** @hidden */
  43222. isOccluded: boolean;
  43223. /** @hidden */
  43224. occlusionRetryCount: number;
  43225. /** @hidden */
  43226. occlusionType: number;
  43227. /** @hidden */
  43228. occlusionQueryAlgorithmType: number;
  43229. }
  43230. interface Engine {
  43231. /**
  43232. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43233. * @return the new query
  43234. */
  43235. createQuery(): WebGLQuery;
  43236. /**
  43237. * Delete and release a webGL query
  43238. * @param query defines the query to delete
  43239. * @return the current engine
  43240. */
  43241. deleteQuery(query: WebGLQuery): Engine;
  43242. /**
  43243. * Check if a given query has resolved and got its value
  43244. * @param query defines the query to check
  43245. * @returns true if the query got its value
  43246. */
  43247. isQueryResultAvailable(query: WebGLQuery): boolean;
  43248. /**
  43249. * Gets the value of a given query
  43250. * @param query defines the query to check
  43251. * @returns the value of the query
  43252. */
  43253. getQueryResult(query: WebGLQuery): number;
  43254. /**
  43255. * Initiates an occlusion query
  43256. * @param algorithmType defines the algorithm to use
  43257. * @param query defines the query to use
  43258. * @returns the current engine
  43259. * @see http://doc.babylonjs.com/features/occlusionquery
  43260. */
  43261. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43262. /**
  43263. * Ends an occlusion query
  43264. * @see http://doc.babylonjs.com/features/occlusionquery
  43265. * @param algorithmType defines the algorithm to use
  43266. * @returns the current engine
  43267. */
  43268. endOcclusionQuery(algorithmType: number): Engine;
  43269. /**
  43270. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43271. * Please note that only one query can be issued at a time
  43272. * @returns a time token used to track the time span
  43273. */
  43274. startTimeQuery(): Nullable<_TimeToken>;
  43275. /**
  43276. * Ends a time query
  43277. * @param token defines the token used to measure the time span
  43278. * @returns the time spent (in ns)
  43279. */
  43280. endTimeQuery(token: _TimeToken): int;
  43281. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  43282. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  43283. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  43284. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  43285. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  43286. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  43287. }
  43288. interface AbstractMesh {
  43289. /**
  43290. * Backing filed
  43291. * @hidden
  43292. */ private __occlusionDataStorage: _OcclusionDataStorage;
  43293. /**
  43294. * Access property
  43295. * @hidden
  43296. */ private _occlusionDataStorage: _OcclusionDataStorage;
  43297. /**
  43298. * This number indicates the number of allowed retries before stop the occlusion query, this is useful if the occlusion query is taking long time before to the query result is retireved, the query result indicates if the object is visible within the scene or not and based on that Babylon.Js engine decideds to show or hide the object.
  43299. * The default value is -1 which means don't break the query and wait till the result
  43300. * @see http://doc.babylonjs.com/features/occlusionquery
  43301. */
  43302. occlusionRetryCount: number;
  43303. /**
  43304. * This property is responsible for starting the occlusion query within the Mesh or not, this property is also used to determine what should happen when the occlusionRetryCount is reached. It has supports 3 values:
  43305. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43306. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43307. * * OCCLUSION_TYPE_STRICT: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken restore the last state of the mesh occlusion if the mesh was visible then show the mesh if was hidden then hide don't show.
  43308. * @see http://doc.babylonjs.com/features/occlusionquery
  43309. */
  43310. occlusionType: number;
  43311. /**
  43312. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43313. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43314. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE (Default Value) which is mapped to GL_ANY_SAMPLES_PASSED_CONSERVATIVE which is a false positive algorithm that is faster than GL_ANY_SAMPLES_PASSED but less accurate.
  43315. * @see http://doc.babylonjs.com/features/occlusionquery
  43316. */
  43317. occlusionQueryAlgorithmType: number;
  43318. /**
  43319. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  43320. * @see http://doc.babylonjs.com/features/occlusionquery
  43321. */
  43322. isOccluded: boolean;
  43323. /**
  43324. * Flag to check the progress status of the query
  43325. * @see http://doc.babylonjs.com/features/occlusionquery
  43326. */
  43327. isOcclusionQueryInProgress: boolean;
  43328. }
  43329. }
  43330. declare module BABYLON {
  43331. /** @hidden */
  43332. export var _forceTransformFeedbackToBundle: boolean;
  43333. interface Engine {
  43334. /**
  43335. * Creates a webGL transform feedback object
  43336. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43337. * @returns the webGL transform feedback object
  43338. */
  43339. createTransformFeedback(): WebGLTransformFeedback;
  43340. /**
  43341. * Delete a webGL transform feedback object
  43342. * @param value defines the webGL transform feedback object to delete
  43343. */
  43344. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43345. /**
  43346. * Bind a webGL transform feedback object to the webgl context
  43347. * @param value defines the webGL transform feedback object to bind
  43348. */
  43349. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43350. /**
  43351. * Begins a transform feedback operation
  43352. * @param usePoints defines if points or triangles must be used
  43353. */
  43354. beginTransformFeedback(usePoints: boolean): void;
  43355. /**
  43356. * Ends a transform feedback operation
  43357. */
  43358. endTransformFeedback(): void;
  43359. /**
  43360. * Specify the varyings to use with transform feedback
  43361. * @param program defines the associated webGL program
  43362. * @param value defines the list of strings representing the varying names
  43363. */
  43364. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43365. /**
  43366. * Bind a webGL buffer for a transform feedback operation
  43367. * @param value defines the webGL buffer to bind
  43368. */
  43369. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43370. }
  43371. }
  43372. declare module BABYLON {
  43373. /**
  43374. * Creation options of the multi render target texture.
  43375. */
  43376. export interface IMultiRenderTargetOptions {
  43377. /**
  43378. * Define if the texture needs to create mip maps after render.
  43379. */
  43380. generateMipMaps?: boolean;
  43381. /**
  43382. * Define the types of all the draw buffers we want to create
  43383. */
  43384. types?: number[];
  43385. /**
  43386. * Define the sampling modes of all the draw buffers we want to create
  43387. */
  43388. samplingModes?: number[];
  43389. /**
  43390. * Define if a depth buffer is required
  43391. */
  43392. generateDepthBuffer?: boolean;
  43393. /**
  43394. * Define if a stencil buffer is required
  43395. */
  43396. generateStencilBuffer?: boolean;
  43397. /**
  43398. * Define if a depth texture is required instead of a depth buffer
  43399. */
  43400. generateDepthTexture?: boolean;
  43401. /**
  43402. * Define the number of desired draw buffers
  43403. */
  43404. textureCount?: number;
  43405. /**
  43406. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43407. */
  43408. doNotChangeAspectRatio?: boolean;
  43409. /**
  43410. * Define the default type of the buffers we are creating
  43411. */
  43412. defaultType?: number;
  43413. }
  43414. /**
  43415. * A multi render target, like a render target provides the ability to render to a texture.
  43416. * Unlike the render target, it can render to several draw buffers in one draw.
  43417. * This is specially interesting in deferred rendering or for any effects requiring more than
  43418. * just one color from a single pass.
  43419. */
  43420. export class MultiRenderTarget extends RenderTargetTexture {
  43421. private _internalTextures;
  43422. private _textures;
  43423. private _multiRenderTargetOptions;
  43424. /**
  43425. * Get if draw buffers are currently supported by the used hardware and browser.
  43426. */
  43427. readonly isSupported: boolean;
  43428. /**
  43429. * Get the list of textures generated by the multi render target.
  43430. */
  43431. readonly textures: Texture[];
  43432. /**
  43433. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43434. */
  43435. readonly depthTexture: Texture;
  43436. /**
  43437. * Set the wrapping mode on U of all the textures we are rendering to.
  43438. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43439. */
  43440. wrapU: number;
  43441. /**
  43442. * Set the wrapping mode on V of all the textures we are rendering to.
  43443. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43444. */
  43445. wrapV: number;
  43446. /**
  43447. * Instantiate a new multi render target texture.
  43448. * A multi render target, like a render target provides the ability to render to a texture.
  43449. * Unlike the render target, it can render to several draw buffers in one draw.
  43450. * This is specially interesting in deferred rendering or for any effects requiring more than
  43451. * just one color from a single pass.
  43452. * @param name Define the name of the texture
  43453. * @param size Define the size of the buffers to render to
  43454. * @param count Define the number of target we are rendering into
  43455. * @param scene Define the scene the texture belongs to
  43456. * @param options Define the options used to create the multi render target
  43457. */
  43458. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43459. /** @hidden */ private _rebuild(): void;
  43460. private _createInternalTextures;
  43461. private _createTextures;
  43462. /**
  43463. * Define the number of samples used if MSAA is enabled.
  43464. */
  43465. samples: number;
  43466. /**
  43467. * Resize all the textures in the multi render target.
  43468. * Be carrefull as it will recreate all the data in the new texture.
  43469. * @param size Define the new size
  43470. */
  43471. resize(size: any): void;
  43472. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43473. /**
  43474. * Dispose the render targets and their associated resources
  43475. */
  43476. dispose(): void;
  43477. /**
  43478. * Release all the underlying texture used as draw buffers.
  43479. */
  43480. releaseInternalTextures(): void;
  43481. }
  43482. }
  43483. declare module BABYLON {
  43484. interface ThinEngine {
  43485. /**
  43486. * Unbind a list of render target textures from the webGL context
  43487. * This is used only when drawBuffer extension or webGL2 are active
  43488. * @param textures defines the render target textures to unbind
  43489. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43490. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43491. */
  43492. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43493. /**
  43494. * Create a multi render target texture
  43495. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43496. * @param size defines the size of the texture
  43497. * @param options defines the creation options
  43498. * @returns the cube texture as an InternalTexture
  43499. */
  43500. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43501. /**
  43502. * Update the sample count for a given multiple render target texture
  43503. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43504. * @param textures defines the textures to update
  43505. * @param samples defines the sample count to set
  43506. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43507. */
  43508. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43509. }
  43510. }
  43511. declare module BABYLON {
  43512. /**
  43513. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  43514. */
  43515. export interface CubeMapInfo {
  43516. /**
  43517. * The pixel array for the front face.
  43518. * This is stored in format, left to right, up to down format.
  43519. */
  43520. front: Nullable<ArrayBufferView>;
  43521. /**
  43522. * The pixel array for the back face.
  43523. * This is stored in format, left to right, up to down format.
  43524. */
  43525. back: Nullable<ArrayBufferView>;
  43526. /**
  43527. * The pixel array for the left face.
  43528. * This is stored in format, left to right, up to down format.
  43529. */
  43530. left: Nullable<ArrayBufferView>;
  43531. /**
  43532. * The pixel array for the right face.
  43533. * This is stored in format, left to right, up to down format.
  43534. */
  43535. right: Nullable<ArrayBufferView>;
  43536. /**
  43537. * The pixel array for the up face.
  43538. * This is stored in format, left to right, up to down format.
  43539. */
  43540. up: Nullable<ArrayBufferView>;
  43541. /**
  43542. * The pixel array for the down face.
  43543. * This is stored in format, left to right, up to down format.
  43544. */
  43545. down: Nullable<ArrayBufferView>;
  43546. /**
  43547. * The size of the cubemap stored.
  43548. *
  43549. * Each faces will be size * size pixels.
  43550. */
  43551. size: number;
  43552. /**
  43553. * The format of the texture.
  43554. *
  43555. * RGBA, RGB.
  43556. */
  43557. format: number;
  43558. /**
  43559. * The type of the texture data.
  43560. *
  43561. * UNSIGNED_INT, FLOAT.
  43562. */
  43563. type: number;
  43564. /**
  43565. * Specifies whether the texture is in gamma space.
  43566. */
  43567. gammaSpace: boolean;
  43568. }
  43569. /**
  43570. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  43571. */
  43572. export class PanoramaToCubeMapTools {
  43573. private static FACE_FRONT;
  43574. private static FACE_BACK;
  43575. private static FACE_RIGHT;
  43576. private static FACE_LEFT;
  43577. private static FACE_DOWN;
  43578. private static FACE_UP;
  43579. /**
  43580. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  43581. *
  43582. * @param float32Array The source data.
  43583. * @param inputWidth The width of the input panorama.
  43584. * @param inputHeight The height of the input panorama.
  43585. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  43586. * @return The cubemap data
  43587. */
  43588. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  43589. private static CreateCubemapTexture;
  43590. private static CalcProjectionSpherical;
  43591. }
  43592. }
  43593. declare module BABYLON {
  43594. /**
  43595. * Helper class dealing with the extraction of spherical polynomial dataArray
  43596. * from a cube map.
  43597. */
  43598. export class CubeMapToSphericalPolynomialTools {
  43599. private static FileFaces;
  43600. /**
  43601. * Converts a texture to the according Spherical Polynomial data.
  43602. * This extracts the first 3 orders only as they are the only one used in the lighting.
  43603. *
  43604. * @param texture The texture to extract the information from.
  43605. * @return The Spherical Polynomial data.
  43606. */
  43607. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  43608. /**
  43609. * Converts a cubemap to the according Spherical Polynomial data.
  43610. * This extracts the first 3 orders only as they are the only one used in the lighting.
  43611. *
  43612. * @param cubeInfo The Cube map to extract the information from.
  43613. * @return The Spherical Polynomial data.
  43614. */
  43615. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  43616. }
  43617. }
  43618. declare module BABYLON {
  43619. interface BaseTexture {
  43620. /**
  43621. * Get the polynomial representation of the texture data.
  43622. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  43623. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  43624. */
  43625. sphericalPolynomial: Nullable<SphericalPolynomial>;
  43626. }
  43627. }
  43628. declare module BABYLON {
  43629. /** @hidden */
  43630. export var rgbdEncodePixelShader: {
  43631. name: string;
  43632. shader: string;
  43633. };
  43634. }
  43635. declare module BABYLON {
  43636. /** @hidden */
  43637. export var rgbdDecodePixelShader: {
  43638. name: string;
  43639. shader: string;
  43640. };
  43641. }
  43642. declare module BABYLON {
  43643. /**
  43644. * Raw texture data and descriptor sufficient for WebGL texture upload
  43645. */
  43646. export interface EnvironmentTextureInfo {
  43647. /**
  43648. * Version of the environment map
  43649. */
  43650. version: number;
  43651. /**
  43652. * Width of image
  43653. */
  43654. width: number;
  43655. /**
  43656. * Irradiance information stored in the file.
  43657. */
  43658. irradiance: any;
  43659. /**
  43660. * Specular information stored in the file.
  43661. */
  43662. specular: any;
  43663. }
  43664. /**
  43665. * Defines One Image in the file. It requires only the position in the file
  43666. * as well as the length.
  43667. */
  43668. interface BufferImageData {
  43669. /**
  43670. * Length of the image data.
  43671. */
  43672. length: number;
  43673. /**
  43674. * Position of the data from the null terminator delimiting the end of the JSON.
  43675. */
  43676. position: number;
  43677. }
  43678. /**
  43679. * Defines the specular data enclosed in the file.
  43680. * This corresponds to the version 1 of the data.
  43681. */
  43682. export interface EnvironmentTextureSpecularInfoV1 {
  43683. /**
  43684. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  43685. */
  43686. specularDataPosition?: number;
  43687. /**
  43688. * This contains all the images data needed to reconstruct the cubemap.
  43689. */
  43690. mipmaps: Array<BufferImageData>;
  43691. /**
  43692. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  43693. */
  43694. lodGenerationScale: number;
  43695. }
  43696. /**
  43697. * Sets of helpers addressing the serialization and deserialization of environment texture
  43698. * stored in a BabylonJS env file.
  43699. * Those files are usually stored as .env files.
  43700. */
  43701. export class EnvironmentTextureTools {
  43702. /**
  43703. * Magic number identifying the env file.
  43704. */
  43705. private static _MagicBytes;
  43706. /**
  43707. * Gets the environment info from an env file.
  43708. * @param data The array buffer containing the .env bytes.
  43709. * @returns the environment file info (the json header) if successfully parsed.
  43710. */
  43711. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  43712. /**
  43713. * Creates an environment texture from a loaded cube texture.
  43714. * @param texture defines the cube texture to convert in env file
  43715. * @return a promise containing the environment data if succesfull.
  43716. */
  43717. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  43718. /**
  43719. * Creates a JSON representation of the spherical data.
  43720. * @param texture defines the texture containing the polynomials
  43721. * @return the JSON representation of the spherical info
  43722. */
  43723. private static _CreateEnvTextureIrradiance;
  43724. /**
  43725. * Creates the ArrayBufferViews used for initializing environment texture image data.
  43726. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  43727. * @param info parameters that determine what views will be created for accessing the underlying buffer
  43728. * @return the views described by info providing access to the underlying buffer
  43729. */
  43730. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  43731. /**
  43732. * Uploads the texture info contained in the env file to the GPU.
  43733. * @param texture defines the internal texture to upload to
  43734. * @param arrayBuffer defines the buffer cotaining the data to load
  43735. * @param info defines the texture info retrieved through the GetEnvInfo method
  43736. * @returns a promise
  43737. */
  43738. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  43739. /**
  43740. * Uploads the levels of image data to the GPU.
  43741. * @param texture defines the internal texture to upload to
  43742. * @param imageData defines the array buffer views of image data [mipmap][face]
  43743. * @returns a promise
  43744. */
  43745. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  43746. /**
  43747. * Uploads spherical polynomials information to the texture.
  43748. * @param texture defines the texture we are trying to upload the information to
  43749. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  43750. */
  43751. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  43752. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  43753. }
  43754. }
  43755. declare module BABYLON {
  43756. /**
  43757. * Contains position and normal vectors for a vertex
  43758. */
  43759. export class PositionNormalVertex {
  43760. /** the position of the vertex (defaut: 0,0,0) */
  43761. position: Vector3;
  43762. /** the normal of the vertex (defaut: 0,1,0) */
  43763. normal: Vector3;
  43764. /**
  43765. * Creates a PositionNormalVertex
  43766. * @param position the position of the vertex (defaut: 0,0,0)
  43767. * @param normal the normal of the vertex (defaut: 0,1,0)
  43768. */
  43769. constructor(
  43770. /** the position of the vertex (defaut: 0,0,0) */
  43771. position?: Vector3,
  43772. /** the normal of the vertex (defaut: 0,1,0) */
  43773. normal?: Vector3);
  43774. /**
  43775. * Clones the PositionNormalVertex
  43776. * @returns the cloned PositionNormalVertex
  43777. */
  43778. clone(): PositionNormalVertex;
  43779. }
  43780. /**
  43781. * Contains position, normal and uv vectors for a vertex
  43782. */
  43783. export class PositionNormalTextureVertex {
  43784. /** the position of the vertex (defaut: 0,0,0) */
  43785. position: Vector3;
  43786. /** the normal of the vertex (defaut: 0,1,0) */
  43787. normal: Vector3;
  43788. /** the uv of the vertex (default: 0,0) */
  43789. uv: Vector2;
  43790. /**
  43791. * Creates a PositionNormalTextureVertex
  43792. * @param position the position of the vertex (defaut: 0,0,0)
  43793. * @param normal the normal of the vertex (defaut: 0,1,0)
  43794. * @param uv the uv of the vertex (default: 0,0)
  43795. */
  43796. constructor(
  43797. /** the position of the vertex (defaut: 0,0,0) */
  43798. position?: Vector3,
  43799. /** the normal of the vertex (defaut: 0,1,0) */
  43800. normal?: Vector3,
  43801. /** the uv of the vertex (default: 0,0) */
  43802. uv?: Vector2);
  43803. /**
  43804. * Clones the PositionNormalTextureVertex
  43805. * @returns the cloned PositionNormalTextureVertex
  43806. */
  43807. clone(): PositionNormalTextureVertex;
  43808. }
  43809. }
  43810. declare module BABYLON {
  43811. /** @hidden */
  43812. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  43813. private _genericAttributeLocation;
  43814. private _varyingLocationCount;
  43815. private _varyingLocationMap;
  43816. private _replacements;
  43817. private _textureCount;
  43818. private _uniforms;
  43819. lineProcessor(line: string): string;
  43820. attributeProcessor(attribute: string): string;
  43821. varyingProcessor(varying: string, isFragment: boolean): string;
  43822. uniformProcessor(uniform: string): string;
  43823. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  43824. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  43825. }
  43826. }
  43827. declare module BABYLON {
  43828. /**
  43829. * Container for accessors for natively-stored mesh data buffers.
  43830. */
  43831. class NativeDataBuffer extends DataBuffer {
  43832. /**
  43833. * Accessor value used to identify/retrieve a natively-stored index buffer.
  43834. */
  43835. nativeIndexBuffer?: any;
  43836. /**
  43837. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  43838. */
  43839. nativeVertexBuffer?: any;
  43840. }
  43841. /** @hidden */
  43842. export class NativeEngine extends Engine {
  43843. private readonly _native;
  43844. getHardwareScalingLevel(): number;
  43845. constructor();
  43846. /**
  43847. * Can be used to override the current requestAnimationFrame requester.
  43848. * @hidden
  43849. */
  43850. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  43851. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43852. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  43853. createVertexBuffer(data: DataArray): NativeDataBuffer;
  43854. recordVertexArrayObject(vertexBuffers: {
  43855. [key: string]: VertexBuffer;
  43856. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  43857. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43858. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  43859. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43860. /**
  43861. * Draw a list of indexed primitives
  43862. * @param fillMode defines the primitive to use
  43863. * @param indexStart defines the starting index
  43864. * @param indexCount defines the number of index to draw
  43865. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43866. */
  43867. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43868. /**
  43869. * Draw a list of unindexed primitives
  43870. * @param fillMode defines the primitive to use
  43871. * @param verticesStart defines the index of first vertex to draw
  43872. * @param verticesCount defines the count of vertices to draw
  43873. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  43874. */
  43875. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43876. createPipelineContext(): IPipelineContext; private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  43877. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  43878. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  43879. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43880. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  43881. protected _setProgram(program: WebGLProgram): void; private _releaseEffect(effect: Effect): void; private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43882. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  43883. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  43884. bindSamplers(effect: Effect): void;
  43885. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43886. getRenderWidth(useScreen?: boolean): number;
  43887. getRenderHeight(useScreen?: boolean): number;
  43888. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43889. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43890. /**
  43891. * Set the z offset to apply to current rendering
  43892. * @param value defines the offset to apply
  43893. */
  43894. setZOffset(value: number): void;
  43895. /**
  43896. * Gets the current value of the zOffset
  43897. * @returns the current zOffset state
  43898. */
  43899. getZOffset(): number;
  43900. /**
  43901. * Enable or disable depth buffering
  43902. * @param enable defines the state to set
  43903. */
  43904. setDepthBuffer(enable: boolean): void;
  43905. /**
  43906. * Gets a boolean indicating if depth writing is enabled
  43907. * @returns the current depth writing state
  43908. */
  43909. getDepthWrite(): boolean;
  43910. /**
  43911. * Enable or disable depth writing
  43912. * @param enable defines the state to set
  43913. */
  43914. setDepthWrite(enable: boolean): void;
  43915. /**
  43916. * Enable or disable color writing
  43917. * @param enable defines the state to set
  43918. */
  43919. setColorWrite(enable: boolean): void;
  43920. /**
  43921. * Gets a boolean indicating if color writing is enabled
  43922. * @returns the current color writing state
  43923. */
  43924. getColorWrite(): boolean;
  43925. /**
  43926. * Sets alpha constants used by some alpha blending modes
  43927. * @param r defines the red component
  43928. * @param g defines the green component
  43929. * @param b defines the blue component
  43930. * @param a defines the alpha component
  43931. */
  43932. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  43933. /**
  43934. * Sets the current alpha mode
  43935. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  43936. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  43937. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43938. */
  43939. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43940. /**
  43941. * Gets the current alpha mode
  43942. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  43943. * @returns the current alpha mode
  43944. */
  43945. getAlphaMode(): number;
  43946. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43947. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43948. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43949. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43950. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43951. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43952. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43953. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43954. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43955. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43956. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43957. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43958. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43959. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43960. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43961. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43962. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43963. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43964. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43965. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43966. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43967. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43968. wipeCaches(bruteForce?: boolean): void; private _createTexture(): WebGLTexture;
  43969. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  43970. /**
  43971. * Usually called from BABYLON.Texture.ts.
  43972. * Passed information to create a WebGLTexture
  43973. * @param urlArg defines a value which contains one of the following:
  43974. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  43975. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  43976. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  43977. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  43978. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  43979. * @param scene needed for loading to the correct scene
  43980. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  43981. * @param onLoad optional callback to be called upon successful completion
  43982. * @param onError optional callback to be called upon failure
  43983. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  43984. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  43985. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  43986. * @param forcedExtension defines the extension to use to pick the right loader
  43987. * @returns a InternalTexture for assignment back into BABYLON.Texture
  43988. */
  43989. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  43990. /**
  43991. * Creates a cube texture
  43992. * @param rootUrl defines the url where the files to load is located
  43993. * @param scene defines the current scene
  43994. * @param files defines the list of files to load (1 per face)
  43995. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  43996. * @param onLoad defines an optional callback raised when the texture is loaded
  43997. * @param onError defines an optional callback raised if there is an issue to load the texture
  43998. * @param format defines the format of the data
  43999. * @param forcedExtension defines the extension to use to pick the right loader
  44000. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  44001. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  44002. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  44003. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  44004. * @returns the cube texture as an InternalTexture
  44005. */
  44006. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>): InternalTexture;
  44007. private _getSamplingFilter;
  44008. private static _GetNativeTextureFormat;
  44009. createRenderTargetTexture(size: number | {
  44010. width: number;
  44011. height: number;
  44012. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44013. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44014. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44015. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44016. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44017. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44018. /**
  44019. * Updates a dynamic vertex buffer.
  44020. * @param vertexBuffer the vertex buffer to update
  44021. * @param data the data used to update the vertex buffer
  44022. * @param byteOffset the byte offset of the data (optional)
  44023. * @param byteLength the byte length of the data (optional)
  44024. */
  44025. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44026. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  44027. private _updateAnisotropicLevel;
  44028. private _getAddressMode;
  44029. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  44030. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  44031. releaseEffects(): void;
  44032. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44033. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44034. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44035. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44036. }
  44037. }
  44038. declare module BABYLON {
  44039. /**
  44040. * Gather the list of clipboard event types as constants.
  44041. */
  44042. export class ClipboardEventTypes {
  44043. /**
  44044. * The clipboard event is fired when a copy command is active (pressed).
  44045. */
  44046. static readonly COPY: number;
  44047. /**
  44048. * The clipboard event is fired when a cut command is active (pressed).
  44049. */
  44050. static readonly CUT: number;
  44051. /**
  44052. * The clipboard event is fired when a paste command is active (pressed).
  44053. */
  44054. static readonly PASTE: number;
  44055. }
  44056. /**
  44057. * This class is used to store clipboard related info for the onClipboardObservable event.
  44058. */
  44059. export class ClipboardInfo {
  44060. /**
  44061. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44062. */
  44063. type: number;
  44064. /**
  44065. * Defines the related dom event
  44066. */
  44067. event: ClipboardEvent;
  44068. /**
  44069. *Creates an instance of ClipboardInfo.
  44070. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44071. * @param event Defines the related dom event
  44072. */
  44073. constructor(
  44074. /**
  44075. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44076. */
  44077. type: number,
  44078. /**
  44079. * Defines the related dom event
  44080. */
  44081. event: ClipboardEvent);
  44082. /**
  44083. * Get the clipboard event's type from the keycode.
  44084. * @param keyCode Defines the keyCode for the current keyboard event.
  44085. * @return {number}
  44086. */
  44087. static GetTypeFromCharacter(keyCode: number): number;
  44088. }
  44089. }
  44090. declare module BABYLON {
  44091. /**
  44092. * Google Daydream controller
  44093. */
  44094. export class DaydreamController extends WebVRController {
  44095. /**
  44096. * Base Url for the controller model.
  44097. */
  44098. static MODEL_BASE_URL: string;
  44099. /**
  44100. * File name for the controller model.
  44101. */
  44102. static MODEL_FILENAME: string;
  44103. /**
  44104. * Gamepad Id prefix used to identify Daydream Controller.
  44105. */
  44106. static readonly GAMEPAD_ID_PREFIX: string;
  44107. /**
  44108. * Creates a new DaydreamController from a gamepad
  44109. * @param vrGamepad the gamepad that the controller should be created from
  44110. */
  44111. constructor(vrGamepad: any);
  44112. /**
  44113. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44114. * @param scene scene in which to add meshes
  44115. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44116. */
  44117. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44118. /**
  44119. * Called once for each button that changed state since the last frame
  44120. * @param buttonIdx Which button index changed
  44121. * @param state New state of the button
  44122. * @param changes Which properties on the state changed since last frame
  44123. */
  44124. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44125. }
  44126. }
  44127. declare module BABYLON {
  44128. /**
  44129. * Gear VR Controller
  44130. */
  44131. export class GearVRController extends WebVRController {
  44132. /**
  44133. * Base Url for the controller model.
  44134. */
  44135. static MODEL_BASE_URL: string;
  44136. /**
  44137. * File name for the controller model.
  44138. */
  44139. static MODEL_FILENAME: string;
  44140. /**
  44141. * Gamepad Id prefix used to identify this controller.
  44142. */
  44143. static readonly GAMEPAD_ID_PREFIX: string;
  44144. private readonly _buttonIndexToObservableNameMap;
  44145. /**
  44146. * Creates a new GearVRController from a gamepad
  44147. * @param vrGamepad the gamepad that the controller should be created from
  44148. */
  44149. constructor(vrGamepad: any);
  44150. /**
  44151. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44152. * @param scene scene in which to add meshes
  44153. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44154. */
  44155. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44156. /**
  44157. * Called once for each button that changed state since the last frame
  44158. * @param buttonIdx Which button index changed
  44159. * @param state New state of the button
  44160. * @param changes Which properties on the state changed since last frame
  44161. */
  44162. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44163. }
  44164. }
  44165. declare module BABYLON {
  44166. /**
  44167. * Class containing static functions to help procedurally build meshes
  44168. */
  44169. export class PolyhedronBuilder {
  44170. /**
  44171. * Creates a polyhedron mesh
  44172. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  44173. * * The parameter `size` (positive float, default 1) sets the polygon size
  44174. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44175. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  44176. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  44177. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  44178. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44179. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  44180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44183. * @param name defines the name of the mesh
  44184. * @param options defines the options used to create the mesh
  44185. * @param scene defines the hosting scene
  44186. * @returns the polyhedron mesh
  44187. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44188. */
  44189. static CreatePolyhedron(name: string, options: {
  44190. type?: number;
  44191. size?: number;
  44192. sizeX?: number;
  44193. sizeY?: number;
  44194. sizeZ?: number;
  44195. custom?: any;
  44196. faceUV?: Vector4[];
  44197. faceColors?: Color4[];
  44198. flat?: boolean;
  44199. updatable?: boolean;
  44200. sideOrientation?: number;
  44201. frontUVs?: Vector4;
  44202. backUVs?: Vector4;
  44203. }, scene?: Nullable<Scene>): Mesh;
  44204. }
  44205. }
  44206. declare module BABYLON {
  44207. /**
  44208. * Gizmo that enables scaling a mesh along 3 axis
  44209. */
  44210. export class ScaleGizmo extends Gizmo {
  44211. /**
  44212. * Internal gizmo used for interactions on the x axis
  44213. */
  44214. xGizmo: AxisScaleGizmo;
  44215. /**
  44216. * Internal gizmo used for interactions on the y axis
  44217. */
  44218. yGizmo: AxisScaleGizmo;
  44219. /**
  44220. * Internal gizmo used for interactions on the z axis
  44221. */
  44222. zGizmo: AxisScaleGizmo;
  44223. /**
  44224. * Internal gizmo used to scale all axis equally
  44225. */
  44226. uniformScaleGizmo: AxisScaleGizmo;
  44227. private _meshAttached;
  44228. private _updateGizmoRotationToMatchAttachedMesh;
  44229. private _snapDistance;
  44230. private _scaleRatio;
  44231. private _uniformScalingMesh;
  44232. private _octahedron;
  44233. /** Fires an event when any of it's sub gizmos are dragged */
  44234. onDragStartObservable: Observable<unknown>;
  44235. /** Fires an event when any of it's sub gizmos are released from dragging */
  44236. onDragEndObservable: Observable<unknown>;
  44237. attachedMesh: Nullable<AbstractMesh>;
  44238. /**
  44239. * Creates a ScaleGizmo
  44240. * @param gizmoLayer The utility layer the gizmo will be added to
  44241. */
  44242. constructor(gizmoLayer?: UtilityLayerRenderer);
  44243. updateGizmoRotationToMatchAttachedMesh: boolean;
  44244. /**
  44245. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44246. */
  44247. snapDistance: number;
  44248. /**
  44249. * Ratio for the scale of the gizmo (Default: 1)
  44250. */
  44251. scaleRatio: number;
  44252. /**
  44253. * Disposes of the gizmo
  44254. */
  44255. dispose(): void;
  44256. }
  44257. }
  44258. declare module BABYLON {
  44259. /**
  44260. * Single axis scale gizmo
  44261. */
  44262. export class AxisScaleGizmo extends Gizmo {
  44263. /**
  44264. * Drag behavior responsible for the gizmos dragging interactions
  44265. */
  44266. dragBehavior: PointerDragBehavior;
  44267. private _pointerObserver;
  44268. /**
  44269. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44270. */
  44271. snapDistance: number;
  44272. /**
  44273. * Event that fires each time the gizmo snaps to a new location.
  44274. * * snapDistance is the the change in distance
  44275. */
  44276. onSnapObservable: Observable<{
  44277. snapDistance: number;
  44278. }>;
  44279. /**
  44280. * If the scaling operation should be done on all axis (default: false)
  44281. */
  44282. uniformScaling: boolean;
  44283. private _isEnabled;
  44284. private _parent;
  44285. private _arrow;
  44286. private _coloredMaterial;
  44287. private _hoverMaterial;
  44288. /**
  44289. * Creates an AxisScaleGizmo
  44290. * @param gizmoLayer The utility layer the gizmo will be added to
  44291. * @param dragAxis The axis which the gizmo will be able to scale on
  44292. * @param color The color of the gizmo
  44293. */
  44294. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44295. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44296. /**
  44297. * If the gizmo is enabled
  44298. */
  44299. isEnabled: boolean;
  44300. /**
  44301. * Disposes of the gizmo
  44302. */
  44303. dispose(): void;
  44304. /**
  44305. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44306. * @param mesh The mesh to replace the default mesh of the gizmo
  44307. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44308. */
  44309. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44310. }
  44311. }
  44312. declare module BABYLON {
  44313. /**
  44314. * Bounding box gizmo
  44315. */
  44316. export class BoundingBoxGizmo extends Gizmo {
  44317. private _lineBoundingBox;
  44318. private _rotateSpheresParent;
  44319. private _scaleBoxesParent;
  44320. private _boundingDimensions;
  44321. private _renderObserver;
  44322. private _pointerObserver;
  44323. private _scaleDragSpeed;
  44324. private _tmpQuaternion;
  44325. private _tmpVector;
  44326. private _tmpRotationMatrix;
  44327. /**
  44328. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  44329. */
  44330. ignoreChildren: boolean;
  44331. /**
  44332. * Returns true if a descendant should be included when computing the bounding box. When null, all descendants are included. If ignoreChildren is set this will be ignored. (Default: null)
  44333. */
  44334. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44335. /**
  44336. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44337. */
  44338. rotationSphereSize: number;
  44339. /**
  44340. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44341. */
  44342. scaleBoxSize: number;
  44343. /**
  44344. * If set, the rotation spheres and scale boxes will increase in size based on the distance away from the camera to have a consistent screen size (Default: false)
  44345. */
  44346. fixedDragMeshScreenSize: boolean;
  44347. /**
  44348. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44349. */
  44350. fixedDragMeshScreenSizeDistanceFactor: number;
  44351. /**
  44352. * Fired when a rotation sphere or scale box is dragged
  44353. */
  44354. onDragStartObservable: Observable<{}>;
  44355. /**
  44356. * Fired when a scale box is dragged
  44357. */
  44358. onScaleBoxDragObservable: Observable<{}>;
  44359. /**
  44360. * Fired when a scale box drag is ended
  44361. */
  44362. onScaleBoxDragEndObservable: Observable<{}>;
  44363. /**
  44364. * Fired when a rotation sphere is dragged
  44365. */
  44366. onRotationSphereDragObservable: Observable<{}>;
  44367. /**
  44368. * Fired when a rotation sphere drag is ended
  44369. */
  44370. onRotationSphereDragEndObservable: Observable<{}>;
  44371. /**
  44372. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  44373. */
  44374. scalePivot: Nullable<Vector3>;
  44375. /**
  44376. * Mesh used as a pivot to rotate the attached mesh
  44377. */
  44378. private _anchorMesh;
  44379. private _existingMeshScale;
  44380. private _dragMesh;
  44381. private pointerDragBehavior;
  44382. private coloredMaterial;
  44383. private hoverColoredMaterial;
  44384. /**
  44385. * Sets the color of the bounding box gizmo
  44386. * @param color the color to set
  44387. */
  44388. setColor(color: Color3): void;
  44389. /**
  44390. * Creates an BoundingBoxGizmo
  44391. * @param gizmoLayer The utility layer the gizmo will be added to
  44392. * @param color The color of the gizmo
  44393. */
  44394. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44395. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44396. private _selectNode;
  44397. /**
  44398. * Updates the bounding box information for the Gizmo
  44399. */
  44400. updateBoundingBox(): void;
  44401. private _updateRotationSpheres;
  44402. private _updateScaleBoxes;
  44403. /**
  44404. * Enables rotation on the specified axis and disables rotation on the others
  44405. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44406. */
  44407. setEnabledRotationAxis(axis: string): void;
  44408. /**
  44409. * Enables/disables scaling
  44410. * @param enable if scaling should be enabled
  44411. */
  44412. setEnabledScaling(enable: boolean): void;
  44413. private _updateDummy;
  44414. /**
  44415. * Enables a pointer drag behavior on the bounding box of the gizmo
  44416. */
  44417. enableDragBehavior(): void;
  44418. /**
  44419. * Disposes of the gizmo
  44420. */
  44421. dispose(): void;
  44422. /**
  44423. * Makes a mesh not pickable and wraps the mesh inside of a bounding box mesh that is pickable. (This is useful to avoid picking within complex geometry)
  44424. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44425. * @returns the bounding box mesh with the passed in mesh as a child
  44426. */
  44427. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44428. /**
  44429. * CustomMeshes are not supported by this gizmo
  44430. * @param mesh The mesh to replace the default mesh of the gizmo
  44431. */
  44432. setCustomMesh(mesh: Mesh): void;
  44433. }
  44434. }
  44435. declare module BABYLON {
  44436. /**
  44437. * Single plane rotation gizmo
  44438. */
  44439. export class PlaneRotationGizmo extends Gizmo {
  44440. /**
  44441. * Drag behavior responsible for the gizmos dragging interactions
  44442. */
  44443. dragBehavior: PointerDragBehavior;
  44444. private _pointerObserver;
  44445. /**
  44446. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44447. */
  44448. snapDistance: number;
  44449. /**
  44450. * Event that fires each time the gizmo snaps to a new location.
  44451. * * snapDistance is the the change in distance
  44452. */
  44453. onSnapObservable: Observable<{
  44454. snapDistance: number;
  44455. }>;
  44456. private _isEnabled;
  44457. private _parent;
  44458. /**
  44459. * Creates a PlaneRotationGizmo
  44460. * @param gizmoLayer The utility layer the gizmo will be added to
  44461. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44462. * @param color The color of the gizmo
  44463. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44464. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44465. */
  44466. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  44467. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44468. /**
  44469. * If the gizmo is enabled
  44470. */
  44471. isEnabled: boolean;
  44472. /**
  44473. * Disposes of the gizmo
  44474. */
  44475. dispose(): void;
  44476. }
  44477. }
  44478. declare module BABYLON {
  44479. /**
  44480. * Gizmo that enables rotating a mesh along 3 axis
  44481. */
  44482. export class RotationGizmo extends Gizmo {
  44483. /**
  44484. * Internal gizmo used for interactions on the x axis
  44485. */
  44486. xGizmo: PlaneRotationGizmo;
  44487. /**
  44488. * Internal gizmo used for interactions on the y axis
  44489. */
  44490. yGizmo: PlaneRotationGizmo;
  44491. /**
  44492. * Internal gizmo used for interactions on the z axis
  44493. */
  44494. zGizmo: PlaneRotationGizmo;
  44495. /** Fires an event when any of it's sub gizmos are dragged */
  44496. onDragStartObservable: Observable<unknown>;
  44497. /** Fires an event when any of it's sub gizmos are released from dragging */
  44498. onDragEndObservable: Observable<unknown>;
  44499. private _meshAttached;
  44500. attachedMesh: Nullable<AbstractMesh>;
  44501. /**
  44502. * Creates a RotationGizmo
  44503. * @param gizmoLayer The utility layer the gizmo will be added to
  44504. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44505. * @param useEulerRotation Use and update Euler angle instead of quaternion
  44506. */
  44507. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  44508. updateGizmoRotationToMatchAttachedMesh: boolean;
  44509. /**
  44510. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44511. */
  44512. snapDistance: number;
  44513. /**
  44514. * Ratio for the scale of the gizmo (Default: 1)
  44515. */
  44516. scaleRatio: number;
  44517. /**
  44518. * Disposes of the gizmo
  44519. */
  44520. dispose(): void;
  44521. /**
  44522. * CustomMeshes are not supported by this gizmo
  44523. * @param mesh The mesh to replace the default mesh of the gizmo
  44524. */
  44525. setCustomMesh(mesh: Mesh): void;
  44526. }
  44527. }
  44528. declare module BABYLON {
  44529. /**
  44530. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44531. */
  44532. export class GizmoManager implements IDisposable {
  44533. private scene;
  44534. /**
  44535. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44536. */
  44537. gizmos: {
  44538. positionGizmo: Nullable<PositionGizmo>;
  44539. rotationGizmo: Nullable<RotationGizmo>;
  44540. scaleGizmo: Nullable<ScaleGizmo>;
  44541. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44542. };
  44543. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44544. clearGizmoOnEmptyPointerEvent: boolean;
  44545. /** Fires an event when the manager is attached to a mesh */
  44546. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44547. private _gizmosEnabled;
  44548. private _pointerObserver;
  44549. private _attachedMesh;
  44550. private _boundingBoxColor;
  44551. private _defaultUtilityLayer;
  44552. private _defaultKeepDepthUtilityLayer;
  44553. /**
  44554. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44555. */
  44556. boundingBoxDragBehavior: SixDofDragBehavior;
  44557. /**
  44558. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44559. */
  44560. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44561. /**
  44562. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44563. */
  44564. usePointerToAttachGizmos: boolean;
  44565. /**
  44566. * Utility layer that the bounding box gizmo belongs to
  44567. */
  44568. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  44569. /**
  44570. * Utility layer that all gizmos besides bounding box belong to
  44571. */
  44572. readonly utilityLayer: UtilityLayerRenderer;
  44573. /**
  44574. * Instatiates a gizmo manager
  44575. * @param scene the scene to overlay the gizmos on top of
  44576. */
  44577. constructor(scene: Scene);
  44578. /**
  44579. * Attaches a set of gizmos to the specified mesh
  44580. * @param mesh The mesh the gizmo's should be attached to
  44581. */
  44582. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44583. /**
  44584. * If the position gizmo is enabled
  44585. */
  44586. positionGizmoEnabled: boolean;
  44587. /**
  44588. * If the rotation gizmo is enabled
  44589. */
  44590. rotationGizmoEnabled: boolean;
  44591. /**
  44592. * If the scale gizmo is enabled
  44593. */
  44594. scaleGizmoEnabled: boolean;
  44595. /**
  44596. * If the boundingBox gizmo is enabled
  44597. */
  44598. boundingBoxGizmoEnabled: boolean;
  44599. /**
  44600. * Disposes of the gizmo manager
  44601. */
  44602. dispose(): void;
  44603. }
  44604. }
  44605. declare module BABYLON {
  44606. /**
  44607. * A directional light is defined by a direction (what a surprise!).
  44608. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44609. * An example of a directional light is when a distance planet is lit by the apparently parallel lines of light from its sun. Light in a downward direction will light the top of an object.
  44610. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44611. */
  44612. export class DirectionalLight extends ShadowLight {
  44613. private _shadowFrustumSize;
  44614. /**
  44615. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44616. */
  44617. /**
  44618. * Specifies a fix frustum size for the shadow generation.
  44619. */
  44620. shadowFrustumSize: number;
  44621. private _shadowOrthoScale;
  44622. /**
  44623. * Gets the shadow projection scale against the optimal computed one.
  44624. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44625. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44626. */
  44627. /**
  44628. * Sets the shadow projection scale against the optimal computed one.
  44629. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44630. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44631. */
  44632. shadowOrthoScale: number;
  44633. /**
  44634. * Automatically compute the projection matrix to best fit (including all the casters)
  44635. * on each frame.
  44636. */
  44637. autoUpdateExtends: boolean;
  44638. private _orthoLeft;
  44639. private _orthoRight;
  44640. private _orthoTop;
  44641. private _orthoBottom;
  44642. /**
  44643. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44644. * The directional light is emitted from everywhere in the given direction.
  44645. * It can cast shadows.
  44646. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44647. * @param name The friendly name of the light
  44648. * @param direction The direction of the light
  44649. * @param scene The scene the light belongs to
  44650. */
  44651. constructor(name: string, direction: Vector3, scene: Scene);
  44652. /**
  44653. * Returns the string "DirectionalLight".
  44654. * @return The class name
  44655. */
  44656. getClassName(): string;
  44657. /**
  44658. * Returns the integer 1.
  44659. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44660. */
  44661. getTypeID(): number;
  44662. /**
  44663. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44664. * Returns the DirectionalLight Shadow projection matrix.
  44665. */
  44666. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44667. /**
  44668. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44669. * Returns the DirectionalLight Shadow projection matrix.
  44670. */
  44671. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44672. /**
  44673. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44674. * Returns the DirectionalLight Shadow projection matrix.
  44675. */
  44676. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44677. protected _buildUniformLayout(): void;
  44678. /**
  44679. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44680. * @param effect The effect to update
  44681. * @param lightIndex The index of the light in the effect to update
  44682. * @returns The directional light
  44683. */
  44684. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44685. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  44686. /**
  44687. * Gets the minZ used for shadow according to both the scene and the light.
  44688. *
  44689. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44690. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44691. * @param activeCamera The camera we are returning the min for
  44692. * @returns the depth min z
  44693. */
  44694. getDepthMinZ(activeCamera: Camera): number;
  44695. /**
  44696. * Gets the maxZ used for shadow according to both the scene and the light.
  44697. *
  44698. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44699. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44700. * @param activeCamera The camera we are returning the max for
  44701. * @returns the depth max z
  44702. */
  44703. getDepthMaxZ(activeCamera: Camera): number;
  44704. /**
  44705. * Prepares the list of defines specific to the light type.
  44706. * @param defines the list of defines
  44707. * @param lightIndex defines the index of the light for the effect
  44708. */
  44709. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44710. }
  44711. }
  44712. declare module BABYLON {
  44713. /**
  44714. * Class containing static functions to help procedurally build meshes
  44715. */
  44716. export class HemisphereBuilder {
  44717. /**
  44718. * Creates a hemisphere mesh
  44719. * @param name defines the name of the mesh
  44720. * @param options defines the options used to create the mesh
  44721. * @param scene defines the hosting scene
  44722. * @returns the hemisphere mesh
  44723. */
  44724. static CreateHemisphere(name: string, options: {
  44725. segments?: number;
  44726. diameter?: number;
  44727. sideOrientation?: number;
  44728. }, scene: any): Mesh;
  44729. }
  44730. }
  44731. declare module BABYLON {
  44732. /**
  44733. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44734. * These values define a cone of light starting from the position, emitting toward the direction.
  44735. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44736. * and the exponent defines the speed of the decay of the light with distance (reach).
  44737. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44738. */
  44739. export class SpotLight extends ShadowLight {
  44740. private _angle;
  44741. private _innerAngle;
  44742. private _cosHalfAngle;
  44743. private _lightAngleScale;
  44744. private _lightAngleOffset;
  44745. /**
  44746. * Gets the cone angle of the spot light in Radians.
  44747. */
  44748. /**
  44749. * Sets the cone angle of the spot light in Radians.
  44750. */
  44751. angle: number;
  44752. /**
  44753. * Only used in gltf falloff mode, this defines the angle where
  44754. * the directional falloff will start before cutting at angle which could be seen
  44755. * as outer angle.
  44756. */
  44757. /**
  44758. * Only used in gltf falloff mode, this defines the angle where
  44759. * the directional falloff will start before cutting at angle which could be seen
  44760. * as outer angle.
  44761. */
  44762. innerAngle: number;
  44763. private _shadowAngleScale;
  44764. /**
  44765. * Allows scaling the angle of the light for shadow generation only.
  44766. */
  44767. /**
  44768. * Allows scaling the angle of the light for shadow generation only.
  44769. */
  44770. shadowAngleScale: number;
  44771. /**
  44772. * The light decay speed with the distance from the emission spot.
  44773. */
  44774. exponent: number;
  44775. private _projectionTextureMatrix;
  44776. /**
  44777. * Allows reading the projecton texture
  44778. */
  44779. readonly projectionTextureMatrix: Matrix;
  44780. protected _projectionTextureLightNear: number;
  44781. /**
  44782. * Gets the near clip of the Spotlight for texture projection.
  44783. */
  44784. /**
  44785. * Sets the near clip of the Spotlight for texture projection.
  44786. */
  44787. projectionTextureLightNear: number;
  44788. protected _projectionTextureLightFar: number;
  44789. /**
  44790. * Gets the far clip of the Spotlight for texture projection.
  44791. */
  44792. /**
  44793. * Sets the far clip of the Spotlight for texture projection.
  44794. */
  44795. projectionTextureLightFar: number;
  44796. protected _projectionTextureUpDirection: Vector3;
  44797. /**
  44798. * Gets the Up vector of the Spotlight for texture projection.
  44799. */
  44800. /**
  44801. * Sets the Up vector of the Spotlight for texture projection.
  44802. */
  44803. projectionTextureUpDirection: Vector3;
  44804. private _projectionTexture;
  44805. /**
  44806. * Gets the projection texture of the light.
  44807. */
  44808. /**
  44809. * Sets the projection texture of the light.
  44810. */
  44811. projectionTexture: Nullable<BaseTexture>;
  44812. private _projectionTextureViewLightDirty;
  44813. private _projectionTextureProjectionLightDirty;
  44814. private _projectionTextureDirty;
  44815. private _projectionTextureViewTargetVector;
  44816. private _projectionTextureViewLightMatrix;
  44817. private _projectionTextureProjectionLightMatrix;
  44818. private _projectionTextureScalingMatrix;
  44819. /**
  44820. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44821. * It can cast shadows.
  44822. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44823. * @param name The light friendly name
  44824. * @param position The position of the spot light in the scene
  44825. * @param direction The direction of the light in the scene
  44826. * @param angle The cone angle of the light in Radians
  44827. * @param exponent The light decay speed with the distance from the emission spot
  44828. * @param scene The scene the lights belongs to
  44829. */
  44830. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44831. /**
  44832. * Returns the string "SpotLight".
  44833. * @returns the class name
  44834. */
  44835. getClassName(): string;
  44836. /**
  44837. * Returns the integer 2.
  44838. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44839. */
  44840. getTypeID(): number;
  44841. /**
  44842. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44843. */
  44844. protected _setDirection(value: Vector3): void;
  44845. /**
  44846. * Overrides the position setter to recompute the projection texture view light Matrix.
  44847. */
  44848. protected _setPosition(value: Vector3): void;
  44849. /**
  44850. * Sets the passed matrix "matrix" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.
  44851. * Returns the SpotLight.
  44852. */
  44853. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44854. protected _computeProjectionTextureViewLightMatrix(): void;
  44855. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44856. /**
  44857. * Main function for light texture projection matrix computing.
  44858. */
  44859. protected _computeProjectionTextureMatrix(): void;
  44860. protected _buildUniformLayout(): void;
  44861. private _computeAngleValues;
  44862. /**
  44863. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44864. * @param effect The effect to update
  44865. * @param lightIndex The index of the light in the effect to update
  44866. * @returns The spot light
  44867. */
  44868. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44869. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  44870. /**
  44871. * Disposes the light and the associated resources.
  44872. */
  44873. dispose(): void;
  44874. /**
  44875. * Prepares the list of defines specific to the light type.
  44876. * @param defines the list of defines
  44877. * @param lightIndex defines the index of the light for the effect
  44878. */
  44879. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44880. }
  44881. }
  44882. declare module BABYLON {
  44883. /**
  44884. * Gizmo that enables viewing a light
  44885. */
  44886. export class LightGizmo extends Gizmo {
  44887. private _lightMesh;
  44888. private _material;
  44889. private cachedPosition;
  44890. private cachedForward;
  44891. /**
  44892. * Creates a LightGizmo
  44893. * @param gizmoLayer The utility layer the gizmo will be added to
  44894. */
  44895. constructor(gizmoLayer?: UtilityLayerRenderer);
  44896. private _light;
  44897. /**
  44898. * The light that the gizmo is attached to
  44899. */
  44900. light: Nullable<Light>;
  44901. /**
  44902. * Gets the material used to render the light gizmo
  44903. */
  44904. readonly material: StandardMaterial;
  44905. /**
  44906. * @hidden
  44907. * Updates the gizmo to match the attached mesh's position/rotation
  44908. */
  44909. protected _update(): void;
  44910. private static _Scale;
  44911. /**
  44912. * Creates the lines for a light mesh
  44913. */
  44914. private static _createLightLines;
  44915. /**
  44916. * Disposes of the light gizmo
  44917. */
  44918. dispose(): void;
  44919. private static _CreateHemisphericLightMesh;
  44920. private static _CreatePointLightMesh;
  44921. private static _CreateSpotLightMesh;
  44922. private static _CreateDirectionalLightMesh;
  44923. }
  44924. }
  44925. declare module BABYLON {
  44926. /** @hidden */
  44927. export var backgroundFragmentDeclaration: {
  44928. name: string;
  44929. shader: string;
  44930. };
  44931. }
  44932. declare module BABYLON {
  44933. /** @hidden */
  44934. export var backgroundUboDeclaration: {
  44935. name: string;
  44936. shader: string;
  44937. };
  44938. }
  44939. declare module BABYLON {
  44940. /** @hidden */
  44941. export var backgroundPixelShader: {
  44942. name: string;
  44943. shader: string;
  44944. };
  44945. }
  44946. declare module BABYLON {
  44947. /** @hidden */
  44948. export var backgroundVertexDeclaration: {
  44949. name: string;
  44950. shader: string;
  44951. };
  44952. }
  44953. declare module BABYLON {
  44954. /** @hidden */
  44955. export var backgroundVertexShader: {
  44956. name: string;
  44957. shader: string;
  44958. };
  44959. }
  44960. declare module BABYLON {
  44961. /**
  44962. * Background material used to create an efficient environement around your scene.
  44963. */
  44964. export class BackgroundMaterial extends PushMaterial {
  44965. /**
  44966. * Standard reflectance value at parallel view angle.
  44967. */
  44968. static StandardReflectance0: number;
  44969. /**
  44970. * Standard reflectance value at grazing angle.
  44971. */
  44972. static StandardReflectance90: number;
  44973. protected _primaryColor: Color3;
  44974. /**
  44975. * Key light Color (multiply against the environement texture)
  44976. */
  44977. primaryColor: Color3;
  44978. protected __perceptualColor: Nullable<Color3>;
  44979. /**
  44980. * Experimental Internal Use Only.
  44981. *
  44982. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44983. * This acts as a helper to set the primary color to a more "human friendly" value.
  44984. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44985. * output color as close as possible from the chosen value.
  44986. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44987. * part of lighting setup.)
  44988. */ private _perceptualColor: Nullable<Color3>;
  44989. protected _primaryColorShadowLevel: float;
  44990. /**
  44991. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44992. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44993. */
  44994. primaryColorShadowLevel: float;
  44995. protected _primaryColorHighlightLevel: float;
  44996. /**
  44997. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44998. * The primary color is used at the level chosen to define what the white area would look.
  44999. */
  45000. primaryColorHighlightLevel: float;
  45001. protected _reflectionTexture: Nullable<BaseTexture>;
  45002. /**
  45003. * Reflection Texture used in the material.
  45004. * Should be author in a specific way for the best result (refer to the documentation).
  45005. */
  45006. reflectionTexture: Nullable<BaseTexture>;
  45007. protected _reflectionBlur: float;
  45008. /**
  45009. * Reflection Texture level of blur.
  45010. *
  45011. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45012. * texture twice.
  45013. */
  45014. reflectionBlur: float;
  45015. protected _diffuseTexture: Nullable<BaseTexture>;
  45016. /**
  45017. * Diffuse Texture used in the material.
  45018. * Should be author in a specific way for the best result (refer to the documentation).
  45019. */
  45020. diffuseTexture: Nullable<BaseTexture>;
  45021. protected _shadowLights: Nullable<IShadowLight[]>;
  45022. /**
  45023. * Specify the list of lights casting shadow on the material.
  45024. * All scene shadow lights will be included if null.
  45025. */
  45026. shadowLights: Nullable<IShadowLight[]>;
  45027. protected _shadowLevel: float;
  45028. /**
  45029. * Helps adjusting the shadow to a softer level if required.
  45030. * 0 means black shadows and 1 means no shadows.
  45031. */
  45032. shadowLevel: float;
  45033. protected _sceneCenter: Vector3;
  45034. /**
  45035. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45036. * It is usually zero but might be interesting to modify according to your setup.
  45037. */
  45038. sceneCenter: Vector3;
  45039. protected _opacityFresnel: boolean;
  45040. /**
  45041. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45042. * This helps ensuring a nice transition when the camera goes under the ground.
  45043. */
  45044. opacityFresnel: boolean;
  45045. protected _reflectionFresnel: boolean;
  45046. /**
  45047. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45048. * This helps adding a mirror texture on the ground.
  45049. */
  45050. reflectionFresnel: boolean;
  45051. protected _reflectionFalloffDistance: number;
  45052. /**
  45053. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45054. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45055. */
  45056. reflectionFalloffDistance: number;
  45057. protected _reflectionAmount: number;
  45058. /**
  45059. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45060. */
  45061. reflectionAmount: number;
  45062. protected _reflectionReflectance0: number;
  45063. /**
  45064. * This specifies the weight of the reflection at grazing angle.
  45065. */
  45066. reflectionReflectance0: number;
  45067. protected _reflectionReflectance90: number;
  45068. /**
  45069. * This specifies the weight of the reflection at a perpendicular point of view.
  45070. */
  45071. reflectionReflectance90: number;
  45072. /**
  45073. * Sets the reflection reflectance fresnel values according to the default standard
  45074. * empirically know to work well :-)
  45075. */
  45076. reflectionStandardFresnelWeight: number;
  45077. protected _useRGBColor: boolean;
  45078. /**
  45079. * Helps to directly use the maps channels instead of their level.
  45080. */
  45081. useRGBColor: boolean;
  45082. protected _enableNoise: boolean;
  45083. /**
  45084. * This helps reducing the banding effect that could occur on the background.
  45085. */
  45086. enableNoise: boolean;
  45087. /**
  45088. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45089. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45090. * Recommended to be keep at 1.0 except for special cases.
  45091. */
  45092. fovMultiplier: number;
  45093. private _fovMultiplier;
  45094. /**
  45095. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45096. */
  45097. useEquirectangularFOV: boolean;
  45098. private _maxSimultaneousLights;
  45099. /**
  45100. * Number of Simultaneous lights allowed on the material.
  45101. */
  45102. maxSimultaneousLights: int;
  45103. /**
  45104. * Default configuration related to image processing available in the Background Material.
  45105. */
  45106. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45107. /**
  45108. * Keep track of the image processing observer to allow dispose and replace.
  45109. */
  45110. private _imageProcessingObserver;
  45111. /**
  45112. * Attaches a new image processing configuration to the PBR Material.
  45113. * @param configuration (if null the scene configuration will be use)
  45114. */
  45115. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45116. /**
  45117. * Gets the image processing configuration used either in this material.
  45118. */
  45119. /**
  45120. * Sets the Default image processing configuration used either in the this material.
  45121. *
  45122. * If sets to null, the scene one is in use.
  45123. */
  45124. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45125. /**
  45126. * Gets wether the color curves effect is enabled.
  45127. */
  45128. /**
  45129. * Sets wether the color curves effect is enabled.
  45130. */
  45131. cameraColorCurvesEnabled: boolean;
  45132. /**
  45133. * Gets wether the color grading effect is enabled.
  45134. */
  45135. /**
  45136. * Gets wether the color grading effect is enabled.
  45137. */
  45138. cameraColorGradingEnabled: boolean;
  45139. /**
  45140. * Gets wether tonemapping is enabled or not.
  45141. */
  45142. /**
  45143. * Sets wether tonemapping is enabled or not
  45144. */
  45145. cameraToneMappingEnabled: boolean;
  45146. /**
  45147. * The camera exposure used on this material.
  45148. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45149. * This corresponds to a photographic exposure.
  45150. */
  45151. /**
  45152. * The camera exposure used on this material.
  45153. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45154. * This corresponds to a photographic exposure.
  45155. */
  45156. cameraExposure: float;
  45157. /**
  45158. * Gets The camera contrast used on this material.
  45159. */
  45160. /**
  45161. * Sets The camera contrast used on this material.
  45162. */
  45163. cameraContrast: float;
  45164. /**
  45165. * Gets the Color Grading 2D Lookup Texture.
  45166. */
  45167. /**
  45168. * Sets the Color Grading 2D Lookup Texture.
  45169. */
  45170. cameraColorGradingTexture: Nullable<BaseTexture>;
  45171. /**
  45172. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45173. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45174. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  45175. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45176. */
  45177. /**
  45178. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45179. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45180. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  45181. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45182. */
  45183. cameraColorCurves: Nullable<ColorCurves>;
  45184. /**
  45185. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45186. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45187. */
  45188. switchToBGR: boolean;
  45189. private _renderTargets;
  45190. private _reflectionControls;
  45191. private _white;
  45192. private _primaryShadowColor;
  45193. private _primaryHighlightColor;
  45194. /**
  45195. * Instantiates a Background Material in the given scene
  45196. * @param name The friendly name of the material
  45197. * @param scene The scene to add the material to
  45198. */
  45199. constructor(name: string, scene: Scene);
  45200. /**
  45201. * Gets a boolean indicating that current material needs to register RTT
  45202. */
  45203. readonly hasRenderTargetTextures: boolean;
  45204. /**
  45205. * The entire material has been created in order to prevent overdraw.
  45206. * @returns false
  45207. */
  45208. needAlphaTesting(): boolean;
  45209. /**
  45210. * The entire material has been created in order to prevent overdraw.
  45211. * @returns true if blending is enable
  45212. */
  45213. needAlphaBlending(): boolean;
  45214. /**
  45215. * Checks wether the material is ready to be rendered for a given mesh.
  45216. * @param mesh The mesh to render
  45217. * @param subMesh The submesh to check against
  45218. * @param useInstances Specify wether or not the material is used with instances
  45219. * @returns true if all the dependencies are ready (Textures, Effects...)
  45220. */
  45221. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45222. /**
  45223. * Compute the primary color according to the chosen perceptual color.
  45224. */
  45225. private _computePrimaryColorFromPerceptualColor;
  45226. /**
  45227. * Compute the highlights and shadow colors according to their chosen levels.
  45228. */
  45229. private _computePrimaryColors;
  45230. /**
  45231. * Build the uniform buffer used in the material.
  45232. */
  45233. buildUniformLayout(): void;
  45234. /**
  45235. * Unbind the material.
  45236. */
  45237. unbind(): void;
  45238. /**
  45239. * Bind only the world matrix to the material.
  45240. * @param world The world matrix to bind.
  45241. */
  45242. bindOnlyWorldMatrix(world: Matrix): void;
  45243. /**
  45244. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45245. * @param world The world matrix to bind.
  45246. * @param subMesh The submesh to bind for.
  45247. */
  45248. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45249. /**
  45250. * Checks to see if a texture is used in the material.
  45251. * @param texture - Base texture to use.
  45252. * @returns - Boolean specifying if a texture is used in the material.
  45253. */
  45254. hasTexture(texture: BaseTexture): boolean;
  45255. /**
  45256. * Dispose the material.
  45257. * @param forceDisposeEffect Force disposal of the associated effect.
  45258. * @param forceDisposeTextures Force disposal of the associated textures.
  45259. */
  45260. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45261. /**
  45262. * Clones the material.
  45263. * @param name The cloned name.
  45264. * @returns The cloned material.
  45265. */
  45266. clone(name: string): BackgroundMaterial;
  45267. /**
  45268. * Serializes the current material to its JSON representation.
  45269. * @returns The JSON representation.
  45270. */
  45271. serialize(): any;
  45272. /**
  45273. * Gets the class name of the material
  45274. * @returns "BackgroundMaterial"
  45275. */
  45276. getClassName(): string;
  45277. /**
  45278. * Parse a JSON input to create back a background material.
  45279. * @param source The JSON data to parse
  45280. * @param scene The scene to create the parsed material in
  45281. * @param rootUrl The root url of the assets the material depends upon
  45282. * @returns the instantiated BackgroundMaterial.
  45283. */
  45284. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45285. }
  45286. }
  45287. declare module BABYLON {
  45288. /**
  45289. * Represents the different options available during the creation of
  45290. * a Environment helper.
  45291. *
  45292. * This can control the default ground, skybox and image processing setup of your scene.
  45293. */
  45294. export interface IEnvironmentHelperOptions {
  45295. /**
  45296. * Specifies wether or not to create a ground.
  45297. * True by default.
  45298. */
  45299. createGround: boolean;
  45300. /**
  45301. * Specifies the ground size.
  45302. * 15 by default.
  45303. */
  45304. groundSize: number;
  45305. /**
  45306. * The texture used on the ground for the main color.
  45307. * Comes from the BabylonJS CDN by default.
  45308. *
  45309. * Remarks: Can be either a texture or a url.
  45310. */
  45311. groundTexture: string | BaseTexture;
  45312. /**
  45313. * The color mixed in the ground texture by default.
  45314. * BabylonJS clearColor by default.
  45315. */
  45316. groundColor: Color3;
  45317. /**
  45318. * Specifies the ground opacity.
  45319. * 1 by default.
  45320. */
  45321. groundOpacity: number;
  45322. /**
  45323. * Enables the ground to receive shadows.
  45324. * True by default.
  45325. */
  45326. enableGroundShadow: boolean;
  45327. /**
  45328. * Helps preventing the shadow to be fully black on the ground.
  45329. * 0.5 by default.
  45330. */
  45331. groundShadowLevel: number;
  45332. /**
  45333. * Creates a mirror texture attach to the ground.
  45334. * false by default.
  45335. */
  45336. enableGroundMirror: boolean;
  45337. /**
  45338. * Specifies the ground mirror size ratio.
  45339. * 0.3 by default as the default kernel is 64.
  45340. */
  45341. groundMirrorSizeRatio: number;
  45342. /**
  45343. * Specifies the ground mirror blur kernel size.
  45344. * 64 by default.
  45345. */
  45346. groundMirrorBlurKernel: number;
  45347. /**
  45348. * Specifies the ground mirror visibility amount.
  45349. * 1 by default
  45350. */
  45351. groundMirrorAmount: number;
  45352. /**
  45353. * Specifies the ground mirror reflectance weight.
  45354. * This uses the standard weight of the background material to setup the fresnel effect
  45355. * of the mirror.
  45356. * 1 by default.
  45357. */
  45358. groundMirrorFresnelWeight: number;
  45359. /**
  45360. * Specifies the ground mirror Falloff distance.
  45361. * This can helps reducing the size of the reflection.
  45362. * 0 by Default.
  45363. */
  45364. groundMirrorFallOffDistance: number;
  45365. /**
  45366. * Specifies the ground mirror texture type.
  45367. * Unsigned Int by Default.
  45368. */
  45369. groundMirrorTextureType: number;
  45370. /**
  45371. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45372. * the shown objects.
  45373. */
  45374. groundYBias: number;
  45375. /**
  45376. * Specifies wether or not to create a skybox.
  45377. * True by default.
  45378. */
  45379. createSkybox: boolean;
  45380. /**
  45381. * Specifies the skybox size.
  45382. * 20 by default.
  45383. */
  45384. skyboxSize: number;
  45385. /**
  45386. * The texture used on the skybox for the main color.
  45387. * Comes from the BabylonJS CDN by default.
  45388. *
  45389. * Remarks: Can be either a texture or a url.
  45390. */
  45391. skyboxTexture: string | BaseTexture;
  45392. /**
  45393. * The color mixed in the skybox texture by default.
  45394. * BabylonJS clearColor by default.
  45395. */
  45396. skyboxColor: Color3;
  45397. /**
  45398. * The background rotation around the Y axis of the scene.
  45399. * This helps aligning the key lights of your scene with the background.
  45400. * 0 by default.
  45401. */
  45402. backgroundYRotation: number;
  45403. /**
  45404. * Compute automatically the size of the elements to best fit with the scene.
  45405. */
  45406. sizeAuto: boolean;
  45407. /**
  45408. * Default position of the rootMesh if autoSize is not true.
  45409. */
  45410. rootPosition: Vector3;
  45411. /**
  45412. * Sets up the image processing in the scene.
  45413. * true by default.
  45414. */
  45415. setupImageProcessing: boolean;
  45416. /**
  45417. * The texture used as your environment texture in the scene.
  45418. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45419. *
  45420. * Remarks: Can be either a texture or a url.
  45421. */
  45422. environmentTexture: string | BaseTexture;
  45423. /**
  45424. * The value of the exposure to apply to the scene.
  45425. * 0.6 by default if setupImageProcessing is true.
  45426. */
  45427. cameraExposure: number;
  45428. /**
  45429. * The value of the contrast to apply to the scene.
  45430. * 1.6 by default if setupImageProcessing is true.
  45431. */
  45432. cameraContrast: number;
  45433. /**
  45434. * Specifies wether or not tonemapping should be enabled in the scene.
  45435. * true by default if setupImageProcessing is true.
  45436. */
  45437. toneMappingEnabled: boolean;
  45438. }
  45439. /**
  45440. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45441. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45442. * It also helps with the default setup of your imageProcessing configuration.
  45443. */
  45444. export class EnvironmentHelper {
  45445. /**
  45446. * Default ground texture URL.
  45447. */
  45448. private static _groundTextureCDNUrl;
  45449. /**
  45450. * Default skybox texture URL.
  45451. */
  45452. private static _skyboxTextureCDNUrl;
  45453. /**
  45454. * Default environment texture URL.
  45455. */
  45456. private static _environmentTextureCDNUrl;
  45457. /**
  45458. * Creates the default options for the helper.
  45459. */
  45460. private static _getDefaultOptions;
  45461. private _rootMesh;
  45462. /**
  45463. * Gets the root mesh created by the helper.
  45464. */
  45465. readonly rootMesh: Mesh;
  45466. private _skybox;
  45467. /**
  45468. * Gets the skybox created by the helper.
  45469. */
  45470. readonly skybox: Nullable<Mesh>;
  45471. private _skyboxTexture;
  45472. /**
  45473. * Gets the skybox texture created by the helper.
  45474. */
  45475. readonly skyboxTexture: Nullable<BaseTexture>;
  45476. private _skyboxMaterial;
  45477. /**
  45478. * Gets the skybox material created by the helper.
  45479. */
  45480. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45481. private _ground;
  45482. /**
  45483. * Gets the ground mesh created by the helper.
  45484. */
  45485. readonly ground: Nullable<Mesh>;
  45486. private _groundTexture;
  45487. /**
  45488. * Gets the ground texture created by the helper.
  45489. */
  45490. readonly groundTexture: Nullable<BaseTexture>;
  45491. private _groundMirror;
  45492. /**
  45493. * Gets the ground mirror created by the helper.
  45494. */
  45495. readonly groundMirror: Nullable<MirrorTexture>;
  45496. /**
  45497. * Gets the ground mirror render list to helps pushing the meshes
  45498. * you wish in the ground reflection.
  45499. */
  45500. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45501. private _groundMaterial;
  45502. /**
  45503. * Gets the ground material created by the helper.
  45504. */
  45505. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45506. /**
  45507. * Stores the creation options.
  45508. */
  45509. private readonly _scene;
  45510. private _options;
  45511. /**
  45512. * This observable will be notified with any error during the creation of the environment,
  45513. * mainly texture creation errors.
  45514. */
  45515. onErrorObservable: Observable<{
  45516. message?: string;
  45517. exception?: any;
  45518. }>;
  45519. /**
  45520. * constructor
  45521. * @param options Defines the options we want to customize the helper
  45522. * @param scene The scene to add the material to
  45523. */
  45524. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45525. /**
  45526. * Updates the background according to the new options
  45527. * @param options
  45528. */
  45529. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45530. /**
  45531. * Sets the primary color of all the available elements.
  45532. * @param color the main color to affect to the ground and the background
  45533. */
  45534. setMainColor(color: Color3): void;
  45535. /**
  45536. * Setup the image processing according to the specified options.
  45537. */
  45538. private _setupImageProcessing;
  45539. /**
  45540. * Setup the environment texture according to the specified options.
  45541. */
  45542. private _setupEnvironmentTexture;
  45543. /**
  45544. * Setup the background according to the specified options.
  45545. */
  45546. private _setupBackground;
  45547. /**
  45548. * Get the scene sizes according to the setup.
  45549. */
  45550. private _getSceneSize;
  45551. /**
  45552. * Setup the ground according to the specified options.
  45553. */
  45554. private _setupGround;
  45555. /**
  45556. * Setup the ground material according to the specified options.
  45557. */
  45558. private _setupGroundMaterial;
  45559. /**
  45560. * Setup the ground diffuse texture according to the specified options.
  45561. */
  45562. private _setupGroundDiffuseTexture;
  45563. /**
  45564. * Setup the ground mirror texture according to the specified options.
  45565. */
  45566. private _setupGroundMirrorTexture;
  45567. /**
  45568. * Setup the ground to receive the mirror texture.
  45569. */
  45570. private _setupMirrorInGroundMaterial;
  45571. /**
  45572. * Setup the skybox according to the specified options.
  45573. */
  45574. private _setupSkybox;
  45575. /**
  45576. * Setup the skybox material according to the specified options.
  45577. */
  45578. private _setupSkyboxMaterial;
  45579. /**
  45580. * Setup the skybox reflection texture according to the specified options.
  45581. */
  45582. private _setupSkyboxReflectionTexture;
  45583. private _errorHandler;
  45584. /**
  45585. * Dispose all the elements created by the Helper.
  45586. */
  45587. dispose(): void;
  45588. }
  45589. }
  45590. declare module BABYLON {
  45591. /**
  45592. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45593. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45594. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45595. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45596. */
  45597. export class PhotoDome extends TransformNode {
  45598. /**
  45599. * Define the image as a Monoscopic panoramic 360 image.
  45600. */
  45601. static readonly MODE_MONOSCOPIC: number;
  45602. /**
  45603. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45604. */
  45605. static readonly MODE_TOPBOTTOM: number;
  45606. /**
  45607. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45608. */
  45609. static readonly MODE_SIDEBYSIDE: number;
  45610. private _useDirectMapping;
  45611. /**
  45612. * The texture being displayed on the sphere
  45613. */
  45614. protected _photoTexture: Texture;
  45615. /**
  45616. * Gets or sets the texture being displayed on the sphere
  45617. */
  45618. photoTexture: Texture;
  45619. /**
  45620. * Observable raised when an error occured while loading the 360 image
  45621. */
  45622. onLoadErrorObservable: Observable<string>;
  45623. /**
  45624. * The skybox material
  45625. */
  45626. protected _material: BackgroundMaterial;
  45627. /**
  45628. * The surface used for the skybox
  45629. */
  45630. protected _mesh: Mesh;
  45631. /**
  45632. * Gets the mesh used for the skybox.
  45633. */
  45634. readonly mesh: Mesh;
  45635. /**
  45636. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45637. * Also see the options.resolution property.
  45638. */
  45639. fovMultiplier: number;
  45640. private _imageMode;
  45641. /**
  45642. * Gets or set the current video mode for the video. It can be:
  45643. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  45644. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  45645. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  45646. */
  45647. imageMode: number;
  45648. /**
  45649. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45650. * @param name Element's name, child elements will append suffixes for their own names.
  45651. * @param urlsOfPhoto defines the url of the photo to display
  45652. * @param options defines an object containing optional or exposed sub element properties
  45653. * @param onError defines a callback called when an error occured while loading the texture
  45654. */
  45655. constructor(name: string, urlOfPhoto: string, options: {
  45656. resolution?: number;
  45657. size?: number;
  45658. useDirectMapping?: boolean;
  45659. faceForward?: boolean;
  45660. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45661. private _onBeforeCameraRenderObserver;
  45662. private _changeImageMode;
  45663. /**
  45664. * Releases resources associated with this node.
  45665. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45666. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45667. */
  45668. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45669. }
  45670. }
  45671. declare module BABYLON {
  45672. /**
  45673. * Class used to host RGBD texture specific utilities
  45674. */
  45675. export class RGBDTextureTools {
  45676. /**
  45677. * Expand the RGBD Texture from RGBD to Half Float if possible.
  45678. * @param texture the texture to expand.
  45679. */
  45680. static ExpandRGBDTexture(texture: Texture): void;
  45681. }
  45682. }
  45683. declare module BABYLON {
  45684. /**
  45685. * Class used to host texture specific utilities
  45686. */
  45687. export class BRDFTextureTools {
  45688. /**
  45689. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45690. * @param scene defines the hosting scene
  45691. * @returns the environment BRDF texture
  45692. */
  45693. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45694. private static _environmentBRDFBase64Texture;
  45695. }
  45696. }
  45697. declare module BABYLON {
  45698. /**
  45699. * @hidden
  45700. */
  45701. export interface IMaterialClearCoatDefines {
  45702. CLEARCOAT: boolean;
  45703. CLEARCOAT_DEFAULTIOR: boolean;
  45704. CLEARCOAT_TEXTURE: boolean;
  45705. CLEARCOAT_TEXTUREDIRECTUV: number;
  45706. CLEARCOAT_BUMP: boolean;
  45707. CLEARCOAT_BUMPDIRECTUV: number;
  45708. CLEARCOAT_TINT: boolean;
  45709. CLEARCOAT_TINT_TEXTURE: boolean;
  45710. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45711. /** @hidden */ private _areTexturesDirty: boolean;
  45712. }
  45713. /**
  45714. * Define the code related to the clear coat parameters of the pbr material.
  45715. */
  45716. export class PBRClearCoatConfiguration {
  45717. /**
  45718. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45719. * The default fits with a polyurethane material.
  45720. */
  45721. private static readonly _DefaultIndexOfRefraction;
  45722. private _isEnabled;
  45723. /**
  45724. * Defines if the clear coat is enabled in the material.
  45725. */
  45726. isEnabled: boolean;
  45727. /**
  45728. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45729. */
  45730. intensity: number;
  45731. /**
  45732. * Defines the clear coat layer roughness.
  45733. */
  45734. roughness: number;
  45735. private _indexOfRefraction;
  45736. /**
  45737. * Defines the index of refraction of the clear coat.
  45738. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45739. * The default fits with a polyurethane material.
  45740. * Changing the default value is more performance intensive.
  45741. */
  45742. indexOfRefraction: number;
  45743. private _texture;
  45744. /**
  45745. * Stores the clear coat values in a texture.
  45746. */
  45747. texture: Nullable<BaseTexture>;
  45748. private _bumpTexture;
  45749. /**
  45750. * Define the clear coat specific bump texture.
  45751. */
  45752. bumpTexture: Nullable<BaseTexture>;
  45753. private _isTintEnabled;
  45754. /**
  45755. * Defines if the clear coat tint is enabled in the material.
  45756. */
  45757. isTintEnabled: boolean;
  45758. /**
  45759. * Defines the clear coat tint of the material.
  45760. * This is only use if tint is enabled
  45761. */
  45762. tintColor: Color3;
  45763. /**
  45764. * Defines the distance at which the tint color should be found in the
  45765. * clear coat media.
  45766. * This is only use if tint is enabled
  45767. */
  45768. tintColorAtDistance: number;
  45769. /**
  45770. * Defines the clear coat layer thickness.
  45771. * This is only use if tint is enabled
  45772. */
  45773. tintThickness: number;
  45774. private _tintTexture;
  45775. /**
  45776. * Stores the clear tint values in a texture.
  45777. * rgb is tint
  45778. * a is a thickness factor
  45779. */
  45780. tintTexture: Nullable<BaseTexture>;
  45781. /** @hidden */
  45782. private _internalMarkAllSubMeshesAsTexturesDirty;
  45783. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45784. /**
  45785. * Instantiate a new istance of clear coat configuration.
  45786. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45787. */
  45788. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45789. /**
  45790. * Gets wehter the submesh is ready to be used or not.
  45791. * @param defines the list of "defines" to update.
  45792. * @param scene defines the scene the material belongs to.
  45793. * @param engine defines the engine the material belongs to.
  45794. * @param disableBumpMap defines wether the material disables bump or not.
  45795. * @returns - boolean indicating that the submesh is ready or not.
  45796. */
  45797. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45798. /**
  45799. * Checks to see if a texture is used in the material.
  45800. * @param defines the list of "defines" to update.
  45801. * @param scene defines the scene to the material belongs to.
  45802. */
  45803. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45804. /**
  45805. * Binds the material data.
  45806. * @param uniformBuffer defines the Uniform buffer to fill in.
  45807. * @param scene defines the scene the material belongs to.
  45808. * @param engine defines the engine the material belongs to.
  45809. * @param disableBumpMap defines wether the material disables bump or not.
  45810. * @param isFrozen defines wether the material is frozen or not.
  45811. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45812. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45813. */
  45814. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45815. /**
  45816. * Checks to see if a texture is used in the material.
  45817. * @param texture - Base texture to use.
  45818. * @returns - Boolean specifying if a texture is used in the material.
  45819. */
  45820. hasTexture(texture: BaseTexture): boolean;
  45821. /**
  45822. * Returns an array of the actively used textures.
  45823. * @param activeTextures Array of BaseTextures
  45824. */
  45825. getActiveTextures(activeTextures: BaseTexture[]): void;
  45826. /**
  45827. * Returns the animatable textures.
  45828. * @param animatables Array of animatable textures.
  45829. */
  45830. getAnimatables(animatables: IAnimatable[]): void;
  45831. /**
  45832. * Disposes the resources of the material.
  45833. * @param forceDisposeTextures - Forces the disposal of all textures.
  45834. */
  45835. dispose(forceDisposeTextures?: boolean): void;
  45836. /**
  45837. * Get the current class name of the texture useful for serialization or dynamic coding.
  45838. * @returns "PBRClearCoatConfiguration"
  45839. */
  45840. getClassName(): string;
  45841. /**
  45842. * Add fallbacks to the effect fallbacks list.
  45843. * @param defines defines the Base texture to use.
  45844. * @param fallbacks defines the current fallback list.
  45845. * @param currentRank defines the current fallback rank.
  45846. * @returns the new fallback rank.
  45847. */
  45848. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45849. /**
  45850. * Add the required uniforms to the current list.
  45851. * @param uniforms defines the current uniform list.
  45852. */
  45853. static AddUniforms(uniforms: string[]): void;
  45854. /**
  45855. * Add the required samplers to the current list.
  45856. * @param samplers defines the current sampler list.
  45857. */
  45858. static AddSamplers(samplers: string[]): void;
  45859. /**
  45860. * Add the required uniforms to the current buffer.
  45861. * @param uniformBuffer defines the current uniform buffer.
  45862. */
  45863. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45864. /**
  45865. * Makes a duplicate of the current configuration into another one.
  45866. * @param clearCoatConfiguration define the config where to copy the info
  45867. */
  45868. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45869. /**
  45870. * Serializes this clear coat configuration.
  45871. * @returns - An object with the serialized config.
  45872. */
  45873. serialize(): any;
  45874. /**
  45875. * Parses a anisotropy Configuration from a serialized object.
  45876. * @param source - Serialized object.
  45877. * @param scene Defines the scene we are parsing for
  45878. * @param rootUrl Defines the rootUrl to load from
  45879. */
  45880. parse(source: any, scene: Scene, rootUrl: string): void;
  45881. }
  45882. }
  45883. declare module BABYLON {
  45884. /**
  45885. * @hidden
  45886. */
  45887. export interface IMaterialAnisotropicDefines {
  45888. ANISOTROPIC: boolean;
  45889. ANISOTROPIC_TEXTURE: boolean;
  45890. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45891. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  45892. }
  45893. /**
  45894. * Define the code related to the anisotropic parameters of the pbr material.
  45895. */
  45896. export class PBRAnisotropicConfiguration {
  45897. private _isEnabled;
  45898. /**
  45899. * Defines if the anisotropy is enabled in the material.
  45900. */
  45901. isEnabled: boolean;
  45902. /**
  45903. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45904. */
  45905. intensity: number;
  45906. /**
  45907. * Defines if the effect is along the tangents, bitangents or in between.
  45908. * By default, the effect is "strectching" the highlights along the tangents.
  45909. */
  45910. direction: Vector2;
  45911. private _texture;
  45912. /**
  45913. * Stores the anisotropy values in a texture.
  45914. * rg is direction (like normal from -1 to 1)
  45915. * b is a intensity
  45916. */
  45917. texture: Nullable<BaseTexture>;
  45918. /** @hidden */
  45919. private _internalMarkAllSubMeshesAsTexturesDirty;
  45920. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45921. /**
  45922. * Instantiate a new istance of anisotropy configuration.
  45923. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45924. */
  45925. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45926. /**
  45927. * Specifies that the submesh is ready to be used.
  45928. * @param defines the list of "defines" to update.
  45929. * @param scene defines the scene the material belongs to.
  45930. * @returns - boolean indicating that the submesh is ready or not.
  45931. */
  45932. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45933. /**
  45934. * Checks to see if a texture is used in the material.
  45935. * @param defines the list of "defines" to update.
  45936. * @param mesh the mesh we are preparing the defines for.
  45937. * @param scene defines the scene the material belongs to.
  45938. */
  45939. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45940. /**
  45941. * Binds the material data.
  45942. * @param uniformBuffer defines the Uniform buffer to fill in.
  45943. * @param scene defines the scene the material belongs to.
  45944. * @param isFrozen defines wether the material is frozen or not.
  45945. */
  45946. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45947. /**
  45948. * Checks to see if a texture is used in the material.
  45949. * @param texture - Base texture to use.
  45950. * @returns - Boolean specifying if a texture is used in the material.
  45951. */
  45952. hasTexture(texture: BaseTexture): boolean;
  45953. /**
  45954. * Returns an array of the actively used textures.
  45955. * @param activeTextures Array of BaseTextures
  45956. */
  45957. getActiveTextures(activeTextures: BaseTexture[]): void;
  45958. /**
  45959. * Returns the animatable textures.
  45960. * @param animatables Array of animatable textures.
  45961. */
  45962. getAnimatables(animatables: IAnimatable[]): void;
  45963. /**
  45964. * Disposes the resources of the material.
  45965. * @param forceDisposeTextures - Forces the disposal of all textures.
  45966. */
  45967. dispose(forceDisposeTextures?: boolean): void;
  45968. /**
  45969. * Get the current class name of the texture useful for serialization or dynamic coding.
  45970. * @returns "PBRAnisotropicConfiguration"
  45971. */
  45972. getClassName(): string;
  45973. /**
  45974. * Add fallbacks to the effect fallbacks list.
  45975. * @param defines defines the Base texture to use.
  45976. * @param fallbacks defines the current fallback list.
  45977. * @param currentRank defines the current fallback rank.
  45978. * @returns the new fallback rank.
  45979. */
  45980. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45981. /**
  45982. * Add the required uniforms to the current list.
  45983. * @param uniforms defines the current uniform list.
  45984. */
  45985. static AddUniforms(uniforms: string[]): void;
  45986. /**
  45987. * Add the required uniforms to the current buffer.
  45988. * @param uniformBuffer defines the current uniform buffer.
  45989. */
  45990. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45991. /**
  45992. * Add the required samplers to the current list.
  45993. * @param samplers defines the current sampler list.
  45994. */
  45995. static AddSamplers(samplers: string[]): void;
  45996. /**
  45997. * Makes a duplicate of the current configuration into another one.
  45998. * @param anisotropicConfiguration define the config where to copy the info
  45999. */
  46000. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46001. /**
  46002. * Serializes this anisotropy configuration.
  46003. * @returns - An object with the serialized config.
  46004. */
  46005. serialize(): any;
  46006. /**
  46007. * Parses a anisotropy Configuration from a serialized object.
  46008. * @param source - Serialized object.
  46009. * @param scene Defines the scene we are parsing for
  46010. * @param rootUrl Defines the rootUrl to load from
  46011. */
  46012. parse(source: any, scene: Scene, rootUrl: string): void;
  46013. }
  46014. }
  46015. declare module BABYLON {
  46016. /**
  46017. * @hidden
  46018. */
  46019. export interface IMaterialBRDFDefines {
  46020. BRDF_V_HEIGHT_CORRELATED: boolean;
  46021. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46022. SPHERICAL_HARMONICS: boolean;
  46023. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46024. /** @hidden */ private _areMiscDirty: boolean;
  46025. }
  46026. /**
  46027. * Define the code related to the BRDF parameters of the pbr material.
  46028. */
  46029. export class PBRBRDFConfiguration {
  46030. /**
  46031. * Default value used for the energy conservation.
  46032. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46033. */
  46034. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46035. /**
  46036. * Default value used for the Smith Visibility Height Correlated mode.
  46037. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46038. */
  46039. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46040. /**
  46041. * Default value used for the IBL diffuse part.
  46042. * This can help switching back to the polynomials mode globally which is a tiny bit
  46043. * less GPU intensive at the drawback of a lower quality.
  46044. */
  46045. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46046. /**
  46047. * Default value used for activating energy conservation for the specular workflow.
  46048. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46049. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46050. */
  46051. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  46052. private _useEnergyConservation;
  46053. /**
  46054. * Defines if the material uses energy conservation.
  46055. */
  46056. useEnergyConservation: boolean;
  46057. private _useSmithVisibilityHeightCorrelated;
  46058. /**
  46059. * LEGACY Mode set to false
  46060. * Defines if the material uses height smith correlated visibility term.
  46061. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46062. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46063. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46064. * Not relying on height correlated will also disable energy conservation.
  46065. */
  46066. useSmithVisibilityHeightCorrelated: boolean;
  46067. private _useSphericalHarmonics;
  46068. /**
  46069. * LEGACY Mode set to false
  46070. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46071. * diffuse part of the IBL.
  46072. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46073. * to the ground truth.
  46074. */
  46075. useSphericalHarmonics: boolean;
  46076. private _useSpecularGlossinessInputEnergyConservation;
  46077. /**
  46078. * Defines if the material uses energy conservation, when the specular workflow is active.
  46079. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  46080. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  46081. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  46082. */
  46083. useSpecularGlossinessInputEnergyConservation: boolean;
  46084. /** @hidden */
  46085. private _internalMarkAllSubMeshesAsMiscDirty;
  46086. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  46087. /**
  46088. * Instantiate a new istance of clear coat configuration.
  46089. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46090. */
  46091. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46092. /**
  46093. * Checks to see if a texture is used in the material.
  46094. * @param defines the list of "defines" to update.
  46095. */
  46096. prepareDefines(defines: IMaterialBRDFDefines): void;
  46097. /**
  46098. * Get the current class name of the texture useful for serialization or dynamic coding.
  46099. * @returns "PBRClearCoatConfiguration"
  46100. */
  46101. getClassName(): string;
  46102. /**
  46103. * Makes a duplicate of the current configuration into another one.
  46104. * @param brdfConfiguration define the config where to copy the info
  46105. */
  46106. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46107. /**
  46108. * Serializes this BRDF configuration.
  46109. * @returns - An object with the serialized config.
  46110. */
  46111. serialize(): any;
  46112. /**
  46113. * Parses a anisotropy Configuration from a serialized object.
  46114. * @param source - Serialized object.
  46115. * @param scene Defines the scene we are parsing for
  46116. * @param rootUrl Defines the rootUrl to load from
  46117. */
  46118. parse(source: any, scene: Scene, rootUrl: string): void;
  46119. }
  46120. }
  46121. declare module BABYLON {
  46122. /**
  46123. * @hidden
  46124. */
  46125. export interface IMaterialSheenDefines {
  46126. SHEEN: boolean;
  46127. SHEEN_TEXTURE: boolean;
  46128. SHEEN_TEXTUREDIRECTUV: number;
  46129. SHEEN_LINKWITHALBEDO: boolean;
  46130. /** @hidden */ private _areTexturesDirty: boolean;
  46131. }
  46132. /**
  46133. * Define the code related to the Sheen parameters of the pbr material.
  46134. */
  46135. export class PBRSheenConfiguration {
  46136. private _isEnabled;
  46137. /**
  46138. * Defines if the material uses sheen.
  46139. */
  46140. isEnabled: boolean;
  46141. private _linkSheenWithAlbedo;
  46142. /**
  46143. * Defines if the sheen is linked to the sheen color.
  46144. */
  46145. linkSheenWithAlbedo: boolean;
  46146. /**
  46147. * Defines the sheen intensity.
  46148. */
  46149. intensity: number;
  46150. /**
  46151. * Defines the sheen color.
  46152. */
  46153. color: Color3;
  46154. private _texture;
  46155. /**
  46156. * Stores the sheen tint values in a texture.
  46157. * rgb is tint
  46158. * a is a intensity
  46159. */
  46160. texture: Nullable<BaseTexture>;
  46161. /** @hidden */
  46162. private _internalMarkAllSubMeshesAsTexturesDirty;
  46163. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46164. /**
  46165. * Instantiate a new istance of clear coat configuration.
  46166. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46167. */
  46168. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46169. /**
  46170. * Specifies that the submesh is ready to be used.
  46171. * @param defines the list of "defines" to update.
  46172. * @param scene defines the scene the material belongs to.
  46173. * @returns - boolean indicating that the submesh is ready or not.
  46174. */
  46175. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46176. /**
  46177. * Checks to see if a texture is used in the material.
  46178. * @param defines the list of "defines" to update.
  46179. * @param scene defines the scene the material belongs to.
  46180. */
  46181. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46182. /**
  46183. * Binds the material data.
  46184. * @param uniformBuffer defines the Uniform buffer to fill in.
  46185. * @param scene defines the scene the material belongs to.
  46186. * @param isFrozen defines wether the material is frozen or not.
  46187. */
  46188. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46189. /**
  46190. * Checks to see if a texture is used in the material.
  46191. * @param texture - Base texture to use.
  46192. * @returns - Boolean specifying if a texture is used in the material.
  46193. */
  46194. hasTexture(texture: BaseTexture): boolean;
  46195. /**
  46196. * Returns an array of the actively used textures.
  46197. * @param activeTextures Array of BaseTextures
  46198. */
  46199. getActiveTextures(activeTextures: BaseTexture[]): void;
  46200. /**
  46201. * Returns the animatable textures.
  46202. * @param animatables Array of animatable textures.
  46203. */
  46204. getAnimatables(animatables: IAnimatable[]): void;
  46205. /**
  46206. * Disposes the resources of the material.
  46207. * @param forceDisposeTextures - Forces the disposal of all textures.
  46208. */
  46209. dispose(forceDisposeTextures?: boolean): void;
  46210. /**
  46211. * Get the current class name of the texture useful for serialization or dynamic coding.
  46212. * @returns "PBRSheenConfiguration"
  46213. */
  46214. getClassName(): string;
  46215. /**
  46216. * Add fallbacks to the effect fallbacks list.
  46217. * @param defines defines the Base texture to use.
  46218. * @param fallbacks defines the current fallback list.
  46219. * @param currentRank defines the current fallback rank.
  46220. * @returns the new fallback rank.
  46221. */
  46222. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46223. /**
  46224. * Add the required uniforms to the current list.
  46225. * @param uniforms defines the current uniform list.
  46226. */
  46227. static AddUniforms(uniforms: string[]): void;
  46228. /**
  46229. * Add the required uniforms to the current buffer.
  46230. * @param uniformBuffer defines the current uniform buffer.
  46231. */
  46232. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46233. /**
  46234. * Add the required samplers to the current list.
  46235. * @param samplers defines the current sampler list.
  46236. */
  46237. static AddSamplers(samplers: string[]): void;
  46238. /**
  46239. * Makes a duplicate of the current configuration into another one.
  46240. * @param sheenConfiguration define the config where to copy the info
  46241. */
  46242. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46243. /**
  46244. * Serializes this BRDF configuration.
  46245. * @returns - An object with the serialized config.
  46246. */
  46247. serialize(): any;
  46248. /**
  46249. * Parses a anisotropy Configuration from a serialized object.
  46250. * @param source - Serialized object.
  46251. * @param scene Defines the scene we are parsing for
  46252. * @param rootUrl Defines the rootUrl to load from
  46253. */
  46254. parse(source: any, scene: Scene, rootUrl: string): void;
  46255. }
  46256. }
  46257. declare module BABYLON {
  46258. /**
  46259. * @hidden
  46260. */
  46261. export interface IMaterialSubSurfaceDefines {
  46262. SUBSURFACE: boolean;
  46263. SS_REFRACTION: boolean;
  46264. SS_TRANSLUCENCY: boolean;
  46265. SS_SCATERRING: boolean;
  46266. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46267. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46268. SS_REFRACTIONMAP_3D: boolean;
  46269. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46270. SS_LODINREFRACTIONALPHA: boolean;
  46271. SS_GAMMAREFRACTION: boolean;
  46272. SS_RGBDREFRACTION: boolean;
  46273. SS_LINEARSPECULARREFRACTION: boolean;
  46274. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46275. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46276. /** @hidden */ private _areTexturesDirty: boolean;
  46277. }
  46278. /**
  46279. * Define the code related to the sub surface parameters of the pbr material.
  46280. */
  46281. export class PBRSubSurfaceConfiguration {
  46282. private _isRefractionEnabled;
  46283. /**
  46284. * Defines if the refraction is enabled in the material.
  46285. */
  46286. isRefractionEnabled: boolean;
  46287. private _isTranslucencyEnabled;
  46288. /**
  46289. * Defines if the translucency is enabled in the material.
  46290. */
  46291. isTranslucencyEnabled: boolean;
  46292. private _isScatteringEnabled;
  46293. /**
  46294. * Defines the refraction intensity of the material.
  46295. * The refraction when enabled replaces the Diffuse part of the material.
  46296. * The intensity helps transitionning between diffuse and refraction.
  46297. */
  46298. refractionIntensity: number;
  46299. /**
  46300. * Defines the translucency intensity of the material.
  46301. * When translucency has been enabled, this defines how much of the "translucency"
  46302. * is addded to the diffuse part of the material.
  46303. */
  46304. translucencyIntensity: number;
  46305. /**
  46306. * Defines the scattering intensity of the material.
  46307. * When scattering has been enabled, this defines how much of the "scattered light"
  46308. * is addded to the diffuse part of the material.
  46309. */
  46310. scatteringIntensity: number;
  46311. private _thicknessTexture;
  46312. /**
  46313. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46314. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46315. * 0 would mean minimumThickness
  46316. * 1 would mean maximumThickness
  46317. * The other channels might be use as a mask to vary the different effects intensity.
  46318. */
  46319. thicknessTexture: Nullable<BaseTexture>;
  46320. private _refractionTexture;
  46321. /**
  46322. * Defines the texture to use for refraction.
  46323. */
  46324. refractionTexture: Nullable<BaseTexture>;
  46325. private _indexOfRefraction;
  46326. /**
  46327. * Defines the index of refraction used in the material.
  46328. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46329. */
  46330. indexOfRefraction: number;
  46331. private _invertRefractionY;
  46332. /**
  46333. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46334. */
  46335. invertRefractionY: boolean;
  46336. private _linkRefractionWithTransparency;
  46337. /**
  46338. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46339. * Materials half opaque for instance using refraction could benefit from this control.
  46340. */
  46341. linkRefractionWithTransparency: boolean;
  46342. /**
  46343. * Defines the minimum thickness stored in the thickness map.
  46344. * If no thickness map is defined, this value will be used to simulate thickness.
  46345. */
  46346. minimumThickness: number;
  46347. /**
  46348. * Defines the maximum thickness stored in the thickness map.
  46349. */
  46350. maximumThickness: number;
  46351. /**
  46352. * Defines the volume tint of the material.
  46353. * This is used for both translucency and scattering.
  46354. */
  46355. tintColor: Color3;
  46356. /**
  46357. * Defines the distance at which the tint color should be found in the media.
  46358. * This is used for refraction only.
  46359. */
  46360. tintColorAtDistance: number;
  46361. /**
  46362. * Defines how far each channel transmit through the media.
  46363. * It is defined as a color to simplify it selection.
  46364. */
  46365. diffusionDistance: Color3;
  46366. private _useMaskFromThicknessTexture;
  46367. /**
  46368. * Stores the intensity of the different subsurface effects in the thickness texture.
  46369. * * the green channel is the translucency intensity.
  46370. * * the blue channel is the scattering intensity.
  46371. * * the alpha channel is the refraction intensity.
  46372. */
  46373. useMaskFromThicknessTexture: boolean;
  46374. /** @hidden */
  46375. private _internalMarkAllSubMeshesAsTexturesDirty;
  46376. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  46377. /**
  46378. * Instantiate a new istance of sub surface configuration.
  46379. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46380. */
  46381. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46382. /**
  46383. * Gets wehter the submesh is ready to be used or not.
  46384. * @param defines the list of "defines" to update.
  46385. * @param scene defines the scene the material belongs to.
  46386. * @returns - boolean indicating that the submesh is ready or not.
  46387. */
  46388. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46389. /**
  46390. * Checks to see if a texture is used in the material.
  46391. * @param defines the list of "defines" to update.
  46392. * @param scene defines the scene to the material belongs to.
  46393. */
  46394. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46395. /**
  46396. * Binds the material data.
  46397. * @param uniformBuffer defines the Uniform buffer to fill in.
  46398. * @param scene defines the scene the material belongs to.
  46399. * @param engine defines the engine the material belongs to.
  46400. * @param isFrozen defines wether the material is frozen or not.
  46401. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46402. */
  46403. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46404. /**
  46405. * Unbinds the material from the mesh.
  46406. * @param activeEffect defines the effect that should be unbound from.
  46407. * @returns true if unbound, otherwise false
  46408. */
  46409. unbind(activeEffect: Effect): boolean;
  46410. /**
  46411. * Returns the texture used for refraction or null if none is used.
  46412. * @param scene defines the scene the material belongs to.
  46413. * @returns - Refraction texture if present. If no refraction texture and refraction
  46414. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46415. */
  46416. private _getRefractionTexture;
  46417. /**
  46418. * Returns true if alpha blending should be disabled.
  46419. */
  46420. readonly disableAlphaBlending: boolean;
  46421. /**
  46422. * Fills the list of render target textures.
  46423. * @param renderTargets the list of render targets to update
  46424. */
  46425. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46426. /**
  46427. * Checks to see if a texture is used in the material.
  46428. * @param texture - Base texture to use.
  46429. * @returns - Boolean specifying if a texture is used in the material.
  46430. */
  46431. hasTexture(texture: BaseTexture): boolean;
  46432. /**
  46433. * Gets a boolean indicating that current material needs to register RTT
  46434. * @returns true if this uses a render target otherwise false.
  46435. */
  46436. hasRenderTargetTextures(): boolean;
  46437. /**
  46438. * Returns an array of the actively used textures.
  46439. * @param activeTextures Array of BaseTextures
  46440. */
  46441. getActiveTextures(activeTextures: BaseTexture[]): void;
  46442. /**
  46443. * Returns the animatable textures.
  46444. * @param animatables Array of animatable textures.
  46445. */
  46446. getAnimatables(animatables: IAnimatable[]): void;
  46447. /**
  46448. * Disposes the resources of the material.
  46449. * @param forceDisposeTextures - Forces the disposal of all textures.
  46450. */
  46451. dispose(forceDisposeTextures?: boolean): void;
  46452. /**
  46453. * Get the current class name of the texture useful for serialization or dynamic coding.
  46454. * @returns "PBRSubSurfaceConfiguration"
  46455. */
  46456. getClassName(): string;
  46457. /**
  46458. * Add fallbacks to the effect fallbacks list.
  46459. * @param defines defines the Base texture to use.
  46460. * @param fallbacks defines the current fallback list.
  46461. * @param currentRank defines the current fallback rank.
  46462. * @returns the new fallback rank.
  46463. */
  46464. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46465. /**
  46466. * Add the required uniforms to the current list.
  46467. * @param uniforms defines the current uniform list.
  46468. */
  46469. static AddUniforms(uniforms: string[]): void;
  46470. /**
  46471. * Add the required samplers to the current list.
  46472. * @param samplers defines the current sampler list.
  46473. */
  46474. static AddSamplers(samplers: string[]): void;
  46475. /**
  46476. * Add the required uniforms to the current buffer.
  46477. * @param uniformBuffer defines the current uniform buffer.
  46478. */
  46479. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46480. /**
  46481. * Makes a duplicate of the current configuration into another one.
  46482. * @param configuration define the config where to copy the info
  46483. */
  46484. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46485. /**
  46486. * Serializes this Sub Surface configuration.
  46487. * @returns - An object with the serialized config.
  46488. */
  46489. serialize(): any;
  46490. /**
  46491. * Parses a anisotropy Configuration from a serialized object.
  46492. * @param source - Serialized object.
  46493. * @param scene Defines the scene we are parsing for
  46494. * @param rootUrl Defines the rootUrl to load from
  46495. */
  46496. parse(source: any, scene: Scene, rootUrl: string): void;
  46497. }
  46498. }
  46499. declare module BABYLON {
  46500. /** @hidden */
  46501. export var pbrFragmentDeclaration: {
  46502. name: string;
  46503. shader: string;
  46504. };
  46505. }
  46506. declare module BABYLON {
  46507. /** @hidden */
  46508. export var pbrUboDeclaration: {
  46509. name: string;
  46510. shader: string;
  46511. };
  46512. }
  46513. declare module BABYLON {
  46514. /** @hidden */
  46515. export var pbrFragmentExtraDeclaration: {
  46516. name: string;
  46517. shader: string;
  46518. };
  46519. }
  46520. declare module BABYLON {
  46521. /** @hidden */
  46522. export var pbrFragmentSamplersDeclaration: {
  46523. name: string;
  46524. shader: string;
  46525. };
  46526. }
  46527. declare module BABYLON {
  46528. /** @hidden */
  46529. export var pbrHelperFunctions: {
  46530. name: string;
  46531. shader: string;
  46532. };
  46533. }
  46534. declare module BABYLON {
  46535. /** @hidden */
  46536. export var harmonicsFunctions: {
  46537. name: string;
  46538. shader: string;
  46539. };
  46540. }
  46541. declare module BABYLON {
  46542. /** @hidden */
  46543. export var pbrDirectLightingSetupFunctions: {
  46544. name: string;
  46545. shader: string;
  46546. };
  46547. }
  46548. declare module BABYLON {
  46549. /** @hidden */
  46550. export var pbrDirectLightingFalloffFunctions: {
  46551. name: string;
  46552. shader: string;
  46553. };
  46554. }
  46555. declare module BABYLON {
  46556. /** @hidden */
  46557. export var pbrBRDFFunctions: {
  46558. name: string;
  46559. shader: string;
  46560. };
  46561. }
  46562. declare module BABYLON {
  46563. /** @hidden */
  46564. export var pbrDirectLightingFunctions: {
  46565. name: string;
  46566. shader: string;
  46567. };
  46568. }
  46569. declare module BABYLON {
  46570. /** @hidden */
  46571. export var pbrIBLFunctions: {
  46572. name: string;
  46573. shader: string;
  46574. };
  46575. }
  46576. declare module BABYLON {
  46577. /** @hidden */
  46578. export var pbrDebug: {
  46579. name: string;
  46580. shader: string;
  46581. };
  46582. }
  46583. declare module BABYLON {
  46584. /** @hidden */
  46585. export var pbrPixelShader: {
  46586. name: string;
  46587. shader: string;
  46588. };
  46589. }
  46590. declare module BABYLON {
  46591. /** @hidden */
  46592. export var pbrVertexDeclaration: {
  46593. name: string;
  46594. shader: string;
  46595. };
  46596. }
  46597. declare module BABYLON {
  46598. /** @hidden */
  46599. export var pbrVertexShader: {
  46600. name: string;
  46601. shader: string;
  46602. };
  46603. }
  46604. declare module BABYLON {
  46605. /**
  46606. * Manages the defines for the PBR Material.
  46607. * @hidden
  46608. */
  46609. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46610. PBR: boolean;
  46611. MAINUV1: boolean;
  46612. MAINUV2: boolean;
  46613. UV1: boolean;
  46614. UV2: boolean;
  46615. ALBEDO: boolean;
  46616. ALBEDODIRECTUV: number;
  46617. VERTEXCOLOR: boolean;
  46618. AMBIENT: boolean;
  46619. AMBIENTDIRECTUV: number;
  46620. AMBIENTINGRAYSCALE: boolean;
  46621. OPACITY: boolean;
  46622. VERTEXALPHA: boolean;
  46623. OPACITYDIRECTUV: number;
  46624. OPACITYRGB: boolean;
  46625. ALPHATEST: boolean;
  46626. DEPTHPREPASS: boolean;
  46627. ALPHABLEND: boolean;
  46628. ALPHAFROMALBEDO: boolean;
  46629. ALPHATESTVALUE: string;
  46630. SPECULAROVERALPHA: boolean;
  46631. RADIANCEOVERALPHA: boolean;
  46632. ALPHAFRESNEL: boolean;
  46633. LINEARALPHAFRESNEL: boolean;
  46634. PREMULTIPLYALPHA: boolean;
  46635. EMISSIVE: boolean;
  46636. EMISSIVEDIRECTUV: number;
  46637. REFLECTIVITY: boolean;
  46638. REFLECTIVITYDIRECTUV: number;
  46639. SPECULARTERM: boolean;
  46640. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46641. MICROSURFACEAUTOMATIC: boolean;
  46642. LODBASEDMICROSFURACE: boolean;
  46643. MICROSURFACEMAP: boolean;
  46644. MICROSURFACEMAPDIRECTUV: number;
  46645. METALLICWORKFLOW: boolean;
  46646. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46647. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46648. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46649. AOSTOREINMETALMAPRED: boolean;
  46650. ENVIRONMENTBRDF: boolean;
  46651. ENVIRONMENTBRDF_RGBD: boolean;
  46652. NORMAL: boolean;
  46653. TANGENT: boolean;
  46654. BUMP: boolean;
  46655. BUMPDIRECTUV: number;
  46656. OBJECTSPACE_NORMALMAP: boolean;
  46657. PARALLAX: boolean;
  46658. PARALLAXOCCLUSION: boolean;
  46659. NORMALXYSCALE: boolean;
  46660. LIGHTMAP: boolean;
  46661. LIGHTMAPDIRECTUV: number;
  46662. USELIGHTMAPASSHADOWMAP: boolean;
  46663. GAMMALIGHTMAP: boolean;
  46664. RGBDLIGHTMAP: boolean;
  46665. REFLECTION: boolean;
  46666. REFLECTIONMAP_3D: boolean;
  46667. REFLECTIONMAP_SPHERICAL: boolean;
  46668. REFLECTIONMAP_PLANAR: boolean;
  46669. REFLECTIONMAP_CUBIC: boolean;
  46670. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46671. REFLECTIONMAP_PROJECTION: boolean;
  46672. REFLECTIONMAP_SKYBOX: boolean;
  46673. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46674. REFLECTIONMAP_EXPLICIT: boolean;
  46675. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46676. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46677. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46678. INVERTCUBICMAP: boolean;
  46679. USESPHERICALFROMREFLECTIONMAP: boolean;
  46680. USEIRRADIANCEMAP: boolean;
  46681. SPHERICAL_HARMONICS: boolean;
  46682. USESPHERICALINVERTEX: boolean;
  46683. REFLECTIONMAP_OPPOSITEZ: boolean;
  46684. LODINREFLECTIONALPHA: boolean;
  46685. GAMMAREFLECTION: boolean;
  46686. RGBDREFLECTION: boolean;
  46687. LINEARSPECULARREFLECTION: boolean;
  46688. RADIANCEOCCLUSION: boolean;
  46689. HORIZONOCCLUSION: boolean;
  46690. INSTANCES: boolean;
  46691. NUM_BONE_INFLUENCERS: number;
  46692. BonesPerMesh: number;
  46693. BONETEXTURE: boolean;
  46694. NONUNIFORMSCALING: boolean;
  46695. MORPHTARGETS: boolean;
  46696. MORPHTARGETS_NORMAL: boolean;
  46697. MORPHTARGETS_TANGENT: boolean;
  46698. MORPHTARGETS_UV: boolean;
  46699. NUM_MORPH_INFLUENCERS: number;
  46700. IMAGEPROCESSING: boolean;
  46701. VIGNETTE: boolean;
  46702. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46703. VIGNETTEBLENDMODEOPAQUE: boolean;
  46704. TONEMAPPING: boolean;
  46705. TONEMAPPING_ACES: boolean;
  46706. CONTRAST: boolean;
  46707. COLORCURVES: boolean;
  46708. COLORGRADING: boolean;
  46709. COLORGRADING3D: boolean;
  46710. SAMPLER3DGREENDEPTH: boolean;
  46711. SAMPLER3DBGRMAP: boolean;
  46712. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46713. EXPOSURE: boolean;
  46714. MULTIVIEW: boolean;
  46715. USEPHYSICALLIGHTFALLOFF: boolean;
  46716. USEGLTFLIGHTFALLOFF: boolean;
  46717. TWOSIDEDLIGHTING: boolean;
  46718. SHADOWFLOAT: boolean;
  46719. CLIPPLANE: boolean;
  46720. CLIPPLANE2: boolean;
  46721. CLIPPLANE3: boolean;
  46722. CLIPPLANE4: boolean;
  46723. POINTSIZE: boolean;
  46724. FOG: boolean;
  46725. LOGARITHMICDEPTH: boolean;
  46726. FORCENORMALFORWARD: boolean;
  46727. SPECULARAA: boolean;
  46728. CLEARCOAT: boolean;
  46729. CLEARCOAT_DEFAULTIOR: boolean;
  46730. CLEARCOAT_TEXTURE: boolean;
  46731. CLEARCOAT_TEXTUREDIRECTUV: number;
  46732. CLEARCOAT_BUMP: boolean;
  46733. CLEARCOAT_BUMPDIRECTUV: number;
  46734. CLEARCOAT_TINT: boolean;
  46735. CLEARCOAT_TINT_TEXTURE: boolean;
  46736. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46737. ANISOTROPIC: boolean;
  46738. ANISOTROPIC_TEXTURE: boolean;
  46739. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46740. BRDF_V_HEIGHT_CORRELATED: boolean;
  46741. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46742. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  46743. SHEEN: boolean;
  46744. SHEEN_TEXTURE: boolean;
  46745. SHEEN_TEXTUREDIRECTUV: number;
  46746. SHEEN_LINKWITHALBEDO: boolean;
  46747. SUBSURFACE: boolean;
  46748. SS_REFRACTION: boolean;
  46749. SS_TRANSLUCENCY: boolean;
  46750. SS_SCATERRING: boolean;
  46751. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46752. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46753. SS_REFRACTIONMAP_3D: boolean;
  46754. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46755. SS_LODINREFRACTIONALPHA: boolean;
  46756. SS_GAMMAREFRACTION: boolean;
  46757. SS_RGBDREFRACTION: boolean;
  46758. SS_LINEARSPECULARREFRACTION: boolean;
  46759. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46760. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46761. UNLIT: boolean;
  46762. DEBUGMODE: number;
  46763. /**
  46764. * Initializes the PBR Material defines.
  46765. */
  46766. constructor();
  46767. /**
  46768. * Resets the PBR Material defines.
  46769. */
  46770. reset(): void;
  46771. }
  46772. /**
  46773. * The Physically based material base class of BJS.
  46774. *
  46775. * This offers the main features of a standard PBR material.
  46776. * For more information, please refer to the documentation :
  46777. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46778. */
  46779. export abstract class PBRBaseMaterial extends PushMaterial {
  46780. /**
  46781. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46782. */
  46783. static readonly PBRMATERIAL_OPAQUE: number;
  46784. /**
  46785. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46786. */
  46787. static readonly PBRMATERIAL_ALPHATEST: number;
  46788. /**
  46789. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46790. */
  46791. static readonly PBRMATERIAL_ALPHABLEND: number;
  46792. /**
  46793. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46794. * They are also discarded below the alpha cutoff threshold to improve performances.
  46795. */
  46796. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46797. /**
  46798. * Defines the default value of how much AO map is occluding the analytical lights
  46799. * (point spot...).
  46800. */
  46801. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46802. /**
  46803. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46804. */
  46805. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46806. /**
  46807. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46808. * to enhance interoperability with other engines.
  46809. */
  46810. static readonly LIGHTFALLOFF_GLTF: number;
  46811. /**
  46812. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46813. * to enhance interoperability with other materials.
  46814. */
  46815. static readonly LIGHTFALLOFF_STANDARD: number;
  46816. /**
  46817. * Intensity of the direct lights e.g. the four lights available in your scene.
  46818. * This impacts both the direct diffuse and specular highlights.
  46819. */
  46820. protected _directIntensity: number;
  46821. /**
  46822. * Intensity of the emissive part of the material.
  46823. * This helps controlling the emissive effect without modifying the emissive color.
  46824. */
  46825. protected _emissiveIntensity: number;
  46826. /**
  46827. * Intensity of the environment e.g. how much the environment will light the object
  46828. * either through harmonics for rough material or through the refelction for shiny ones.
  46829. */
  46830. protected _environmentIntensity: number;
  46831. /**
  46832. * This is a special control allowing the reduction of the specular highlights coming from the
  46833. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46834. */
  46835. protected _specularIntensity: number;
  46836. /**
  46837. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46838. */
  46839. private _lightingInfos;
  46840. /**
  46841. * Debug Control allowing disabling the bump map on this material.
  46842. */
  46843. protected _disableBumpMap: boolean;
  46844. /**
  46845. * AKA Diffuse Texture in standard nomenclature.
  46846. */
  46847. protected _albedoTexture: Nullable<BaseTexture>;
  46848. /**
  46849. * AKA Occlusion Texture in other nomenclature.
  46850. */
  46851. protected _ambientTexture: Nullable<BaseTexture>;
  46852. /**
  46853. * AKA Occlusion Texture Intensity in other nomenclature.
  46854. */
  46855. protected _ambientTextureStrength: number;
  46856. /**
  46857. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46858. * 1 means it completely occludes it
  46859. * 0 mean it has no impact
  46860. */
  46861. protected _ambientTextureImpactOnAnalyticalLights: number;
  46862. /**
  46863. * Stores the alpha values in a texture.
  46864. */
  46865. protected _opacityTexture: Nullable<BaseTexture>;
  46866. /**
  46867. * Stores the reflection values in a texture.
  46868. */
  46869. protected _reflectionTexture: Nullable<BaseTexture>;
  46870. /**
  46871. * Stores the emissive values in a texture.
  46872. */
  46873. protected _emissiveTexture: Nullable<BaseTexture>;
  46874. /**
  46875. * AKA Specular texture in other nomenclature.
  46876. */
  46877. protected _reflectivityTexture: Nullable<BaseTexture>;
  46878. /**
  46879. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46880. */
  46881. protected _metallicTexture: Nullable<BaseTexture>;
  46882. /**
  46883. * Specifies the metallic scalar of the metallic/roughness workflow.
  46884. * Can also be used to scale the metalness values of the metallic texture.
  46885. */
  46886. protected _metallic: Nullable<number>;
  46887. /**
  46888. * Specifies the roughness scalar of the metallic/roughness workflow.
  46889. * Can also be used to scale the roughness values of the metallic texture.
  46890. */
  46891. protected _roughness: Nullable<number>;
  46892. /**
  46893. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46894. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46895. */
  46896. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46897. /**
  46898. * Stores surface normal data used to displace a mesh in a texture.
  46899. */
  46900. protected _bumpTexture: Nullable<BaseTexture>;
  46901. /**
  46902. * Stores the pre-calculated light information of a mesh in a texture.
  46903. */
  46904. protected _lightmapTexture: Nullable<BaseTexture>;
  46905. /**
  46906. * The color of a material in ambient lighting.
  46907. */
  46908. protected _ambientColor: Color3;
  46909. /**
  46910. * AKA Diffuse Color in other nomenclature.
  46911. */
  46912. protected _albedoColor: Color3;
  46913. /**
  46914. * AKA Specular Color in other nomenclature.
  46915. */
  46916. protected _reflectivityColor: Color3;
  46917. /**
  46918. * The color applied when light is reflected from a material.
  46919. */
  46920. protected _reflectionColor: Color3;
  46921. /**
  46922. * The color applied when light is emitted from a material.
  46923. */
  46924. protected _emissiveColor: Color3;
  46925. /**
  46926. * AKA Glossiness in other nomenclature.
  46927. */
  46928. protected _microSurface: number;
  46929. /**
  46930. * Specifies that the material will use the light map as a show map.
  46931. */
  46932. protected _useLightmapAsShadowmap: boolean;
  46933. /**
  46934. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46935. * makes the reflect vector face the model (under horizon).
  46936. */
  46937. protected _useHorizonOcclusion: boolean;
  46938. /**
  46939. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46940. * too much the area relying on ambient texture to define their ambient occlusion.
  46941. */
  46942. protected _useRadianceOcclusion: boolean;
  46943. /**
  46944. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46945. */
  46946. protected _useAlphaFromAlbedoTexture: boolean;
  46947. /**
  46948. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46949. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46950. */
  46951. protected _useSpecularOverAlpha: boolean;
  46952. /**
  46953. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46954. */
  46955. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46956. /**
  46957. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46958. */
  46959. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46960. /**
  46961. * Specifies if the metallic texture contains the roughness information in its green channel.
  46962. */
  46963. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46964. /**
  46965. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46966. */
  46967. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46968. /**
  46969. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46970. */
  46971. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46972. /**
  46973. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46974. */
  46975. protected _useAmbientInGrayScale: boolean;
  46976. /**
  46977. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46978. * The material will try to infer what glossiness each pixel should be.
  46979. */
  46980. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46981. /**
  46982. * Defines the falloff type used in this material.
  46983. * It by default is Physical.
  46984. */
  46985. protected _lightFalloff: number;
  46986. /**
  46987. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46988. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46989. */
  46990. protected _useRadianceOverAlpha: boolean;
  46991. /**
  46992. * Allows using an object space normal map (instead of tangent space).
  46993. */
  46994. protected _useObjectSpaceNormalMap: boolean;
  46995. /**
  46996. * Allows using the bump map in parallax mode.
  46997. */
  46998. protected _useParallax: boolean;
  46999. /**
  47000. * Allows using the bump map in parallax occlusion mode.
  47001. */
  47002. protected _useParallaxOcclusion: boolean;
  47003. /**
  47004. * Controls the scale bias of the parallax mode.
  47005. */
  47006. protected _parallaxScaleBias: number;
  47007. /**
  47008. * If sets to true, disables all the lights affecting the material.
  47009. */
  47010. protected _disableLighting: boolean;
  47011. /**
  47012. * Number of Simultaneous lights allowed on the material.
  47013. */
  47014. protected _maxSimultaneousLights: number;
  47015. /**
  47016. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47017. */
  47018. protected _invertNormalMapX: boolean;
  47019. /**
  47020. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47021. */
  47022. protected _invertNormalMapY: boolean;
  47023. /**
  47024. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47025. */
  47026. protected _twoSidedLighting: boolean;
  47027. /**
  47028. * Defines the alpha limits in alpha test mode.
  47029. */
  47030. protected _alphaCutOff: number;
  47031. /**
  47032. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47033. */
  47034. protected _forceAlphaTest: boolean;
  47035. /**
  47036. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47037. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47038. */
  47039. protected _useAlphaFresnel: boolean;
  47040. /**
  47041. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47042. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47043. */
  47044. protected _useLinearAlphaFresnel: boolean;
  47045. /**
  47046. * The transparency mode of the material.
  47047. */
  47048. protected _transparencyMode: Nullable<number>;
  47049. /**
  47050. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47051. * from cos thetav and roughness:
  47052. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47053. */
  47054. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47055. /**
  47056. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47057. */
  47058. protected _forceIrradianceInFragment: boolean;
  47059. /**
  47060. * Force normal to face away from face.
  47061. */
  47062. protected _forceNormalForward: boolean;
  47063. /**
  47064. * Enables specular anti aliasing in the PBR shader.
  47065. * It will both interacts on the Geometry for analytical and IBL lighting.
  47066. * It also prefilter the roughness map based on the bump values.
  47067. */
  47068. protected _enableSpecularAntiAliasing: boolean;
  47069. /**
  47070. * Default configuration related to image processing available in the PBR Material.
  47071. */
  47072. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47073. /**
  47074. * Keep track of the image processing observer to allow dispose and replace.
  47075. */
  47076. private _imageProcessingObserver;
  47077. /**
  47078. * Attaches a new image processing configuration to the PBR Material.
  47079. * @param configuration
  47080. */
  47081. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47082. /**
  47083. * Stores the available render targets.
  47084. */
  47085. private _renderTargets;
  47086. /**
  47087. * Sets the global ambient color for the material used in lighting calculations.
  47088. */
  47089. private _globalAmbientColor;
  47090. /**
  47091. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47092. */
  47093. private _useLogarithmicDepth;
  47094. /**
  47095. * If set to true, no lighting calculations will be applied.
  47096. */
  47097. private _unlit;
  47098. private _debugMode;
  47099. /**
  47100. * @hidden
  47101. * This is reserved for the inspector.
  47102. * Defines the material debug mode.
  47103. * It helps seeing only some components of the material while troubleshooting.
  47104. */
  47105. debugMode: number;
  47106. /**
  47107. * @hidden
  47108. * This is reserved for the inspector.
  47109. * Specify from where on screen the debug mode should start.
  47110. * The value goes from -1 (full screen) to 1 (not visible)
  47111. * It helps with side by side comparison against the final render
  47112. * This defaults to -1
  47113. */
  47114. private debugLimit;
  47115. /**
  47116. * @hidden
  47117. * This is reserved for the inspector.
  47118. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47119. * You can use the factor to better multiply the final value.
  47120. */
  47121. private debugFactor;
  47122. /**
  47123. * Defines the clear coat layer parameters for the material.
  47124. */
  47125. readonly clearCoat: PBRClearCoatConfiguration;
  47126. /**
  47127. * Defines the anisotropic parameters for the material.
  47128. */
  47129. readonly anisotropy: PBRAnisotropicConfiguration;
  47130. /**
  47131. * Defines the BRDF parameters for the material.
  47132. */
  47133. readonly brdf: PBRBRDFConfiguration;
  47134. /**
  47135. * Defines the Sheen parameters for the material.
  47136. */
  47137. readonly sheen: PBRSheenConfiguration;
  47138. /**
  47139. * Defines the SubSurface parameters for the material.
  47140. */
  47141. readonly subSurface: PBRSubSurfaceConfiguration;
  47142. /**
  47143. * Custom callback helping to override the default shader used in the material.
  47144. */
  47145. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47146. protected _rebuildInParallel: boolean;
  47147. /**
  47148. * Instantiates a new PBRMaterial instance.
  47149. *
  47150. * @param name The material name
  47151. * @param scene The scene the material will be use in.
  47152. */
  47153. constructor(name: string, scene: Scene);
  47154. /**
  47155. * Gets a boolean indicating that current material needs to register RTT
  47156. */
  47157. readonly hasRenderTargetTextures: boolean;
  47158. /**
  47159. * Gets the name of the material class.
  47160. */
  47161. getClassName(): string;
  47162. /**
  47163. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47164. */
  47165. /**
  47166. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47167. */
  47168. useLogarithmicDepth: boolean;
  47169. /**
  47170. * Gets the current transparency mode.
  47171. */
  47172. /**
  47173. * Sets the transparency mode of the material.
  47174. *
  47175. * | Value | Type | Description |
  47176. * | ----- | ----------------------------------- | ----------- |
  47177. * | 0 | OPAQUE | |
  47178. * | 1 | ALPHATEST | |
  47179. * | 2 | ALPHABLEND | |
  47180. * | 3 | ALPHATESTANDBLEND | |
  47181. *
  47182. */
  47183. transparencyMode: Nullable<number>;
  47184. /**
  47185. * Returns true if alpha blending should be disabled.
  47186. */
  47187. private readonly _disableAlphaBlending;
  47188. /**
  47189. * Specifies whether or not this material should be rendered in alpha blend mode.
  47190. */
  47191. needAlphaBlending(): boolean;
  47192. /**
  47193. * Specifies if the mesh will require alpha blending.
  47194. * @param mesh - BJS mesh.
  47195. */
  47196. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47197. /**
  47198. * Specifies whether or not this material should be rendered in alpha test mode.
  47199. */
  47200. needAlphaTesting(): boolean;
  47201. /**
  47202. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47203. */
  47204. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47205. /**
  47206. * Gets the texture used for the alpha test.
  47207. */
  47208. getAlphaTestTexture(): Nullable<BaseTexture>;
  47209. /**
  47210. * Specifies that the submesh is ready to be used.
  47211. * @param mesh - BJS mesh.
  47212. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47213. * @param useInstances - Specifies that instances should be used.
  47214. * @returns - boolean indicating that the submesh is ready or not.
  47215. */
  47216. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47217. /**
  47218. * Specifies if the material uses metallic roughness workflow.
  47219. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47220. */
  47221. isMetallicWorkflow(): boolean;
  47222. private _prepareEffect;
  47223. private _prepareDefines;
  47224. /**
  47225. * Force shader compilation
  47226. */
  47227. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47228. clipPlane: boolean;
  47229. }>): void;
  47230. /**
  47231. * Initializes the uniform buffer layout for the shader.
  47232. */
  47233. buildUniformLayout(): void;
  47234. /**
  47235. * Unbinds the material from the mesh
  47236. */
  47237. unbind(): void;
  47238. /**
  47239. * Binds the submesh data.
  47240. * @param world - The world matrix.
  47241. * @param mesh - The BJS mesh.
  47242. * @param subMesh - A submesh of the BJS mesh.
  47243. */
  47244. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47245. /**
  47246. * Returns the animatable textures.
  47247. * @returns - Array of animatable textures.
  47248. */
  47249. getAnimatables(): IAnimatable[];
  47250. /**
  47251. * Returns the texture used for reflections.
  47252. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47253. */
  47254. private _getReflectionTexture;
  47255. /**
  47256. * Returns an array of the actively used textures.
  47257. * @returns - Array of BaseTextures
  47258. */
  47259. getActiveTextures(): BaseTexture[];
  47260. /**
  47261. * Checks to see if a texture is used in the material.
  47262. * @param texture - Base texture to use.
  47263. * @returns - Boolean specifying if a texture is used in the material.
  47264. */
  47265. hasTexture(texture: BaseTexture): boolean;
  47266. /**
  47267. * Disposes the resources of the material.
  47268. * @param forceDisposeEffect - Forces the disposal of effects.
  47269. * @param forceDisposeTextures - Forces the disposal of all textures.
  47270. */
  47271. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47272. }
  47273. }
  47274. declare module BABYLON {
  47275. /**
  47276. * The Physically based material of BJS.
  47277. *
  47278. * This offers the main features of a standard PBR material.
  47279. * For more information, please refer to the documentation :
  47280. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47281. */
  47282. export class PBRMaterial extends PBRBaseMaterial {
  47283. /**
  47284. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47285. */
  47286. static readonly PBRMATERIAL_OPAQUE: number;
  47287. /**
  47288. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47289. */
  47290. static readonly PBRMATERIAL_ALPHATEST: number;
  47291. /**
  47292. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47293. */
  47294. static readonly PBRMATERIAL_ALPHABLEND: number;
  47295. /**
  47296. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47297. * They are also discarded below the alpha cutoff threshold to improve performances.
  47298. */
  47299. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47300. /**
  47301. * Defines the default value of how much AO map is occluding the analytical lights
  47302. * (point spot...).
  47303. */
  47304. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47305. /**
  47306. * Intensity of the direct lights e.g. the four lights available in your scene.
  47307. * This impacts both the direct diffuse and specular highlights.
  47308. */
  47309. directIntensity: number;
  47310. /**
  47311. * Intensity of the emissive part of the material.
  47312. * This helps controlling the emissive effect without modifying the emissive color.
  47313. */
  47314. emissiveIntensity: number;
  47315. /**
  47316. * Intensity of the environment e.g. how much the environment will light the object
  47317. * either through harmonics for rough material or through the refelction for shiny ones.
  47318. */
  47319. environmentIntensity: number;
  47320. /**
  47321. * This is a special control allowing the reduction of the specular highlights coming from the
  47322. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47323. */
  47324. specularIntensity: number;
  47325. /**
  47326. * Debug Control allowing disabling the bump map on this material.
  47327. */
  47328. disableBumpMap: boolean;
  47329. /**
  47330. * AKA Diffuse Texture in standard nomenclature.
  47331. */
  47332. albedoTexture: BaseTexture;
  47333. /**
  47334. * AKA Occlusion Texture in other nomenclature.
  47335. */
  47336. ambientTexture: BaseTexture;
  47337. /**
  47338. * AKA Occlusion Texture Intensity in other nomenclature.
  47339. */
  47340. ambientTextureStrength: number;
  47341. /**
  47342. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47343. * 1 means it completely occludes it
  47344. * 0 mean it has no impact
  47345. */
  47346. ambientTextureImpactOnAnalyticalLights: number;
  47347. /**
  47348. * Stores the alpha values in a texture.
  47349. */
  47350. opacityTexture: BaseTexture;
  47351. /**
  47352. * Stores the reflection values in a texture.
  47353. */
  47354. reflectionTexture: Nullable<BaseTexture>;
  47355. /**
  47356. * Stores the emissive values in a texture.
  47357. */
  47358. emissiveTexture: BaseTexture;
  47359. /**
  47360. * AKA Specular texture in other nomenclature.
  47361. */
  47362. reflectivityTexture: BaseTexture;
  47363. /**
  47364. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47365. */
  47366. metallicTexture: BaseTexture;
  47367. /**
  47368. * Specifies the metallic scalar of the metallic/roughness workflow.
  47369. * Can also be used to scale the metalness values of the metallic texture.
  47370. */
  47371. metallic: Nullable<number>;
  47372. /**
  47373. * Specifies the roughness scalar of the metallic/roughness workflow.
  47374. * Can also be used to scale the roughness values of the metallic texture.
  47375. */
  47376. roughness: Nullable<number>;
  47377. /**
  47378. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47379. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47380. */
  47381. microSurfaceTexture: BaseTexture;
  47382. /**
  47383. * Stores surface normal data used to displace a mesh in a texture.
  47384. */
  47385. bumpTexture: BaseTexture;
  47386. /**
  47387. * Stores the pre-calculated light information of a mesh in a texture.
  47388. */
  47389. lightmapTexture: BaseTexture;
  47390. /**
  47391. * Stores the refracted light information in a texture.
  47392. */
  47393. refractionTexture: Nullable<BaseTexture>;
  47394. /**
  47395. * The color of a material in ambient lighting.
  47396. */
  47397. ambientColor: Color3;
  47398. /**
  47399. * AKA Diffuse Color in other nomenclature.
  47400. */
  47401. albedoColor: Color3;
  47402. /**
  47403. * AKA Specular Color in other nomenclature.
  47404. */
  47405. reflectivityColor: Color3;
  47406. /**
  47407. * The color reflected from the material.
  47408. */
  47409. reflectionColor: Color3;
  47410. /**
  47411. * The color emitted from the material.
  47412. */
  47413. emissiveColor: Color3;
  47414. /**
  47415. * AKA Glossiness in other nomenclature.
  47416. */
  47417. microSurface: number;
  47418. /**
  47419. * source material index of refraction (IOR)' / 'destination material IOR.
  47420. */
  47421. indexOfRefraction: number;
  47422. /**
  47423. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47424. */
  47425. invertRefractionY: boolean;
  47426. /**
  47427. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47428. * Materials half opaque for instance using refraction could benefit from this control.
  47429. */
  47430. linkRefractionWithTransparency: boolean;
  47431. /**
  47432. * If true, the light map contains occlusion information instead of lighting info.
  47433. */
  47434. useLightmapAsShadowmap: boolean;
  47435. /**
  47436. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47437. */
  47438. useAlphaFromAlbedoTexture: boolean;
  47439. /**
  47440. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47441. */
  47442. forceAlphaTest: boolean;
  47443. /**
  47444. * Defines the alpha limits in alpha test mode.
  47445. */
  47446. alphaCutOff: number;
  47447. /**
  47448. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47449. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47450. */
  47451. useSpecularOverAlpha: boolean;
  47452. /**
  47453. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47454. */
  47455. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47456. /**
  47457. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47458. */
  47459. useRoughnessFromMetallicTextureAlpha: boolean;
  47460. /**
  47461. * Specifies if the metallic texture contains the roughness information in its green channel.
  47462. */
  47463. useRoughnessFromMetallicTextureGreen: boolean;
  47464. /**
  47465. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47466. */
  47467. useMetallnessFromMetallicTextureBlue: boolean;
  47468. /**
  47469. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47470. */
  47471. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47472. /**
  47473. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47474. */
  47475. useAmbientInGrayScale: boolean;
  47476. /**
  47477. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47478. * The material will try to infer what glossiness each pixel should be.
  47479. */
  47480. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47481. /**
  47482. * BJS is using an harcoded light falloff based on a manually sets up range.
  47483. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47484. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47485. */
  47486. /**
  47487. * BJS is using an harcoded light falloff based on a manually sets up range.
  47488. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47489. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47490. */
  47491. usePhysicalLightFalloff: boolean;
  47492. /**
  47493. * In order to support the falloff compatibility with gltf, a special mode has been added
  47494. * to reproduce the gltf light falloff.
  47495. */
  47496. /**
  47497. * In order to support the falloff compatibility with gltf, a special mode has been added
  47498. * to reproduce the gltf light falloff.
  47499. */
  47500. useGLTFLightFalloff: boolean;
  47501. /**
  47502. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47503. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47504. */
  47505. useRadianceOverAlpha: boolean;
  47506. /**
  47507. * Allows using an object space normal map (instead of tangent space).
  47508. */
  47509. useObjectSpaceNormalMap: boolean;
  47510. /**
  47511. * Allows using the bump map in parallax mode.
  47512. */
  47513. useParallax: boolean;
  47514. /**
  47515. * Allows using the bump map in parallax occlusion mode.
  47516. */
  47517. useParallaxOcclusion: boolean;
  47518. /**
  47519. * Controls the scale bias of the parallax mode.
  47520. */
  47521. parallaxScaleBias: number;
  47522. /**
  47523. * If sets to true, disables all the lights affecting the material.
  47524. */
  47525. disableLighting: boolean;
  47526. /**
  47527. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47528. */
  47529. forceIrradianceInFragment: boolean;
  47530. /**
  47531. * Number of Simultaneous lights allowed on the material.
  47532. */
  47533. maxSimultaneousLights: number;
  47534. /**
  47535. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47536. */
  47537. invertNormalMapX: boolean;
  47538. /**
  47539. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47540. */
  47541. invertNormalMapY: boolean;
  47542. /**
  47543. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47544. */
  47545. twoSidedLighting: boolean;
  47546. /**
  47547. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47548. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47549. */
  47550. useAlphaFresnel: boolean;
  47551. /**
  47552. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47553. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47554. */
  47555. useLinearAlphaFresnel: boolean;
  47556. /**
  47557. * Let user defines the brdf lookup texture used for IBL.
  47558. * A default 8bit version is embedded but you could point at :
  47559. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  47560. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47561. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  47562. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47563. */
  47564. environmentBRDFTexture: Nullable<BaseTexture>;
  47565. /**
  47566. * Force normal to face away from face.
  47567. */
  47568. forceNormalForward: boolean;
  47569. /**
  47570. * Enables specular anti aliasing in the PBR shader.
  47571. * It will both interacts on the Geometry for analytical and IBL lighting.
  47572. * It also prefilter the roughness map based on the bump values.
  47573. */
  47574. enableSpecularAntiAliasing: boolean;
  47575. /**
  47576. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47577. * makes the reflect vector face the model (under horizon).
  47578. */
  47579. useHorizonOcclusion: boolean;
  47580. /**
  47581. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47582. * too much the area relying on ambient texture to define their ambient occlusion.
  47583. */
  47584. useRadianceOcclusion: boolean;
  47585. /**
  47586. * If set to true, no lighting calculations will be applied.
  47587. */
  47588. unlit: boolean;
  47589. /**
  47590. * Gets the image processing configuration used either in this material.
  47591. */
  47592. /**
  47593. * Sets the Default image processing configuration used either in the this material.
  47594. *
  47595. * If sets to null, the scene one is in use.
  47596. */
  47597. imageProcessingConfiguration: ImageProcessingConfiguration;
  47598. /**
  47599. * Gets wether the color curves effect is enabled.
  47600. */
  47601. /**
  47602. * Sets wether the color curves effect is enabled.
  47603. */
  47604. cameraColorCurvesEnabled: boolean;
  47605. /**
  47606. * Gets wether the color grading effect is enabled.
  47607. */
  47608. /**
  47609. * Gets wether the color grading effect is enabled.
  47610. */
  47611. cameraColorGradingEnabled: boolean;
  47612. /**
  47613. * Gets wether tonemapping is enabled or not.
  47614. */
  47615. /**
  47616. * Sets wether tonemapping is enabled or not
  47617. */
  47618. cameraToneMappingEnabled: boolean;
  47619. /**
  47620. * The camera exposure used on this material.
  47621. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47622. * This corresponds to a photographic exposure.
  47623. */
  47624. /**
  47625. * The camera exposure used on this material.
  47626. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47627. * This corresponds to a photographic exposure.
  47628. */
  47629. cameraExposure: number;
  47630. /**
  47631. * Gets The camera contrast used on this material.
  47632. */
  47633. /**
  47634. * Sets The camera contrast used on this material.
  47635. */
  47636. cameraContrast: number;
  47637. /**
  47638. * Gets the Color Grading 2D Lookup Texture.
  47639. */
  47640. /**
  47641. * Sets the Color Grading 2D Lookup Texture.
  47642. */
  47643. cameraColorGradingTexture: Nullable<BaseTexture>;
  47644. /**
  47645. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47646. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47647. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  47648. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47649. */
  47650. /**
  47651. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47652. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47653. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  47654. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47655. */
  47656. cameraColorCurves: Nullable<ColorCurves>;
  47657. /**
  47658. * Instantiates a new PBRMaterial instance.
  47659. *
  47660. * @param name The material name
  47661. * @param scene The scene the material will be use in.
  47662. */
  47663. constructor(name: string, scene: Scene);
  47664. /**
  47665. * Returns the name of this material class.
  47666. */
  47667. getClassName(): string;
  47668. /**
  47669. * Makes a duplicate of the current material.
  47670. * @param name - name to use for the new material.
  47671. */
  47672. clone(name: string): PBRMaterial;
  47673. /**
  47674. * Serializes this PBR Material.
  47675. * @returns - An object with the serialized material.
  47676. */
  47677. serialize(): any;
  47678. /**
  47679. * Parses a PBR Material from a serialized object.
  47680. * @param source - Serialized object.
  47681. * @param scene - BJS scene instance.
  47682. * @param rootUrl - url for the scene object
  47683. * @returns - PBRMaterial
  47684. */
  47685. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47686. }
  47687. }
  47688. declare module BABYLON {
  47689. /**
  47690. * Direct draw surface info
  47691. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47692. */
  47693. export interface DDSInfo {
  47694. /**
  47695. * Width of the texture
  47696. */
  47697. width: number;
  47698. /**
  47699. * Width of the texture
  47700. */
  47701. height: number;
  47702. /**
  47703. * Number of Mipmaps for the texture
  47704. * @see https://en.wikipedia.org/wiki/Mipmap
  47705. */
  47706. mipmapCount: number;
  47707. /**
  47708. * If the textures format is a known fourCC format
  47709. * @see https://www.fourcc.org/
  47710. */
  47711. isFourCC: boolean;
  47712. /**
  47713. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47714. */
  47715. isRGB: boolean;
  47716. /**
  47717. * If the texture is a lumincance format
  47718. */
  47719. isLuminance: boolean;
  47720. /**
  47721. * If this is a cube texture
  47722. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47723. */
  47724. isCube: boolean;
  47725. /**
  47726. * If the texture is a compressed format eg. FOURCC_DXT1
  47727. */
  47728. isCompressed: boolean;
  47729. /**
  47730. * The dxgiFormat of the texture
  47731. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47732. */
  47733. dxgiFormat: number;
  47734. /**
  47735. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47736. */
  47737. textureType: number;
  47738. /**
  47739. * Sphericle polynomial created for the dds texture
  47740. */
  47741. sphericalPolynomial?: SphericalPolynomial;
  47742. }
  47743. /**
  47744. * Class used to provide DDS decompression tools
  47745. */
  47746. export class DDSTools {
  47747. /**
  47748. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47749. */
  47750. static StoreLODInAlphaChannel: boolean;
  47751. /**
  47752. * Gets DDS information from an array buffer
  47753. * @param arrayBuffer defines the array buffer to read data from
  47754. * @returns the DDS information
  47755. */
  47756. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47757. private static _FloatView;
  47758. private static _Int32View;
  47759. private static _ToHalfFloat;
  47760. private static _FromHalfFloat;
  47761. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47762. private static _GetHalfFloatRGBAArrayBuffer;
  47763. private static _GetFloatRGBAArrayBuffer;
  47764. private static _GetFloatAsUIntRGBAArrayBuffer;
  47765. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47766. private static _GetRGBAArrayBuffer;
  47767. private static _ExtractLongWordOrder;
  47768. private static _GetRGBArrayBuffer;
  47769. private static _GetLuminanceArrayBuffer;
  47770. /**
  47771. * Uploads DDS Levels to a Babylon Texture
  47772. * @hidden
  47773. */
  47774. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47775. }
  47776. interface ThinEngine {
  47777. /**
  47778. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47779. * @param rootUrl defines the url where the file to load is located
  47780. * @param scene defines the current scene
  47781. * @param lodScale defines scale to apply to the mip map selection
  47782. * @param lodOffset defines offset to apply to the mip map selection
  47783. * @param onLoad defines an optional callback raised when the texture is loaded
  47784. * @param onError defines an optional callback raised if there is an issue to load the texture
  47785. * @param format defines the format of the data
  47786. * @param forcedExtension defines the extension to use to pick the right loader
  47787. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47788. * @returns the cube texture as an InternalTexture
  47789. */
  47790. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  47791. }
  47792. }
  47793. declare module BABYLON {
  47794. /**
  47795. * Implementation of the DDS Texture Loader.
  47796. * @hidden
  47797. */
  47798. export class _DDSTextureLoader implements IInternalTextureLoader {
  47799. /**
  47800. * Defines wether the loader supports cascade loading the different faces.
  47801. */
  47802. readonly supportCascades: boolean;
  47803. /**
  47804. * This returns if the loader support the current file information.
  47805. * @param extension defines the file extension of the file being loaded
  47806. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47807. * @param fallback defines the fallback internal texture if any
  47808. * @param isBase64 defines whether the texture is encoded as a base64
  47809. * @param isBuffer defines whether the texture data are stored as a buffer
  47810. * @returns true if the loader can load the specified file
  47811. */
  47812. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47813. /**
  47814. * Transform the url before loading if required.
  47815. * @param rootUrl the url of the texture
  47816. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47817. * @returns the transformed texture
  47818. */
  47819. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47820. /**
  47821. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47822. * @param rootUrl the url of the texture
  47823. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47824. * @returns the fallback texture
  47825. */
  47826. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47827. /**
  47828. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47829. * @param data contains the texture data
  47830. * @param texture defines the BabylonJS internal texture
  47831. * @param createPolynomials will be true if polynomials have been requested
  47832. * @param onLoad defines the callback to trigger once the texture is ready
  47833. * @param onError defines the callback to trigger in case of error
  47834. */
  47835. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47836. /**
  47837. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47838. * @param data contains the texture data
  47839. * @param texture defines the BabylonJS internal texture
  47840. * @param callback defines the method to call once ready to upload
  47841. */
  47842. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47843. }
  47844. }
  47845. declare module BABYLON {
  47846. /**
  47847. * Implementation of the ENV Texture Loader.
  47848. * @hidden
  47849. */
  47850. export class _ENVTextureLoader implements IInternalTextureLoader {
  47851. /**
  47852. * Defines wether the loader supports cascade loading the different faces.
  47853. */
  47854. readonly supportCascades: boolean;
  47855. /**
  47856. * This returns if the loader support the current file information.
  47857. * @param extension defines the file extension of the file being loaded
  47858. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47859. * @param fallback defines the fallback internal texture if any
  47860. * @param isBase64 defines whether the texture is encoded as a base64
  47861. * @param isBuffer defines whether the texture data are stored as a buffer
  47862. * @returns true if the loader can load the specified file
  47863. */
  47864. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47865. /**
  47866. * Transform the url before loading if required.
  47867. * @param rootUrl the url of the texture
  47868. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47869. * @returns the transformed texture
  47870. */
  47871. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47872. /**
  47873. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47874. * @param rootUrl the url of the texture
  47875. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47876. * @returns the fallback texture
  47877. */
  47878. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47879. /**
  47880. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47881. * @param data contains the texture data
  47882. * @param texture defines the BabylonJS internal texture
  47883. * @param createPolynomials will be true if polynomials have been requested
  47884. * @param onLoad defines the callback to trigger once the texture is ready
  47885. * @param onError defines the callback to trigger in case of error
  47886. */
  47887. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47888. /**
  47889. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47890. * @param data contains the texture data
  47891. * @param texture defines the BabylonJS internal texture
  47892. * @param callback defines the method to call once ready to upload
  47893. */
  47894. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47895. }
  47896. }
  47897. declare module BABYLON {
  47898. /**
  47899. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47900. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47901. */
  47902. export class KhronosTextureContainer {
  47903. /** contents of the KTX container file */
  47904. arrayBuffer: any;
  47905. private static HEADER_LEN;
  47906. private static COMPRESSED_2D;
  47907. private static COMPRESSED_3D;
  47908. private static TEX_2D;
  47909. private static TEX_3D;
  47910. /**
  47911. * Gets the openGL type
  47912. */
  47913. glType: number;
  47914. /**
  47915. * Gets the openGL type size
  47916. */
  47917. glTypeSize: number;
  47918. /**
  47919. * Gets the openGL format
  47920. */
  47921. glFormat: number;
  47922. /**
  47923. * Gets the openGL internal format
  47924. */
  47925. glInternalFormat: number;
  47926. /**
  47927. * Gets the base internal format
  47928. */
  47929. glBaseInternalFormat: number;
  47930. /**
  47931. * Gets image width in pixel
  47932. */
  47933. pixelWidth: number;
  47934. /**
  47935. * Gets image height in pixel
  47936. */
  47937. pixelHeight: number;
  47938. /**
  47939. * Gets image depth in pixels
  47940. */
  47941. pixelDepth: number;
  47942. /**
  47943. * Gets the number of array elements
  47944. */
  47945. numberOfArrayElements: number;
  47946. /**
  47947. * Gets the number of faces
  47948. */
  47949. numberOfFaces: number;
  47950. /**
  47951. * Gets the number of mipmap levels
  47952. */
  47953. numberOfMipmapLevels: number;
  47954. /**
  47955. * Gets the bytes of key value data
  47956. */
  47957. bytesOfKeyValueData: number;
  47958. /**
  47959. * Gets the load type
  47960. */
  47961. loadType: number;
  47962. /**
  47963. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47964. */
  47965. isInvalid: boolean;
  47966. /**
  47967. * Creates a new KhronosTextureContainer
  47968. * @param arrayBuffer contents of the KTX container file
  47969. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47970. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47971. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47972. */
  47973. constructor(
  47974. /** contents of the KTX container file */
  47975. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47976. /**
  47977. * Uploads KTX content to a Babylon Texture.
  47978. * It is assumed that the texture has already been created & is currently bound
  47979. * @hidden
  47980. */
  47981. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47982. private _upload2DCompressedLevels;
  47983. }
  47984. }
  47985. declare module BABYLON {
  47986. /**
  47987. * Implementation of the KTX Texture Loader.
  47988. * @hidden
  47989. */
  47990. export class _KTXTextureLoader implements IInternalTextureLoader {
  47991. /**
  47992. * Defines wether the loader supports cascade loading the different faces.
  47993. */
  47994. readonly supportCascades: boolean;
  47995. /**
  47996. * This returns if the loader support the current file information.
  47997. * @param extension defines the file extension of the file being loaded
  47998. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47999. * @param fallback defines the fallback internal texture if any
  48000. * @param isBase64 defines whether the texture is encoded as a base64
  48001. * @param isBuffer defines whether the texture data are stored as a buffer
  48002. * @returns true if the loader can load the specified file
  48003. */
  48004. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48005. /**
  48006. * Transform the url before loading if required.
  48007. * @param rootUrl the url of the texture
  48008. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48009. * @returns the transformed texture
  48010. */
  48011. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48012. /**
  48013. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48014. * @param rootUrl the url of the texture
  48015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48016. * @returns the fallback texture
  48017. */
  48018. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48019. /**
  48020. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48021. * @param data contains the texture data
  48022. * @param texture defines the BabylonJS internal texture
  48023. * @param createPolynomials will be true if polynomials have been requested
  48024. * @param onLoad defines the callback to trigger once the texture is ready
  48025. * @param onError defines the callback to trigger in case of error
  48026. */
  48027. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48028. /**
  48029. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48030. * @param data contains the texture data
  48031. * @param texture defines the BabylonJS internal texture
  48032. * @param callback defines the method to call once ready to upload
  48033. */
  48034. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48035. }
  48036. }
  48037. declare module BABYLON {
  48038. /**
  48039. * Options for the default xr helper
  48040. */
  48041. export class WebXRDefaultExperienceOptions {
  48042. /**
  48043. * Floor meshes that should be used for teleporting
  48044. */
  48045. floorMeshes: Array<AbstractMesh>;
  48046. }
  48047. /**
  48048. * Default experience which provides a similar setup to the previous webVRExperience
  48049. */
  48050. export class WebXRDefaultExperience {
  48051. /**
  48052. * Base experience
  48053. */
  48054. baseExperience: WebXRExperienceHelper;
  48055. /**
  48056. * Input experience extension
  48057. */
  48058. input: WebXRInput;
  48059. /**
  48060. * Loads the controller models
  48061. */
  48062. controllerModelLoader: WebXRControllerModelLoader;
  48063. /**
  48064. * Enables laser pointer and selection
  48065. */
  48066. pointerSelection: WebXRControllerPointerSelection;
  48067. /**
  48068. * Enables teleportation
  48069. */
  48070. teleportation: WebXRControllerTeleportation;
  48071. /**
  48072. * Enables ui for enetering/exiting xr
  48073. */
  48074. enterExitUI: WebXREnterExitUI;
  48075. /**
  48076. * Default output canvas xr should render to
  48077. */
  48078. outputCanvas: WebXRManagedOutputCanvas;
  48079. /**
  48080. * Creates the default xr experience
  48081. * @param scene scene
  48082. * @param options options for basic configuration
  48083. * @returns resulting WebXRDefaultExperience
  48084. */
  48085. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48086. private constructor();
  48087. /**
  48088. * DIsposes of the experience helper
  48089. */
  48090. dispose(): void;
  48091. }
  48092. }
  48093. declare module BABYLON {
  48094. /** @hidden */
  48095. export var _forceSceneHelpersToBundle: boolean;
  48096. interface Scene {
  48097. /**
  48098. * Creates a default light for the scene.
  48099. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48100. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48101. */
  48102. createDefaultLight(replace?: boolean): void;
  48103. /**
  48104. * Creates a default camera for the scene.
  48105. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48106. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48107. * @param replace has default false, when true replaces the active camera in the scene
  48108. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48109. */
  48110. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48111. /**
  48112. * Creates a default camera and a default light.
  48113. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48114. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48115. * @param replace has the default false, when true replaces the active camera/light in the scene
  48116. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48117. */
  48118. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48119. /**
  48120. * Creates a new sky box
  48121. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48122. * @param environmentTexture defines the texture to use as environment texture
  48123. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48124. * @param scale defines the overall scale of the skybox
  48125. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48126. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48127. * @returns a new mesh holding the sky box
  48128. */
  48129. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48130. /**
  48131. * Creates a new environment
  48132. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48133. * @param options defines the options you can use to configure the environment
  48134. * @returns the new EnvironmentHelper
  48135. */
  48136. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48137. /**
  48138. * Creates a new VREXperienceHelper
  48139. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48140. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48141. * @returns a new VREXperienceHelper
  48142. */
  48143. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48144. /**
  48145. * Creates a new WebXRDefaultExperience
  48146. * @see http://doc.babylonjs.com/how_to/webxr
  48147. * @param options experience options
  48148. * @returns a promise for a new WebXRDefaultExperience
  48149. */
  48150. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48151. }
  48152. }
  48153. declare module BABYLON {
  48154. /**
  48155. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48156. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48157. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48158. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48159. */
  48160. export class VideoDome extends TransformNode {
  48161. /**
  48162. * Define the video source as a Monoscopic panoramic 360 video.
  48163. */
  48164. static readonly MODE_MONOSCOPIC: number;
  48165. /**
  48166. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48167. */
  48168. static readonly MODE_TOPBOTTOM: number;
  48169. /**
  48170. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48171. */
  48172. static readonly MODE_SIDEBYSIDE: number;
  48173. private _halfDome;
  48174. private _useDirectMapping;
  48175. /**
  48176. * The video texture being displayed on the sphere
  48177. */
  48178. protected _videoTexture: VideoTexture;
  48179. /**
  48180. * Gets the video texture being displayed on the sphere
  48181. */
  48182. readonly videoTexture: VideoTexture;
  48183. /**
  48184. * The skybox material
  48185. */
  48186. protected _material: BackgroundMaterial;
  48187. /**
  48188. * The surface used for the skybox
  48189. */
  48190. protected _mesh: Mesh;
  48191. /**
  48192. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  48193. */
  48194. private _halfDomeMask;
  48195. /**
  48196. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48197. * Also see the options.resolution property.
  48198. */
  48199. fovMultiplier: number;
  48200. private _videoMode;
  48201. /**
  48202. * Gets or set the current video mode for the video. It can be:
  48203. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48204. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48205. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48206. */
  48207. videoMode: number;
  48208. /**
  48209. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  48210. *
  48211. */
  48212. /**
  48213. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  48214. */
  48215. halfDome: boolean;
  48216. /**
  48217. * Oberserver used in Stereoscopic VR Mode.
  48218. */
  48219. private _onBeforeCameraRenderObserver;
  48220. /**
  48221. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48222. * @param name Element's name, child elements will append suffixes for their own names.
  48223. * @param urlsOrVideo defines the url(s) or the video element to use
  48224. * @param options An object containing optional or exposed sub element properties
  48225. */
  48226. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48227. resolution?: number;
  48228. clickToPlay?: boolean;
  48229. autoPlay?: boolean;
  48230. loop?: boolean;
  48231. size?: number;
  48232. poster?: string;
  48233. faceForward?: boolean;
  48234. useDirectMapping?: boolean;
  48235. halfDomeMode?: boolean;
  48236. }, scene: Scene);
  48237. private _changeVideoMode;
  48238. /**
  48239. * Releases resources associated with this node.
  48240. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48241. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48242. */
  48243. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48244. }
  48245. }
  48246. declare module BABYLON {
  48247. /**
  48248. * This class can be used to get instrumentation data from a Babylon engine
  48249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48250. */
  48251. export class EngineInstrumentation implements IDisposable {
  48252. /**
  48253. * Define the instrumented engine.
  48254. */
  48255. engine: Engine;
  48256. private _captureGPUFrameTime;
  48257. private _gpuFrameTimeToken;
  48258. private _gpuFrameTime;
  48259. private _captureShaderCompilationTime;
  48260. private _shaderCompilationTime;
  48261. private _onBeginFrameObserver;
  48262. private _onEndFrameObserver;
  48263. private _onBeforeShaderCompilationObserver;
  48264. private _onAfterShaderCompilationObserver;
  48265. /**
  48266. * Gets the perf counter used for GPU frame time
  48267. */
  48268. readonly gpuFrameTimeCounter: PerfCounter;
  48269. /**
  48270. * Gets the GPU frame time capture status
  48271. */
  48272. /**
  48273. * Enable or disable the GPU frame time capture
  48274. */
  48275. captureGPUFrameTime: boolean;
  48276. /**
  48277. * Gets the perf counter used for shader compilation time
  48278. */
  48279. readonly shaderCompilationTimeCounter: PerfCounter;
  48280. /**
  48281. * Gets the shader compilation time capture status
  48282. */
  48283. /**
  48284. * Enable or disable the shader compilation time capture
  48285. */
  48286. captureShaderCompilationTime: boolean;
  48287. /**
  48288. * Instantiates a new engine instrumentation.
  48289. * This class can be used to get instrumentation data from a Babylon engine
  48290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48291. * @param engine Defines the engine to instrument
  48292. */
  48293. constructor(
  48294. /**
  48295. * Define the instrumented engine.
  48296. */
  48297. engine: Engine);
  48298. /**
  48299. * Dispose and release associated resources.
  48300. */
  48301. dispose(): void;
  48302. }
  48303. }
  48304. declare module BABYLON {
  48305. /**
  48306. * This class can be used to get instrumentation data from a Babylon engine
  48307. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48308. */
  48309. export class SceneInstrumentation implements IDisposable {
  48310. /**
  48311. * Defines the scene to instrument
  48312. */
  48313. scene: Scene;
  48314. private _captureActiveMeshesEvaluationTime;
  48315. private _activeMeshesEvaluationTime;
  48316. private _captureRenderTargetsRenderTime;
  48317. private _renderTargetsRenderTime;
  48318. private _captureFrameTime;
  48319. private _frameTime;
  48320. private _captureRenderTime;
  48321. private _renderTime;
  48322. private _captureInterFrameTime;
  48323. private _interFrameTime;
  48324. private _captureParticlesRenderTime;
  48325. private _particlesRenderTime;
  48326. private _captureSpritesRenderTime;
  48327. private _spritesRenderTime;
  48328. private _capturePhysicsTime;
  48329. private _physicsTime;
  48330. private _captureAnimationsTime;
  48331. private _animationsTime;
  48332. private _captureCameraRenderTime;
  48333. private _cameraRenderTime;
  48334. private _onBeforeActiveMeshesEvaluationObserver;
  48335. private _onAfterActiveMeshesEvaluationObserver;
  48336. private _onBeforeRenderTargetsRenderObserver;
  48337. private _onAfterRenderTargetsRenderObserver;
  48338. private _onAfterRenderObserver;
  48339. private _onBeforeDrawPhaseObserver;
  48340. private _onAfterDrawPhaseObserver;
  48341. private _onBeforeAnimationsObserver;
  48342. private _onBeforeParticlesRenderingObserver;
  48343. private _onAfterParticlesRenderingObserver;
  48344. private _onBeforeSpritesRenderingObserver;
  48345. private _onAfterSpritesRenderingObserver;
  48346. private _onBeforePhysicsObserver;
  48347. private _onAfterPhysicsObserver;
  48348. private _onAfterAnimationsObserver;
  48349. private _onBeforeCameraRenderObserver;
  48350. private _onAfterCameraRenderObserver;
  48351. /**
  48352. * Gets the perf counter used for active meshes evaluation time
  48353. */
  48354. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48355. /**
  48356. * Gets the active meshes evaluation time capture status
  48357. */
  48358. /**
  48359. * Enable or disable the active meshes evaluation time capture
  48360. */
  48361. captureActiveMeshesEvaluationTime: boolean;
  48362. /**
  48363. * Gets the perf counter used for render targets render time
  48364. */
  48365. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48366. /**
  48367. * Gets the render targets render time capture status
  48368. */
  48369. /**
  48370. * Enable or disable the render targets render time capture
  48371. */
  48372. captureRenderTargetsRenderTime: boolean;
  48373. /**
  48374. * Gets the perf counter used for particles render time
  48375. */
  48376. readonly particlesRenderTimeCounter: PerfCounter;
  48377. /**
  48378. * Gets the particles render time capture status
  48379. */
  48380. /**
  48381. * Enable or disable the particles render time capture
  48382. */
  48383. captureParticlesRenderTime: boolean;
  48384. /**
  48385. * Gets the perf counter used for sprites render time
  48386. */
  48387. readonly spritesRenderTimeCounter: PerfCounter;
  48388. /**
  48389. * Gets the sprites render time capture status
  48390. */
  48391. /**
  48392. * Enable or disable the sprites render time capture
  48393. */
  48394. captureSpritesRenderTime: boolean;
  48395. /**
  48396. * Gets the perf counter used for physics time
  48397. */
  48398. readonly physicsTimeCounter: PerfCounter;
  48399. /**
  48400. * Gets the physics time capture status
  48401. */
  48402. /**
  48403. * Enable or disable the physics time capture
  48404. */
  48405. capturePhysicsTime: boolean;
  48406. /**
  48407. * Gets the perf counter used for animations time
  48408. */
  48409. readonly animationsTimeCounter: PerfCounter;
  48410. /**
  48411. * Gets the animations time capture status
  48412. */
  48413. /**
  48414. * Enable or disable the animations time capture
  48415. */
  48416. captureAnimationsTime: boolean;
  48417. /**
  48418. * Gets the perf counter used for frame time capture
  48419. */
  48420. readonly frameTimeCounter: PerfCounter;
  48421. /**
  48422. * Gets the frame time capture status
  48423. */
  48424. /**
  48425. * Enable or disable the frame time capture
  48426. */
  48427. captureFrameTime: boolean;
  48428. /**
  48429. * Gets the perf counter used for inter-frames time capture
  48430. */
  48431. readonly interFrameTimeCounter: PerfCounter;
  48432. /**
  48433. * Gets the inter-frames time capture status
  48434. */
  48435. /**
  48436. * Enable or disable the inter-frames time capture
  48437. */
  48438. captureInterFrameTime: boolean;
  48439. /**
  48440. * Gets the perf counter used for render time capture
  48441. */
  48442. readonly renderTimeCounter: PerfCounter;
  48443. /**
  48444. * Gets the render time capture status
  48445. */
  48446. /**
  48447. * Enable or disable the render time capture
  48448. */
  48449. captureRenderTime: boolean;
  48450. /**
  48451. * Gets the perf counter used for camera render time capture
  48452. */
  48453. readonly cameraRenderTimeCounter: PerfCounter;
  48454. /**
  48455. * Gets the camera render time capture status
  48456. */
  48457. /**
  48458. * Enable or disable the camera render time capture
  48459. */
  48460. captureCameraRenderTime: boolean;
  48461. /**
  48462. * Gets the perf counter used for draw calls
  48463. */
  48464. readonly drawCallsCounter: PerfCounter;
  48465. /**
  48466. * Instantiates a new scene instrumentation.
  48467. * This class can be used to get instrumentation data from a Babylon engine
  48468. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48469. * @param scene Defines the scene to instrument
  48470. */
  48471. constructor(
  48472. /**
  48473. * Defines the scene to instrument
  48474. */
  48475. scene: Scene);
  48476. /**
  48477. * Dispose and release associated resources.
  48478. */
  48479. dispose(): void;
  48480. }
  48481. }
  48482. declare module BABYLON {
  48483. /** @hidden */
  48484. export var glowMapGenerationPixelShader: {
  48485. name: string;
  48486. shader: string;
  48487. };
  48488. }
  48489. declare module BABYLON {
  48490. /** @hidden */
  48491. export var glowMapGenerationVertexShader: {
  48492. name: string;
  48493. shader: string;
  48494. };
  48495. }
  48496. declare module BABYLON {
  48497. /**
  48498. * Effect layer options. This helps customizing the behaviour
  48499. * of the effect layer.
  48500. */
  48501. export interface IEffectLayerOptions {
  48502. /**
  48503. * Multiplication factor apply to the canvas size to compute the render target size
  48504. * used to generated the objects (the smaller the faster).
  48505. */
  48506. mainTextureRatio: number;
  48507. /**
  48508. * Enforces a fixed size texture to ensure effect stability across devices.
  48509. */
  48510. mainTextureFixedSize?: number;
  48511. /**
  48512. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48513. */
  48514. alphaBlendingMode: number;
  48515. /**
  48516. * The camera attached to the layer.
  48517. */
  48518. camera: Nullable<Camera>;
  48519. /**
  48520. * The rendering group to draw the layer in.
  48521. */
  48522. renderingGroupId: number;
  48523. }
  48524. /**
  48525. * The effect layer Helps adding post process effect blended with the main pass.
  48526. *
  48527. * This can be for instance use to generate glow or higlight effects on the scene.
  48528. *
  48529. * The effect layer class can not be used directly and is intented to inherited from to be
  48530. * customized per effects.
  48531. */
  48532. export abstract class EffectLayer {
  48533. private _vertexBuffers;
  48534. private _indexBuffer;
  48535. private _cachedDefines;
  48536. private _effectLayerMapGenerationEffect;
  48537. private _effectLayerOptions;
  48538. private _mergeEffect;
  48539. protected _scene: Scene;
  48540. protected _engine: Engine;
  48541. protected _maxSize: number;
  48542. protected _mainTextureDesiredSize: ISize;
  48543. protected _mainTexture: RenderTargetTexture;
  48544. protected _shouldRender: boolean;
  48545. protected _postProcesses: PostProcess[];
  48546. protected _textures: BaseTexture[];
  48547. protected _emissiveTextureAndColor: {
  48548. texture: Nullable<BaseTexture>;
  48549. color: Color4;
  48550. };
  48551. /**
  48552. * The name of the layer
  48553. */
  48554. name: string;
  48555. /**
  48556. * The clear color of the texture used to generate the glow map.
  48557. */
  48558. neutralColor: Color4;
  48559. /**
  48560. * Specifies wether the highlight layer is enabled or not.
  48561. */
  48562. isEnabled: boolean;
  48563. /**
  48564. * Gets the camera attached to the layer.
  48565. */
  48566. readonly camera: Nullable<Camera>;
  48567. /**
  48568. * Gets the rendering group id the layer should render in.
  48569. */
  48570. renderingGroupId: number;
  48571. /**
  48572. * An event triggered when the effect layer has been disposed.
  48573. */
  48574. onDisposeObservable: Observable<EffectLayer>;
  48575. /**
  48576. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48577. */
  48578. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48579. /**
  48580. * An event triggered when the generated texture is being merged in the scene.
  48581. */
  48582. onBeforeComposeObservable: Observable<EffectLayer>;
  48583. /**
  48584. * An event triggered when the generated texture has been merged in the scene.
  48585. */
  48586. onAfterComposeObservable: Observable<EffectLayer>;
  48587. /**
  48588. * An event triggered when the efffect layer changes its size.
  48589. */
  48590. onSizeChangedObservable: Observable<EffectLayer>;
  48591. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48592. /**
  48593. * Instantiates a new effect Layer and references it in the scene.
  48594. * @param name The name of the layer
  48595. * @param scene The scene to use the layer in
  48596. */
  48597. constructor(
  48598. /** The Friendly of the effect in the scene */
  48599. name: string, scene: Scene);
  48600. /**
  48601. * Get the effect name of the layer.
  48602. * @return The effect name
  48603. */
  48604. abstract getEffectName(): string;
  48605. /**
  48606. * Checks for the readiness of the element composing the layer.
  48607. * @param subMesh the mesh to check for
  48608. * @param useInstances specify wether or not to use instances to render the mesh
  48609. * @return true if ready otherwise, false
  48610. */
  48611. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48612. /**
  48613. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48614. * @returns true if the effect requires stencil during the main canvas render pass.
  48615. */
  48616. abstract needStencil(): boolean;
  48617. /**
  48618. * Create the merge effect. This is the shader use to blit the information back
  48619. * to the main canvas at the end of the scene rendering.
  48620. * @returns The effect containing the shader used to merge the effect on the main canvas
  48621. */
  48622. protected abstract _createMergeEffect(): Effect;
  48623. /**
  48624. * Creates the render target textures and post processes used in the effect layer.
  48625. */
  48626. protected abstract _createTextureAndPostProcesses(): void;
  48627. /**
  48628. * Implementation specific of rendering the generating effect on the main canvas.
  48629. * @param effect The effect used to render through
  48630. */
  48631. protected abstract _internalRender(effect: Effect): void;
  48632. /**
  48633. * Sets the required values for both the emissive texture and and the main color.
  48634. */
  48635. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48636. /**
  48637. * Free any resources and references associated to a mesh.
  48638. * Internal use
  48639. * @param mesh The mesh to free.
  48640. */
  48641. abstract _disposeMesh(mesh: Mesh): void;
  48642. /**
  48643. * Serializes this layer (Glow or Highlight for example)
  48644. * @returns a serialized layer object
  48645. */
  48646. abstract serialize?(): any;
  48647. /**
  48648. * Initializes the effect layer with the required options.
  48649. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48650. */
  48651. protected _init(options: Partial<IEffectLayerOptions>): void;
  48652. /**
  48653. * Generates the index buffer of the full screen quad blending to the main canvas.
  48654. */
  48655. private _generateIndexBuffer;
  48656. /**
  48657. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48658. */
  48659. private _generateVertexBuffer;
  48660. /**
  48661. * Sets the main texture desired size which is the closest power of two
  48662. * of the engine canvas size.
  48663. */
  48664. private _setMainTextureSize;
  48665. /**
  48666. * Creates the main texture for the effect layer.
  48667. */
  48668. protected _createMainTexture(): void;
  48669. /**
  48670. * Adds specific effects defines.
  48671. * @param defines The defines to add specifics to.
  48672. */
  48673. protected _addCustomEffectDefines(defines: string[]): void;
  48674. /**
  48675. * Checks for the readiness of the element composing the layer.
  48676. * @param subMesh the mesh to check for
  48677. * @param useInstances specify wether or not to use instances to render the mesh
  48678. * @param emissiveTexture the associated emissive texture used to generate the glow
  48679. * @return true if ready otherwise, false
  48680. */
  48681. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48682. /**
  48683. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48684. */
  48685. render(): void;
  48686. /**
  48687. * Determine if a given mesh will be used in the current effect.
  48688. * @param mesh mesh to test
  48689. * @returns true if the mesh will be used
  48690. */
  48691. hasMesh(mesh: AbstractMesh): boolean;
  48692. /**
  48693. * Returns true if the layer contains information to display, otherwise false.
  48694. * @returns true if the glow layer should be rendered
  48695. */
  48696. shouldRender(): boolean;
  48697. /**
  48698. * Returns true if the mesh should render, otherwise false.
  48699. * @param mesh The mesh to render
  48700. * @returns true if it should render otherwise false
  48701. */
  48702. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48703. /**
  48704. * Returns true if the mesh can be rendered, otherwise false.
  48705. * @param mesh The mesh to render
  48706. * @param material The material used on the mesh
  48707. * @returns true if it can be rendered otherwise false
  48708. */
  48709. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48710. /**
  48711. * Returns true if the mesh should render, otherwise false.
  48712. * @param mesh The mesh to render
  48713. * @returns true if it should render otherwise false
  48714. */
  48715. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48716. /**
  48717. * Renders the submesh passed in parameter to the generation map.
  48718. */
  48719. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  48720. /**
  48721. * Rebuild the required buffers.
  48722. * @hidden Internal use only.
  48723. */ private _rebuild(): void;
  48724. /**
  48725. * Dispose only the render target textures and post process.
  48726. */
  48727. private _disposeTextureAndPostProcesses;
  48728. /**
  48729. * Dispose the highlight layer and free resources.
  48730. */
  48731. dispose(): void;
  48732. /**
  48733. * Gets the class name of the effect layer
  48734. * @returns the string with the class name of the effect layer
  48735. */
  48736. getClassName(): string;
  48737. /**
  48738. * Creates an effect layer from parsed effect layer data
  48739. * @param parsedEffectLayer defines effect layer data
  48740. * @param scene defines the current scene
  48741. * @param rootUrl defines the root URL containing the effect layer information
  48742. * @returns a parsed effect Layer
  48743. */
  48744. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48745. }
  48746. }
  48747. declare module BABYLON {
  48748. interface AbstractScene {
  48749. /**
  48750. * The list of effect layers (highlights/glow) added to the scene
  48751. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48752. * @see http://doc.babylonjs.com/how_to/glow_layer
  48753. */
  48754. effectLayers: Array<EffectLayer>;
  48755. /**
  48756. * Removes the given effect layer from this scene.
  48757. * @param toRemove defines the effect layer to remove
  48758. * @returns the index of the removed effect layer
  48759. */
  48760. removeEffectLayer(toRemove: EffectLayer): number;
  48761. /**
  48762. * Adds the given effect layer to this scene
  48763. * @param newEffectLayer defines the effect layer to add
  48764. */
  48765. addEffectLayer(newEffectLayer: EffectLayer): void;
  48766. }
  48767. /**
  48768. * Defines the layer scene component responsible to manage any effect layers
  48769. * in a given scene.
  48770. */
  48771. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48772. /**
  48773. * The component name helpfull to identify the component in the list of scene components.
  48774. */
  48775. readonly name: string;
  48776. /**
  48777. * The scene the component belongs to.
  48778. */
  48779. scene: Scene;
  48780. private _engine;
  48781. private _renderEffects;
  48782. private _needStencil;
  48783. private _previousStencilState;
  48784. /**
  48785. * Creates a new instance of the component for the given scene
  48786. * @param scene Defines the scene to register the component in
  48787. */
  48788. constructor(scene: Scene);
  48789. /**
  48790. * Registers the component in a given scene
  48791. */
  48792. register(): void;
  48793. /**
  48794. * Rebuilds the elements related to this component in case of
  48795. * context lost for instance.
  48796. */
  48797. rebuild(): void;
  48798. /**
  48799. * Serializes the component data to the specified json object
  48800. * @param serializationObject The object to serialize to
  48801. */
  48802. serialize(serializationObject: any): void;
  48803. /**
  48804. * Adds all the elements from the container to the scene
  48805. * @param container the container holding the elements
  48806. */
  48807. addFromContainer(container: AbstractScene): void;
  48808. /**
  48809. * Removes all the elements in the container from the scene
  48810. * @param container contains the elements to remove
  48811. * @param dispose if the removed element should be disposed (default: false)
  48812. */
  48813. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48814. /**
  48815. * Disposes the component and the associated ressources.
  48816. */
  48817. dispose(): void;
  48818. private _isReadyForMesh;
  48819. private _renderMainTexture;
  48820. private _setStencil;
  48821. private _setStencilBack;
  48822. private _draw;
  48823. private _drawCamera;
  48824. private _drawRenderingGroup;
  48825. }
  48826. }
  48827. declare module BABYLON {
  48828. /** @hidden */
  48829. export var glowMapMergePixelShader: {
  48830. name: string;
  48831. shader: string;
  48832. };
  48833. }
  48834. declare module BABYLON {
  48835. /** @hidden */
  48836. export var glowMapMergeVertexShader: {
  48837. name: string;
  48838. shader: string;
  48839. };
  48840. }
  48841. declare module BABYLON {
  48842. interface AbstractScene {
  48843. /**
  48844. * Return a the first highlight layer of the scene with a given name.
  48845. * @param name The name of the highlight layer to look for.
  48846. * @return The highlight layer if found otherwise null.
  48847. */
  48848. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48849. }
  48850. /**
  48851. * Glow layer options. This helps customizing the behaviour
  48852. * of the glow layer.
  48853. */
  48854. export interface IGlowLayerOptions {
  48855. /**
  48856. * Multiplication factor apply to the canvas size to compute the render target size
  48857. * used to generated the glowing objects (the smaller the faster).
  48858. */
  48859. mainTextureRatio: number;
  48860. /**
  48861. * Enforces a fixed size texture to ensure resize independant blur.
  48862. */
  48863. mainTextureFixedSize?: number;
  48864. /**
  48865. * How big is the kernel of the blur texture.
  48866. */
  48867. blurKernelSize: number;
  48868. /**
  48869. * The camera attached to the layer.
  48870. */
  48871. camera: Nullable<Camera>;
  48872. /**
  48873. * Enable MSAA by chosing the number of samples.
  48874. */
  48875. mainTextureSamples?: number;
  48876. /**
  48877. * The rendering group to draw the layer in.
  48878. */
  48879. renderingGroupId: number;
  48880. }
  48881. /**
  48882. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48883. *
  48884. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48885. * glowy meshes to your scene.
  48886. *
  48887. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48888. */
  48889. export class GlowLayer extends EffectLayer {
  48890. /**
  48891. * Effect Name of the layer.
  48892. */
  48893. static readonly EffectName: string;
  48894. /**
  48895. * The default blur kernel size used for the glow.
  48896. */
  48897. static DefaultBlurKernelSize: number;
  48898. /**
  48899. * The default texture size ratio used for the glow.
  48900. */
  48901. static DefaultTextureRatio: number;
  48902. /**
  48903. * Sets the kernel size of the blur.
  48904. */
  48905. /**
  48906. * Gets the kernel size of the blur.
  48907. */
  48908. blurKernelSize: number;
  48909. /**
  48910. * Sets the glow intensity.
  48911. */
  48912. /**
  48913. * Gets the glow intensity.
  48914. */
  48915. intensity: number;
  48916. private _options;
  48917. private _intensity;
  48918. private _horizontalBlurPostprocess1;
  48919. private _verticalBlurPostprocess1;
  48920. private _horizontalBlurPostprocess2;
  48921. private _verticalBlurPostprocess2;
  48922. private _blurTexture1;
  48923. private _blurTexture2;
  48924. private _postProcesses1;
  48925. private _postProcesses2;
  48926. private _includedOnlyMeshes;
  48927. private _excludedMeshes;
  48928. /**
  48929. * Callback used to let the user override the color selection on a per mesh basis
  48930. */
  48931. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48932. /**
  48933. * Callback used to let the user override the texture selection on a per mesh basis
  48934. */
  48935. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48936. /**
  48937. * Instantiates a new glow Layer and references it to the scene.
  48938. * @param name The name of the layer
  48939. * @param scene The scene to use the layer in
  48940. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48941. */
  48942. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48943. /**
  48944. * Get the effect name of the layer.
  48945. * @return The effect name
  48946. */
  48947. getEffectName(): string;
  48948. /**
  48949. * Create the merge effect. This is the shader use to blit the information back
  48950. * to the main canvas at the end of the scene rendering.
  48951. */
  48952. protected _createMergeEffect(): Effect;
  48953. /**
  48954. * Creates the render target textures and post processes used in the glow layer.
  48955. */
  48956. protected _createTextureAndPostProcesses(): void;
  48957. /**
  48958. * Checks for the readiness of the element composing the layer.
  48959. * @param subMesh the mesh to check for
  48960. * @param useInstances specify wether or not to use instances to render the mesh
  48961. * @param emissiveTexture the associated emissive texture used to generate the glow
  48962. * @return true if ready otherwise, false
  48963. */
  48964. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48965. /**
  48966. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48967. */
  48968. needStencil(): boolean;
  48969. /**
  48970. * Returns true if the mesh can be rendered, otherwise false.
  48971. * @param mesh The mesh to render
  48972. * @param material The material used on the mesh
  48973. * @returns true if it can be rendered otherwise false
  48974. */
  48975. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48976. /**
  48977. * Implementation specific of rendering the generating effect on the main canvas.
  48978. * @param effect The effect used to render through
  48979. */
  48980. protected _internalRender(effect: Effect): void;
  48981. /**
  48982. * Sets the required values for both the emissive texture and and the main color.
  48983. */
  48984. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48985. /**
  48986. * Returns true if the mesh should render, otherwise false.
  48987. * @param mesh The mesh to render
  48988. * @returns true if it should render otherwise false
  48989. */
  48990. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48991. /**
  48992. * Adds specific effects defines.
  48993. * @param defines The defines to add specifics to.
  48994. */
  48995. protected _addCustomEffectDefines(defines: string[]): void;
  48996. /**
  48997. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48998. * @param mesh The mesh to exclude from the glow layer
  48999. */
  49000. addExcludedMesh(mesh: Mesh): void;
  49001. /**
  49002. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49003. * @param mesh The mesh to remove
  49004. */
  49005. removeExcludedMesh(mesh: Mesh): void;
  49006. /**
  49007. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49008. * @param mesh The mesh to include in the glow layer
  49009. */
  49010. addIncludedOnlyMesh(mesh: Mesh): void;
  49011. /**
  49012. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49013. * @param mesh The mesh to remove
  49014. */
  49015. removeIncludedOnlyMesh(mesh: Mesh): void;
  49016. /**
  49017. * Determine if a given mesh will be used in the glow layer
  49018. * @param mesh The mesh to test
  49019. * @returns true if the mesh will be highlighted by the current glow layer
  49020. */
  49021. hasMesh(mesh: AbstractMesh): boolean;
  49022. /**
  49023. * Free any resources and references associated to a mesh.
  49024. * Internal use
  49025. * @param mesh The mesh to free.
  49026. * @hidden
  49027. */ private _disposeMesh(mesh: Mesh): void;
  49028. /**
  49029. * Gets the class name of the effect layer
  49030. * @returns the string with the class name of the effect layer
  49031. */
  49032. getClassName(): string;
  49033. /**
  49034. * Serializes this glow layer
  49035. * @returns a serialized glow layer object
  49036. */
  49037. serialize(): any;
  49038. /**
  49039. * Creates a Glow Layer from parsed glow layer data
  49040. * @param parsedGlowLayer defines glow layer data
  49041. * @param scene defines the current scene
  49042. * @param rootUrl defines the root URL containing the glow layer information
  49043. * @returns a parsed Glow Layer
  49044. */
  49045. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49046. }
  49047. }
  49048. declare module BABYLON {
  49049. /** @hidden */
  49050. export var glowBlurPostProcessPixelShader: {
  49051. name: string;
  49052. shader: string;
  49053. };
  49054. }
  49055. declare module BABYLON {
  49056. interface AbstractScene {
  49057. /**
  49058. * Return a the first highlight layer of the scene with a given name.
  49059. * @param name The name of the highlight layer to look for.
  49060. * @return The highlight layer if found otherwise null.
  49061. */
  49062. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49063. }
  49064. /**
  49065. * Highlight layer options. This helps customizing the behaviour
  49066. * of the highlight layer.
  49067. */
  49068. export interface IHighlightLayerOptions {
  49069. /**
  49070. * Multiplication factor apply to the canvas size to compute the render target size
  49071. * used to generated the glowing objects (the smaller the faster).
  49072. */
  49073. mainTextureRatio: number;
  49074. /**
  49075. * Enforces a fixed size texture to ensure resize independant blur.
  49076. */
  49077. mainTextureFixedSize?: number;
  49078. /**
  49079. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49080. * of the picture to blur (the smaller the faster).
  49081. */
  49082. blurTextureSizeRatio: number;
  49083. /**
  49084. * How big in texel of the blur texture is the vertical blur.
  49085. */
  49086. blurVerticalSize: number;
  49087. /**
  49088. * How big in texel of the blur texture is the horizontal blur.
  49089. */
  49090. blurHorizontalSize: number;
  49091. /**
  49092. * Alpha blending mode used to apply the blur. Default is combine.
  49093. */
  49094. alphaBlendingMode: number;
  49095. /**
  49096. * The camera attached to the layer.
  49097. */
  49098. camera: Nullable<Camera>;
  49099. /**
  49100. * Should we display highlight as a solid stroke?
  49101. */
  49102. isStroke?: boolean;
  49103. /**
  49104. * The rendering group to draw the layer in.
  49105. */
  49106. renderingGroupId: number;
  49107. }
  49108. /**
  49109. * The highlight layer Helps adding a glow effect around a mesh.
  49110. *
  49111. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49112. * glowy meshes to your scene.
  49113. *
  49114. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49115. */
  49116. export class HighlightLayer extends EffectLayer {
  49117. name: string;
  49118. /**
  49119. * Effect Name of the highlight layer.
  49120. */
  49121. static readonly EffectName: string;
  49122. /**
  49123. * The neutral color used during the preparation of the glow effect.
  49124. * This is black by default as the blend operation is a blend operation.
  49125. */
  49126. static NeutralColor: Color4;
  49127. /**
  49128. * Stencil value used for glowing meshes.
  49129. */
  49130. static GlowingMeshStencilReference: number;
  49131. /**
  49132. * Stencil value used for the other meshes in the scene.
  49133. */
  49134. static NormalMeshStencilReference: number;
  49135. /**
  49136. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49137. */
  49138. innerGlow: boolean;
  49139. /**
  49140. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49141. */
  49142. outerGlow: boolean;
  49143. /**
  49144. * Specifies the horizontal size of the blur.
  49145. */
  49146. /**
  49147. * Gets the horizontal size of the blur.
  49148. */
  49149. blurHorizontalSize: number;
  49150. /**
  49151. * Specifies the vertical size of the blur.
  49152. */
  49153. /**
  49154. * Gets the vertical size of the blur.
  49155. */
  49156. blurVerticalSize: number;
  49157. /**
  49158. * An event triggered when the highlight layer is being blurred.
  49159. */
  49160. onBeforeBlurObservable: Observable<HighlightLayer>;
  49161. /**
  49162. * An event triggered when the highlight layer has been blurred.
  49163. */
  49164. onAfterBlurObservable: Observable<HighlightLayer>;
  49165. private _instanceGlowingMeshStencilReference;
  49166. private _options;
  49167. private _downSamplePostprocess;
  49168. private _horizontalBlurPostprocess;
  49169. private _verticalBlurPostprocess;
  49170. private _blurTexture;
  49171. private _meshes;
  49172. private _excludedMeshes;
  49173. /**
  49174. * Instantiates a new highlight Layer and references it to the scene..
  49175. * @param name The name of the layer
  49176. * @param scene The scene to use the layer in
  49177. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49178. */
  49179. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49180. /**
  49181. * Get the effect name of the layer.
  49182. * @return The effect name
  49183. */
  49184. getEffectName(): string;
  49185. /**
  49186. * Create the merge effect. This is the shader use to blit the information back
  49187. * to the main canvas at the end of the scene rendering.
  49188. */
  49189. protected _createMergeEffect(): Effect;
  49190. /**
  49191. * Creates the render target textures and post processes used in the highlight layer.
  49192. */
  49193. protected _createTextureAndPostProcesses(): void;
  49194. /**
  49195. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49196. */
  49197. needStencil(): boolean;
  49198. /**
  49199. * Checks for the readiness of the element composing the layer.
  49200. * @param subMesh the mesh to check for
  49201. * @param useInstances specify wether or not to use instances to render the mesh
  49202. * @param emissiveTexture the associated emissive texture used to generate the glow
  49203. * @return true if ready otherwise, false
  49204. */
  49205. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49206. /**
  49207. * Implementation specific of rendering the generating effect on the main canvas.
  49208. * @param effect The effect used to render through
  49209. */
  49210. protected _internalRender(effect: Effect): void;
  49211. /**
  49212. * Returns true if the layer contains information to display, otherwise false.
  49213. */
  49214. shouldRender(): boolean;
  49215. /**
  49216. * Returns true if the mesh should render, otherwise false.
  49217. * @param mesh The mesh to render
  49218. * @returns true if it should render otherwise false
  49219. */
  49220. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49221. /**
  49222. * Sets the required values for both the emissive texture and and the main color.
  49223. */
  49224. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49225. /**
  49226. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49227. * @param mesh The mesh to exclude from the highlight layer
  49228. */
  49229. addExcludedMesh(mesh: Mesh): void;
  49230. /**
  49231. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49232. * @param mesh The mesh to highlight
  49233. */
  49234. removeExcludedMesh(mesh: Mesh): void;
  49235. /**
  49236. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49237. * @param mesh mesh to test
  49238. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49239. */
  49240. hasMesh(mesh: AbstractMesh): boolean;
  49241. /**
  49242. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49243. * @param mesh The mesh to highlight
  49244. * @param color The color of the highlight
  49245. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49246. */
  49247. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49248. /**
  49249. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49250. * @param mesh The mesh to highlight
  49251. */
  49252. removeMesh(mesh: Mesh): void;
  49253. /**
  49254. * Force the stencil to the normal expected value for none glowing parts
  49255. */
  49256. private _defaultStencilReference;
  49257. /**
  49258. * Free any resources and references associated to a mesh.
  49259. * Internal use
  49260. * @param mesh The mesh to free.
  49261. * @hidden
  49262. */ private _disposeMesh(mesh: Mesh): void;
  49263. /**
  49264. * Dispose the highlight layer and free resources.
  49265. */
  49266. dispose(): void;
  49267. /**
  49268. * Gets the class name of the effect layer
  49269. * @returns the string with the class name of the effect layer
  49270. */
  49271. getClassName(): string;
  49272. /**
  49273. * Serializes this Highlight layer
  49274. * @returns a serialized Highlight layer object
  49275. */
  49276. serialize(): any;
  49277. /**
  49278. * Creates a Highlight layer from parsed Highlight layer data
  49279. * @param parsedHightlightLayer defines the Highlight layer data
  49280. * @param scene defines the current scene
  49281. * @param rootUrl defines the root URL containing the Highlight layer information
  49282. * @returns a parsed Highlight layer
  49283. */
  49284. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49285. }
  49286. }
  49287. declare module BABYLON {
  49288. interface AbstractScene {
  49289. /**
  49290. * The list of layers (background and foreground) of the scene
  49291. */
  49292. layers: Array<Layer>;
  49293. }
  49294. /**
  49295. * Defines the layer scene component responsible to manage any layers
  49296. * in a given scene.
  49297. */
  49298. export class LayerSceneComponent implements ISceneComponent {
  49299. /**
  49300. * The component name helpfull to identify the component in the list of scene components.
  49301. */
  49302. readonly name: string;
  49303. /**
  49304. * The scene the component belongs to.
  49305. */
  49306. scene: Scene;
  49307. private _engine;
  49308. /**
  49309. * Creates a new instance of the component for the given scene
  49310. * @param scene Defines the scene to register the component in
  49311. */
  49312. constructor(scene: Scene);
  49313. /**
  49314. * Registers the component in a given scene
  49315. */
  49316. register(): void;
  49317. /**
  49318. * Rebuilds the elements related to this component in case of
  49319. * context lost for instance.
  49320. */
  49321. rebuild(): void;
  49322. /**
  49323. * Disposes the component and the associated ressources.
  49324. */
  49325. dispose(): void;
  49326. private _draw;
  49327. private _drawCameraPredicate;
  49328. private _drawCameraBackground;
  49329. private _drawCameraForeground;
  49330. private _drawRenderTargetPredicate;
  49331. private _drawRenderTargetBackground;
  49332. private _drawRenderTargetForeground;
  49333. /**
  49334. * Adds all the elements from the container to the scene
  49335. * @param container the container holding the elements
  49336. */
  49337. addFromContainer(container: AbstractScene): void;
  49338. /**
  49339. * Removes all the elements in the container from the scene
  49340. * @param container contains the elements to remove
  49341. * @param dispose if the removed element should be disposed (default: false)
  49342. */
  49343. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49344. }
  49345. }
  49346. declare module BABYLON {
  49347. /** @hidden */
  49348. export var layerPixelShader: {
  49349. name: string;
  49350. shader: string;
  49351. };
  49352. }
  49353. declare module BABYLON {
  49354. /** @hidden */
  49355. export var layerVertexShader: {
  49356. name: string;
  49357. shader: string;
  49358. };
  49359. }
  49360. declare module BABYLON {
  49361. /**
  49362. * This represents a full screen 2d layer.
  49363. * This can be useful to display a picture in the background of your scene for instance.
  49364. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49365. */
  49366. export class Layer {
  49367. /**
  49368. * Define the name of the layer.
  49369. */
  49370. name: string;
  49371. /**
  49372. * Define the texture the layer should display.
  49373. */
  49374. texture: Nullable<Texture>;
  49375. /**
  49376. * Is the layer in background or foreground.
  49377. */
  49378. isBackground: boolean;
  49379. /**
  49380. * Define the color of the layer (instead of texture).
  49381. */
  49382. color: Color4;
  49383. /**
  49384. * Define the scale of the layer in order to zoom in out of the texture.
  49385. */
  49386. scale: Vector2;
  49387. /**
  49388. * Define an offset for the layer in order to shift the texture.
  49389. */
  49390. offset: Vector2;
  49391. /**
  49392. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49393. */
  49394. alphaBlendingMode: number;
  49395. /**
  49396. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49397. * Alpha test will not mix with the background color in case of transparency.
  49398. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49399. */
  49400. alphaTest: boolean;
  49401. /**
  49402. * Define a mask to restrict the layer to only some of the scene cameras.
  49403. */
  49404. layerMask: number;
  49405. /**
  49406. * Define the list of render target the layer is visible into.
  49407. */
  49408. renderTargetTextures: RenderTargetTexture[];
  49409. /**
  49410. * Define if the layer is only used in renderTarget or if it also
  49411. * renders in the main frame buffer of the canvas.
  49412. */
  49413. renderOnlyInRenderTargetTextures: boolean;
  49414. private _scene;
  49415. private _vertexBuffers;
  49416. private _indexBuffer;
  49417. private _effect;
  49418. private _alphaTestEffect;
  49419. /**
  49420. * An event triggered when the layer is disposed.
  49421. */
  49422. onDisposeObservable: Observable<Layer>;
  49423. private _onDisposeObserver;
  49424. /**
  49425. * Back compatibility with callback before the onDisposeObservable existed.
  49426. * The set callback will be triggered when the layer has been disposed.
  49427. */
  49428. onDispose: () => void;
  49429. /**
  49430. * An event triggered before rendering the scene
  49431. */
  49432. onBeforeRenderObservable: Observable<Layer>;
  49433. private _onBeforeRenderObserver;
  49434. /**
  49435. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49436. * The set callback will be triggered just before rendering the layer.
  49437. */
  49438. onBeforeRender: () => void;
  49439. /**
  49440. * An event triggered after rendering the scene
  49441. */
  49442. onAfterRenderObservable: Observable<Layer>;
  49443. private _onAfterRenderObserver;
  49444. /**
  49445. * Back compatibility with callback before the onAfterRenderObservable existed.
  49446. * The set callback will be triggered just after rendering the layer.
  49447. */
  49448. onAfterRender: () => void;
  49449. /**
  49450. * Instantiates a new layer.
  49451. * This represents a full screen 2d layer.
  49452. * This can be useful to display a picture in the background of your scene for instance.
  49453. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49454. * @param name Define the name of the layer in the scene
  49455. * @param imgUrl Define the url of the texture to display in the layer
  49456. * @param scene Define the scene the layer belongs to
  49457. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49458. * @param color Defines a color for the layer
  49459. */
  49460. constructor(
  49461. /**
  49462. * Define the name of the layer.
  49463. */
  49464. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49465. private _createIndexBuffer;
  49466. /** @hidden */ private _rebuild(): void;
  49467. /**
  49468. * Renders the layer in the scene.
  49469. */
  49470. render(): void;
  49471. /**
  49472. * Disposes and releases the associated ressources.
  49473. */
  49474. dispose(): void;
  49475. }
  49476. }
  49477. declare module BABYLON {
  49478. /** @hidden */
  49479. export var lensFlarePixelShader: {
  49480. name: string;
  49481. shader: string;
  49482. };
  49483. }
  49484. declare module BABYLON {
  49485. /** @hidden */
  49486. export var lensFlareVertexShader: {
  49487. name: string;
  49488. shader: string;
  49489. };
  49490. }
  49491. declare module BABYLON {
  49492. /**
  49493. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49494. * It is usually composed of several `lensFlare`.
  49495. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49496. */
  49497. export class LensFlareSystem {
  49498. /**
  49499. * Define the name of the lens flare system
  49500. */
  49501. name: string;
  49502. /**
  49503. * List of lens flares used in this system.
  49504. */
  49505. lensFlares: LensFlare[];
  49506. /**
  49507. * Define a limit from the border the lens flare can be visible.
  49508. */
  49509. borderLimit: number;
  49510. /**
  49511. * Define a viewport border we do not want to see the lens flare in.
  49512. */
  49513. viewportBorder: number;
  49514. /**
  49515. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49516. */
  49517. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49518. /**
  49519. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49520. */
  49521. layerMask: number;
  49522. /**
  49523. * Define the id of the lens flare system in the scene.
  49524. * (equal to name by default)
  49525. */
  49526. id: string;
  49527. private _scene;
  49528. private _emitter;
  49529. private _vertexBuffers;
  49530. private _indexBuffer;
  49531. private _effect;
  49532. private _positionX;
  49533. private _positionY;
  49534. private _isEnabled;
  49535. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  49536. /**
  49537. * Instantiates a lens flare system.
  49538. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49539. * It is usually composed of several `lensFlare`.
  49540. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49541. * @param name Define the name of the lens flare system in the scene
  49542. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49543. * @param scene Define the scene the lens flare system belongs to
  49544. */
  49545. constructor(
  49546. /**
  49547. * Define the name of the lens flare system
  49548. */
  49549. name: string, emitter: any, scene: Scene);
  49550. /**
  49551. * Define if the lens flare system is enabled.
  49552. */
  49553. isEnabled: boolean;
  49554. /**
  49555. * Get the scene the effects belongs to.
  49556. * @returns the scene holding the lens flare system
  49557. */
  49558. getScene(): Scene;
  49559. /**
  49560. * Get the emitter of the lens flare system.
  49561. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49562. * @returns the emitter of the lens flare system
  49563. */
  49564. getEmitter(): any;
  49565. /**
  49566. * Set the emitter of the lens flare system.
  49567. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49568. * @param newEmitter Define the new emitter of the system
  49569. */
  49570. setEmitter(newEmitter: any): void;
  49571. /**
  49572. * Get the lens flare system emitter position.
  49573. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49574. * @returns the position
  49575. */
  49576. getEmitterPosition(): Vector3;
  49577. /**
  49578. * @hidden
  49579. */
  49580. computeEffectivePosition(globalViewport: Viewport): boolean;
  49581. /** @hidden */ private _isVisible(): boolean;
  49582. /**
  49583. * @hidden
  49584. */
  49585. render(): boolean;
  49586. /**
  49587. * Dispose and release the lens flare with its associated resources.
  49588. */
  49589. dispose(): void;
  49590. /**
  49591. * Parse a lens flare system from a JSON repressentation
  49592. * @param parsedLensFlareSystem Define the JSON to parse
  49593. * @param scene Define the scene the parsed system should be instantiated in
  49594. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49595. * @returns the parsed system
  49596. */
  49597. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49598. /**
  49599. * Serialize the current Lens Flare System into a JSON representation.
  49600. * @returns the serialized JSON
  49601. */
  49602. serialize(): any;
  49603. }
  49604. }
  49605. declare module BABYLON {
  49606. /**
  49607. * This represents one of the lens effect in a `lensFlareSystem`.
  49608. * It controls one of the indiviual texture used in the effect.
  49609. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49610. */
  49611. export class LensFlare {
  49612. /**
  49613. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49614. */
  49615. size: number;
  49616. /**
  49617. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  49618. */
  49619. position: number;
  49620. /**
  49621. * Define the lens color.
  49622. */
  49623. color: Color3;
  49624. /**
  49625. * Define the lens texture.
  49626. */
  49627. texture: Nullable<Texture>;
  49628. /**
  49629. * Define the alpha mode to render this particular lens.
  49630. */
  49631. alphaMode: number;
  49632. private _system;
  49633. /**
  49634. * Creates a new Lens Flare.
  49635. * This represents one of the lens effect in a `lensFlareSystem`.
  49636. * It controls one of the indiviual texture used in the effect.
  49637. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49638. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49639. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  49640. * @param color Define the lens color
  49641. * @param imgUrl Define the lens texture url
  49642. * @param system Define the `lensFlareSystem` this flare is part of
  49643. * @returns The newly created Lens Flare
  49644. */
  49645. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49646. /**
  49647. * Instantiates a new Lens Flare.
  49648. * This represents one of the lens effect in a `lensFlareSystem`.
  49649. * It controls one of the indiviual texture used in the effect.
  49650. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49651. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49652. * @param position Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  49653. * @param color Define the lens color
  49654. * @param imgUrl Define the lens texture url
  49655. * @param system Define the `lensFlareSystem` this flare is part of
  49656. */
  49657. constructor(
  49658. /**
  49659. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49660. */
  49661. size: number,
  49662. /**
  49663. * Define the position of the lens flare in the system. (a floating value between -1 and 1). A value of 0 is located on the emitter. A value greater than 0 is beyond the emitter and a value lesser than 0 is behind.
  49664. */
  49665. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49666. /**
  49667. * Dispose and release the lens flare with its associated resources.
  49668. */
  49669. dispose(): void;
  49670. }
  49671. }
  49672. declare module BABYLON {
  49673. interface AbstractScene {
  49674. /**
  49675. * The list of lens flare system added to the scene
  49676. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49677. */
  49678. lensFlareSystems: Array<LensFlareSystem>;
  49679. /**
  49680. * Removes the given lens flare system from this scene.
  49681. * @param toRemove The lens flare system to remove
  49682. * @returns The index of the removed lens flare system
  49683. */
  49684. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49685. /**
  49686. * Adds the given lens flare system to this scene
  49687. * @param newLensFlareSystem The lens flare system to add
  49688. */
  49689. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49690. /**
  49691. * Gets a lens flare system using its name
  49692. * @param name defines the name to look for
  49693. * @returns the lens flare system or null if not found
  49694. */
  49695. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49696. /**
  49697. * Gets a lens flare system using its id
  49698. * @param id defines the id to look for
  49699. * @returns the lens flare system or null if not found
  49700. */
  49701. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49702. }
  49703. /**
  49704. * Defines the lens flare scene component responsible to manage any lens flares
  49705. * in a given scene.
  49706. */
  49707. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49708. /**
  49709. * The component name helpfull to identify the component in the list of scene components.
  49710. */
  49711. readonly name: string;
  49712. /**
  49713. * The scene the component belongs to.
  49714. */
  49715. scene: Scene;
  49716. /**
  49717. * Creates a new instance of the component for the given scene
  49718. * @param scene Defines the scene to register the component in
  49719. */
  49720. constructor(scene: Scene);
  49721. /**
  49722. * Registers the component in a given scene
  49723. */
  49724. register(): void;
  49725. /**
  49726. * Rebuilds the elements related to this component in case of
  49727. * context lost for instance.
  49728. */
  49729. rebuild(): void;
  49730. /**
  49731. * Adds all the elements from the container to the scene
  49732. * @param container the container holding the elements
  49733. */
  49734. addFromContainer(container: AbstractScene): void;
  49735. /**
  49736. * Removes all the elements in the container from the scene
  49737. * @param container contains the elements to remove
  49738. * @param dispose if the removed element should be disposed (default: false)
  49739. */
  49740. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49741. /**
  49742. * Serializes the component data to the specified json object
  49743. * @param serializationObject The object to serialize to
  49744. */
  49745. serialize(serializationObject: any): void;
  49746. /**
  49747. * Disposes the component and the associated ressources.
  49748. */
  49749. dispose(): void;
  49750. private _draw;
  49751. }
  49752. }
  49753. declare module BABYLON {
  49754. /**
  49755. * Defines the shadow generator component responsible to manage any shadow generators
  49756. * in a given scene.
  49757. */
  49758. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49759. /**
  49760. * The component name helpfull to identify the component in the list of scene components.
  49761. */
  49762. readonly name: string;
  49763. /**
  49764. * The scene the component belongs to.
  49765. */
  49766. scene: Scene;
  49767. /**
  49768. * Creates a new instance of the component for the given scene
  49769. * @param scene Defines the scene to register the component in
  49770. */
  49771. constructor(scene: Scene);
  49772. /**
  49773. * Registers the component in a given scene
  49774. */
  49775. register(): void;
  49776. /**
  49777. * Rebuilds the elements related to this component in case of
  49778. * context lost for instance.
  49779. */
  49780. rebuild(): void;
  49781. /**
  49782. * Serializes the component data to the specified json object
  49783. * @param serializationObject The object to serialize to
  49784. */
  49785. serialize(serializationObject: any): void;
  49786. /**
  49787. * Adds all the elements from the container to the scene
  49788. * @param container the container holding the elements
  49789. */
  49790. addFromContainer(container: AbstractScene): void;
  49791. /**
  49792. * Removes all the elements in the container from the scene
  49793. * @param container contains the elements to remove
  49794. * @param dispose if the removed element should be disposed (default: false)
  49795. */
  49796. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49797. /**
  49798. * Rebuilds the elements related to this component in case of
  49799. * context lost for instance.
  49800. */
  49801. dispose(): void;
  49802. private _gatherRenderTargets;
  49803. }
  49804. }
  49805. declare module BABYLON {
  49806. /**
  49807. * A point light is a light defined by an unique point in world space.
  49808. * The light is emitted in every direction from this point.
  49809. * A good example of a point light is a standard light bulb.
  49810. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49811. */
  49812. export class PointLight extends ShadowLight {
  49813. private _shadowAngle;
  49814. /**
  49815. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49816. * This specifies what angle the shadow will use to be created.
  49817. *
  49818. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49819. */
  49820. /**
  49821. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49822. * This specifies what angle the shadow will use to be created.
  49823. *
  49824. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49825. */
  49826. shadowAngle: number;
  49827. /**
  49828. * Gets the direction if it has been set.
  49829. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49830. */
  49831. /**
  49832. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49833. */
  49834. direction: Vector3;
  49835. /**
  49836. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49837. * A PointLight emits the light in every direction.
  49838. * It can cast shadows.
  49839. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49840. * ```javascript
  49841. * var pointLight = new PointLight("pl", camera.position, scene);
  49842. * ```
  49843. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49844. * @param name The light friendly name
  49845. * @param position The position of the point light in the scene
  49846. * @param scene The scene the lights belongs to
  49847. */
  49848. constructor(name: string, position: Vector3, scene: Scene);
  49849. /**
  49850. * Returns the string "PointLight"
  49851. * @returns the class name
  49852. */
  49853. getClassName(): string;
  49854. /**
  49855. * Returns the integer 0.
  49856. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49857. */
  49858. getTypeID(): number;
  49859. /**
  49860. * Specifies wether or not the shadowmap should be a cube texture.
  49861. * @returns true if the shadowmap needs to be a cube texture.
  49862. */
  49863. needCube(): boolean;
  49864. /**
  49865. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49866. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49867. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49868. */
  49869. getShadowDirection(faceIndex?: number): Vector3;
  49870. /**
  49871. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49872. * - fov = PI / 2
  49873. * - aspect ratio : 1.0
  49874. * - z-near and far equal to the active camera minZ and maxZ.
  49875. * Returns the PointLight.
  49876. */
  49877. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49878. protected _buildUniformLayout(): void;
  49879. /**
  49880. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49881. * @param effect The effect to update
  49882. * @param lightIndex The index of the light in the effect to update
  49883. * @returns The point light
  49884. */
  49885. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49886. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49887. /**
  49888. * Prepares the list of defines specific to the light type.
  49889. * @param defines the list of defines
  49890. * @param lightIndex defines the index of the light for the effect
  49891. */
  49892. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49893. }
  49894. }
  49895. declare module BABYLON {
  49896. /**
  49897. * Header information of HDR texture files.
  49898. */
  49899. export interface HDRInfo {
  49900. /**
  49901. * The height of the texture in pixels.
  49902. */
  49903. height: number;
  49904. /**
  49905. * The width of the texture in pixels.
  49906. */
  49907. width: number;
  49908. /**
  49909. * The index of the beginning of the data in the binary file.
  49910. */
  49911. dataPosition: number;
  49912. }
  49913. /**
  49914. * This groups tools to convert HDR texture to native colors array.
  49915. */
  49916. export class HDRTools {
  49917. private static Ldexp;
  49918. private static Rgbe2float;
  49919. private static readStringLine;
  49920. /**
  49921. * Reads header information from an RGBE texture stored in a native array.
  49922. * More information on this format are available here:
  49923. * https://en.wikipedia.org/wiki/RGBE_image_format
  49924. *
  49925. * @param uint8array The binary file stored in native array.
  49926. * @return The header information.
  49927. */
  49928. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49929. /**
  49930. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49931. * This RGBE texture needs to store the information as a panorama.
  49932. *
  49933. * More information on this format are available here:
  49934. * https://en.wikipedia.org/wiki/RGBE_image_format
  49935. *
  49936. * @param buffer The binary file stored in an array buffer.
  49937. * @param size The expected size of the extracted cubemap.
  49938. * @return The Cube Map information.
  49939. */
  49940. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49941. /**
  49942. * Returns the pixels data extracted from an RGBE texture.
  49943. * This pixels will be stored left to right up to down in the R G B order in one array.
  49944. *
  49945. * More information on this format are available here:
  49946. * https://en.wikipedia.org/wiki/RGBE_image_format
  49947. *
  49948. * @param uint8array The binary file stored in an array buffer.
  49949. * @param hdrInfo The header information of the file.
  49950. * @return The pixels data in RGB right to left up to down order.
  49951. */
  49952. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49953. private static RGBE_ReadPixels_RLE;
  49954. }
  49955. }
  49956. declare module BABYLON {
  49957. /**
  49958. * This represents a texture coming from an HDR input.
  49959. *
  49960. * The only supported format is currently panorama picture stored in RGBE format.
  49961. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49962. */
  49963. export class HDRCubeTexture extends BaseTexture {
  49964. private static _facesMapping;
  49965. private _generateHarmonics;
  49966. private _noMipmap;
  49967. private _textureMatrix;
  49968. private _size;
  49969. private _onLoad;
  49970. private _onError;
  49971. /**
  49972. * The texture URL.
  49973. */
  49974. url: string;
  49975. /**
  49976. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49977. */
  49978. coordinatesMode: number;
  49979. protected _isBlocking: boolean;
  49980. /**
  49981. * Sets wether or not the texture is blocking during loading.
  49982. */
  49983. /**
  49984. * Gets wether or not the texture is blocking during loading.
  49985. */
  49986. isBlocking: boolean;
  49987. protected _rotationY: number;
  49988. /**
  49989. * Sets texture matrix rotation angle around Y axis in radians.
  49990. */
  49991. /**
  49992. * Gets texture matrix rotation angle around Y axis radians.
  49993. */
  49994. rotationY: number;
  49995. /**
  49996. * Gets or sets the center of the bounding box associated with the cube texture
  49997. * It must define where the camera used to render the texture was set
  49998. */
  49999. boundingBoxPosition: Vector3;
  50000. private _boundingBoxSize;
  50001. /**
  50002. * Gets or sets the size of the bounding box associated with the cube texture
  50003. * When defined, the cubemap will switch to local mode
  50004. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50005. * @example https://www.babylonjs-playground.com/#RNASML
  50006. */
  50007. boundingBoxSize: Vector3;
  50008. /**
  50009. * Instantiates an HDRTexture from the following parameters.
  50010. *
  50011. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50012. * @param scene The scene the texture will be used in
  50013. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50014. * @param noMipmap Forces to not generate the mipmap if true
  50015. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50016. * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  50017. * @param reserved Reserved flag for internal use.
  50018. */
  50019. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50020. /**
  50021. * Get the current class name of the texture useful for serialization or dynamic coding.
  50022. * @returns "HDRCubeTexture"
  50023. */
  50024. getClassName(): string;
  50025. /**
  50026. * Occurs when the file is raw .hdr file.
  50027. */
  50028. private loadTexture;
  50029. clone(): HDRCubeTexture;
  50030. delayLoad(): void;
  50031. /**
  50032. * Get the texture reflection matrix used to rotate/transform the reflection.
  50033. * @returns the reflection matrix
  50034. */
  50035. getReflectionTextureMatrix(): Matrix;
  50036. /**
  50037. * Set the texture reflection matrix used to rotate/transform the reflection.
  50038. * @param value Define the reflection matrix to set
  50039. */
  50040. setReflectionTextureMatrix(value: Matrix): void;
  50041. /**
  50042. * Parses a JSON representation of an HDR Texture in order to create the texture
  50043. * @param parsedTexture Define the JSON representation
  50044. * @param scene Define the scene the texture should be created in
  50045. * @param rootUrl Define the root url in case we need to load relative dependencies
  50046. * @returns the newly created texture after parsing
  50047. */
  50048. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50049. serialize(): any;
  50050. }
  50051. }
  50052. declare module BABYLON {
  50053. /**
  50054. * Class used to control physics engine
  50055. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50056. */
  50057. export class PhysicsEngine implements IPhysicsEngine {
  50058. private _physicsPlugin;
  50059. /**
  50060. * Global value used to control the smallest number supported by the simulation
  50061. */
  50062. static Epsilon: number;
  50063. private _impostors;
  50064. private _joints;
  50065. /**
  50066. * Gets the gravity vector used by the simulation
  50067. */
  50068. gravity: Vector3;
  50069. /**
  50070. * Factory used to create the default physics plugin.
  50071. * @returns The default physics plugin
  50072. */
  50073. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50074. /**
  50075. * Creates a new Physics Engine
  50076. * @param gravity defines the gravity vector used by the simulation
  50077. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50078. */
  50079. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50080. /**
  50081. * Sets the gravity vector used by the simulation
  50082. * @param gravity defines the gravity vector to use
  50083. */
  50084. setGravity(gravity: Vector3): void;
  50085. /**
  50086. * Set the time step of the physics engine.
  50087. * Default is 1/60.
  50088. * To slow it down, enter 1/600 for example.
  50089. * To speed it up, 1/30
  50090. * @param newTimeStep defines the new timestep to apply to this world.
  50091. */
  50092. setTimeStep(newTimeStep?: number): void;
  50093. /**
  50094. * Get the time step of the physics engine.
  50095. * @returns the current time step
  50096. */
  50097. getTimeStep(): number;
  50098. /**
  50099. * Release all resources
  50100. */
  50101. dispose(): void;
  50102. /**
  50103. * Gets the name of the current physics plugin
  50104. * @returns the name of the plugin
  50105. */
  50106. getPhysicsPluginName(): string;
  50107. /**
  50108. * Adding a new impostor for the impostor tracking.
  50109. * This will be done by the impostor itself.
  50110. * @param impostor the impostor to add
  50111. */
  50112. addImpostor(impostor: PhysicsImpostor): void;
  50113. /**
  50114. * Remove an impostor from the engine.
  50115. * This impostor and its mesh will not longer be updated by the physics engine.
  50116. * @param impostor the impostor to remove
  50117. */
  50118. removeImpostor(impostor: PhysicsImpostor): void;
  50119. /**
  50120. * Add a joint to the physics engine
  50121. * @param mainImpostor defines the main impostor to which the joint is added.
  50122. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50123. * @param joint defines the joint that will connect both impostors.
  50124. */
  50125. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50126. /**
  50127. * Removes a joint from the simulation
  50128. * @param mainImpostor defines the impostor used with the joint
  50129. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50130. * @param joint defines the joint to remove
  50131. */
  50132. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50133. /**
  50134. * Called by the scene. No need to call it.
  50135. * @param delta defines the timespam between frames
  50136. */ private _step(delta: number): void;
  50137. /**
  50138. * Gets the current plugin used to run the simulation
  50139. * @returns current plugin
  50140. */
  50141. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50142. /**
  50143. * Gets the list of physic impostors
  50144. * @returns an array of PhysicsImpostor
  50145. */
  50146. getImpostors(): Array<PhysicsImpostor>;
  50147. /**
  50148. * Gets the impostor for a physics enabled object
  50149. * @param object defines the object impersonated by the impostor
  50150. * @returns the PhysicsImpostor or null if not found
  50151. */
  50152. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50153. /**
  50154. * Gets the impostor for a physics body object
  50155. * @param body defines physics body used by the impostor
  50156. * @returns the PhysicsImpostor or null if not found
  50157. */
  50158. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50159. /**
  50160. * Does a raycast in the physics world
  50161. * @param from when should the ray start?
  50162. * @param to when should the ray end?
  50163. * @returns PhysicsRaycastResult
  50164. */
  50165. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50166. }
  50167. }
  50168. declare module BABYLON {
  50169. /** @hidden */
  50170. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50171. private _useDeltaForWorldStep;
  50172. world: any;
  50173. name: string;
  50174. private _physicsMaterials;
  50175. private _fixedTimeStep;
  50176. private _cannonRaycastResult;
  50177. private _raycastResult;
  50178. private _physicsBodysToRemoveAfterStep;
  50179. BJSCANNON: any;
  50180. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50181. setGravity(gravity: Vector3): void;
  50182. setTimeStep(timeStep: number): void;
  50183. getTimeStep(): number;
  50184. executeStep(delta: number): void;
  50185. private _removeMarkedPhysicsBodiesFromWorld;
  50186. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50187. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50188. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50189. private _processChildMeshes;
  50190. removePhysicsBody(impostor: PhysicsImpostor): void;
  50191. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50192. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50193. private _addMaterial;
  50194. private _checkWithEpsilon;
  50195. private _createShape;
  50196. private _createHeightmap;
  50197. private _minus90X;
  50198. private _plus90X;
  50199. private _tmpPosition;
  50200. private _tmpDeltaPosition;
  50201. private _tmpUnityRotation;
  50202. private _updatePhysicsBodyTransformation;
  50203. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50204. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50205. isSupported(): boolean;
  50206. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50207. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50208. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50209. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50210. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50211. getBodyMass(impostor: PhysicsImpostor): number;
  50212. getBodyFriction(impostor: PhysicsImpostor): number;
  50213. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50214. getBodyRestitution(impostor: PhysicsImpostor): number;
  50215. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50216. sleepBody(impostor: PhysicsImpostor): void;
  50217. wakeUpBody(impostor: PhysicsImpostor): void;
  50218. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50219. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50220. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50221. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50222. getRadius(impostor: PhysicsImpostor): number;
  50223. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50224. dispose(): void;
  50225. private _extendNamespace;
  50226. /**
  50227. * Does a raycast in the physics world
  50228. * @param from when should the ray start?
  50229. * @param to when should the ray end?
  50230. * @returns PhysicsRaycastResult
  50231. */
  50232. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50233. }
  50234. }
  50235. declare module BABYLON {
  50236. /** @hidden */
  50237. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50238. world: any;
  50239. name: string;
  50240. BJSOIMO: any;
  50241. private _raycastResult;
  50242. constructor(iterations?: number, oimoInjection?: any);
  50243. setGravity(gravity: Vector3): void;
  50244. setTimeStep(timeStep: number): void;
  50245. getTimeStep(): number;
  50246. private _tmpImpostorsArray;
  50247. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50248. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50249. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50250. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50251. private _tmpPositionVector;
  50252. removePhysicsBody(impostor: PhysicsImpostor): void;
  50253. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50254. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50255. isSupported(): boolean;
  50256. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50257. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50258. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50259. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50260. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50261. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50262. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50263. getBodyMass(impostor: PhysicsImpostor): number;
  50264. getBodyFriction(impostor: PhysicsImpostor): number;
  50265. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50266. getBodyRestitution(impostor: PhysicsImpostor): number;
  50267. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50268. sleepBody(impostor: PhysicsImpostor): void;
  50269. wakeUpBody(impostor: PhysicsImpostor): void;
  50270. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50271. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50272. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50273. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50274. getRadius(impostor: PhysicsImpostor): number;
  50275. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50276. dispose(): void;
  50277. /**
  50278. * Does a raycast in the physics world
  50279. * @param from when should the ray start?
  50280. * @param to when should the ray end?
  50281. * @returns PhysicsRaycastResult
  50282. */
  50283. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50284. }
  50285. }
  50286. declare module BABYLON {
  50287. /**
  50288. * Class containing static functions to help procedurally build meshes
  50289. */
  50290. export class RibbonBuilder {
  50291. /**
  50292. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50293. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50294. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50295. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50296. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  50297. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  50298. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  50299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50301. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50302. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  50303. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50304. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  50305. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50307. * @param name defines the name of the mesh
  50308. * @param options defines the options used to create the mesh
  50309. * @param scene defines the hosting scene
  50310. * @returns the ribbon mesh
  50311. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50312. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50313. */
  50314. static CreateRibbon(name: string, options: {
  50315. pathArray: Vector3[][];
  50316. closeArray?: boolean;
  50317. closePath?: boolean;
  50318. offset?: number;
  50319. updatable?: boolean;
  50320. sideOrientation?: number;
  50321. frontUVs?: Vector4;
  50322. backUVs?: Vector4;
  50323. instance?: Mesh;
  50324. invertUV?: boolean;
  50325. uvs?: Vector2[];
  50326. colors?: Color4[];
  50327. }, scene?: Nullable<Scene>): Mesh;
  50328. }
  50329. }
  50330. declare module BABYLON {
  50331. /**
  50332. * Class containing static functions to help procedurally build meshes
  50333. */
  50334. export class ShapeBuilder {
  50335. /**
  50336. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50337. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  50338. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50339. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  50340. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50341. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  50342. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  50343. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50346. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50348. * @param name defines the name of the mesh
  50349. * @param options defines the options used to create the mesh
  50350. * @param scene defines the hosting scene
  50351. * @returns the extruded shape mesh
  50352. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50353. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50354. */
  50355. static ExtrudeShape(name: string, options: {
  50356. shape: Vector3[];
  50357. path: Vector3[];
  50358. scale?: number;
  50359. rotation?: number;
  50360. cap?: number;
  50361. updatable?: boolean;
  50362. sideOrientation?: number;
  50363. frontUVs?: Vector4;
  50364. backUVs?: Vector4;
  50365. instance?: Mesh;
  50366. invertUV?: boolean;
  50367. }, scene?: Nullable<Scene>): Mesh;
  50368. /**
  50369. * Creates an custom extruded shape mesh.
  50370. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50371. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  50372. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50373. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  50374. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50375. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  50376. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50377. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50378. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50379. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  50380. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  50381. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50384. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50386. * @param name defines the name of the mesh
  50387. * @param options defines the options used to create the mesh
  50388. * @param scene defines the hosting scene
  50389. * @returns the custom extruded shape mesh
  50390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50393. */
  50394. static ExtrudeShapeCustom(name: string, options: {
  50395. shape: Vector3[];
  50396. path: Vector3[];
  50397. scaleFunction?: any;
  50398. rotationFunction?: any;
  50399. ribbonCloseArray?: boolean;
  50400. ribbonClosePath?: boolean;
  50401. cap?: number;
  50402. updatable?: boolean;
  50403. sideOrientation?: number;
  50404. frontUVs?: Vector4;
  50405. backUVs?: Vector4;
  50406. instance?: Mesh;
  50407. invertUV?: boolean;
  50408. }, scene?: Nullable<Scene>): Mesh;
  50409. private static _ExtrudeShapeGeneric;
  50410. }
  50411. }
  50412. declare module BABYLON {
  50413. /**
  50414. * AmmoJS Physics plugin
  50415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50416. * @see https://github.com/kripken/ammo.js/
  50417. */
  50418. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50419. private _useDeltaForWorldStep;
  50420. /**
  50421. * Reference to the Ammo library
  50422. */
  50423. bjsAMMO: any;
  50424. /**
  50425. * Created ammoJS world which physics bodies are added to
  50426. */
  50427. world: any;
  50428. /**
  50429. * Name of the plugin
  50430. */
  50431. name: string;
  50432. private _timeStep;
  50433. private _fixedTimeStep;
  50434. private _maxSteps;
  50435. private _tmpQuaternion;
  50436. private _tmpAmmoTransform;
  50437. private _tmpAmmoQuaternion;
  50438. private _tmpAmmoConcreteContactResultCallback;
  50439. private _collisionConfiguration;
  50440. private _dispatcher;
  50441. private _overlappingPairCache;
  50442. private _solver;
  50443. private _softBodySolver;
  50444. private _tmpAmmoVectorA;
  50445. private _tmpAmmoVectorB;
  50446. private _tmpAmmoVectorC;
  50447. private _tmpAmmoVectorD;
  50448. private _tmpContactCallbackResult;
  50449. private _tmpAmmoVectorRCA;
  50450. private _tmpAmmoVectorRCB;
  50451. private _raycastResult;
  50452. private static readonly DISABLE_COLLISION_FLAG;
  50453. private static readonly KINEMATIC_FLAG;
  50454. private static readonly DISABLE_DEACTIVATION_FLAG;
  50455. /**
  50456. * Initializes the ammoJS plugin
  50457. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50458. * @param ammoInjection can be used to inject your own ammo reference
  50459. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  50460. */
  50461. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  50462. /**
  50463. * Sets the gravity of the physics world (m/(s^2))
  50464. * @param gravity Gravity to set
  50465. */
  50466. setGravity(gravity: Vector3): void;
  50467. /**
  50468. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50469. * @param timeStep timestep to use in seconds
  50470. */
  50471. setTimeStep(timeStep: number): void;
  50472. /**
  50473. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  50474. * @param fixedTimeStep fixedTimeStep to use in seconds
  50475. */
  50476. setFixedTimeStep(fixedTimeStep: number): void;
  50477. /**
  50478. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50479. * @param maxSteps the maximum number of steps by the physics engine per frame
  50480. */
  50481. setMaxSteps(maxSteps: number): void;
  50482. /**
  50483. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50484. * @returns the current timestep in seconds
  50485. */
  50486. getTimeStep(): number;
  50487. private _isImpostorInContact;
  50488. private _isImpostorPairInContact;
  50489. private _stepSimulation;
  50490. /**
  50491. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50492. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50493. * After the step the babylon meshes are set to the position of the physics imposters
  50494. * @param delta amount of time to step forward
  50495. * @param impostors array of imposters to update before/after the step
  50496. */
  50497. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50498. /**
  50499. * Update babylon mesh to match physics world object
  50500. * @param impostor imposter to match
  50501. */
  50502. private _afterSoftStep;
  50503. /**
  50504. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50505. * @param impostor imposter to match
  50506. */
  50507. private _ropeStep;
  50508. /**
  50509. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50510. * @param impostor imposter to match
  50511. */
  50512. private _softbodyOrClothStep;
  50513. private _tmpVector;
  50514. private _tmpMatrix;
  50515. /**
  50516. * Applies an impulse on the imposter
  50517. * @param impostor imposter to apply impulse to
  50518. * @param force amount of force to be applied to the imposter
  50519. * @param contactPoint the location to apply the impulse on the imposter
  50520. */
  50521. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50522. /**
  50523. * Applies a force on the imposter
  50524. * @param impostor imposter to apply force
  50525. * @param force amount of force to be applied to the imposter
  50526. * @param contactPoint the location to apply the force on the imposter
  50527. */
  50528. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50529. /**
  50530. * Creates a physics body using the plugin
  50531. * @param impostor the imposter to create the physics body on
  50532. */
  50533. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50534. /**
  50535. * Removes the physics body from the imposter and disposes of the body's memory
  50536. * @param impostor imposter to remove the physics body from
  50537. */
  50538. removePhysicsBody(impostor: PhysicsImpostor): void;
  50539. /**
  50540. * Generates a joint
  50541. * @param impostorJoint the imposter joint to create the joint with
  50542. */
  50543. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50544. /**
  50545. * Removes a joint
  50546. * @param impostorJoint the imposter joint to remove the joint from
  50547. */
  50548. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50549. private _addMeshVerts;
  50550. /**
  50551. * Initialise the soft body vertices to match its object's (mesh) vertices
  50552. * Softbody vertices (nodes) are in world space and to match this
  50553. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50554. * @param impostor to create the softbody for
  50555. */
  50556. private _softVertexData;
  50557. /**
  50558. * Create an impostor's soft body
  50559. * @param impostor to create the softbody for
  50560. */
  50561. private _createSoftbody;
  50562. /**
  50563. * Create cloth for an impostor
  50564. * @param impostor to create the softbody for
  50565. */
  50566. private _createCloth;
  50567. /**
  50568. * Create rope for an impostor
  50569. * @param impostor to create the softbody for
  50570. */
  50571. private _createRope;
  50572. private _addHullVerts;
  50573. private _createShape;
  50574. /**
  50575. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50576. * @param impostor imposter containing the physics body and babylon object
  50577. */
  50578. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50579. /**
  50580. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50581. * @param impostor imposter containing the physics body and babylon object
  50582. * @param newPosition new position
  50583. * @param newRotation new rotation
  50584. */
  50585. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50586. /**
  50587. * If this plugin is supported
  50588. * @returns true if its supported
  50589. */
  50590. isSupported(): boolean;
  50591. /**
  50592. * Sets the linear velocity of the physics body
  50593. * @param impostor imposter to set the velocity on
  50594. * @param velocity velocity to set
  50595. */
  50596. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50597. /**
  50598. * Sets the angular velocity of the physics body
  50599. * @param impostor imposter to set the velocity on
  50600. * @param velocity velocity to set
  50601. */
  50602. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50603. /**
  50604. * gets the linear velocity
  50605. * @param impostor imposter to get linear velocity from
  50606. * @returns linear velocity
  50607. */
  50608. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50609. /**
  50610. * gets the angular velocity
  50611. * @param impostor imposter to get angular velocity from
  50612. * @returns angular velocity
  50613. */
  50614. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50615. /**
  50616. * Sets the mass of physics body
  50617. * @param impostor imposter to set the mass on
  50618. * @param mass mass to set
  50619. */
  50620. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50621. /**
  50622. * Gets the mass of the physics body
  50623. * @param impostor imposter to get the mass from
  50624. * @returns mass
  50625. */
  50626. getBodyMass(impostor: PhysicsImpostor): number;
  50627. /**
  50628. * Gets friction of the impostor
  50629. * @param impostor impostor to get friction from
  50630. * @returns friction value
  50631. */
  50632. getBodyFriction(impostor: PhysicsImpostor): number;
  50633. /**
  50634. * Sets friction of the impostor
  50635. * @param impostor impostor to set friction on
  50636. * @param friction friction value
  50637. */
  50638. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50639. /**
  50640. * Gets restitution of the impostor
  50641. * @param impostor impostor to get restitution from
  50642. * @returns restitution value
  50643. */
  50644. getBodyRestitution(impostor: PhysicsImpostor): number;
  50645. /**
  50646. * Sets resitution of the impostor
  50647. * @param impostor impostor to set resitution on
  50648. * @param restitution resitution value
  50649. */
  50650. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50651. /**
  50652. * Gets pressure inside the impostor
  50653. * @param impostor impostor to get pressure from
  50654. * @returns pressure value
  50655. */
  50656. getBodyPressure(impostor: PhysicsImpostor): number;
  50657. /**
  50658. * Sets pressure inside a soft body impostor
  50659. * Cloth and rope must remain 0 pressure
  50660. * @param impostor impostor to set pressure on
  50661. * @param pressure pressure value
  50662. */
  50663. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50664. /**
  50665. * Gets stiffness of the impostor
  50666. * @param impostor impostor to get stiffness from
  50667. * @returns pressure value
  50668. */
  50669. getBodyStiffness(impostor: PhysicsImpostor): number;
  50670. /**
  50671. * Sets stiffness of the impostor
  50672. * @param impostor impostor to set stiffness on
  50673. * @param stiffness stiffness value from 0 to 1
  50674. */
  50675. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50676. /**
  50677. * Gets velocityIterations of the impostor
  50678. * @param impostor impostor to get velocity iterations from
  50679. * @returns velocityIterations value
  50680. */
  50681. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50682. /**
  50683. * Sets velocityIterations of the impostor
  50684. * @param impostor impostor to set velocity iterations on
  50685. * @param velocityIterations velocityIterations value
  50686. */
  50687. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50688. /**
  50689. * Gets positionIterations of the impostor
  50690. * @param impostor impostor to get position iterations from
  50691. * @returns positionIterations value
  50692. */
  50693. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50694. /**
  50695. * Sets positionIterations of the impostor
  50696. * @param impostor impostor to set position on
  50697. * @param positionIterations positionIterations value
  50698. */
  50699. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50700. /**
  50701. * Append an anchor to a cloth object
  50702. * @param impostor is the cloth impostor to add anchor to
  50703. * @param otherImpostor is the rigid impostor to anchor to
  50704. * @param width ratio across width from 0 to 1
  50705. * @param height ratio up height from 0 to 1
  50706. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50707. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50708. */
  50709. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50710. /**
  50711. * Append an hook to a rope object
  50712. * @param impostor is the rope impostor to add hook to
  50713. * @param otherImpostor is the rigid impostor to hook to
  50714. * @param length ratio along the rope from 0 to 1
  50715. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50716. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50717. */
  50718. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50719. /**
  50720. * Sleeps the physics body and stops it from being active
  50721. * @param impostor impostor to sleep
  50722. */
  50723. sleepBody(impostor: PhysicsImpostor): void;
  50724. /**
  50725. * Activates the physics body
  50726. * @param impostor impostor to activate
  50727. */
  50728. wakeUpBody(impostor: PhysicsImpostor): void;
  50729. /**
  50730. * Updates the distance parameters of the joint
  50731. * @param joint joint to update
  50732. * @param maxDistance maximum distance of the joint
  50733. * @param minDistance minimum distance of the joint
  50734. */
  50735. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50736. /**
  50737. * Sets a motor on the joint
  50738. * @param joint joint to set motor on
  50739. * @param speed speed of the motor
  50740. * @param maxForce maximum force of the motor
  50741. * @param motorIndex index of the motor
  50742. */
  50743. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50744. /**
  50745. * Sets the motors limit
  50746. * @param joint joint to set limit on
  50747. * @param upperLimit upper limit
  50748. * @param lowerLimit lower limit
  50749. */
  50750. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50751. /**
  50752. * Syncs the position and rotation of a mesh with the impostor
  50753. * @param mesh mesh to sync
  50754. * @param impostor impostor to update the mesh with
  50755. */
  50756. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50757. /**
  50758. * Gets the radius of the impostor
  50759. * @param impostor impostor to get radius from
  50760. * @returns the radius
  50761. */
  50762. getRadius(impostor: PhysicsImpostor): number;
  50763. /**
  50764. * Gets the box size of the impostor
  50765. * @param impostor impostor to get box size from
  50766. * @param result the resulting box size
  50767. */
  50768. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50769. /**
  50770. * Disposes of the impostor
  50771. */
  50772. dispose(): void;
  50773. /**
  50774. * Does a raycast in the physics world
  50775. * @param from when should the ray start?
  50776. * @param to when should the ray end?
  50777. * @returns PhysicsRaycastResult
  50778. */
  50779. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50780. }
  50781. }
  50782. declare module BABYLON {
  50783. interface AbstractScene {
  50784. /**
  50785. * The list of reflection probes added to the scene
  50786. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50787. */
  50788. reflectionProbes: Array<ReflectionProbe>;
  50789. /**
  50790. * Removes the given reflection probe from this scene.
  50791. * @param toRemove The reflection probe to remove
  50792. * @returns The index of the removed reflection probe
  50793. */
  50794. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50795. /**
  50796. * Adds the given reflection probe to this scene.
  50797. * @param newReflectionProbe The reflection probe to add
  50798. */
  50799. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50800. }
  50801. /**
  50802. * Class used to generate realtime reflection / refraction cube textures
  50803. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50804. */
  50805. export class ReflectionProbe {
  50806. /** defines the name of the probe */
  50807. name: string;
  50808. private _scene;
  50809. private _renderTargetTexture;
  50810. private _projectionMatrix;
  50811. private _viewMatrix;
  50812. private _target;
  50813. private _add;
  50814. private _attachedMesh;
  50815. private _invertYAxis;
  50816. /** Gets or sets probe position (center of the cube map) */
  50817. position: Vector3;
  50818. /**
  50819. * Creates a new reflection probe
  50820. * @param name defines the name of the probe
  50821. * @param size defines the texture resolution (for each face)
  50822. * @param scene defines the hosting scene
  50823. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50824. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50825. */
  50826. constructor(
  50827. /** defines the name of the probe */
  50828. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50829. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50830. samples: number;
  50831. /** Gets or sets the refresh rate to use (on every frame by default) */
  50832. refreshRate: number;
  50833. /**
  50834. * Gets the hosting scene
  50835. * @returns a Scene
  50836. */
  50837. getScene(): Scene;
  50838. /** Gets the internal CubeTexture used to render to */
  50839. readonly cubeTexture: RenderTargetTexture;
  50840. /** Gets the list of meshes to render */
  50841. readonly renderList: Nullable<AbstractMesh[]>;
  50842. /**
  50843. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50844. * @param mesh defines the mesh to attach to
  50845. */
  50846. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50847. /**
  50848. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50849. * @param renderingGroupId The rendering group id corresponding to its index
  50850. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50851. */
  50852. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50853. /**
  50854. * Clean all associated resources
  50855. */
  50856. dispose(): void;
  50857. /**
  50858. * Converts the reflection probe information to a readable string for debug purpose.
  50859. * @param fullDetails Supports for multiple levels of logging within scene loading
  50860. * @returns the human readable reflection probe info
  50861. */
  50862. toString(fullDetails?: boolean): string;
  50863. /**
  50864. * Get the class name of the relfection probe.
  50865. * @returns "ReflectionProbe"
  50866. */
  50867. getClassName(): string;
  50868. /**
  50869. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50870. * @returns The JSON representation of the texture
  50871. */
  50872. serialize(): any;
  50873. /**
  50874. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50875. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50876. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50877. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50878. * @returns The parsed reflection probe if successful
  50879. */
  50880. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50881. }
  50882. }
  50883. declare module BABYLON {
  50884. /** @hidden */
  50885. export var _BabylonLoaderRegistered: boolean;
  50886. }
  50887. declare module BABYLON {
  50888. /**
  50889. * The Physically based simple base material of BJS.
  50890. *
  50891. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50892. * It is used as the base class for both the specGloss and metalRough conventions.
  50893. */
  50894. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50895. /**
  50896. * Number of Simultaneous lights allowed on the material.
  50897. */
  50898. maxSimultaneousLights: number;
  50899. /**
  50900. * If sets to true, disables all the lights affecting the material.
  50901. */
  50902. disableLighting: boolean;
  50903. /**
  50904. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50905. */
  50906. environmentTexture: BaseTexture;
  50907. /**
  50908. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50909. */
  50910. invertNormalMapX: boolean;
  50911. /**
  50912. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50913. */
  50914. invertNormalMapY: boolean;
  50915. /**
  50916. * Normal map used in the model.
  50917. */
  50918. normalTexture: BaseTexture;
  50919. /**
  50920. * Emissivie color used to self-illuminate the model.
  50921. */
  50922. emissiveColor: Color3;
  50923. /**
  50924. * Emissivie texture used to self-illuminate the model.
  50925. */
  50926. emissiveTexture: BaseTexture;
  50927. /**
  50928. * Occlusion Channel Strenght.
  50929. */
  50930. occlusionStrength: number;
  50931. /**
  50932. * Occlusion Texture of the material (adding extra occlusion effects).
  50933. */
  50934. occlusionTexture: BaseTexture;
  50935. /**
  50936. * Defines the alpha limits in alpha test mode.
  50937. */
  50938. alphaCutOff: number;
  50939. /**
  50940. * Gets the current double sided mode.
  50941. */
  50942. /**
  50943. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50944. */
  50945. doubleSided: boolean;
  50946. /**
  50947. * Stores the pre-calculated light information of a mesh in a texture.
  50948. */
  50949. lightmapTexture: BaseTexture;
  50950. /**
  50951. * If true, the light map contains occlusion information instead of lighting info.
  50952. */
  50953. useLightmapAsShadowmap: boolean;
  50954. /**
  50955. * Instantiates a new PBRMaterial instance.
  50956. *
  50957. * @param name The material name
  50958. * @param scene The scene the material will be use in.
  50959. */
  50960. constructor(name: string, scene: Scene);
  50961. getClassName(): string;
  50962. }
  50963. }
  50964. declare module BABYLON {
  50965. /**
  50966. * The PBR material of BJS following the metal roughness convention.
  50967. *
  50968. * This fits to the PBR convention in the GLTF definition:
  50969. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50970. */
  50971. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50972. /**
  50973. * The base color has two different interpretations depending on the value of metalness.
  50974. * When the material is a metal, the base color is the specific measured reflectance value
  50975. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50976. * of the material.
  50977. */
  50978. baseColor: Color3;
  50979. /**
  50980. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50981. * well as opacity information in the alpha channel.
  50982. */
  50983. baseTexture: BaseTexture;
  50984. /**
  50985. * Specifies the metallic scalar value of the material.
  50986. * Can also be used to scale the metalness values of the metallic texture.
  50987. */
  50988. metallic: number;
  50989. /**
  50990. * Specifies the roughness scalar value of the material.
  50991. * Can also be used to scale the roughness values of the metallic texture.
  50992. */
  50993. roughness: number;
  50994. /**
  50995. * Texture containing both the metallic value in the B channel and the
  50996. * roughness value in the G channel to keep better precision.
  50997. */
  50998. metallicRoughnessTexture: BaseTexture;
  50999. /**
  51000. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51001. *
  51002. * @param name The material name
  51003. * @param scene The scene the material will be use in.
  51004. */
  51005. constructor(name: string, scene: Scene);
  51006. /**
  51007. * Return the currrent class name of the material.
  51008. */
  51009. getClassName(): string;
  51010. /**
  51011. * Makes a duplicate of the current material.
  51012. * @param name - name to use for the new material.
  51013. */
  51014. clone(name: string): PBRMetallicRoughnessMaterial;
  51015. /**
  51016. * Serialize the material to a parsable JSON object.
  51017. */
  51018. serialize(): any;
  51019. /**
  51020. * Parses a JSON object correponding to the serialize function.
  51021. */
  51022. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51023. }
  51024. }
  51025. declare module BABYLON {
  51026. /**
  51027. * The PBR material of BJS following the specular glossiness convention.
  51028. *
  51029. * This fits to the PBR convention in the GLTF definition:
  51030. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51031. */
  51032. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51033. /**
  51034. * Specifies the diffuse color of the material.
  51035. */
  51036. diffuseColor: Color3;
  51037. /**
  51038. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51039. * channel.
  51040. */
  51041. diffuseTexture: BaseTexture;
  51042. /**
  51043. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51044. */
  51045. specularColor: Color3;
  51046. /**
  51047. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51048. */
  51049. glossiness: number;
  51050. /**
  51051. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51052. */
  51053. specularGlossinessTexture: BaseTexture;
  51054. /**
  51055. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51056. *
  51057. * @param name The material name
  51058. * @param scene The scene the material will be use in.
  51059. */
  51060. constructor(name: string, scene: Scene);
  51061. /**
  51062. * Return the currrent class name of the material.
  51063. */
  51064. getClassName(): string;
  51065. /**
  51066. * Makes a duplicate of the current material.
  51067. * @param name - name to use for the new material.
  51068. */
  51069. clone(name: string): PBRSpecularGlossinessMaterial;
  51070. /**
  51071. * Serialize the material to a parsable JSON object.
  51072. */
  51073. serialize(): any;
  51074. /**
  51075. * Parses a JSON object correponding to the serialize function.
  51076. */
  51077. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51078. }
  51079. }
  51080. declare module BABYLON {
  51081. /**
  51082. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51083. * It can help converting any input color in a desired output one. This can then be used to create effects
  51084. * from sepia, black and white to sixties or futuristic rendering...
  51085. *
  51086. * The only supported format is currently 3dl.
  51087. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51088. */
  51089. export class ColorGradingTexture extends BaseTexture {
  51090. /**
  51091. * The current texture matrix. (will always be identity in color grading texture)
  51092. */
  51093. private _textureMatrix;
  51094. /**
  51095. * The texture URL.
  51096. */
  51097. url: string;
  51098. /**
  51099. * Empty line regex stored for GC.
  51100. */
  51101. private static _noneEmptyLineRegex;
  51102. private _engine;
  51103. /**
  51104. * Instantiates a ColorGradingTexture from the following parameters.
  51105. *
  51106. * @param url The location of the color gradind data (currently only supporting 3dl)
  51107. * @param scene The scene the texture will be used in
  51108. */
  51109. constructor(url: string, scene: Scene);
  51110. /**
  51111. * Returns the texture matrix used in most of the material.
  51112. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51113. */
  51114. getTextureMatrix(): Matrix;
  51115. /**
  51116. * Occurs when the file being loaded is a .3dl LUT file.
  51117. */
  51118. private load3dlTexture;
  51119. /**
  51120. * Starts the loading process of the texture.
  51121. */
  51122. private loadTexture;
  51123. /**
  51124. * Clones the color gradind texture.
  51125. */
  51126. clone(): ColorGradingTexture;
  51127. /**
  51128. * Called during delayed load for textures.
  51129. */
  51130. delayLoad(): void;
  51131. /**
  51132. * Parses a color grading texture serialized by Babylon.
  51133. * @param parsedTexture The texture information being parsedTexture
  51134. * @param scene The scene to load the texture in
  51135. * @param rootUrl The root url of the data assets to load
  51136. * @return A color gradind texture
  51137. */
  51138. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51139. /**
  51140. * Serializes the LUT texture to json format.
  51141. */
  51142. serialize(): any;
  51143. }
  51144. }
  51145. declare module BABYLON {
  51146. /**
  51147. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51148. */
  51149. export class EquiRectangularCubeTexture extends BaseTexture {
  51150. /** The six faces of the cube. */
  51151. private static _FacesMapping;
  51152. private _noMipmap;
  51153. private _onLoad;
  51154. private _onError;
  51155. /** The size of the cubemap. */
  51156. private _size;
  51157. /** The buffer of the image. */
  51158. private _buffer;
  51159. /** The width of the input image. */
  51160. private _width;
  51161. /** The height of the input image. */
  51162. private _height;
  51163. /** The URL to the image. */
  51164. url: string;
  51165. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51166. coordinatesMode: number;
  51167. /**
  51168. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51169. * @param url The location of the image
  51170. * @param scene The scene the texture will be used in
  51171. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51172. * @param noMipmap Forces to not generate the mipmap if true
  51173. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51174. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51175. * @param onLoad — defines a callback called when texture is loaded
  51176. * @param onError — defines a callback called if there is an error
  51177. */
  51178. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51179. /**
  51180. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51181. */
  51182. private loadImage;
  51183. /**
  51184. * Convert the image buffer into a cubemap and create a CubeTexture.
  51185. */
  51186. private loadTexture;
  51187. /**
  51188. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51189. * @param buffer The ArrayBuffer that should be converted.
  51190. * @returns The buffer as Float32Array.
  51191. */
  51192. private getFloat32ArrayFromArrayBuffer;
  51193. /**
  51194. * Get the current class name of the texture useful for serialization or dynamic coding.
  51195. * @returns "EquiRectangularCubeTexture"
  51196. */
  51197. getClassName(): string;
  51198. /**
  51199. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51200. * @returns A clone of the current EquiRectangularCubeTexture.
  51201. */
  51202. clone(): EquiRectangularCubeTexture;
  51203. }
  51204. }
  51205. declare module BABYLON {
  51206. /**
  51207. * Based on jsTGALoader - Javascript loader for TGA file
  51208. * By Vincent Thibault
  51209. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51210. */
  51211. export class TGATools {
  51212. private static _TYPE_INDEXED;
  51213. private static _TYPE_RGB;
  51214. private static _TYPE_GREY;
  51215. private static _TYPE_RLE_INDEXED;
  51216. private static _TYPE_RLE_RGB;
  51217. private static _TYPE_RLE_GREY;
  51218. private static _ORIGIN_MASK;
  51219. private static _ORIGIN_SHIFT;
  51220. private static _ORIGIN_BL;
  51221. private static _ORIGIN_BR;
  51222. private static _ORIGIN_UL;
  51223. private static _ORIGIN_UR;
  51224. /**
  51225. * Gets the header of a TGA file
  51226. * @param data defines the TGA data
  51227. * @returns the header
  51228. */
  51229. static GetTGAHeader(data: Uint8Array): any;
  51230. /**
  51231. * Uploads TGA content to a Babylon Texture
  51232. * @hidden
  51233. */
  51234. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51235. /** @hidden */ private static _getImageData8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51236. /** @hidden */ private static _getImageData16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51237. /** @hidden */ private static _getImageData24bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51238. /** @hidden */ private static _getImageData32bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51239. /** @hidden */ private static _getImageDataGrey8bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51240. /** @hidden */ private static _getImageDataGrey16bits(header: any, palettes: Uint8Array, pixel_data: Uint8Array, y_start: number, y_step: number, y_end: number, x_start: number, x_step: number, x_end: number): Uint8Array;
  51241. }
  51242. }
  51243. declare module BABYLON {
  51244. /**
  51245. * Implementation of the TGA Texture Loader.
  51246. * @hidden
  51247. */
  51248. export class _TGATextureLoader implements IInternalTextureLoader {
  51249. /**
  51250. * Defines wether the loader supports cascade loading the different faces.
  51251. */
  51252. readonly supportCascades: boolean;
  51253. /**
  51254. * This returns if the loader support the current file information.
  51255. * @param extension defines the file extension of the file being loaded
  51256. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51257. * @param fallback defines the fallback internal texture if any
  51258. * @param isBase64 defines whether the texture is encoded as a base64
  51259. * @param isBuffer defines whether the texture data are stored as a buffer
  51260. * @returns true if the loader can load the specified file
  51261. */
  51262. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51263. /**
  51264. * Transform the url before loading if required.
  51265. * @param rootUrl the url of the texture
  51266. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51267. * @returns the transformed texture
  51268. */
  51269. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51270. /**
  51271. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51272. * @param rootUrl the url of the texture
  51273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51274. * @returns the fallback texture
  51275. */
  51276. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51277. /**
  51278. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51279. * @param data contains the texture data
  51280. * @param texture defines the BabylonJS internal texture
  51281. * @param createPolynomials will be true if polynomials have been requested
  51282. * @param onLoad defines the callback to trigger once the texture is ready
  51283. * @param onError defines the callback to trigger in case of error
  51284. */
  51285. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51286. /**
  51287. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51288. * @param data contains the texture data
  51289. * @param texture defines the BabylonJS internal texture
  51290. * @param callback defines the method to call once ready to upload
  51291. */
  51292. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51293. }
  51294. }
  51295. declare module BABYLON {
  51296. /**
  51297. * Info about the .basis files
  51298. */
  51299. class BasisFileInfo {
  51300. /**
  51301. * If the file has alpha
  51302. */
  51303. hasAlpha: boolean;
  51304. /**
  51305. * Info about each image of the basis file
  51306. */
  51307. images: Array<{
  51308. levels: Array<{
  51309. width: number;
  51310. height: number;
  51311. transcodedPixels: ArrayBufferView;
  51312. }>;
  51313. }>;
  51314. }
  51315. /**
  51316. * Result of transcoding a basis file
  51317. */
  51318. class TranscodeResult {
  51319. /**
  51320. * Info about the .basis file
  51321. */
  51322. fileInfo: BasisFileInfo;
  51323. /**
  51324. * Format to use when loading the file
  51325. */
  51326. format: number;
  51327. }
  51328. /**
  51329. * Configuration options for the Basis transcoder
  51330. */
  51331. export class BasisTranscodeConfiguration {
  51332. /**
  51333. * Supported compression formats used to determine the supported output format of the transcoder
  51334. */
  51335. supportedCompressionFormats?: {
  51336. /**
  51337. * etc1 compression format
  51338. */
  51339. etc1?: boolean;
  51340. /**
  51341. * s3tc compression format
  51342. */
  51343. s3tc?: boolean;
  51344. /**
  51345. * pvrtc compression format
  51346. */
  51347. pvrtc?: boolean;
  51348. /**
  51349. * etc2 compression format
  51350. */
  51351. etc2?: boolean;
  51352. };
  51353. /**
  51354. * If mipmap levels should be loaded for transcoded images (Default: true)
  51355. */
  51356. loadMipmapLevels?: boolean;
  51357. /**
  51358. * Index of a single image to load (Default: all images)
  51359. */
  51360. loadSingleImage?: number;
  51361. }
  51362. /**
  51363. * Used to load .Basis files
  51364. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  51365. */
  51366. export class BasisTools {
  51367. private static _IgnoreSupportedFormats;
  51368. /**
  51369. * URL to use when loading the basis transcoder
  51370. */
  51371. static JSModuleURL: string;
  51372. /**
  51373. * URL to use when loading the wasm module for the transcoder
  51374. */
  51375. static WasmModuleURL: string;
  51376. /**
  51377. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  51378. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  51379. * @returns internal format corresponding to the Basis format
  51380. */
  51381. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  51382. private static _WorkerPromise;
  51383. private static _Worker;
  51384. private static _actionId;
  51385. private static _CreateWorkerAsync;
  51386. /**
  51387. * Transcodes a loaded image file to compressed pixel data
  51388. * @param imageData image data to transcode
  51389. * @param config configuration options for the transcoding
  51390. * @returns a promise resulting in the transcoded image
  51391. */
  51392. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  51393. /**
  51394. * Loads a texture from the transcode result
  51395. * @param texture texture load to
  51396. * @param transcodeResult the result of transcoding the basis file to load from
  51397. */
  51398. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  51399. }
  51400. }
  51401. declare module BABYLON {
  51402. /**
  51403. * Loader for .basis file format
  51404. */
  51405. export class _BasisTextureLoader implements IInternalTextureLoader {
  51406. /**
  51407. * Defines whether the loader supports cascade loading the different faces.
  51408. */
  51409. readonly supportCascades: boolean;
  51410. /**
  51411. * This returns if the loader support the current file information.
  51412. * @param extension defines the file extension of the file being loaded
  51413. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51414. * @param fallback defines the fallback internal texture if any
  51415. * @param isBase64 defines whether the texture is encoded as a base64
  51416. * @param isBuffer defines whether the texture data are stored as a buffer
  51417. * @returns true if the loader can load the specified file
  51418. */
  51419. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51420. /**
  51421. * Transform the url before loading if required.
  51422. * @param rootUrl the url of the texture
  51423. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51424. * @returns the transformed texture
  51425. */
  51426. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51427. /**
  51428. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51429. * @param rootUrl the url of the texture
  51430. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51431. * @returns the fallback texture
  51432. */
  51433. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51434. /**
  51435. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  51436. * @param data contains the texture data
  51437. * @param texture defines the BabylonJS internal texture
  51438. * @param createPolynomials will be true if polynomials have been requested
  51439. * @param onLoad defines the callback to trigger once the texture is ready
  51440. * @param onError defines the callback to trigger in case of error
  51441. */
  51442. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51443. /**
  51444. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51445. * @param data contains the texture data
  51446. * @param texture defines the BabylonJS internal texture
  51447. * @param callback defines the method to call once ready to upload
  51448. */
  51449. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51450. }
  51451. }
  51452. declare module BABYLON {
  51453. /**
  51454. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  51455. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51456. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51457. */
  51458. export class CustomProceduralTexture extends ProceduralTexture {
  51459. private _animate;
  51460. private _time;
  51461. private _config;
  51462. private _texturePath;
  51463. /**
  51464. * Instantiates a new Custom Procedural Texture.
  51465. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  51466. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51467. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51468. * @param name Define the name of the texture
  51469. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51470. * @param size Define the size of the texture to create
  51471. * @param scene Define the scene the texture belongs to
  51472. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51473. * @param generateMipMaps Define if the texture should creates mip maps or not
  51474. */
  51475. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51476. private _loadJson;
  51477. /**
  51478. * Is the texture ready to be used ? (rendered at least once)
  51479. * @returns true if ready, otherwise, false.
  51480. */
  51481. isReady(): boolean;
  51482. /**
  51483. * Render the texture to its associated render target.
  51484. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51485. */
  51486. render(useCameraPostProcess?: boolean): void;
  51487. /**
  51488. * Update the list of dependant textures samplers in the shader.
  51489. */
  51490. updateTextures(): void;
  51491. /**
  51492. * Update the uniform values of the procedural texture in the shader.
  51493. */
  51494. updateShaderUniforms(): void;
  51495. /**
  51496. * Define if the texture animates or not.
  51497. */
  51498. animate: boolean;
  51499. }
  51500. }
  51501. declare module BABYLON {
  51502. /** @hidden */
  51503. export var noisePixelShader: {
  51504. name: string;
  51505. shader: string;
  51506. };
  51507. }
  51508. declare module BABYLON {
  51509. /**
  51510. * Class used to generate noise procedural textures
  51511. */
  51512. export class NoiseProceduralTexture extends ProceduralTexture {
  51513. private _time;
  51514. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51515. brightness: number;
  51516. /** Defines the number of octaves to process */
  51517. octaves: number;
  51518. /** Defines the level of persistence (0.8 by default) */
  51519. persistence: number;
  51520. /** Gets or sets animation speed factor (default is 1) */
  51521. animationSpeedFactor: number;
  51522. /**
  51523. * Creates a new NoiseProceduralTexture
  51524. * @param name defines the name fo the texture
  51525. * @param size defines the size of the texture (default is 256)
  51526. * @param scene defines the hosting scene
  51527. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51528. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51529. */
  51530. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51531. private _updateShaderUniforms;
  51532. protected _getDefines(): string;
  51533. /** Generate the current state of the procedural texture */
  51534. render(useCameraPostProcess?: boolean): void;
  51535. /**
  51536. * Serializes this noise procedural texture
  51537. * @returns a serialized noise procedural texture object
  51538. */
  51539. serialize(): any;
  51540. /**
  51541. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51542. * @param parsedTexture defines parsed texture data
  51543. * @param scene defines the current scene
  51544. * @param rootUrl defines the root URL containing noise procedural texture information
  51545. * @returns a parsed NoiseProceduralTexture
  51546. */
  51547. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51548. }
  51549. }
  51550. declare module BABYLON {
  51551. /**
  51552. * Raw cube texture where the raw buffers are passed in
  51553. */
  51554. export class RawCubeTexture extends CubeTexture {
  51555. /**
  51556. * Creates a cube texture where the raw buffers are passed in.
  51557. * @param scene defines the scene the texture is attached to
  51558. * @param data defines the array of data to use to create each face
  51559. * @param size defines the size of the textures
  51560. * @param format defines the format of the data
  51561. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51562. * @param generateMipMaps defines if the engine should generate the mip levels
  51563. * @param invertY defines if data must be stored with Y axis inverted
  51564. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51565. * @param compression defines the compression used (null by default)
  51566. */
  51567. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51568. /**
  51569. * Updates the raw cube texture.
  51570. * @param data defines the data to store
  51571. * @param format defines the data format
  51572. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51573. * @param invertY defines if data must be stored with Y axis inverted
  51574. * @param compression defines the compression used (null by default)
  51575. * @param level defines which level of the texture to update
  51576. */
  51577. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51578. /**
  51579. * Updates a raw cube texture with RGBD encoded data.
  51580. * @param data defines the array of data [mipmap][face] to use to create each face
  51581. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51582. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51583. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51584. * @returns a promsie that resolves when the operation is complete
  51585. */
  51586. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51587. /**
  51588. * Clones the raw cube texture.
  51589. * @return a new cube texture
  51590. */
  51591. clone(): CubeTexture;
  51592. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51593. }
  51594. }
  51595. declare module BABYLON {
  51596. /**
  51597. * Class used to store 3D textures containing user data
  51598. */
  51599. export class RawTexture3D extends Texture {
  51600. /** Gets or sets the texture format to use */
  51601. format: number;
  51602. private _engine;
  51603. /**
  51604. * Create a new RawTexture3D
  51605. * @param data defines the data of the texture
  51606. * @param width defines the width of the texture
  51607. * @param height defines the height of the texture
  51608. * @param depth defines the depth of the texture
  51609. * @param format defines the texture format to use
  51610. * @param scene defines the hosting scene
  51611. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51612. * @param invertY defines if texture must be stored with Y axis inverted
  51613. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51614. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51615. */
  51616. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51617. /** Gets or sets the texture format to use */
  51618. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51619. /**
  51620. * Update the texture with new data
  51621. * @param data defines the data to store in the texture
  51622. */
  51623. update(data: ArrayBufferView): void;
  51624. }
  51625. }
  51626. declare module BABYLON {
  51627. /**
  51628. * Creates a refraction texture used by refraction channel of the standard material.
  51629. * It is like a mirror but to see through a material.
  51630. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51631. */
  51632. export class RefractionTexture extends RenderTargetTexture {
  51633. /**
  51634. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51635. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  51636. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51637. */
  51638. refractionPlane: Plane;
  51639. /**
  51640. * Define how deep under the surface we should see.
  51641. */
  51642. depth: number;
  51643. /**
  51644. * Creates a refraction texture used by refraction channel of the standard material.
  51645. * It is like a mirror but to see through a material.
  51646. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51647. * @param name Define the texture name
  51648. * @param size Define the size of the underlying texture
  51649. * @param scene Define the scene the refraction belongs to
  51650. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51651. */
  51652. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51653. /**
  51654. * Clone the refraction texture.
  51655. * @returns the cloned texture
  51656. */
  51657. clone(): RefractionTexture;
  51658. /**
  51659. * Serialize the texture to a JSON representation you could use in Parse later on
  51660. * @returns the serialized JSON representation
  51661. */
  51662. serialize(): any;
  51663. }
  51664. }
  51665. declare module BABYLON {
  51666. /**
  51667. * Defines the options related to the creation of an HtmlElementTexture
  51668. */
  51669. export interface IHtmlElementTextureOptions {
  51670. /**
  51671. * Defines wether mip maps should be created or not.
  51672. */
  51673. generateMipMaps?: boolean;
  51674. /**
  51675. * Defines the sampling mode of the texture.
  51676. */
  51677. samplingMode?: number;
  51678. /**
  51679. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51680. */
  51681. engine: Nullable<ThinEngine>;
  51682. /**
  51683. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51684. */
  51685. scene: Nullable<Scene>;
  51686. }
  51687. /**
  51688. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51689. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51690. * is automatically managed.
  51691. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51692. * in your application.
  51693. *
  51694. * As the update is not automatic, you need to call them manually.
  51695. */
  51696. export class HtmlElementTexture extends BaseTexture {
  51697. /**
  51698. * The texture URL.
  51699. */
  51700. element: HTMLVideoElement | HTMLCanvasElement;
  51701. private static readonly DefaultOptions;
  51702. private _textureMatrix;
  51703. private _engine;
  51704. private _isVideo;
  51705. private _generateMipMaps;
  51706. private _samplingMode;
  51707. /**
  51708. * Instantiates a HtmlElementTexture from the following parameters.
  51709. *
  51710. * @param name Defines the name of the texture
  51711. * @param element Defines the video or canvas the texture is filled with
  51712. * @param options Defines the other none mandatory texture creation options
  51713. */
  51714. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51715. private _createInternalTexture;
  51716. /**
  51717. * Returns the texture matrix used in most of the material.
  51718. */
  51719. getTextureMatrix(): Matrix;
  51720. /**
  51721. * Updates the content of the texture.
  51722. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51723. */
  51724. update(invertY?: Nullable<boolean>): void;
  51725. }
  51726. }
  51727. declare module BABYLON {
  51728. /**
  51729. * Enum used to define the target of a block
  51730. */
  51731. export enum NodeMaterialBlockTargets {
  51732. /** Vertex shader */
  51733. Vertex = 1,
  51734. /** Fragment shader */
  51735. Fragment = 2,
  51736. /** Neutral */
  51737. Neutral = 4,
  51738. /** Vertex and Fragment */
  51739. VertexAndFragment = 3
  51740. }
  51741. }
  51742. declare module BABYLON {
  51743. /**
  51744. * Defines the kind of connection point for node based material
  51745. */
  51746. export enum NodeMaterialBlockConnectionPointTypes {
  51747. /** Float */
  51748. Float = 1,
  51749. /** Int */
  51750. Int = 2,
  51751. /** Vector2 */
  51752. Vector2 = 4,
  51753. /** Vector3 */
  51754. Vector3 = 8,
  51755. /** Vector4 */
  51756. Vector4 = 16,
  51757. /** Color3 */
  51758. Color3 = 32,
  51759. /** Color4 */
  51760. Color4 = 64,
  51761. /** Matrix */
  51762. Matrix = 128,
  51763. /** Detect type based on connection */
  51764. AutoDetect = 1024,
  51765. /** Output type that will be defined by input type */
  51766. BasedOnInput = 2048
  51767. }
  51768. }
  51769. declare module BABYLON {
  51770. /**
  51771. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51772. */
  51773. export enum NodeMaterialBlockConnectionPointMode {
  51774. /** Value is an uniform */
  51775. Uniform = 0,
  51776. /** Value is a mesh attribute */
  51777. Attribute = 1,
  51778. /** Value is a varying between vertex and fragment shaders */
  51779. Varying = 2,
  51780. /** Mode is undefined */
  51781. Undefined = 3
  51782. }
  51783. }
  51784. declare module BABYLON {
  51785. /**
  51786. * Enum used to define system values e.g. values automatically provided by the system
  51787. */
  51788. export enum NodeMaterialSystemValues {
  51789. /** World */
  51790. World = 1,
  51791. /** View */
  51792. View = 2,
  51793. /** Projection */
  51794. Projection = 3,
  51795. /** ViewProjection */
  51796. ViewProjection = 4,
  51797. /** WorldView */
  51798. WorldView = 5,
  51799. /** WorldViewProjection */
  51800. WorldViewProjection = 6,
  51801. /** CameraPosition */
  51802. CameraPosition = 7,
  51803. /** Fog Color */
  51804. FogColor = 8,
  51805. /** Delta time */
  51806. DeltaTime = 9
  51807. }
  51808. }
  51809. declare module BABYLON {
  51810. /**
  51811. * Root class for all node material optimizers
  51812. */
  51813. export class NodeMaterialOptimizer {
  51814. /**
  51815. * Function used to optimize a NodeMaterial graph
  51816. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  51817. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  51818. */
  51819. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  51820. }
  51821. }
  51822. declare module BABYLON {
  51823. /**
  51824. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  51825. */
  51826. export class TransformBlock extends NodeMaterialBlock {
  51827. /**
  51828. * Defines the value to use to complement W value to transform it to a Vector4
  51829. */
  51830. complementW: number;
  51831. /**
  51832. * Defines the value to use to complement z value to transform it to a Vector4
  51833. */
  51834. complementZ: number;
  51835. /**
  51836. * Creates a new TransformBlock
  51837. * @param name defines the block name
  51838. */
  51839. constructor(name: string);
  51840. /**
  51841. * Gets the current class name
  51842. * @returns the class name
  51843. */
  51844. getClassName(): string;
  51845. /**
  51846. * Gets the vector input
  51847. */
  51848. readonly vector: NodeMaterialConnectionPoint;
  51849. /**
  51850. * Gets the output component
  51851. */
  51852. readonly output: NodeMaterialConnectionPoint;
  51853. /**
  51854. * Gets the matrix transform input
  51855. */
  51856. readonly transform: NodeMaterialConnectionPoint;
  51857. protected _buildBlock(state: NodeMaterialBuildState): this;
  51858. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51859. protected _dumpPropertiesCode(): string;
  51860. }
  51861. }
  51862. declare module BABYLON {
  51863. /**
  51864. * Block used to output the vertex position
  51865. */
  51866. export class VertexOutputBlock extends NodeMaterialBlock {
  51867. /**
  51868. * Creates a new VertexOutputBlock
  51869. * @param name defines the block name
  51870. */
  51871. constructor(name: string);
  51872. /**
  51873. * Gets the current class name
  51874. * @returns the class name
  51875. */
  51876. getClassName(): string;
  51877. /**
  51878. * Gets the vector input component
  51879. */
  51880. readonly vector: NodeMaterialConnectionPoint;
  51881. protected _buildBlock(state: NodeMaterialBuildState): this;
  51882. }
  51883. }
  51884. declare module BABYLON {
  51885. /**
  51886. * Block used to output the final color
  51887. */
  51888. export class FragmentOutputBlock extends NodeMaterialBlock {
  51889. /**
  51890. * Create a new FragmentOutputBlock
  51891. * @param name defines the block name
  51892. */
  51893. constructor(name: string);
  51894. /**
  51895. * Gets the current class name
  51896. * @returns the class name
  51897. */
  51898. getClassName(): string;
  51899. /**
  51900. * Gets the rgba input component
  51901. */
  51902. readonly rgba: NodeMaterialConnectionPoint;
  51903. /**
  51904. * Gets the rgb input component
  51905. */
  51906. readonly rgb: NodeMaterialConnectionPoint;
  51907. /**
  51908. * Gets the a input component
  51909. */
  51910. readonly a: NodeMaterialConnectionPoint;
  51911. protected _buildBlock(state: NodeMaterialBuildState): this;
  51912. }
  51913. }
  51914. declare module BABYLON {
  51915. /**
  51916. * Block used to read a reflection texture from a sampler
  51917. */
  51918. export class ReflectionTextureBlock extends NodeMaterialBlock {
  51919. private _define3DName;
  51920. private _defineCubicName;
  51921. private _defineExplicitName;
  51922. private _defineProjectionName;
  51923. private _defineLocalCubicName;
  51924. private _defineSphericalName;
  51925. private _definePlanarName;
  51926. private _defineEquirectangularName;
  51927. private _defineMirroredEquirectangularFixedName;
  51928. private _defineEquirectangularFixedName;
  51929. private _defineSkyboxName;
  51930. private _cubeSamplerName;
  51931. private _2DSamplerName;
  51932. private _positionUVWName;
  51933. private _directionWName;
  51934. private _reflectionCoordsName;
  51935. private _reflection2DCoordsName;
  51936. private _reflectionColorName;
  51937. private _reflectionMatrixName;
  51938. /**
  51939. * Gets or sets the texture associated with the node
  51940. */
  51941. texture: Nullable<BaseTexture>;
  51942. /**
  51943. * Create a new TextureBlock
  51944. * @param name defines the block name
  51945. */
  51946. constructor(name: string);
  51947. /**
  51948. * Gets the current class name
  51949. * @returns the class name
  51950. */
  51951. getClassName(): string;
  51952. /**
  51953. * Gets the world position input component
  51954. */
  51955. readonly position: NodeMaterialConnectionPoint;
  51956. /**
  51957. * Gets the world position input component
  51958. */
  51959. readonly worldPosition: NodeMaterialConnectionPoint;
  51960. /**
  51961. * Gets the world normal input component
  51962. */
  51963. readonly worldNormal: NodeMaterialConnectionPoint;
  51964. /**
  51965. * Gets the world input component
  51966. */
  51967. readonly world: NodeMaterialConnectionPoint;
  51968. /**
  51969. * Gets the camera (or eye) position component
  51970. */
  51971. readonly cameraPosition: NodeMaterialConnectionPoint;
  51972. /**
  51973. * Gets the view input component
  51974. */
  51975. readonly view: NodeMaterialConnectionPoint;
  51976. /**
  51977. * Gets the rgb output component
  51978. */
  51979. readonly rgb: NodeMaterialConnectionPoint;
  51980. /**
  51981. * Gets the r output component
  51982. */
  51983. readonly r: NodeMaterialConnectionPoint;
  51984. /**
  51985. * Gets the g output component
  51986. */
  51987. readonly g: NodeMaterialConnectionPoint;
  51988. /**
  51989. * Gets the b output component
  51990. */
  51991. readonly b: NodeMaterialConnectionPoint;
  51992. autoConfigure(material: NodeMaterial): void;
  51993. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51994. isReady(): boolean;
  51995. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51996. private _injectVertexCode;
  51997. private _writeOutput;
  51998. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51999. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52000. }
  52001. }
  52002. declare module BABYLON {
  52003. /**
  52004. * Interface used to configure the node material editor
  52005. */
  52006. export interface INodeMaterialEditorOptions {
  52007. /** Define the URl to load node editor script */
  52008. editorURL?: string;
  52009. }
  52010. /** @hidden */
  52011. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52012. /** BONES */
  52013. NUM_BONE_INFLUENCERS: number;
  52014. BonesPerMesh: number;
  52015. BONETEXTURE: boolean;
  52016. /** MORPH TARGETS */
  52017. MORPHTARGETS: boolean;
  52018. MORPHTARGETS_NORMAL: boolean;
  52019. MORPHTARGETS_TANGENT: boolean;
  52020. MORPHTARGETS_UV: boolean;
  52021. NUM_MORPH_INFLUENCERS: number;
  52022. /** IMAGE PROCESSING */
  52023. IMAGEPROCESSING: boolean;
  52024. VIGNETTE: boolean;
  52025. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52026. VIGNETTEBLENDMODEOPAQUE: boolean;
  52027. TONEMAPPING: boolean;
  52028. TONEMAPPING_ACES: boolean;
  52029. CONTRAST: boolean;
  52030. EXPOSURE: boolean;
  52031. COLORCURVES: boolean;
  52032. COLORGRADING: boolean;
  52033. COLORGRADING3D: boolean;
  52034. SAMPLER3DGREENDEPTH: boolean;
  52035. SAMPLER3DBGRMAP: boolean;
  52036. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52037. /** MISC. */
  52038. BUMPDIRECTUV: number;
  52039. constructor();
  52040. setValue(name: string, value: boolean): void;
  52041. }
  52042. /**
  52043. * Class used to configure NodeMaterial
  52044. */
  52045. export interface INodeMaterialOptions {
  52046. /**
  52047. * Defines if blocks should emit comments
  52048. */
  52049. emitComments: boolean;
  52050. }
  52051. /**
  52052. * Class used to create a node based material built by assembling shader blocks
  52053. */
  52054. export class NodeMaterial extends PushMaterial {
  52055. private static _BuildIdGenerator;
  52056. private _options;
  52057. private _vertexCompilationState;
  52058. private _fragmentCompilationState;
  52059. private _sharedData;
  52060. private _buildId;
  52061. private _buildWasSuccessful;
  52062. private _cachedWorldViewMatrix;
  52063. private _cachedWorldViewProjectionMatrix;
  52064. private _optimizers;
  52065. private _animationFrame;
  52066. /** Define the URl to load node editor script */
  52067. static EditorURL: string;
  52068. private BJSNODEMATERIALEDITOR;
  52069. /** Get the inspector from bundle or global */
  52070. private _getGlobalNodeMaterialEditor;
  52071. /**
  52072. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  52073. */
  52074. ignoreAlpha: boolean;
  52075. /**
  52076. * Defines the maximum number of lights that can be used in the material
  52077. */
  52078. maxSimultaneousLights: number;
  52079. /**
  52080. * Observable raised when the material is built
  52081. */
  52082. onBuildObservable: Observable<NodeMaterial>;
  52083. /**
  52084. * Gets or sets the root nodes of the material vertex shader
  52085. */ private _vertexOutputNodes: NodeMaterialBlock[];
  52086. /**
  52087. * Gets or sets the root nodes of the material fragment (pixel) shader
  52088. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  52089. /** Gets or sets options to control the node material overall behavior */
  52090. options: INodeMaterialOptions;
  52091. /**
  52092. * Default configuration related to image processing available in the standard Material.
  52093. */
  52094. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52095. /**
  52096. * Gets the image processing configuration used either in this material.
  52097. */
  52098. /**
  52099. * Sets the Default image processing configuration used either in the this material.
  52100. *
  52101. * If sets to null, the scene one is in use.
  52102. */
  52103. imageProcessingConfiguration: ImageProcessingConfiguration;
  52104. /**
  52105. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  52106. */
  52107. attachedBlocks: NodeMaterialBlock[];
  52108. /**
  52109. * Create a new node based material
  52110. * @param name defines the material name
  52111. * @param scene defines the hosting scene
  52112. * @param options defines creation option
  52113. */
  52114. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52115. /**
  52116. * Gets the current class name of the material e.g. "NodeMaterial"
  52117. * @returns the class name
  52118. */
  52119. getClassName(): string;
  52120. /**
  52121. * Keep track of the image processing observer to allow dispose and replace.
  52122. */
  52123. private _imageProcessingObserver;
  52124. /**
  52125. * Attaches a new image processing configuration to the Standard Material.
  52126. * @param configuration
  52127. */
  52128. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52129. /**
  52130. * Get a block by its name
  52131. * @param name defines the name of the block to retrieve
  52132. * @returns the required block or null if not found
  52133. */
  52134. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  52135. /**
  52136. * Get a block by its name
  52137. * @param predicate defines the predicate used to find the good candidate
  52138. * @returns the required block or null if not found
  52139. */
  52140. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  52141. /**
  52142. * Get an input block by its name
  52143. * @param predicate defines the predicate used to find the good candidate
  52144. * @returns the required input block or null if not found
  52145. */
  52146. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  52147. /**
  52148. * Gets the list of input blocks attached to this material
  52149. * @returns an array of InputBlocks
  52150. */
  52151. getInputBlocks(): InputBlock[];
  52152. /**
  52153. * Adds a new optimizer to the list of optimizers
  52154. * @param optimizer defines the optimizers to add
  52155. * @returns the current material
  52156. */
  52157. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52158. /**
  52159. * Remove an optimizer from the list of optimizers
  52160. * @param optimizer defines the optimizers to remove
  52161. * @returns the current material
  52162. */
  52163. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52164. /**
  52165. * Add a new block to the list of output nodes
  52166. * @param node defines the node to add
  52167. * @returns the current material
  52168. */
  52169. addOutputNode(node: NodeMaterialBlock): this;
  52170. /**
  52171. * Remove a block from the list of root nodes
  52172. * @param node defines the node to remove
  52173. * @returns the current material
  52174. */
  52175. removeOutputNode(node: NodeMaterialBlock): this;
  52176. private _addVertexOutputNode;
  52177. private _removeVertexOutputNode;
  52178. private _addFragmentOutputNode;
  52179. private _removeFragmentOutputNode;
  52180. /**
  52181. * Specifies if the material will require alpha blending
  52182. * @returns a boolean specifying if alpha blending is needed
  52183. */
  52184. needAlphaBlending(): boolean;
  52185. /**
  52186. * Specifies if this material should be rendered in alpha test mode
  52187. * @returns a boolean specifying if an alpha test is needed.
  52188. */
  52189. needAlphaTesting(): boolean;
  52190. private _initializeBlock;
  52191. private _resetDualBlocks;
  52192. /**
  52193. * Build the material and generates the inner effect
  52194. * @param verbose defines if the build should log activity
  52195. */
  52196. build(verbose?: boolean): void;
  52197. /**
  52198. * Runs an otpimization phase to try to improve the shader code
  52199. */
  52200. optimize(): void;
  52201. private _prepareDefinesForAttributes;
  52202. /**
  52203. * Get if the submesh is ready to be used and all its information available.
  52204. * Child classes can use it to update shaders
  52205. * @param mesh defines the mesh to check
  52206. * @param subMesh defines which submesh to check
  52207. * @param useInstances specifies that instances should be used
  52208. * @returns a boolean indicating that the submesh is ready or not
  52209. */
  52210. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52211. /**
  52212. * Get a string representing the shaders built by the current node graph
  52213. */
  52214. readonly compiledShaders: string;
  52215. /**
  52216. * Binds the world matrix to the material
  52217. * @param world defines the world transformation matrix
  52218. */
  52219. bindOnlyWorldMatrix(world: Matrix): void;
  52220. /**
  52221. * Binds the submesh to this material by preparing the effect and shader to draw
  52222. * @param world defines the world transformation matrix
  52223. * @param mesh defines the mesh containing the submesh
  52224. * @param subMesh defines the submesh to bind the material to
  52225. */
  52226. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52227. /**
  52228. * Gets the active textures from the material
  52229. * @returns an array of textures
  52230. */
  52231. getActiveTextures(): BaseTexture[];
  52232. /**
  52233. * Gets the list of texture blocks
  52234. * @returns an array of texture blocks
  52235. */
  52236. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  52237. /**
  52238. * Specifies if the material uses a texture
  52239. * @param texture defines the texture to check against the material
  52240. * @returns a boolean specifying if the material uses the texture
  52241. */
  52242. hasTexture(texture: BaseTexture): boolean;
  52243. /**
  52244. * Disposes the material
  52245. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52246. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52247. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52248. */
  52249. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52250. /** Creates the node editor window. */
  52251. private _createNodeEditor;
  52252. /**
  52253. * Launch the node material editor
  52254. * @param config Define the configuration of the editor
  52255. * @return a promise fulfilled when the node editor is visible
  52256. */
  52257. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52258. /**
  52259. * Clear the current material
  52260. */
  52261. clear(): void;
  52262. /**
  52263. * Clear the current material and set it to a default state
  52264. */
  52265. setToDefault(): void;
  52266. /**
  52267. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  52268. * @param url defines the url to load from
  52269. * @returns a promise that will fullfil when the material is fully loaded
  52270. */
  52271. loadAsync(url: string): Promise<unknown>;
  52272. private _gatherBlocks;
  52273. /**
  52274. * Generate a string containing the code declaration required to create an equivalent of this material
  52275. * @returns a string
  52276. */
  52277. generateCode(): string;
  52278. /**
  52279. * Serializes this material in a JSON representation
  52280. * @returns the serialized material object
  52281. */
  52282. serialize(): any;
  52283. private _restoreConnections;
  52284. /**
  52285. * Clear the current graph and load a new one from a serialization object
  52286. * @param source defines the JSON representation of the material
  52287. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52288. */
  52289. loadFromSerialization(source: any, rootUrl?: string): void;
  52290. /**
  52291. * Creates a node material from parsed material data
  52292. * @param source defines the JSON representation of the material
  52293. * @param scene defines the hosting scene
  52294. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52295. * @returns a new node material
  52296. */
  52297. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  52298. /**
  52299. * Creates a new node material set to default basic configuration
  52300. * @param name defines the name of the material
  52301. * @param scene defines the hosting scene
  52302. * @returns a new NodeMaterial
  52303. */
  52304. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  52305. }
  52306. }
  52307. declare module BABYLON {
  52308. /**
  52309. * Block used to read a texture from a sampler
  52310. */
  52311. export class TextureBlock extends NodeMaterialBlock {
  52312. private _defineName;
  52313. private _linearDefineName;
  52314. private _samplerName;
  52315. private _transformedUVName;
  52316. private _textureTransformName;
  52317. private _textureInfoName;
  52318. private _mainUVName;
  52319. private _mainUVDefineName;
  52320. /**
  52321. * Gets or sets the texture associated with the node
  52322. */
  52323. texture: Nullable<Texture>;
  52324. /**
  52325. * Create a new TextureBlock
  52326. * @param name defines the block name
  52327. */
  52328. constructor(name: string);
  52329. /**
  52330. * Gets the current class name
  52331. * @returns the class name
  52332. */
  52333. getClassName(): string;
  52334. /**
  52335. * Gets the uv input component
  52336. */
  52337. readonly uv: NodeMaterialConnectionPoint;
  52338. /**
  52339. * Gets the rgba output component
  52340. */
  52341. readonly rgba: NodeMaterialConnectionPoint;
  52342. /**
  52343. * Gets the rgb output component
  52344. */
  52345. readonly rgb: NodeMaterialConnectionPoint;
  52346. /**
  52347. * Gets the r output component
  52348. */
  52349. readonly r: NodeMaterialConnectionPoint;
  52350. /**
  52351. * Gets the g output component
  52352. */
  52353. readonly g: NodeMaterialConnectionPoint;
  52354. /**
  52355. * Gets the b output component
  52356. */
  52357. readonly b: NodeMaterialConnectionPoint;
  52358. /**
  52359. * Gets the a output component
  52360. */
  52361. readonly a: NodeMaterialConnectionPoint;
  52362. readonly target: NodeMaterialBlockTargets;
  52363. autoConfigure(material: NodeMaterial): void;
  52364. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52365. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52366. isReady(): boolean;
  52367. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52368. private readonly _isMixed;
  52369. private _injectVertexCode;
  52370. private _writeOutput;
  52371. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52372. protected _dumpPropertiesCode(): string;
  52373. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52374. }
  52375. }
  52376. declare module BABYLON {
  52377. /**
  52378. * Class used to store shared data between 2 NodeMaterialBuildState
  52379. */
  52380. export class NodeMaterialBuildStateSharedData {
  52381. /**
  52382. * Gets the list of emitted varyings
  52383. */
  52384. temps: string[];
  52385. /**
  52386. * Gets the list of emitted varyings
  52387. */
  52388. varyings: string[];
  52389. /**
  52390. * Gets the varying declaration string
  52391. */
  52392. varyingDeclaration: string;
  52393. /**
  52394. * Input blocks
  52395. */
  52396. inputBlocks: InputBlock[];
  52397. /**
  52398. * Input blocks
  52399. */
  52400. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  52401. /**
  52402. * Bindable blocks (Blocks that need to set data to the effect)
  52403. */
  52404. bindableBlocks: NodeMaterialBlock[];
  52405. /**
  52406. * List of blocks that can provide a compilation fallback
  52407. */
  52408. blocksWithFallbacks: NodeMaterialBlock[];
  52409. /**
  52410. * List of blocks that can provide a define update
  52411. */
  52412. blocksWithDefines: NodeMaterialBlock[];
  52413. /**
  52414. * List of blocks that can provide a repeatable content
  52415. */
  52416. repeatableContentBlocks: NodeMaterialBlock[];
  52417. /**
  52418. * List of blocks that can provide a dynamic list of uniforms
  52419. */
  52420. dynamicUniformBlocks: NodeMaterialBlock[];
  52421. /**
  52422. * List of blocks that can block the isReady function for the material
  52423. */
  52424. blockingBlocks: NodeMaterialBlock[];
  52425. /**
  52426. * Gets the list of animated inputs
  52427. */
  52428. animatedInputs: InputBlock[];
  52429. /**
  52430. * Build Id used to avoid multiple recompilations
  52431. */
  52432. buildId: number;
  52433. /** List of emitted variables */
  52434. variableNames: {
  52435. [key: string]: number;
  52436. };
  52437. /** List of emitted defines */
  52438. defineNames: {
  52439. [key: string]: number;
  52440. };
  52441. /** Should emit comments? */
  52442. emitComments: boolean;
  52443. /** Emit build activity */
  52444. verbose: boolean;
  52445. /** Gets or sets the hosting scene */
  52446. scene: Scene;
  52447. /**
  52448. * Gets the compilation hints emitted at compilation time
  52449. */
  52450. hints: {
  52451. needWorldViewMatrix: boolean;
  52452. needWorldViewProjectionMatrix: boolean;
  52453. needAlphaBlending: boolean;
  52454. needAlphaTesting: boolean;
  52455. };
  52456. /**
  52457. * List of compilation checks
  52458. */
  52459. checks: {
  52460. emitVertex: boolean;
  52461. emitFragment: boolean;
  52462. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52463. };
  52464. /** Creates a new shared data */
  52465. constructor();
  52466. /**
  52467. * Emits console errors and exceptions if there is a failing check
  52468. */
  52469. emitErrors(): void;
  52470. }
  52471. }
  52472. declare module BABYLON {
  52473. /**
  52474. * Class used to store node based material build state
  52475. */
  52476. export class NodeMaterialBuildState {
  52477. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  52478. supportUniformBuffers: boolean;
  52479. /**
  52480. * Gets the list of emitted attributes
  52481. */
  52482. attributes: string[];
  52483. /**
  52484. * Gets the list of emitted uniforms
  52485. */
  52486. uniforms: string[];
  52487. /**
  52488. * Gets the list of emitted constants
  52489. */
  52490. constants: string[];
  52491. /**
  52492. * Gets the list of emitted uniform buffers
  52493. */
  52494. uniformBuffers: string[];
  52495. /**
  52496. * Gets the list of emitted samplers
  52497. */
  52498. samplers: string[];
  52499. /**
  52500. * Gets the list of emitted functions
  52501. */
  52502. functions: {
  52503. [key: string]: string;
  52504. };
  52505. /**
  52506. * Gets the list of emitted extensions
  52507. */
  52508. extensions: {
  52509. [key: string]: string;
  52510. };
  52511. /**
  52512. * Gets the target of the compilation state
  52513. */
  52514. target: NodeMaterialBlockTargets;
  52515. /**
  52516. * Gets the list of emitted counters
  52517. */
  52518. counters: {
  52519. [key: string]: number;
  52520. };
  52521. /**
  52522. * Shared data between multiple NodeMaterialBuildState instances
  52523. */
  52524. sharedData: NodeMaterialBuildStateSharedData;
  52525. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  52526. /** @hidden */ private _attributeDeclaration: string;
  52527. /** @hidden */ private _uniformDeclaration: string;
  52528. /** @hidden */ private _constantDeclaration: string;
  52529. /** @hidden */ private _samplerDeclaration: string;
  52530. /** @hidden */ private _varyingTransfer: string;
  52531. private _repeatableContentAnchorIndex;
  52532. /** @hidden */ private _builtCompilationString: string;
  52533. /**
  52534. * Gets the emitted compilation strings
  52535. */
  52536. compilationString: string;
  52537. /**
  52538. * Finalize the compilation strings
  52539. * @param state defines the current compilation state
  52540. */
  52541. finalize(state: NodeMaterialBuildState): void;
  52542. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  52543. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  52544. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  52545. /** @hidden */ private _excludeVariableName(name: string): void;
  52546. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52547. /** @hidden */ private _emitExtension(name: string, extension: string): void;
  52548. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  52549. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52550. replaceStrings?: {
  52551. search: RegExp;
  52552. replace: string;
  52553. }[];
  52554. repeatKey?: string;
  52555. }): string;
  52556. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52557. repeatKey?: string;
  52558. removeAttributes?: boolean;
  52559. removeUniforms?: boolean;
  52560. removeVaryings?: boolean;
  52561. removeIfDef?: boolean;
  52562. replaceStrings?: {
  52563. search: RegExp;
  52564. replace: string;
  52565. }[];
  52566. }, storeKey?: string): void;
  52567. /** @hidden */ private _registerTempVariable(name: string): boolean;
  52568. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  52569. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  52570. /** @hidden */ private _emitFloat(value: number): string;
  52571. }
  52572. }
  52573. declare module BABYLON {
  52574. /**
  52575. * Defines a block that can be used inside a node based material
  52576. */
  52577. export class NodeMaterialBlock {
  52578. private _buildId;
  52579. private _buildTarget;
  52580. private _target;
  52581. private _isFinalMerger;
  52582. private _isInput;
  52583. /** @hidden */ private _codeVariableName: string;
  52584. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  52585. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  52586. /** @hidden */ private _preparationId: number;
  52587. /**
  52588. * Gets or sets the name of the block
  52589. */
  52590. name: string;
  52591. /**
  52592. * Gets or sets the unique id of the node
  52593. */
  52594. uniqueId: number;
  52595. /**
  52596. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52597. */
  52598. readonly isFinalMerger: boolean;
  52599. /**
  52600. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  52601. */
  52602. readonly isInput: boolean;
  52603. /**
  52604. * Gets or sets the build Id
  52605. */
  52606. buildId: number;
  52607. /**
  52608. * Gets or sets the target of the block
  52609. */
  52610. target: NodeMaterialBlockTargets;
  52611. /**
  52612. * Gets the list of input points
  52613. */
  52614. readonly inputs: NodeMaterialConnectionPoint[];
  52615. /** Gets the list of output points */
  52616. readonly outputs: NodeMaterialConnectionPoint[];
  52617. /**
  52618. * Find an input by its name
  52619. * @param name defines the name of the input to look for
  52620. * @returns the input or null if not found
  52621. */
  52622. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52623. /**
  52624. * Find an output by its name
  52625. * @param name defines the name of the outputto look for
  52626. * @returns the output or null if not found
  52627. */
  52628. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52629. /**
  52630. * Creates a new NodeMaterialBlock
  52631. * @param name defines the block name
  52632. * @param target defines the target of that block (Vertex by default)
  52633. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52634. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  52635. */
  52636. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  52637. /**
  52638. * Initialize the block and prepare the context for build
  52639. * @param state defines the state that will be used for the build
  52640. */
  52641. initialize(state: NodeMaterialBuildState): void;
  52642. /**
  52643. * Bind data to effect. Will only be called for blocks with isBindable === true
  52644. * @param effect defines the effect to bind data to
  52645. * @param nodeMaterial defines the hosting NodeMaterial
  52646. * @param mesh defines the mesh that will be rendered
  52647. */
  52648. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52649. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52650. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52651. protected _writeFloat(value: number): string;
  52652. /**
  52653. * Gets the current class name e.g. "NodeMaterialBlock"
  52654. * @returns the class name
  52655. */
  52656. getClassName(): string;
  52657. /**
  52658. * Register a new input. Must be called inside a block constructor
  52659. * @param name defines the connection point name
  52660. * @param type defines the connection point type
  52661. * @param isOptional defines a boolean indicating that this input can be omitted
  52662. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52663. * @returns the current block
  52664. */
  52665. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52666. /**
  52667. * Register a new output. Must be called inside a block constructor
  52668. * @param name defines the connection point name
  52669. * @param type defines the connection point type
  52670. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  52671. * @returns the current block
  52672. */
  52673. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52674. /**
  52675. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52676. * @param forOutput defines an optional connection point to check compatibility with
  52677. * @returns the first available input or null
  52678. */
  52679. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52680. /**
  52681. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52682. * @param forBlock defines an optional block to check compatibility with
  52683. * @returns the first available input or null
  52684. */
  52685. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52686. /**
  52687. * Gets the sibling of the given output
  52688. * @param current defines the current output
  52689. * @returns the next output in the list or null
  52690. */
  52691. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  52692. /**
  52693. * Connect current block with another block
  52694. * @param other defines the block to connect with
  52695. * @param options define the various options to help pick the right connections
  52696. * @returns the current block
  52697. */
  52698. connectTo(other: NodeMaterialBlock, options?: {
  52699. input?: string;
  52700. output?: string;
  52701. outputSwizzle?: string;
  52702. }): this | undefined;
  52703. protected _buildBlock(state: NodeMaterialBuildState): void;
  52704. /**
  52705. * Add uniforms, samplers and uniform buffers at compilation time
  52706. * @param state defines the state to update
  52707. * @param nodeMaterial defines the node material requesting the update
  52708. * @param defines defines the material defines to update
  52709. */
  52710. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52711. /**
  52712. * Add potential fallbacks if shader compilation fails
  52713. * @param mesh defines the mesh to be rendered
  52714. * @param fallbacks defines the current prioritized list of fallbacks
  52715. */
  52716. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52717. /**
  52718. * Initialize defines for shader compilation
  52719. * @param mesh defines the mesh to be rendered
  52720. * @param nodeMaterial defines the node material requesting the update
  52721. * @param defines defines the material defines to update
  52722. * @param useInstances specifies that instances should be used
  52723. */
  52724. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52725. /**
  52726. * Update defines for shader compilation
  52727. * @param mesh defines the mesh to be rendered
  52728. * @param nodeMaterial defines the node material requesting the update
  52729. * @param defines defines the material defines to update
  52730. * @param useInstances specifies that instances should be used
  52731. */
  52732. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52733. /**
  52734. * Lets the block try to connect some inputs automatically
  52735. * @param material defines the hosting NodeMaterial
  52736. */
  52737. autoConfigure(material: NodeMaterial): void;
  52738. /**
  52739. * Function called when a block is declared as repeatable content generator
  52740. * @param vertexShaderState defines the current compilation state for the vertex shader
  52741. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52742. * @param mesh defines the mesh to be rendered
  52743. * @param defines defines the material defines to update
  52744. */
  52745. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52746. /**
  52747. * Checks if the block is ready
  52748. * @param mesh defines the mesh to be rendered
  52749. * @param nodeMaterial defines the node material requesting the update
  52750. * @param defines defines the material defines to update
  52751. * @param useInstances specifies that instances should be used
  52752. * @returns true if the block is ready
  52753. */
  52754. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52755. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  52756. private _processBuild;
  52757. /**
  52758. * Compile the current node and generate the shader code
  52759. * @param state defines the current compilation state (uniforms, samplers, current string)
  52760. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  52761. * @returns true if already built
  52762. */
  52763. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  52764. protected _inputRename(name: string): string;
  52765. protected _outputRename(name: string): string;
  52766. protected _dumpPropertiesCode(): string;
  52767. /** @hidden */ private _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  52768. /**
  52769. * Clone the current block to a new identical block
  52770. * @param scene defines the hosting scene
  52771. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  52772. * @returns a copy of the current block
  52773. */
  52774. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  52775. /**
  52776. * Serializes this block in a JSON representation
  52777. * @returns the serialized block object
  52778. */
  52779. serialize(): any;
  52780. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52781. }
  52782. }
  52783. declare module BABYLON {
  52784. /**
  52785. * Enum defining the type of animations supported by InputBlock
  52786. */
  52787. export enum AnimatedInputBlockTypes {
  52788. /** No animation */
  52789. None = 0,
  52790. /** Time based animation. Will only work for floats */
  52791. Time = 1
  52792. }
  52793. }
  52794. declare module BABYLON {
  52795. /**
  52796. * Block used to expose an input value
  52797. */
  52798. export class InputBlock extends NodeMaterialBlock {
  52799. private _mode;
  52800. private _associatedVariableName;
  52801. private _storedValue;
  52802. private _valueCallback;
  52803. private _type;
  52804. private _animationType;
  52805. /** Gets or set a value used to limit the range of float values */
  52806. min: number;
  52807. /** Gets or set a value used to limit the range of float values */
  52808. max: number;
  52809. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  52810. matrixMode: number;
  52811. /** @hidden */ private _systemValue: Nullable<NodeMaterialSystemValues>;
  52812. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  52813. visibleInInspector: boolean;
  52814. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  52815. isConstant: boolean;
  52816. /**
  52817. * Gets or sets the connection point type (default is float)
  52818. */
  52819. readonly type: NodeMaterialBlockConnectionPointTypes;
  52820. /**
  52821. * Creates a new InputBlock
  52822. * @param name defines the block name
  52823. * @param target defines the target of that block (Vertex by default)
  52824. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  52825. */
  52826. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  52827. /**
  52828. * Gets the output component
  52829. */
  52830. readonly output: NodeMaterialConnectionPoint;
  52831. /**
  52832. * Set the source of this connection point to a vertex attribute
  52833. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  52834. * @returns the current connection point
  52835. */
  52836. setAsAttribute(attributeName?: string): InputBlock;
  52837. /**
  52838. * Set the source of this connection point to a system value
  52839. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  52840. * @returns the current connection point
  52841. */
  52842. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  52843. /**
  52844. * Gets or sets the value of that point.
  52845. * Please note that this value will be ignored if valueCallback is defined
  52846. */
  52847. value: any;
  52848. /**
  52849. * Gets or sets a callback used to get the value of that point.
  52850. * Please note that setting this value will force the connection point to ignore the value property
  52851. */
  52852. valueCallback: () => any;
  52853. /**
  52854. * Gets or sets the associated variable name in the shader
  52855. */
  52856. associatedVariableName: string;
  52857. /** Gets or sets the type of animation applied to the input */
  52858. animationType: AnimatedInputBlockTypes;
  52859. /**
  52860. * Gets a boolean indicating that this connection point not defined yet
  52861. */
  52862. readonly isUndefined: boolean;
  52863. /**
  52864. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  52865. * In this case the connection point name must be the name of the uniform to use.
  52866. * Can only be set on inputs
  52867. */
  52868. isUniform: boolean;
  52869. /**
  52870. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  52871. * In this case the connection point name must be the name of the attribute to use
  52872. * Can only be set on inputs
  52873. */
  52874. isAttribute: boolean;
  52875. /**
  52876. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  52877. * Can only be set on exit points
  52878. */
  52879. isVarying: boolean;
  52880. /**
  52881. * Gets a boolean indicating that the current connection point is a system value
  52882. */
  52883. readonly isSystemValue: boolean;
  52884. /**
  52885. * Gets or sets the current well known value or null if not defined as a system value
  52886. */
  52887. systemValue: Nullable<NodeMaterialSystemValues>;
  52888. /**
  52889. * Gets the current class name
  52890. * @returns the class name
  52891. */
  52892. getClassName(): string;
  52893. /**
  52894. * Animate the input if animationType !== None
  52895. * @param scene defines the rendering scene
  52896. */
  52897. animate(scene: Scene): void;
  52898. private _emitDefine;
  52899. initialize(state: NodeMaterialBuildState): void;
  52900. /**
  52901. * Set the input block to its default value (based on its type)
  52902. */
  52903. setDefaultValue(): void;
  52904. private _emitConstant;
  52905. private _emit;
  52906. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  52907. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  52908. protected _buildBlock(state: NodeMaterialBuildState): void;
  52909. protected _dumpPropertiesCode(): string;
  52910. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52911. }
  52912. }
  52913. declare module BABYLON {
  52914. /**
  52915. * Defines a connection point for a block
  52916. */
  52917. export class NodeMaterialConnectionPoint {
  52918. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  52919. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52920. private _endpoints;
  52921. private _associatedVariableName;
  52922. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52923. /** @hidden */ private _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  52924. private _type;
  52925. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  52926. /**
  52927. * Gets or sets the additional types supported by this connection point
  52928. */
  52929. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52930. /**
  52931. * Gets or sets the additional types excluded by this connection point
  52932. */
  52933. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  52934. /**
  52935. * Gets or sets the associated variable name in the shader
  52936. */
  52937. associatedVariableName: string;
  52938. /**
  52939. * Gets or sets the connection point type (default is float)
  52940. */
  52941. type: NodeMaterialBlockConnectionPointTypes;
  52942. /**
  52943. * Gets or sets the connection point name
  52944. */
  52945. name: string;
  52946. /**
  52947. * Gets or sets a boolean indicating that this connection point can be omitted
  52948. */
  52949. isOptional: boolean;
  52950. /**
  52951. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  52952. */
  52953. define: string;
  52954. /** Gets or sets the target of that connection point */
  52955. target: NodeMaterialBlockTargets;
  52956. /**
  52957. * Gets a boolean indicating that the current point is connected
  52958. */
  52959. readonly isConnected: boolean;
  52960. /**
  52961. * Gets a boolean indicating that the current point is connected to an input block
  52962. */
  52963. readonly isConnectedToInputBlock: boolean;
  52964. /**
  52965. * Gets a the connected input block (if any)
  52966. */
  52967. readonly connectInputBlock: Nullable<InputBlock>;
  52968. /** Get the other side of the connection (if any) */
  52969. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52970. /** Get the block that owns this connection point */
  52971. readonly ownerBlock: NodeMaterialBlock;
  52972. /** Get the block connected on the other side of this connection (if any) */
  52973. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  52974. /** Get the block connected on the endpoints of this connection (if any) */
  52975. readonly connectedBlocks: Array<NodeMaterialBlock>;
  52976. /** Gets the list of connected endpoints */
  52977. readonly endpoints: NodeMaterialConnectionPoint[];
  52978. /** Gets a boolean indicating if that output point is connected to at least one input */
  52979. readonly hasEndpoints: boolean;
  52980. /**
  52981. * Creates a new connection point
  52982. * @param name defines the connection point name
  52983. * @param ownerBlock defines the block hosting this connection point
  52984. */
  52985. constructor(name: string, ownerBlock: NodeMaterialBlock);
  52986. /**
  52987. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  52988. * @returns the class name
  52989. */
  52990. getClassName(): string;
  52991. /**
  52992. * Gets an boolean indicating if the current point can be connected to another point
  52993. * @param connectionPoint defines the other connection point
  52994. * @returns true if the connection is possible
  52995. */
  52996. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  52997. /**
  52998. * Connect this point to another connection point
  52999. * @param connectionPoint defines the other connection point
  53000. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  53001. * @returns the current connection point
  53002. */
  53003. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  53004. /**
  53005. * Disconnect this point from one of his endpoint
  53006. * @param endpoint defines the other connection point
  53007. * @returns the current connection point
  53008. */
  53009. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53010. /**
  53011. * Serializes this point in a JSON representation
  53012. * @returns the serialized point object
  53013. */
  53014. serialize(): any;
  53015. }
  53016. }
  53017. declare module BABYLON {
  53018. /**
  53019. * Block used to add support for vertex skinning (bones)
  53020. */
  53021. export class BonesBlock extends NodeMaterialBlock {
  53022. /**
  53023. * Creates a new BonesBlock
  53024. * @param name defines the block name
  53025. */
  53026. constructor(name: string);
  53027. /**
  53028. * Initialize the block and prepare the context for build
  53029. * @param state defines the state that will be used for the build
  53030. */
  53031. initialize(state: NodeMaterialBuildState): void;
  53032. /**
  53033. * Gets the current class name
  53034. * @returns the class name
  53035. */
  53036. getClassName(): string;
  53037. /**
  53038. * Gets the matrix indices input component
  53039. */
  53040. readonly matricesIndices: NodeMaterialConnectionPoint;
  53041. /**
  53042. * Gets the matrix weights input component
  53043. */
  53044. readonly matricesWeights: NodeMaterialConnectionPoint;
  53045. /**
  53046. * Gets the extra matrix indices input component
  53047. */
  53048. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53049. /**
  53050. * Gets the extra matrix weights input component
  53051. */
  53052. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53053. /**
  53054. * Gets the world input component
  53055. */
  53056. readonly world: NodeMaterialConnectionPoint;
  53057. /**
  53058. * Gets the output component
  53059. */
  53060. readonly output: NodeMaterialConnectionPoint;
  53061. autoConfigure(material: NodeMaterial): void;
  53062. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53063. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53064. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53065. protected _buildBlock(state: NodeMaterialBuildState): this;
  53066. }
  53067. }
  53068. declare module BABYLON {
  53069. /**
  53070. * Block used to add support for instances
  53071. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53072. */
  53073. export class InstancesBlock extends NodeMaterialBlock {
  53074. /**
  53075. * Creates a new InstancesBlock
  53076. * @param name defines the block name
  53077. */
  53078. constructor(name: string);
  53079. /**
  53080. * Gets the current class name
  53081. * @returns the class name
  53082. */
  53083. getClassName(): string;
  53084. /**
  53085. * Gets the first world row input component
  53086. */
  53087. readonly world0: NodeMaterialConnectionPoint;
  53088. /**
  53089. * Gets the second world row input component
  53090. */
  53091. readonly world1: NodeMaterialConnectionPoint;
  53092. /**
  53093. * Gets the third world row input component
  53094. */
  53095. readonly world2: NodeMaterialConnectionPoint;
  53096. /**
  53097. * Gets the forth world row input component
  53098. */
  53099. readonly world3: NodeMaterialConnectionPoint;
  53100. /**
  53101. * Gets the world input component
  53102. */
  53103. readonly world: NodeMaterialConnectionPoint;
  53104. /**
  53105. * Gets the output component
  53106. */
  53107. readonly output: NodeMaterialConnectionPoint;
  53108. autoConfigure(material: NodeMaterial): void;
  53109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53110. protected _buildBlock(state: NodeMaterialBuildState): this;
  53111. }
  53112. }
  53113. declare module BABYLON {
  53114. /**
  53115. * Block used to add morph targets support to vertex shader
  53116. */
  53117. export class MorphTargetsBlock extends NodeMaterialBlock {
  53118. private _repeatableContentAnchor;
  53119. private _repeatebleContentGenerated;
  53120. /**
  53121. * Create a new MorphTargetsBlock
  53122. * @param name defines the block name
  53123. */
  53124. constructor(name: string);
  53125. /**
  53126. * Gets the current class name
  53127. * @returns the class name
  53128. */
  53129. getClassName(): string;
  53130. /**
  53131. * Gets the position input component
  53132. */
  53133. readonly position: NodeMaterialConnectionPoint;
  53134. /**
  53135. * Gets the normal input component
  53136. */
  53137. readonly normal: NodeMaterialConnectionPoint;
  53138. /**
  53139. * Gets the tangent input component
  53140. */
  53141. readonly tangent: NodeMaterialConnectionPoint;
  53142. /**
  53143. * Gets the tangent input component
  53144. */
  53145. readonly uv: NodeMaterialConnectionPoint;
  53146. /**
  53147. * Gets the position output component
  53148. */
  53149. readonly positionOutput: NodeMaterialConnectionPoint;
  53150. /**
  53151. * Gets the normal output component
  53152. */
  53153. readonly normalOutput: NodeMaterialConnectionPoint;
  53154. /**
  53155. * Gets the tangent output component
  53156. */
  53157. readonly tangentOutput: NodeMaterialConnectionPoint;
  53158. /**
  53159. * Gets the tangent output component
  53160. */
  53161. readonly uvOutput: NodeMaterialConnectionPoint;
  53162. initialize(state: NodeMaterialBuildState): void;
  53163. autoConfigure(material: NodeMaterial): void;
  53164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53165. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53166. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53167. protected _buildBlock(state: NodeMaterialBuildState): this;
  53168. }
  53169. }
  53170. declare module BABYLON {
  53171. /**
  53172. * Block used to get data information from a light
  53173. */
  53174. export class LightInformationBlock extends NodeMaterialBlock {
  53175. private _lightDataUniformName;
  53176. private _lightColorUniformName;
  53177. private _lightTypeDefineName;
  53178. /**
  53179. * Gets or sets the light associated with this block
  53180. */
  53181. light: Nullable<Light>;
  53182. /**
  53183. * Creates a new LightInformationBlock
  53184. * @param name defines the block name
  53185. */
  53186. constructor(name: string);
  53187. /**
  53188. * Gets the current class name
  53189. * @returns the class name
  53190. */
  53191. getClassName(): string;
  53192. /**
  53193. * Gets the world position input component
  53194. */
  53195. readonly worldPosition: NodeMaterialConnectionPoint;
  53196. /**
  53197. * Gets the direction output component
  53198. */
  53199. readonly direction: NodeMaterialConnectionPoint;
  53200. /**
  53201. * Gets the direction output component
  53202. */
  53203. readonly color: NodeMaterialConnectionPoint;
  53204. /**
  53205. * Gets the direction output component
  53206. */
  53207. readonly intensity: NodeMaterialConnectionPoint;
  53208. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53209. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53210. protected _buildBlock(state: NodeMaterialBuildState): this;
  53211. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53212. }
  53213. }
  53214. declare module BABYLON {
  53215. /**
  53216. * Block used to add image processing support to fragment shader
  53217. */
  53218. export class ImageProcessingBlock extends NodeMaterialBlock {
  53219. /**
  53220. * Create a new ImageProcessingBlock
  53221. * @param name defines the block name
  53222. */
  53223. constructor(name: string);
  53224. /**
  53225. * Gets the current class name
  53226. * @returns the class name
  53227. */
  53228. getClassName(): string;
  53229. /**
  53230. * Gets the color input component
  53231. */
  53232. readonly color: NodeMaterialConnectionPoint;
  53233. /**
  53234. * Gets the output component
  53235. */
  53236. readonly output: NodeMaterialConnectionPoint;
  53237. /**
  53238. * Initialize the block and prepare the context for build
  53239. * @param state defines the state that will be used for the build
  53240. */
  53241. initialize(state: NodeMaterialBuildState): void;
  53242. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53243. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53244. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53245. protected _buildBlock(state: NodeMaterialBuildState): this;
  53246. }
  53247. }
  53248. declare module BABYLON {
  53249. /**
  53250. * Block used to pertub normals based on a normal map
  53251. */
  53252. export class PerturbNormalBlock extends NodeMaterialBlock {
  53253. private _tangentSpaceParameterName;
  53254. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  53255. invertX: boolean;
  53256. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  53257. invertY: boolean;
  53258. /**
  53259. * Create a new PerturbNormalBlock
  53260. * @param name defines the block name
  53261. */
  53262. constructor(name: string);
  53263. /**
  53264. * Gets the current class name
  53265. * @returns the class name
  53266. */
  53267. getClassName(): string;
  53268. /**
  53269. * Gets the world position input component
  53270. */
  53271. readonly worldPosition: NodeMaterialConnectionPoint;
  53272. /**
  53273. * Gets the world normal input component
  53274. */
  53275. readonly worldNormal: NodeMaterialConnectionPoint;
  53276. /**
  53277. * Gets the uv input component
  53278. */
  53279. readonly uv: NodeMaterialConnectionPoint;
  53280. /**
  53281. * Gets the normal map color input component
  53282. */
  53283. readonly normalMapColor: NodeMaterialConnectionPoint;
  53284. /**
  53285. * Gets the strength input component
  53286. */
  53287. readonly strength: NodeMaterialConnectionPoint;
  53288. /**
  53289. * Gets the output component
  53290. */
  53291. readonly output: NodeMaterialConnectionPoint;
  53292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53293. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53294. autoConfigure(material: NodeMaterial): void;
  53295. protected _buildBlock(state: NodeMaterialBuildState): this;
  53296. protected _dumpPropertiesCode(): string;
  53297. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53298. }
  53299. }
  53300. declare module BABYLON {
  53301. /**
  53302. * Block used to discard a pixel if a value is smaller than a cutoff
  53303. */
  53304. export class DiscardBlock extends NodeMaterialBlock {
  53305. /**
  53306. * Create a new DiscardBlock
  53307. * @param name defines the block name
  53308. */
  53309. constructor(name: string);
  53310. /**
  53311. * Gets the current class name
  53312. * @returns the class name
  53313. */
  53314. getClassName(): string;
  53315. /**
  53316. * Gets the color input component
  53317. */
  53318. readonly value: NodeMaterialConnectionPoint;
  53319. /**
  53320. * Gets the cutoff input component
  53321. */
  53322. readonly cutoff: NodeMaterialConnectionPoint;
  53323. protected _buildBlock(state: NodeMaterialBuildState): this;
  53324. }
  53325. }
  53326. declare module BABYLON {
  53327. /**
  53328. * Block used to add support for scene fog
  53329. */
  53330. export class FogBlock extends NodeMaterialBlock {
  53331. private _fogDistanceName;
  53332. private _fogParameters;
  53333. /**
  53334. * Create a new FogBlock
  53335. * @param name defines the block name
  53336. */
  53337. constructor(name: string);
  53338. /**
  53339. * Gets the current class name
  53340. * @returns the class name
  53341. */
  53342. getClassName(): string;
  53343. /**
  53344. * Gets the world position input component
  53345. */
  53346. readonly worldPosition: NodeMaterialConnectionPoint;
  53347. /**
  53348. * Gets the view input component
  53349. */
  53350. readonly view: NodeMaterialConnectionPoint;
  53351. /**
  53352. * Gets the color input component
  53353. */
  53354. readonly input: NodeMaterialConnectionPoint;
  53355. /**
  53356. * Gets the fog color input component
  53357. */
  53358. readonly fogColor: NodeMaterialConnectionPoint;
  53359. /**
  53360. * Gets the output component
  53361. */
  53362. readonly output: NodeMaterialConnectionPoint;
  53363. autoConfigure(material: NodeMaterial): void;
  53364. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53365. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53366. protected _buildBlock(state: NodeMaterialBuildState): this;
  53367. }
  53368. }
  53369. declare module BABYLON {
  53370. /**
  53371. * Block used to add light in the fragment shader
  53372. */
  53373. export class LightBlock extends NodeMaterialBlock {
  53374. private _lightId;
  53375. /**
  53376. * Gets or sets the light associated with this block
  53377. */
  53378. light: Nullable<Light>;
  53379. /**
  53380. * Create a new LightBlock
  53381. * @param name defines the block name
  53382. */
  53383. constructor(name: string);
  53384. /**
  53385. * Gets the current class name
  53386. * @returns the class name
  53387. */
  53388. getClassName(): string;
  53389. /**
  53390. * Gets the world position input component
  53391. */
  53392. readonly worldPosition: NodeMaterialConnectionPoint;
  53393. /**
  53394. * Gets the world normal input component
  53395. */
  53396. readonly worldNormal: NodeMaterialConnectionPoint;
  53397. /**
  53398. * Gets the camera (or eye) position component
  53399. */
  53400. readonly cameraPosition: NodeMaterialConnectionPoint;
  53401. /**
  53402. * Gets the glossiness component
  53403. */
  53404. readonly glossiness: NodeMaterialConnectionPoint;
  53405. /**
  53406. * Gets the glossinness power component
  53407. */
  53408. readonly glossPower: NodeMaterialConnectionPoint;
  53409. /**
  53410. * Gets the diffuse color component
  53411. */
  53412. readonly diffuseColor: NodeMaterialConnectionPoint;
  53413. /**
  53414. * Gets the specular color component
  53415. */
  53416. readonly specularColor: NodeMaterialConnectionPoint;
  53417. /**
  53418. * Gets the diffuse output component
  53419. */
  53420. readonly diffuseOutput: NodeMaterialConnectionPoint;
  53421. /**
  53422. * Gets the specular output component
  53423. */
  53424. readonly specularOutput: NodeMaterialConnectionPoint;
  53425. autoConfigure(material: NodeMaterial): void;
  53426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53427. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53428. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53429. private _injectVertexCode;
  53430. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53431. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53432. }
  53433. }
  53434. declare module BABYLON {
  53435. /**
  53436. * Block used to multiply 2 values
  53437. */
  53438. export class MultiplyBlock extends NodeMaterialBlock {
  53439. /**
  53440. * Creates a new MultiplyBlock
  53441. * @param name defines the block name
  53442. */
  53443. constructor(name: string);
  53444. /**
  53445. * Gets the current class name
  53446. * @returns the class name
  53447. */
  53448. getClassName(): string;
  53449. /**
  53450. * Gets the left operand input component
  53451. */
  53452. readonly left: NodeMaterialConnectionPoint;
  53453. /**
  53454. * Gets the right operand input component
  53455. */
  53456. readonly right: NodeMaterialConnectionPoint;
  53457. /**
  53458. * Gets the output component
  53459. */
  53460. readonly output: NodeMaterialConnectionPoint;
  53461. protected _buildBlock(state: NodeMaterialBuildState): this;
  53462. }
  53463. }
  53464. declare module BABYLON {
  53465. /**
  53466. * Block used to add 2 vectors
  53467. */
  53468. export class AddBlock extends NodeMaterialBlock {
  53469. /**
  53470. * Creates a new AddBlock
  53471. * @param name defines the block name
  53472. */
  53473. constructor(name: string);
  53474. /**
  53475. * Gets the current class name
  53476. * @returns the class name
  53477. */
  53478. getClassName(): string;
  53479. /**
  53480. * Gets the left operand input component
  53481. */
  53482. readonly left: NodeMaterialConnectionPoint;
  53483. /**
  53484. * Gets the right operand input component
  53485. */
  53486. readonly right: NodeMaterialConnectionPoint;
  53487. /**
  53488. * Gets the output component
  53489. */
  53490. readonly output: NodeMaterialConnectionPoint;
  53491. protected _buildBlock(state: NodeMaterialBuildState): this;
  53492. }
  53493. }
  53494. declare module BABYLON {
  53495. /**
  53496. * Block used to scale a vector by a float
  53497. */
  53498. export class ScaleBlock extends NodeMaterialBlock {
  53499. /**
  53500. * Creates a new ScaleBlock
  53501. * @param name defines the block name
  53502. */
  53503. constructor(name: string);
  53504. /**
  53505. * Gets the current class name
  53506. * @returns the class name
  53507. */
  53508. getClassName(): string;
  53509. /**
  53510. * Gets the input component
  53511. */
  53512. readonly input: NodeMaterialConnectionPoint;
  53513. /**
  53514. * Gets the factor input component
  53515. */
  53516. readonly factor: NodeMaterialConnectionPoint;
  53517. /**
  53518. * Gets the output component
  53519. */
  53520. readonly output: NodeMaterialConnectionPoint;
  53521. protected _buildBlock(state: NodeMaterialBuildState): this;
  53522. }
  53523. }
  53524. declare module BABYLON {
  53525. /**
  53526. * Block used to clamp a float
  53527. */
  53528. export class ClampBlock extends NodeMaterialBlock {
  53529. /** Gets or sets the minimum range */
  53530. minimum: number;
  53531. /** Gets or sets the maximum range */
  53532. maximum: number;
  53533. /**
  53534. * Creates a new ClampBlock
  53535. * @param name defines the block name
  53536. */
  53537. constructor(name: string);
  53538. /**
  53539. * Gets the current class name
  53540. * @returns the class name
  53541. */
  53542. getClassName(): string;
  53543. /**
  53544. * Gets the value input component
  53545. */
  53546. readonly value: NodeMaterialConnectionPoint;
  53547. /**
  53548. * Gets the output component
  53549. */
  53550. readonly output: NodeMaterialConnectionPoint;
  53551. protected _buildBlock(state: NodeMaterialBuildState): this;
  53552. protected _dumpPropertiesCode(): string;
  53553. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53554. }
  53555. }
  53556. declare module BABYLON {
  53557. /**
  53558. * Block used to apply a cross product between 2 vectors
  53559. */
  53560. export class CrossBlock extends NodeMaterialBlock {
  53561. /**
  53562. * Creates a new CrossBlock
  53563. * @param name defines the block name
  53564. */
  53565. constructor(name: string);
  53566. /**
  53567. * Gets the current class name
  53568. * @returns the class name
  53569. */
  53570. getClassName(): string;
  53571. /**
  53572. * Gets the left operand input component
  53573. */
  53574. readonly left: NodeMaterialConnectionPoint;
  53575. /**
  53576. * Gets the right operand input component
  53577. */
  53578. readonly right: NodeMaterialConnectionPoint;
  53579. /**
  53580. * Gets the output component
  53581. */
  53582. readonly output: NodeMaterialConnectionPoint;
  53583. protected _buildBlock(state: NodeMaterialBuildState): this;
  53584. }
  53585. }
  53586. declare module BABYLON {
  53587. /**
  53588. * Block used to apply a dot product between 2 vectors
  53589. */
  53590. export class DotBlock extends NodeMaterialBlock {
  53591. /**
  53592. * Creates a new DotBlock
  53593. * @param name defines the block name
  53594. */
  53595. constructor(name: string);
  53596. /**
  53597. * Gets the current class name
  53598. * @returns the class name
  53599. */
  53600. getClassName(): string;
  53601. /**
  53602. * Gets the left operand input component
  53603. */
  53604. readonly left: NodeMaterialConnectionPoint;
  53605. /**
  53606. * Gets the right operand input component
  53607. */
  53608. readonly right: NodeMaterialConnectionPoint;
  53609. /**
  53610. * Gets the output component
  53611. */
  53612. readonly output: NodeMaterialConnectionPoint;
  53613. protected _buildBlock(state: NodeMaterialBuildState): this;
  53614. }
  53615. }
  53616. declare module BABYLON {
  53617. /**
  53618. * Block used to remap a float from a range to a new one
  53619. */
  53620. export class RemapBlock extends NodeMaterialBlock {
  53621. /**
  53622. * Gets or sets the source range
  53623. */
  53624. sourceRange: Vector2;
  53625. /**
  53626. * Gets or sets the target range
  53627. */
  53628. targetRange: Vector2;
  53629. /**
  53630. * Creates a new RemapBlock
  53631. * @param name defines the block name
  53632. */
  53633. constructor(name: string);
  53634. /**
  53635. * Gets the current class name
  53636. * @returns the class name
  53637. */
  53638. getClassName(): string;
  53639. /**
  53640. * Gets the input component
  53641. */
  53642. readonly input: NodeMaterialConnectionPoint;
  53643. /**
  53644. * Gets the source min input component
  53645. */
  53646. readonly sourceMin: NodeMaterialConnectionPoint;
  53647. /**
  53648. * Gets the source max input component
  53649. */
  53650. readonly sourceMax: NodeMaterialConnectionPoint;
  53651. /**
  53652. * Gets the target min input component
  53653. */
  53654. readonly targetMin: NodeMaterialConnectionPoint;
  53655. /**
  53656. * Gets the target max input component
  53657. */
  53658. readonly targetMax: NodeMaterialConnectionPoint;
  53659. /**
  53660. * Gets the output component
  53661. */
  53662. readonly output: NodeMaterialConnectionPoint;
  53663. protected _buildBlock(state: NodeMaterialBuildState): this;
  53664. protected _dumpPropertiesCode(): string;
  53665. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53666. }
  53667. }
  53668. declare module BABYLON {
  53669. /**
  53670. * Block used to normalize a vector
  53671. */
  53672. export class NormalizeBlock extends NodeMaterialBlock {
  53673. /**
  53674. * Creates a new NormalizeBlock
  53675. * @param name defines the block name
  53676. */
  53677. constructor(name: string);
  53678. /**
  53679. * Gets the current class name
  53680. * @returns the class name
  53681. */
  53682. getClassName(): string;
  53683. /**
  53684. * Gets the input component
  53685. */
  53686. readonly input: NodeMaterialConnectionPoint;
  53687. /**
  53688. * Gets the output component
  53689. */
  53690. readonly output: NodeMaterialConnectionPoint;
  53691. protected _buildBlock(state: NodeMaterialBuildState): this;
  53692. }
  53693. }
  53694. declare module BABYLON {
  53695. /**
  53696. * Operations supported by the Trigonometry block
  53697. */
  53698. export enum TrigonometryBlockOperations {
  53699. /** Cos */
  53700. Cos = 0,
  53701. /** Sin */
  53702. Sin = 1,
  53703. /** Abs */
  53704. Abs = 2,
  53705. /** Exp */
  53706. Exp = 3,
  53707. /** Exp2 */
  53708. Exp2 = 4,
  53709. /** Round */
  53710. Round = 5,
  53711. /** Floor */
  53712. Floor = 6,
  53713. /** Ceiling */
  53714. Ceiling = 7,
  53715. /** Square root */
  53716. Sqrt = 8,
  53717. /** Log */
  53718. Log = 9,
  53719. /** Tangent */
  53720. Tan = 10,
  53721. /** Arc tangent */
  53722. ArcTan = 11,
  53723. /** Arc cosinus */
  53724. ArcCos = 12,
  53725. /** Arc sinus */
  53726. ArcSin = 13,
  53727. /** Fraction */
  53728. Fract = 14,
  53729. /** Sign */
  53730. Sign = 15,
  53731. /** To radians (from degrees) */
  53732. Radians = 16,
  53733. /** To degrees (from radians) */
  53734. Degrees = 17
  53735. }
  53736. /**
  53737. * Block used to apply trigonometry operation to floats
  53738. */
  53739. export class TrigonometryBlock extends NodeMaterialBlock {
  53740. /**
  53741. * Gets or sets the operation applied by the block
  53742. */
  53743. operation: TrigonometryBlockOperations;
  53744. /**
  53745. * Creates a new TrigonometryBlock
  53746. * @param name defines the block name
  53747. */
  53748. constructor(name: string);
  53749. /**
  53750. * Gets the current class name
  53751. * @returns the class name
  53752. */
  53753. getClassName(): string;
  53754. /**
  53755. * Gets the input component
  53756. */
  53757. readonly input: NodeMaterialConnectionPoint;
  53758. /**
  53759. * Gets the output component
  53760. */
  53761. readonly output: NodeMaterialConnectionPoint;
  53762. protected _buildBlock(state: NodeMaterialBuildState): this;
  53763. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53764. }
  53765. }
  53766. declare module BABYLON {
  53767. /**
  53768. * Block used to create a Color3/4 out of individual inputs (one for each component)
  53769. */
  53770. export class ColorMergerBlock extends NodeMaterialBlock {
  53771. /**
  53772. * Create a new ColorMergerBlock
  53773. * @param name defines the block name
  53774. */
  53775. constructor(name: string);
  53776. /**
  53777. * Gets the current class name
  53778. * @returns the class name
  53779. */
  53780. getClassName(): string;
  53781. /**
  53782. * Gets the r component (input)
  53783. */
  53784. readonly r: NodeMaterialConnectionPoint;
  53785. /**
  53786. * Gets the g component (input)
  53787. */
  53788. readonly g: NodeMaterialConnectionPoint;
  53789. /**
  53790. * Gets the b component (input)
  53791. */
  53792. readonly b: NodeMaterialConnectionPoint;
  53793. /**
  53794. * Gets the a component (input)
  53795. */
  53796. readonly a: NodeMaterialConnectionPoint;
  53797. /**
  53798. * Gets the rgba component (output)
  53799. */
  53800. readonly rgba: NodeMaterialConnectionPoint;
  53801. /**
  53802. * Gets the rgb component (output)
  53803. */
  53804. readonly rgb: NodeMaterialConnectionPoint;
  53805. protected _buildBlock(state: NodeMaterialBuildState): this;
  53806. }
  53807. }
  53808. declare module BABYLON {
  53809. /**
  53810. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  53811. */
  53812. export class VectorMergerBlock extends NodeMaterialBlock {
  53813. /**
  53814. * Create a new VectorMergerBlock
  53815. * @param name defines the block name
  53816. */
  53817. constructor(name: string);
  53818. /**
  53819. * Gets the current class name
  53820. * @returns the class name
  53821. */
  53822. getClassName(): string;
  53823. /**
  53824. * Gets the x component (input)
  53825. */
  53826. readonly x: NodeMaterialConnectionPoint;
  53827. /**
  53828. * Gets the y component (input)
  53829. */
  53830. readonly y: NodeMaterialConnectionPoint;
  53831. /**
  53832. * Gets the z component (input)
  53833. */
  53834. readonly z: NodeMaterialConnectionPoint;
  53835. /**
  53836. * Gets the w component (input)
  53837. */
  53838. readonly w: NodeMaterialConnectionPoint;
  53839. /**
  53840. * Gets the xyzw component (output)
  53841. */
  53842. readonly xyzw: NodeMaterialConnectionPoint;
  53843. /**
  53844. * Gets the xyz component (output)
  53845. */
  53846. readonly xyz: NodeMaterialConnectionPoint;
  53847. /**
  53848. * Gets the xy component (output)
  53849. */
  53850. readonly xy: NodeMaterialConnectionPoint;
  53851. protected _buildBlock(state: NodeMaterialBuildState): this;
  53852. }
  53853. }
  53854. declare module BABYLON {
  53855. /**
  53856. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  53857. */
  53858. export class ColorSplitterBlock extends NodeMaterialBlock {
  53859. /**
  53860. * Create a new ColorSplitterBlock
  53861. * @param name defines the block name
  53862. */
  53863. constructor(name: string);
  53864. /**
  53865. * Gets the current class name
  53866. * @returns the class name
  53867. */
  53868. getClassName(): string;
  53869. /**
  53870. * Gets the rgba component (input)
  53871. */
  53872. readonly rgba: NodeMaterialConnectionPoint;
  53873. /**
  53874. * Gets the rgb component (input)
  53875. */
  53876. readonly rgbIn: NodeMaterialConnectionPoint;
  53877. /**
  53878. * Gets the rgb component (output)
  53879. */
  53880. readonly rgbOut: NodeMaterialConnectionPoint;
  53881. /**
  53882. * Gets the r component (output)
  53883. */
  53884. readonly r: NodeMaterialConnectionPoint;
  53885. /**
  53886. * Gets the g component (output)
  53887. */
  53888. readonly g: NodeMaterialConnectionPoint;
  53889. /**
  53890. * Gets the b component (output)
  53891. */
  53892. readonly b: NodeMaterialConnectionPoint;
  53893. /**
  53894. * Gets the a component (output)
  53895. */
  53896. readonly a: NodeMaterialConnectionPoint;
  53897. protected _inputRename(name: string): string;
  53898. protected _outputRename(name: string): string;
  53899. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53900. }
  53901. }
  53902. declare module BABYLON {
  53903. /**
  53904. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  53905. */
  53906. export class VectorSplitterBlock extends NodeMaterialBlock {
  53907. /**
  53908. * Create a new VectorSplitterBlock
  53909. * @param name defines the block name
  53910. */
  53911. constructor(name: string);
  53912. /**
  53913. * Gets the current class name
  53914. * @returns the class name
  53915. */
  53916. getClassName(): string;
  53917. /**
  53918. * Gets the xyzw component (input)
  53919. */
  53920. readonly xyzw: NodeMaterialConnectionPoint;
  53921. /**
  53922. * Gets the xyz component (input)
  53923. */
  53924. readonly xyzIn: NodeMaterialConnectionPoint;
  53925. /**
  53926. * Gets the xy component (input)
  53927. */
  53928. readonly xyIn: NodeMaterialConnectionPoint;
  53929. /**
  53930. * Gets the xyz component (output)
  53931. */
  53932. readonly xyzOut: NodeMaterialConnectionPoint;
  53933. /**
  53934. * Gets the xy component (output)
  53935. */
  53936. readonly xyOut: NodeMaterialConnectionPoint;
  53937. /**
  53938. * Gets the x component (output)
  53939. */
  53940. readonly x: NodeMaterialConnectionPoint;
  53941. /**
  53942. * Gets the y component (output)
  53943. */
  53944. readonly y: NodeMaterialConnectionPoint;
  53945. /**
  53946. * Gets the z component (output)
  53947. */
  53948. readonly z: NodeMaterialConnectionPoint;
  53949. /**
  53950. * Gets the w component (output)
  53951. */
  53952. readonly w: NodeMaterialConnectionPoint;
  53953. protected _inputRename(name: string): string;
  53954. protected _outputRename(name: string): string;
  53955. protected _buildBlock(state: NodeMaterialBuildState): this;
  53956. }
  53957. }
  53958. declare module BABYLON {
  53959. /**
  53960. * Block used to lerp between 2 values
  53961. */
  53962. export class LerpBlock extends NodeMaterialBlock {
  53963. /**
  53964. * Creates a new LerpBlock
  53965. * @param name defines the block name
  53966. */
  53967. constructor(name: string);
  53968. /**
  53969. * Gets the current class name
  53970. * @returns the class name
  53971. */
  53972. getClassName(): string;
  53973. /**
  53974. * Gets the left operand input component
  53975. */
  53976. readonly left: NodeMaterialConnectionPoint;
  53977. /**
  53978. * Gets the right operand input component
  53979. */
  53980. readonly right: NodeMaterialConnectionPoint;
  53981. /**
  53982. * Gets the gradient operand input component
  53983. */
  53984. readonly gradient: NodeMaterialConnectionPoint;
  53985. /**
  53986. * Gets the output component
  53987. */
  53988. readonly output: NodeMaterialConnectionPoint;
  53989. protected _buildBlock(state: NodeMaterialBuildState): this;
  53990. }
  53991. }
  53992. declare module BABYLON {
  53993. /**
  53994. * Block used to divide 2 vectors
  53995. */
  53996. export class DivideBlock extends NodeMaterialBlock {
  53997. /**
  53998. * Creates a new DivideBlock
  53999. * @param name defines the block name
  54000. */
  54001. constructor(name: string);
  54002. /**
  54003. * Gets the current class name
  54004. * @returns the class name
  54005. */
  54006. getClassName(): string;
  54007. /**
  54008. * Gets the left operand input component
  54009. */
  54010. readonly left: NodeMaterialConnectionPoint;
  54011. /**
  54012. * Gets the right operand input component
  54013. */
  54014. readonly right: NodeMaterialConnectionPoint;
  54015. /**
  54016. * Gets the output component
  54017. */
  54018. readonly output: NodeMaterialConnectionPoint;
  54019. protected _buildBlock(state: NodeMaterialBuildState): this;
  54020. }
  54021. }
  54022. declare module BABYLON {
  54023. /**
  54024. * Block used to subtract 2 vectors
  54025. */
  54026. export class SubtractBlock extends NodeMaterialBlock {
  54027. /**
  54028. * Creates a new SubtractBlock
  54029. * @param name defines the block name
  54030. */
  54031. constructor(name: string);
  54032. /**
  54033. * Gets the current class name
  54034. * @returns the class name
  54035. */
  54036. getClassName(): string;
  54037. /**
  54038. * Gets the left operand input component
  54039. */
  54040. readonly left: NodeMaterialConnectionPoint;
  54041. /**
  54042. * Gets the right operand input component
  54043. */
  54044. readonly right: NodeMaterialConnectionPoint;
  54045. /**
  54046. * Gets the output component
  54047. */
  54048. readonly output: NodeMaterialConnectionPoint;
  54049. protected _buildBlock(state: NodeMaterialBuildState): this;
  54050. }
  54051. }
  54052. declare module BABYLON {
  54053. /**
  54054. * Block used to step a value
  54055. */
  54056. export class StepBlock extends NodeMaterialBlock {
  54057. /**
  54058. * Creates a new StepBlock
  54059. * @param name defines the block name
  54060. */
  54061. constructor(name: string);
  54062. /**
  54063. * Gets the current class name
  54064. * @returns the class name
  54065. */
  54066. getClassName(): string;
  54067. /**
  54068. * Gets the value operand input component
  54069. */
  54070. readonly value: NodeMaterialConnectionPoint;
  54071. /**
  54072. * Gets the edge operand input component
  54073. */
  54074. readonly edge: NodeMaterialConnectionPoint;
  54075. /**
  54076. * Gets the output component
  54077. */
  54078. readonly output: NodeMaterialConnectionPoint;
  54079. protected _buildBlock(state: NodeMaterialBuildState): this;
  54080. }
  54081. }
  54082. declare module BABYLON {
  54083. /**
  54084. * Block used to get the opposite (1 - x) of a value
  54085. */
  54086. export class OneMinusBlock extends NodeMaterialBlock {
  54087. /**
  54088. * Creates a new OneMinusBlock
  54089. * @param name defines the block name
  54090. */
  54091. constructor(name: string);
  54092. /**
  54093. * Gets the current class name
  54094. * @returns the class name
  54095. */
  54096. getClassName(): string;
  54097. /**
  54098. * Gets the input component
  54099. */
  54100. readonly input: NodeMaterialConnectionPoint;
  54101. /**
  54102. * Gets the output component
  54103. */
  54104. readonly output: NodeMaterialConnectionPoint;
  54105. protected _buildBlock(state: NodeMaterialBuildState): this;
  54106. }
  54107. }
  54108. declare module BABYLON {
  54109. /**
  54110. * Block used to get the view direction
  54111. */
  54112. export class ViewDirectionBlock extends NodeMaterialBlock {
  54113. /**
  54114. * Creates a new ViewDirectionBlock
  54115. * @param name defines the block name
  54116. */
  54117. constructor(name: string);
  54118. /**
  54119. * Gets the current class name
  54120. * @returns the class name
  54121. */
  54122. getClassName(): string;
  54123. /**
  54124. * Gets the world position component
  54125. */
  54126. readonly worldPosition: NodeMaterialConnectionPoint;
  54127. /**
  54128. * Gets the camera position component
  54129. */
  54130. readonly cameraPosition: NodeMaterialConnectionPoint;
  54131. /**
  54132. * Gets the output component
  54133. */
  54134. readonly output: NodeMaterialConnectionPoint;
  54135. autoConfigure(material: NodeMaterial): void;
  54136. protected _buildBlock(state: NodeMaterialBuildState): this;
  54137. }
  54138. }
  54139. declare module BABYLON {
  54140. /**
  54141. * Block used to compute fresnel value
  54142. */
  54143. export class FresnelBlock extends NodeMaterialBlock {
  54144. /**
  54145. * Create a new FresnelBlock
  54146. * @param name defines the block name
  54147. */
  54148. constructor(name: string);
  54149. /**
  54150. * Gets the current class name
  54151. * @returns the class name
  54152. */
  54153. getClassName(): string;
  54154. /**
  54155. * Gets the world normal input component
  54156. */
  54157. readonly worldNormal: NodeMaterialConnectionPoint;
  54158. /**
  54159. * Gets the view direction input component
  54160. */
  54161. readonly viewDirection: NodeMaterialConnectionPoint;
  54162. /**
  54163. * Gets the bias input component
  54164. */
  54165. readonly bias: NodeMaterialConnectionPoint;
  54166. /**
  54167. * Gets the camera (or eye) position component
  54168. */
  54169. readonly power: NodeMaterialConnectionPoint;
  54170. /**
  54171. * Gets the fresnel output component
  54172. */
  54173. readonly fresnel: NodeMaterialConnectionPoint;
  54174. autoConfigure(material: NodeMaterial): void;
  54175. protected _buildBlock(state: NodeMaterialBuildState): this;
  54176. }
  54177. }
  54178. declare module BABYLON {
  54179. /**
  54180. * Block used to get the max of 2 values
  54181. */
  54182. export class MaxBlock extends NodeMaterialBlock {
  54183. /**
  54184. * Creates a new MaxBlock
  54185. * @param name defines the block name
  54186. */
  54187. constructor(name: string);
  54188. /**
  54189. * Gets the current class name
  54190. * @returns the class name
  54191. */
  54192. getClassName(): string;
  54193. /**
  54194. * Gets the left operand input component
  54195. */
  54196. readonly left: NodeMaterialConnectionPoint;
  54197. /**
  54198. * Gets the right operand input component
  54199. */
  54200. readonly right: NodeMaterialConnectionPoint;
  54201. /**
  54202. * Gets the output component
  54203. */
  54204. readonly output: NodeMaterialConnectionPoint;
  54205. protected _buildBlock(state: NodeMaterialBuildState): this;
  54206. }
  54207. }
  54208. declare module BABYLON {
  54209. /**
  54210. * Block used to get the min of 2 values
  54211. */
  54212. export class MinBlock extends NodeMaterialBlock {
  54213. /**
  54214. * Creates a new MinBlock
  54215. * @param name defines the block name
  54216. */
  54217. constructor(name: string);
  54218. /**
  54219. * Gets the current class name
  54220. * @returns the class name
  54221. */
  54222. getClassName(): string;
  54223. /**
  54224. * Gets the left operand input component
  54225. */
  54226. readonly left: NodeMaterialConnectionPoint;
  54227. /**
  54228. * Gets the right operand input component
  54229. */
  54230. readonly right: NodeMaterialConnectionPoint;
  54231. /**
  54232. * Gets the output component
  54233. */
  54234. readonly output: NodeMaterialConnectionPoint;
  54235. protected _buildBlock(state: NodeMaterialBuildState): this;
  54236. }
  54237. }
  54238. declare module BABYLON {
  54239. /**
  54240. * Block used to get the distance between 2 values
  54241. */
  54242. export class DistanceBlock extends NodeMaterialBlock {
  54243. /**
  54244. * Creates a new DistanceBlock
  54245. * @param name defines the block name
  54246. */
  54247. constructor(name: string);
  54248. /**
  54249. * Gets the current class name
  54250. * @returns the class name
  54251. */
  54252. getClassName(): string;
  54253. /**
  54254. * Gets the left operand input component
  54255. */
  54256. readonly left: NodeMaterialConnectionPoint;
  54257. /**
  54258. * Gets the right operand input component
  54259. */
  54260. readonly right: NodeMaterialConnectionPoint;
  54261. /**
  54262. * Gets the output component
  54263. */
  54264. readonly output: NodeMaterialConnectionPoint;
  54265. protected _buildBlock(state: NodeMaterialBuildState): this;
  54266. }
  54267. }
  54268. declare module BABYLON {
  54269. /**
  54270. * Block used to get the length of a vector
  54271. */
  54272. export class LengthBlock extends NodeMaterialBlock {
  54273. /**
  54274. * Creates a new LengthBlock
  54275. * @param name defines the block name
  54276. */
  54277. constructor(name: string);
  54278. /**
  54279. * Gets the current class name
  54280. * @returns the class name
  54281. */
  54282. getClassName(): string;
  54283. /**
  54284. * Gets the value input component
  54285. */
  54286. readonly value: NodeMaterialConnectionPoint;
  54287. /**
  54288. * Gets the output component
  54289. */
  54290. readonly output: NodeMaterialConnectionPoint;
  54291. protected _buildBlock(state: NodeMaterialBuildState): this;
  54292. }
  54293. }
  54294. declare module BABYLON {
  54295. /**
  54296. * Block used to get negative version of a value (i.e. x * -1)
  54297. */
  54298. export class NegateBlock extends NodeMaterialBlock {
  54299. /**
  54300. * Creates a new NegateBlock
  54301. * @param name defines the block name
  54302. */
  54303. constructor(name: string);
  54304. /**
  54305. * Gets the current class name
  54306. * @returns the class name
  54307. */
  54308. getClassName(): string;
  54309. /**
  54310. * Gets the value input component
  54311. */
  54312. readonly value: NodeMaterialConnectionPoint;
  54313. /**
  54314. * Gets the output component
  54315. */
  54316. readonly output: NodeMaterialConnectionPoint;
  54317. protected _buildBlock(state: NodeMaterialBuildState): this;
  54318. }
  54319. }
  54320. declare module BABYLON {
  54321. /**
  54322. * Block used to get the value of the first parameter raised to the power of the second
  54323. */
  54324. export class PowBlock extends NodeMaterialBlock {
  54325. /**
  54326. * Creates a new PowBlock
  54327. * @param name defines the block name
  54328. */
  54329. constructor(name: string);
  54330. /**
  54331. * Gets the current class name
  54332. * @returns the class name
  54333. */
  54334. getClassName(): string;
  54335. /**
  54336. * Gets the value operand input component
  54337. */
  54338. readonly value: NodeMaterialConnectionPoint;
  54339. /**
  54340. * Gets the power operand input component
  54341. */
  54342. readonly power: NodeMaterialConnectionPoint;
  54343. /**
  54344. * Gets the output component
  54345. */
  54346. readonly output: NodeMaterialConnectionPoint;
  54347. protected _buildBlock(state: NodeMaterialBuildState): this;
  54348. }
  54349. }
  54350. declare module BABYLON {
  54351. /**
  54352. * Block used to get a random number
  54353. */
  54354. export class RandomNumberBlock extends NodeMaterialBlock {
  54355. /**
  54356. * Creates a new RandomNumberBlock
  54357. * @param name defines the block name
  54358. */
  54359. constructor(name: string);
  54360. /**
  54361. * Gets the current class name
  54362. * @returns the class name
  54363. */
  54364. getClassName(): string;
  54365. /**
  54366. * Gets the seed input component
  54367. */
  54368. readonly seed: NodeMaterialConnectionPoint;
  54369. /**
  54370. * Gets the output component
  54371. */
  54372. readonly output: NodeMaterialConnectionPoint;
  54373. protected _buildBlock(state: NodeMaterialBuildState): this;
  54374. }
  54375. }
  54376. declare module BABYLON {
  54377. /**
  54378. * Block used to compute arc tangent of 2 values
  54379. */
  54380. export class ArcTan2Block extends NodeMaterialBlock {
  54381. /**
  54382. * Creates a new ArcTan2Block
  54383. * @param name defines the block name
  54384. */
  54385. constructor(name: string);
  54386. /**
  54387. * Gets the current class name
  54388. * @returns the class name
  54389. */
  54390. getClassName(): string;
  54391. /**
  54392. * Gets the x operand input component
  54393. */
  54394. readonly x: NodeMaterialConnectionPoint;
  54395. /**
  54396. * Gets the y operand input component
  54397. */
  54398. readonly y: NodeMaterialConnectionPoint;
  54399. /**
  54400. * Gets the output component
  54401. */
  54402. readonly output: NodeMaterialConnectionPoint;
  54403. protected _buildBlock(state: NodeMaterialBuildState): this;
  54404. }
  54405. }
  54406. declare module BABYLON {
  54407. /**
  54408. * Block used to smooth step a value
  54409. */
  54410. export class SmoothStepBlock extends NodeMaterialBlock {
  54411. /**
  54412. * Creates a new SmoothStepBlock
  54413. * @param name defines the block name
  54414. */
  54415. constructor(name: string);
  54416. /**
  54417. * Gets the current class name
  54418. * @returns the class name
  54419. */
  54420. getClassName(): string;
  54421. /**
  54422. * Gets the value operand input component
  54423. */
  54424. readonly value: NodeMaterialConnectionPoint;
  54425. /**
  54426. * Gets the first edge operand input component
  54427. */
  54428. readonly edge0: NodeMaterialConnectionPoint;
  54429. /**
  54430. * Gets the second edge operand input component
  54431. */
  54432. readonly edge1: NodeMaterialConnectionPoint;
  54433. /**
  54434. * Gets the output component
  54435. */
  54436. readonly output: NodeMaterialConnectionPoint;
  54437. protected _buildBlock(state: NodeMaterialBuildState): this;
  54438. }
  54439. }
  54440. declare module BABYLON {
  54441. /**
  54442. * Block used to get the reciprocal (1 / x) of a value
  54443. */
  54444. export class ReciprocalBlock extends NodeMaterialBlock {
  54445. /**
  54446. * Creates a new ReciprocalBlock
  54447. * @param name defines the block name
  54448. */
  54449. constructor(name: string);
  54450. /**
  54451. * Gets the current class name
  54452. * @returns the class name
  54453. */
  54454. getClassName(): string;
  54455. /**
  54456. * Gets the input component
  54457. */
  54458. readonly input: NodeMaterialConnectionPoint;
  54459. /**
  54460. * Gets the output component
  54461. */
  54462. readonly output: NodeMaterialConnectionPoint;
  54463. protected _buildBlock(state: NodeMaterialBuildState): this;
  54464. }
  54465. }
  54466. declare module BABYLON {
  54467. /**
  54468. * Block used to replace a color by another one
  54469. */
  54470. export class ReplaceColorBlock extends NodeMaterialBlock {
  54471. /**
  54472. * Creates a new ReplaceColorBlock
  54473. * @param name defines the block name
  54474. */
  54475. constructor(name: string);
  54476. /**
  54477. * Gets the current class name
  54478. * @returns the class name
  54479. */
  54480. getClassName(): string;
  54481. /**
  54482. * Gets the value input component
  54483. */
  54484. readonly value: NodeMaterialConnectionPoint;
  54485. /**
  54486. * Gets the reference input component
  54487. */
  54488. readonly reference: NodeMaterialConnectionPoint;
  54489. /**
  54490. * Gets the distance input component
  54491. */
  54492. readonly distance: NodeMaterialConnectionPoint;
  54493. /**
  54494. * Gets the replacement input component
  54495. */
  54496. readonly replacement: NodeMaterialConnectionPoint;
  54497. /**
  54498. * Gets the output component
  54499. */
  54500. readonly output: NodeMaterialConnectionPoint;
  54501. protected _buildBlock(state: NodeMaterialBuildState): this;
  54502. }
  54503. }
  54504. declare module BABYLON {
  54505. /**
  54506. * Block used to posterize a value
  54507. * @see https://en.wikipedia.org/wiki/Posterization
  54508. */
  54509. export class PosterizeBlock extends NodeMaterialBlock {
  54510. /**
  54511. * Creates a new PosterizeBlock
  54512. * @param name defines the block name
  54513. */
  54514. constructor(name: string);
  54515. /**
  54516. * Gets the current class name
  54517. * @returns the class name
  54518. */
  54519. getClassName(): string;
  54520. /**
  54521. * Gets the value input component
  54522. */
  54523. readonly value: NodeMaterialConnectionPoint;
  54524. /**
  54525. * Gets the steps input component
  54526. */
  54527. readonly steps: NodeMaterialConnectionPoint;
  54528. /**
  54529. * Gets the output component
  54530. */
  54531. readonly output: NodeMaterialConnectionPoint;
  54532. protected _buildBlock(state: NodeMaterialBuildState): this;
  54533. }
  54534. }
  54535. declare module BABYLON {
  54536. /**
  54537. * Operations supported by the Wave block
  54538. */
  54539. export enum WaveBlockKind {
  54540. /** SawTooth */
  54541. SawTooth = 0,
  54542. /** Square */
  54543. Square = 1,
  54544. /** Triangle */
  54545. Triangle = 2
  54546. }
  54547. /**
  54548. * Block used to apply wave operation to floats
  54549. */
  54550. export class WaveBlock extends NodeMaterialBlock {
  54551. /**
  54552. * Gets or sets the kibnd of wave to be applied by the block
  54553. */
  54554. kind: WaveBlockKind;
  54555. /**
  54556. * Creates a new WaveBlock
  54557. * @param name defines the block name
  54558. */
  54559. constructor(name: string);
  54560. /**
  54561. * Gets the current class name
  54562. * @returns the class name
  54563. */
  54564. getClassName(): string;
  54565. /**
  54566. * Gets the input component
  54567. */
  54568. readonly input: NodeMaterialConnectionPoint;
  54569. /**
  54570. * Gets the output component
  54571. */
  54572. readonly output: NodeMaterialConnectionPoint;
  54573. protected _buildBlock(state: NodeMaterialBuildState): this;
  54574. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54575. }
  54576. }
  54577. declare module BABYLON {
  54578. /**
  54579. * Class used to store a color step for the GradientBlock
  54580. */
  54581. export class GradientBlockColorStep {
  54582. /**
  54583. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  54584. */
  54585. step: number;
  54586. /**
  54587. * Gets or sets the color associated with this step
  54588. */
  54589. color: Color3;
  54590. /**
  54591. * Creates a new GradientBlockColorStep
  54592. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  54593. * @param color defines the color associated with this step
  54594. */
  54595. constructor(
  54596. /**
  54597. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  54598. */
  54599. step: number,
  54600. /**
  54601. * Gets or sets the color associated with this step
  54602. */
  54603. color: Color3);
  54604. }
  54605. /**
  54606. * Block used to return a color from a gradient based on an input value between 0 and 1
  54607. */
  54608. export class GradientBlock extends NodeMaterialBlock {
  54609. /**
  54610. * Gets or sets the list of color steps
  54611. */
  54612. colorSteps: GradientBlockColorStep[];
  54613. /**
  54614. * Creates a new GradientBlock
  54615. * @param name defines the block name
  54616. */
  54617. constructor(name: string);
  54618. /**
  54619. * Gets the current class name
  54620. * @returns the class name
  54621. */
  54622. getClassName(): string;
  54623. /**
  54624. * Gets the gradient input component
  54625. */
  54626. readonly gradient: NodeMaterialConnectionPoint;
  54627. /**
  54628. * Gets the output component
  54629. */
  54630. readonly output: NodeMaterialConnectionPoint;
  54631. private _writeColorConstant;
  54632. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54633. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54634. protected _dumpPropertiesCode(): string;
  54635. }
  54636. }
  54637. declare module BABYLON {
  54638. /**
  54639. * Block used to normalize lerp between 2 values
  54640. */
  54641. export class NLerpBlock extends NodeMaterialBlock {
  54642. /**
  54643. * Creates a new NLerpBlock
  54644. * @param name defines the block name
  54645. */
  54646. constructor(name: string);
  54647. /**
  54648. * Gets the current class name
  54649. * @returns the class name
  54650. */
  54651. getClassName(): string;
  54652. /**
  54653. * Gets the left operand input component
  54654. */
  54655. readonly left: NodeMaterialConnectionPoint;
  54656. /**
  54657. * Gets the right operand input component
  54658. */
  54659. readonly right: NodeMaterialConnectionPoint;
  54660. /**
  54661. * Gets the gradient operand input component
  54662. */
  54663. readonly gradient: NodeMaterialConnectionPoint;
  54664. /**
  54665. * Gets the output component
  54666. */
  54667. readonly output: NodeMaterialConnectionPoint;
  54668. protected _buildBlock(state: NodeMaterialBuildState): this;
  54669. }
  54670. }
  54671. declare module BABYLON {
  54672. /**
  54673. * Effect Render Options
  54674. */
  54675. export interface IEffectRendererOptions {
  54676. /**
  54677. * Defines the vertices positions.
  54678. */
  54679. positions?: number[];
  54680. /**
  54681. * Defines the indices.
  54682. */
  54683. indices?: number[];
  54684. }
  54685. /**
  54686. * Helper class to render one or more effects
  54687. */
  54688. export class EffectRenderer {
  54689. private engine;
  54690. private static _DefaultOptions;
  54691. private _vertexBuffers;
  54692. private _indexBuffer;
  54693. private _ringBufferIndex;
  54694. private _ringScreenBuffer;
  54695. private _fullscreenViewport;
  54696. private _getNextFrameBuffer;
  54697. /**
  54698. * Creates an effect renderer
  54699. * @param engine the engine to use for rendering
  54700. * @param options defines the options of the effect renderer
  54701. */
  54702. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  54703. /**
  54704. * Sets the current viewport in normalized coordinates 0-1
  54705. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  54706. */
  54707. setViewport(viewport?: Viewport): void;
  54708. /**
  54709. * Binds the embedded attributes buffer to the effect.
  54710. * @param effect Defines the effect to bind the attributes for
  54711. */
  54712. bindBuffers(effect: Effect): void;
  54713. /**
  54714. * Sets the current effect wrapper to use during draw.
  54715. * The effect needs to be ready before calling this api.
  54716. * This also sets the default full screen position attribute.
  54717. * @param effectWrapper Defines the effect to draw with
  54718. */
  54719. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  54720. /**
  54721. * Draws a full screen quad.
  54722. */
  54723. draw(): void;
  54724. /**
  54725. * renders one or more effects to a specified texture
  54726. * @param effectWrappers list of effects to renderer
  54727. * @param outputTexture texture to draw to, if null it will render to the screen
  54728. */
  54729. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54730. /**
  54731. * Disposes of the effect renderer
  54732. */
  54733. dispose(): void;
  54734. }
  54735. /**
  54736. * Options to create an EffectWrapper
  54737. */
  54738. interface EffectWrapperCreationOptions {
  54739. /**
  54740. * Engine to use to create the effect
  54741. */
  54742. engine: ThinEngine;
  54743. /**
  54744. * Fragment shader for the effect
  54745. */
  54746. fragmentShader: string;
  54747. /**
  54748. * Vertex shader for the effect
  54749. */
  54750. vertexShader?: string;
  54751. /**
  54752. * Attributes to use in the shader
  54753. */
  54754. attributeNames?: Array<string>;
  54755. /**
  54756. * Uniforms to use in the shader
  54757. */
  54758. uniformNames?: Array<string>;
  54759. /**
  54760. * Texture sampler names to use in the shader
  54761. */
  54762. samplerNames?: Array<string>;
  54763. /**
  54764. * The friendly name of the effect displayed in Spector.
  54765. */
  54766. name?: string;
  54767. }
  54768. /**
  54769. * Wraps an effect to be used for rendering
  54770. */
  54771. export class EffectWrapper {
  54772. /**
  54773. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54774. */
  54775. onApplyObservable: Observable<{}>;
  54776. /**
  54777. * The underlying effect
  54778. */
  54779. effect: Effect;
  54780. /**
  54781. * Creates an effect to be renderer
  54782. * @param creationOptions options to create the effect
  54783. */
  54784. constructor(creationOptions: EffectWrapperCreationOptions);
  54785. /**
  54786. * Disposes of the effect wrapper
  54787. */
  54788. dispose(): void;
  54789. }
  54790. }
  54791. declare module BABYLON {
  54792. /**
  54793. * Helper class to push actions to a pool of workers.
  54794. */
  54795. export class WorkerPool implements IDisposable {
  54796. private _workerInfos;
  54797. private _pendingActions;
  54798. /**
  54799. * Constructor
  54800. * @param workers Array of workers to use for actions
  54801. */
  54802. constructor(workers: Array<Worker>);
  54803. /**
  54804. * Terminates all workers and clears any pending actions.
  54805. */
  54806. dispose(): void;
  54807. /**
  54808. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54809. * pended until a worker has completed its action.
  54810. * @param action The action to perform. Call onComplete when the action is complete.
  54811. */
  54812. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54813. private _execute;
  54814. }
  54815. }
  54816. declare module BABYLON {
  54817. /**
  54818. * Configuration for Draco compression
  54819. */
  54820. export interface IDracoCompressionConfiguration {
  54821. /**
  54822. * Configuration for the decoder.
  54823. */
  54824. decoder: {
  54825. /**
  54826. * The url to the WebAssembly module.
  54827. */
  54828. wasmUrl?: string;
  54829. /**
  54830. * The url to the WebAssembly binary.
  54831. */
  54832. wasmBinaryUrl?: string;
  54833. /**
  54834. * The url to the fallback JavaScript module.
  54835. */
  54836. fallbackUrl?: string;
  54837. };
  54838. }
  54839. /**
  54840. * Draco compression (https://google.github.io/draco/)
  54841. *
  54842. * This class wraps the Draco module.
  54843. *
  54844. * **Encoder**
  54845. *
  54846. * The encoder is not currently implemented.
  54847. *
  54848. * **Decoder**
  54849. *
  54850. * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.
  54851. *
  54852. * To update the configuration, use the following code:
  54853. * ```javascript
  54854. * DracoCompression.Configuration = {
  54855. * decoder: {
  54856. * wasmUrl: "<url to the WebAssembly library>",
  54857. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54858. * fallbackUrl: "<url to the fallback JavaScript library>",
  54859. * }
  54860. * };
  54861. * ```
  54862. *
  54863. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  54864. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54865. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54866. *
  54867. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54868. * ```javascript
  54869. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54870. * ```
  54871. *
  54872. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54873. */
  54874. export class DracoCompression implements IDisposable {
  54875. private _workerPoolPromise?;
  54876. private _decoderModulePromise?;
  54877. /**
  54878. * The configuration. Defaults to the following urls:
  54879. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54880. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54881. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54882. */
  54883. static Configuration: IDracoCompressionConfiguration;
  54884. /**
  54885. * Returns true if the decoder configuration is available.
  54886. */
  54887. static readonly DecoderAvailable: boolean;
  54888. /**
  54889. * Default number of workers to create when creating the draco compression object.
  54890. */
  54891. static DefaultNumWorkers: number;
  54892. private static GetDefaultNumWorkers;
  54893. private static _Default;
  54894. /**
  54895. * Default instance for the draco compression object.
  54896. */
  54897. static readonly Default: DracoCompression;
  54898. /**
  54899. * Constructor
  54900. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54901. */
  54902. constructor(numWorkers?: number);
  54903. /**
  54904. * Stop all async operations and release resources.
  54905. */
  54906. dispose(): void;
  54907. /**
  54908. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54909. * @returns a promise that resolves when ready
  54910. */
  54911. whenReadyAsync(): Promise<void>;
  54912. /**
  54913. * Decode Draco compressed mesh data to vertex data.
  54914. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54915. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54916. * @returns A promise that resolves with the decoded vertex data
  54917. */
  54918. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54919. [kind: string]: number;
  54920. }): Promise<VertexData>;
  54921. }
  54922. }
  54923. declare module BABYLON {
  54924. /**
  54925. * Class for building Constructive Solid Geometry
  54926. */
  54927. export class CSG {
  54928. private polygons;
  54929. /**
  54930. * The world matrix
  54931. */
  54932. matrix: Matrix;
  54933. /**
  54934. * Stores the position
  54935. */
  54936. position: Vector3;
  54937. /**
  54938. * Stores the rotation
  54939. */
  54940. rotation: Vector3;
  54941. /**
  54942. * Stores the rotation quaternion
  54943. */
  54944. rotationQuaternion: Nullable<Quaternion>;
  54945. /**
  54946. * Stores the scaling vector
  54947. */
  54948. scaling: Vector3;
  54949. /**
  54950. * Convert the Mesh to CSG
  54951. * @param mesh The Mesh to convert to CSG
  54952. * @returns A new CSG from the Mesh
  54953. */
  54954. static FromMesh(mesh: Mesh): CSG;
  54955. /**
  54956. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54957. * @param polygons Polygons used to construct a CSG solid
  54958. */
  54959. private static FromPolygons;
  54960. /**
  54961. * Clones, or makes a deep copy, of the CSG
  54962. * @returns A new CSG
  54963. */
  54964. clone(): CSG;
  54965. /**
  54966. * Unions this CSG with another CSG
  54967. * @param csg The CSG to union against this CSG
  54968. * @returns The unioned CSG
  54969. */
  54970. union(csg: CSG): CSG;
  54971. /**
  54972. * Unions this CSG with another CSG in place
  54973. * @param csg The CSG to union against this CSG
  54974. */
  54975. unionInPlace(csg: CSG): void;
  54976. /**
  54977. * Subtracts this CSG with another CSG
  54978. * @param csg The CSG to subtract against this CSG
  54979. * @returns A new CSG
  54980. */
  54981. subtract(csg: CSG): CSG;
  54982. /**
  54983. * Subtracts this CSG with another CSG in place
  54984. * @param csg The CSG to subtact against this CSG
  54985. */
  54986. subtractInPlace(csg: CSG): void;
  54987. /**
  54988. * Intersect this CSG with another CSG
  54989. * @param csg The CSG to intersect against this CSG
  54990. * @returns A new CSG
  54991. */
  54992. intersect(csg: CSG): CSG;
  54993. /**
  54994. * Intersects this CSG with another CSG in place
  54995. * @param csg The CSG to intersect against this CSG
  54996. */
  54997. intersectInPlace(csg: CSG): void;
  54998. /**
  54999. * Return a new CSG solid with solid and empty space switched. This solid is
  55000. * not modified.
  55001. * @returns A new CSG solid with solid and empty space switched
  55002. */
  55003. inverse(): CSG;
  55004. /**
  55005. * Inverses the CSG in place
  55006. */
  55007. inverseInPlace(): void;
  55008. /**
  55009. * This is used to keep meshes transformations so they can be restored
  55010. * when we build back a Babylon Mesh
  55011. * NB : All CSG operations are performed in world coordinates
  55012. * @param csg The CSG to copy the transform attributes from
  55013. * @returns This CSG
  55014. */
  55015. copyTransformAttributes(csg: CSG): CSG;
  55016. /**
  55017. * Build Raw mesh from CSG
  55018. * Coordinates here are in world space
  55019. * @param name The name of the mesh geometry
  55020. * @param scene The Scene
  55021. * @param keepSubMeshes Specifies if the submeshes should be kept
  55022. * @returns A new Mesh
  55023. */
  55024. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55025. /**
  55026. * Build Mesh from CSG taking material and transforms into account
  55027. * @param name The name of the Mesh
  55028. * @param material The material of the Mesh
  55029. * @param scene The Scene
  55030. * @param keepSubMeshes Specifies if submeshes should be kept
  55031. * @returns The new Mesh
  55032. */
  55033. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  55034. }
  55035. }
  55036. declare module BABYLON {
  55037. /**
  55038. * Class used to create a trail following a mesh
  55039. */
  55040. export class TrailMesh extends Mesh {
  55041. private _generator;
  55042. private _autoStart;
  55043. private _running;
  55044. private _diameter;
  55045. private _length;
  55046. private _sectionPolygonPointsCount;
  55047. private _sectionVectors;
  55048. private _sectionNormalVectors;
  55049. private _beforeRenderObserver;
  55050. /**
  55051. * @constructor
  55052. * @param name The value used by scene.getMeshByName() to do a lookup.
  55053. * @param generator The mesh to generate a trail.
  55054. * @param scene The scene to add this mesh to.
  55055. * @param diameter Diameter of trailing mesh. Default is 1.
  55056. * @param length Length of trailing mesh. Default is 60.
  55057. * @param autoStart Automatically start trailing mesh. Default true.
  55058. */
  55059. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55060. /**
  55061. * "TrailMesh"
  55062. * @returns "TrailMesh"
  55063. */
  55064. getClassName(): string;
  55065. private _createMesh;
  55066. /**
  55067. * Start trailing mesh.
  55068. */
  55069. start(): void;
  55070. /**
  55071. * Stop trailing mesh.
  55072. */
  55073. stop(): void;
  55074. /**
  55075. * Update trailing mesh geometry.
  55076. */
  55077. update(): void;
  55078. /**
  55079. * Returns a new TrailMesh object.
  55080. * @param name is a string, the name given to the new mesh
  55081. * @param newGenerator use new generator object for cloned trail mesh
  55082. * @returns a new mesh
  55083. */
  55084. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55085. /**
  55086. * Serializes this trail mesh
  55087. * @param serializationObject object to write serialization to
  55088. */
  55089. serialize(serializationObject: any): void;
  55090. /**
  55091. * Parses a serialized trail mesh
  55092. * @param parsedMesh the serialized mesh
  55093. * @param scene the scene to create the trail mesh in
  55094. * @returns the created trail mesh
  55095. */
  55096. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55097. }
  55098. }
  55099. declare module BABYLON {
  55100. /**
  55101. * Class containing static functions to help procedurally build meshes
  55102. */
  55103. export class TiledBoxBuilder {
  55104. /**
  55105. * Creates a box mesh
  55106. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  55107. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55111. * @param name defines the name of the mesh
  55112. * @param options defines the options used to create the mesh
  55113. * @param scene defines the hosting scene
  55114. * @returns the box mesh
  55115. */
  55116. static CreateTiledBox(name: string, options: {
  55117. pattern?: number;
  55118. width?: number;
  55119. height?: number;
  55120. depth?: number;
  55121. tileSize?: number;
  55122. tileWidth?: number;
  55123. tileHeight?: number;
  55124. alignHorizontal?: number;
  55125. alignVertical?: number;
  55126. faceUV?: Vector4[];
  55127. faceColors?: Color4[];
  55128. sideOrientation?: number;
  55129. updatable?: boolean;
  55130. }, scene?: Nullable<Scene>): Mesh;
  55131. }
  55132. }
  55133. declare module BABYLON {
  55134. /**
  55135. * Class containing static functions to help procedurally build meshes
  55136. */
  55137. export class TorusKnotBuilder {
  55138. /**
  55139. * Creates a torus knot mesh
  55140. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55141. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55142. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55143. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55147. * @param name defines the name of the mesh
  55148. * @param options defines the options used to create the mesh
  55149. * @param scene defines the hosting scene
  55150. * @returns the torus knot mesh
  55151. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55152. */
  55153. static CreateTorusKnot(name: string, options: {
  55154. radius?: number;
  55155. tube?: number;
  55156. radialSegments?: number;
  55157. tubularSegments?: number;
  55158. p?: number;
  55159. q?: number;
  55160. updatable?: boolean;
  55161. sideOrientation?: number;
  55162. frontUVs?: Vector4;
  55163. backUVs?: Vector4;
  55164. }, scene: any): Mesh;
  55165. }
  55166. }
  55167. declare module BABYLON {
  55168. /**
  55169. * Polygon
  55170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55171. */
  55172. export class Polygon {
  55173. /**
  55174. * Creates a rectangle
  55175. * @param xmin bottom X coord
  55176. * @param ymin bottom Y coord
  55177. * @param xmax top X coord
  55178. * @param ymax top Y coord
  55179. * @returns points that make the resulting rectation
  55180. */
  55181. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55182. /**
  55183. * Creates a circle
  55184. * @param radius radius of circle
  55185. * @param cx scale in x
  55186. * @param cy scale in y
  55187. * @param numberOfSides number of sides that make up the circle
  55188. * @returns points that make the resulting circle
  55189. */
  55190. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55191. /**
  55192. * Creates a polygon from input string
  55193. * @param input Input polygon data
  55194. * @returns the parsed points
  55195. */
  55196. static Parse(input: string): Vector2[];
  55197. /**
  55198. * Starts building a polygon from x and y coordinates
  55199. * @param x x coordinate
  55200. * @param y y coordinate
  55201. * @returns the started path2
  55202. */
  55203. static StartingAt(x: number, y: number): Path2;
  55204. }
  55205. /**
  55206. * Builds a polygon
  55207. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55208. */
  55209. export class PolygonMeshBuilder {
  55210. private _points;
  55211. private _outlinepoints;
  55212. private _holes;
  55213. private _name;
  55214. private _scene;
  55215. private _epoints;
  55216. private _eholes;
  55217. private _addToepoint;
  55218. /**
  55219. * Babylon reference to the earcut plugin.
  55220. */
  55221. bjsEarcut: any;
  55222. /**
  55223. * Creates a PolygonMeshBuilder
  55224. * @param name name of the builder
  55225. * @param contours Path of the polygon
  55226. * @param scene scene to add to when creating the mesh
  55227. * @param earcutInjection can be used to inject your own earcut reference
  55228. */
  55229. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55230. /**
  55231. * Adds a whole within the polygon
  55232. * @param hole Array of points defining the hole
  55233. * @returns this
  55234. */
  55235. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55236. /**
  55237. * Creates the polygon
  55238. * @param updatable If the mesh should be updatable
  55239. * @param depth The depth of the mesh created
  55240. * @returns the created mesh
  55241. */
  55242. build(updatable?: boolean, depth?: number): Mesh;
  55243. /**
  55244. * Creates the polygon
  55245. * @param depth The depth of the mesh created
  55246. * @returns the created VertexData
  55247. */
  55248. buildVertexData(depth?: number): VertexData;
  55249. /**
  55250. * Adds a side to the polygon
  55251. * @param positions points that make the polygon
  55252. * @param normals normals of the polygon
  55253. * @param uvs uvs of the polygon
  55254. * @param indices indices of the polygon
  55255. * @param bounds bounds of the polygon
  55256. * @param points points of the polygon
  55257. * @param depth depth of the polygon
  55258. * @param flip flip of the polygon
  55259. */
  55260. private addSide;
  55261. }
  55262. }
  55263. declare module BABYLON {
  55264. /**
  55265. * Class containing static functions to help procedurally build meshes
  55266. */
  55267. export class PolygonBuilder {
  55268. /**
  55269. * Creates a polygon mesh
  55270. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55271. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  55272. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55275. * * Remember you can only change the shape positions, not their number when updating a polygon
  55276. * @param name defines the name of the mesh
  55277. * @param options defines the options used to create the mesh
  55278. * @param scene defines the hosting scene
  55279. * @param earcutInjection can be used to inject your own earcut reference
  55280. * @returns the polygon mesh
  55281. */
  55282. static CreatePolygon(name: string, options: {
  55283. shape: Vector3[];
  55284. holes?: Vector3[][];
  55285. depth?: number;
  55286. faceUV?: Vector4[];
  55287. faceColors?: Color4[];
  55288. updatable?: boolean;
  55289. sideOrientation?: number;
  55290. frontUVs?: Vector4;
  55291. backUVs?: Vector4;
  55292. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55293. /**
  55294. * Creates an extruded polygon mesh, with depth in the Y direction.
  55295. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  55296. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55297. * @param name defines the name of the mesh
  55298. * @param options defines the options used to create the mesh
  55299. * @param scene defines the hosting scene
  55300. * @param earcutInjection can be used to inject your own earcut reference
  55301. * @returns the polygon mesh
  55302. */
  55303. static ExtrudePolygon(name: string, options: {
  55304. shape: Vector3[];
  55305. holes?: Vector3[][];
  55306. depth?: number;
  55307. faceUV?: Vector4[];
  55308. faceColors?: Color4[];
  55309. updatable?: boolean;
  55310. sideOrientation?: number;
  55311. frontUVs?: Vector4;
  55312. backUVs?: Vector4;
  55313. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55314. }
  55315. }
  55316. declare module BABYLON {
  55317. /**
  55318. * Class containing static functions to help procedurally build meshes
  55319. */
  55320. export class LatheBuilder {
  55321. /**
  55322. * Creates lathe mesh.
  55323. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55324. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  55325. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55326. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55327. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55328. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  55329. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55330. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  55331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55333. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55335. * @param name defines the name of the mesh
  55336. * @param options defines the options used to create the mesh
  55337. * @param scene defines the hosting scene
  55338. * @returns the lathe mesh
  55339. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55340. */
  55341. static CreateLathe(name: string, options: {
  55342. shape: Vector3[];
  55343. radius?: number;
  55344. tessellation?: number;
  55345. clip?: number;
  55346. arc?: number;
  55347. closed?: boolean;
  55348. updatable?: boolean;
  55349. sideOrientation?: number;
  55350. frontUVs?: Vector4;
  55351. backUVs?: Vector4;
  55352. cap?: number;
  55353. invertUV?: boolean;
  55354. }, scene?: Nullable<Scene>): Mesh;
  55355. }
  55356. }
  55357. declare module BABYLON {
  55358. /**
  55359. * Class containing static functions to help procedurally build meshes
  55360. */
  55361. export class TiledPlaneBuilder {
  55362. /**
  55363. * Creates a tiled plane mesh
  55364. * * The parameter `pattern` will, depending on value, do nothing or
  55365. * * * flip (reflect about central vertical) alternate tiles across and up
  55366. * * * flip every tile on alternate rows
  55367. * * * rotate (180 degs) alternate tiles across and up
  55368. * * * rotate every tile on alternate rows
  55369. * * * flip and rotate alternate tiles across and up
  55370. * * * flip and rotate every tile on alternate rows
  55371. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55372. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55374. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55375. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  55376. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  55377. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55378. * @param name defines the name of the mesh
  55379. * @param options defines the options used to create the mesh
  55380. * @param scene defines the hosting scene
  55381. * @returns the box mesh
  55382. */
  55383. static CreateTiledPlane(name: string, options: {
  55384. pattern?: number;
  55385. tileSize?: number;
  55386. tileWidth?: number;
  55387. tileHeight?: number;
  55388. size?: number;
  55389. width?: number;
  55390. height?: number;
  55391. alignHorizontal?: number;
  55392. alignVertical?: number;
  55393. sideOrientation?: number;
  55394. frontUVs?: Vector4;
  55395. backUVs?: Vector4;
  55396. updatable?: boolean;
  55397. }, scene?: Nullable<Scene>): Mesh;
  55398. }
  55399. }
  55400. declare module BABYLON {
  55401. /**
  55402. * Class containing static functions to help procedurally build meshes
  55403. */
  55404. export class TubeBuilder {
  55405. /**
  55406. * Creates a tube mesh.
  55407. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55408. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55409. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55410. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55411. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55412. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  55413. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55414. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  55415. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  55416. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55417. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55418. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55420. * @param name defines the name of the mesh
  55421. * @param options defines the options used to create the mesh
  55422. * @param scene defines the hosting scene
  55423. * @returns the tube mesh
  55424. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55425. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55426. */
  55427. static CreateTube(name: string, options: {
  55428. path: Vector3[];
  55429. radius?: number;
  55430. tessellation?: number;
  55431. radiusFunction?: {
  55432. (i: number, distance: number): number;
  55433. };
  55434. cap?: number;
  55435. arc?: number;
  55436. updatable?: boolean;
  55437. sideOrientation?: number;
  55438. frontUVs?: Vector4;
  55439. backUVs?: Vector4;
  55440. instance?: Mesh;
  55441. invertUV?: boolean;
  55442. }, scene?: Nullable<Scene>): Mesh;
  55443. }
  55444. }
  55445. declare module BABYLON {
  55446. /**
  55447. * Class containing static functions to help procedurally build meshes
  55448. */
  55449. export class IcoSphereBuilder {
  55450. /**
  55451. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55452. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55453. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  55454. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55455. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  55456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55459. * @param name defines the name of the mesh
  55460. * @param options defines the options used to create the mesh
  55461. * @param scene defines the hosting scene
  55462. * @returns the icosahedron mesh
  55463. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55464. */
  55465. static CreateIcoSphere(name: string, options: {
  55466. radius?: number;
  55467. radiusX?: number;
  55468. radiusY?: number;
  55469. radiusZ?: number;
  55470. flat?: boolean;
  55471. subdivisions?: number;
  55472. sideOrientation?: number;
  55473. frontUVs?: Vector4;
  55474. backUVs?: Vector4;
  55475. updatable?: boolean;
  55476. }, scene?: Nullable<Scene>): Mesh;
  55477. }
  55478. }
  55479. declare module BABYLON {
  55480. /**
  55481. * Class containing static functions to help procedurally build meshes
  55482. */
  55483. export class DecalBuilder {
  55484. /**
  55485. * Creates a decal mesh.
  55486. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  55487. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55488. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55489. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55490. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55491. * @param name defines the name of the mesh
  55492. * @param sourceMesh defines the mesh where the decal must be applied
  55493. * @param options defines the options used to create the mesh
  55494. * @param scene defines the hosting scene
  55495. * @returns the decal mesh
  55496. * @see https://doc.babylonjs.com/how_to/decals
  55497. */
  55498. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55499. position?: Vector3;
  55500. normal?: Vector3;
  55501. size?: Vector3;
  55502. angle?: number;
  55503. }): Mesh;
  55504. }
  55505. }
  55506. declare module BABYLON {
  55507. /**
  55508. * Class containing static functions to help procedurally build meshes
  55509. */
  55510. export class MeshBuilder {
  55511. /**
  55512. * Creates a box mesh
  55513. * * The parameter `size` sets the size (float) of each box side (default 1)
  55514. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55515. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  55516. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55520. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55521. * @param name defines the name of the mesh
  55522. * @param options defines the options used to create the mesh
  55523. * @param scene defines the hosting scene
  55524. * @returns the box mesh
  55525. */
  55526. static CreateBox(name: string, options: {
  55527. size?: number;
  55528. width?: number;
  55529. height?: number;
  55530. depth?: number;
  55531. faceUV?: Vector4[];
  55532. faceColors?: Color4[];
  55533. sideOrientation?: number;
  55534. frontUVs?: Vector4;
  55535. backUVs?: Vector4;
  55536. updatable?: boolean;
  55537. }, scene?: Nullable<Scene>): Mesh;
  55538. /**
  55539. * Creates a tiled box mesh
  55540. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55542. * @param name defines the name of the mesh
  55543. * @param options defines the options used to create the mesh
  55544. * @param scene defines the hosting scene
  55545. * @returns the tiled box mesh
  55546. */
  55547. static CreateTiledBox(name: string, options: {
  55548. pattern?: number;
  55549. size?: number;
  55550. width?: number;
  55551. height?: number;
  55552. depth: number;
  55553. tileSize?: number;
  55554. tileWidth?: number;
  55555. tileHeight?: number;
  55556. faceUV?: Vector4[];
  55557. faceColors?: Color4[];
  55558. alignHorizontal?: number;
  55559. alignVertical?: number;
  55560. sideOrientation?: number;
  55561. updatable?: boolean;
  55562. }, scene?: Nullable<Scene>): Mesh;
  55563. /**
  55564. * Creates a sphere mesh
  55565. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55566. * * You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters `diameterX`, `diameterY` and `diameterZ` (all by default have the same value of `diameter`)
  55567. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55568. * * You can create an unclosed sphere with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio
  55569. * * You can create an unclosed sphere on its height with the parameter `slice` (positive float, default1), valued between 0 and 1, what is the height ratio (longitude)
  55570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55571. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55573. * @param name defines the name of the mesh
  55574. * @param options defines the options used to create the mesh
  55575. * @param scene defines the hosting scene
  55576. * @returns the sphere mesh
  55577. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55578. */
  55579. static CreateSphere(name: string, options: {
  55580. segments?: number;
  55581. diameter?: number;
  55582. diameterX?: number;
  55583. diameterY?: number;
  55584. diameterZ?: number;
  55585. arc?: number;
  55586. slice?: number;
  55587. sideOrientation?: number;
  55588. frontUVs?: Vector4;
  55589. backUVs?: Vector4;
  55590. updatable?: boolean;
  55591. }, scene?: Nullable<Scene>): Mesh;
  55592. /**
  55593. * Creates a plane polygonal mesh. By default, this is a disc
  55594. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55595. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  55596. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  55597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55600. * @param name defines the name of the mesh
  55601. * @param options defines the options used to create the mesh
  55602. * @param scene defines the hosting scene
  55603. * @returns the plane polygonal mesh
  55604. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55605. */
  55606. static CreateDisc(name: string, options: {
  55607. radius?: number;
  55608. tessellation?: number;
  55609. arc?: number;
  55610. updatable?: boolean;
  55611. sideOrientation?: number;
  55612. frontUVs?: Vector4;
  55613. backUVs?: Vector4;
  55614. }, scene?: Nullable<Scene>): Mesh;
  55615. /**
  55616. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55617. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55618. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value of `radius`)
  55619. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55620. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  55621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55624. * @param name defines the name of the mesh
  55625. * @param options defines the options used to create the mesh
  55626. * @param scene defines the hosting scene
  55627. * @returns the icosahedron mesh
  55628. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55629. */
  55630. static CreateIcoSphere(name: string, options: {
  55631. radius?: number;
  55632. radiusX?: number;
  55633. radiusY?: number;
  55634. radiusZ?: number;
  55635. flat?: boolean;
  55636. subdivisions?: number;
  55637. sideOrientation?: number;
  55638. frontUVs?: Vector4;
  55639. backUVs?: Vector4;
  55640. updatable?: boolean;
  55641. }, scene?: Nullable<Scene>): Mesh;
  55642. /**
  55643. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55644. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55645. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55646. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55647. * * The parameter `offset` (positive integer, default : rounded half size of the pathArray length), is taken in account only if the `pathArray` is containing a single path
  55648. * * It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
  55649. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon
  55650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55652. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55653. * * The parameter `uvs` is an optional flat array of `Vector2` to update/set each ribbon vertex with its own custom UV values instead of the computed ones
  55654. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55655. * * Note that if you use the parameters `uvs` or `colors`, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you set `closePath` to `true`, there's one extra vertex per path in the geometry
  55656. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55657. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55658. * @param name defines the name of the mesh
  55659. * @param options defines the options used to create the mesh
  55660. * @param scene defines the hosting scene
  55661. * @returns the ribbon mesh
  55662. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55663. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55664. */
  55665. static CreateRibbon(name: string, options: {
  55666. pathArray: Vector3[][];
  55667. closeArray?: boolean;
  55668. closePath?: boolean;
  55669. offset?: number;
  55670. updatable?: boolean;
  55671. sideOrientation?: number;
  55672. frontUVs?: Vector4;
  55673. backUVs?: Vector4;
  55674. instance?: Mesh;
  55675. invertUV?: boolean;
  55676. uvs?: Vector2[];
  55677. colors?: Color4[];
  55678. }, scene?: Nullable<Scene>): Mesh;
  55679. /**
  55680. * Creates a cylinder or a cone mesh
  55681. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55682. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55683. * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero.
  55684. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55685. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55686. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55687. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55688. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  55689. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55690. * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).
  55691. * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
  55692. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55693. * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
  55694. * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
  55695. * * If `enclose` is false, a ring surface is one element.
  55696. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55697. * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  55698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55700. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55701. * @param name defines the name of the mesh
  55702. * @param options defines the options used to create the mesh
  55703. * @param scene defines the hosting scene
  55704. * @returns the cylinder mesh
  55705. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55706. */
  55707. static CreateCylinder(name: string, options: {
  55708. height?: number;
  55709. diameterTop?: number;
  55710. diameterBottom?: number;
  55711. diameter?: number;
  55712. tessellation?: number;
  55713. subdivisions?: number;
  55714. arc?: number;
  55715. faceColors?: Color4[];
  55716. faceUV?: Vector4[];
  55717. updatable?: boolean;
  55718. hasRings?: boolean;
  55719. enclose?: boolean;
  55720. cap?: number;
  55721. sideOrientation?: number;
  55722. frontUVs?: Vector4;
  55723. backUVs?: Vector4;
  55724. }, scene?: Nullable<Scene>): Mesh;
  55725. /**
  55726. * Creates a torus mesh
  55727. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55728. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55729. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55733. * @param name defines the name of the mesh
  55734. * @param options defines the options used to create the mesh
  55735. * @param scene defines the hosting scene
  55736. * @returns the torus mesh
  55737. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55738. */
  55739. static CreateTorus(name: string, options: {
  55740. diameter?: number;
  55741. thickness?: number;
  55742. tessellation?: number;
  55743. updatable?: boolean;
  55744. sideOrientation?: number;
  55745. frontUVs?: Vector4;
  55746. backUVs?: Vector4;
  55747. }, scene?: Nullable<Scene>): Mesh;
  55748. /**
  55749. * Creates a torus knot mesh
  55750. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55751. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55752. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55753. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55757. * @param name defines the name of the mesh
  55758. * @param options defines the options used to create the mesh
  55759. * @param scene defines the hosting scene
  55760. * @returns the torus knot mesh
  55761. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55762. */
  55763. static CreateTorusKnot(name: string, options: {
  55764. radius?: number;
  55765. tube?: number;
  55766. radialSegments?: number;
  55767. tubularSegments?: number;
  55768. p?: number;
  55769. q?: number;
  55770. updatable?: boolean;
  55771. sideOrientation?: number;
  55772. frontUVs?: Vector4;
  55773. backUVs?: Vector4;
  55774. }, scene?: Nullable<Scene>): Mesh;
  55775. /**
  55776. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55777. * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
  55778. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55779. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55780. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55781. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55782. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55783. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  55784. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55786. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55787. * @param name defines the name of the new line system
  55788. * @param options defines the options used to create the line system
  55789. * @param scene defines the hosting scene
  55790. * @returns a new line system mesh
  55791. */
  55792. static CreateLineSystem(name: string, options: {
  55793. lines: Vector3[][];
  55794. updatable?: boolean;
  55795. instance?: Nullable<LinesMesh>;
  55796. colors?: Nullable<Color4[][]>;
  55797. useVertexAlpha?: boolean;
  55798. }, scene: Nullable<Scene>): LinesMesh;
  55799. /**
  55800. * Creates a line mesh
  55801. * A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  55802. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55803. * * The parameter `points` is an array successive Vector3
  55804. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  55805. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55806. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55807. * * When updating an instance, remember that only point positions can change, not the number of points
  55808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55809. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55810. * @param name defines the name of the new line system
  55811. * @param options defines the options used to create the line system
  55812. * @param scene defines the hosting scene
  55813. * @returns a new line mesh
  55814. */
  55815. static CreateLines(name: string, options: {
  55816. points: Vector3[];
  55817. updatable?: boolean;
  55818. instance?: Nullable<LinesMesh>;
  55819. colors?: Color4[];
  55820. useVertexAlpha?: boolean;
  55821. }, scene?: Nullable<Scene>): LinesMesh;
  55822. /**
  55823. * Creates a dashed line mesh
  55824. * * A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
  55825. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55826. * * The parameter `points` is an array successive Vector3
  55827. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55828. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55829. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55830. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
  55831. * * When updating an instance, remember that only point positions can change, not the number of points
  55832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55833. * @param name defines the name of the mesh
  55834. * @param options defines the options used to create the mesh
  55835. * @param scene defines the hosting scene
  55836. * @returns the dashed line mesh
  55837. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55838. */
  55839. static CreateDashedLines(name: string, options: {
  55840. points: Vector3[];
  55841. dashSize?: number;
  55842. gapSize?: number;
  55843. dashNb?: number;
  55844. updatable?: boolean;
  55845. instance?: LinesMesh;
  55846. }, scene?: Nullable<Scene>): LinesMesh;
  55847. /**
  55848. * Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55849. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  55850. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55851. * * The parameter `rotation` (float, default 0 radians) is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve.
  55852. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55853. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  55854. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  55855. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55858. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55860. * @param name defines the name of the mesh
  55861. * @param options defines the options used to create the mesh
  55862. * @param scene defines the hosting scene
  55863. * @returns the extruded shape mesh
  55864. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55865. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55866. */
  55867. static ExtrudeShape(name: string, options: {
  55868. shape: Vector3[];
  55869. path: Vector3[];
  55870. scale?: number;
  55871. rotation?: number;
  55872. cap?: number;
  55873. updatable?: boolean;
  55874. sideOrientation?: number;
  55875. frontUVs?: Vector4;
  55876. backUVs?: Vector4;
  55877. instance?: Mesh;
  55878. invertUV?: boolean;
  55879. }, scene?: Nullable<Scene>): Mesh;
  55880. /**
  55881. * Creates an custom extruded shape mesh.
  55882. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55883. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  55884. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55885. * * The parameter `rotationFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  55886. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55887. * * The parameter `scaleFunction` (JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path
  55888. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55889. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55890. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55891. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  55892. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  55893. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55896. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55898. * @param name defines the name of the mesh
  55899. * @param options defines the options used to create the mesh
  55900. * @param scene defines the hosting scene
  55901. * @returns the custom extruded shape mesh
  55902. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55903. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55905. */
  55906. static ExtrudeShapeCustom(name: string, options: {
  55907. shape: Vector3[];
  55908. path: Vector3[];
  55909. scaleFunction?: any;
  55910. rotationFunction?: any;
  55911. ribbonCloseArray?: boolean;
  55912. ribbonClosePath?: boolean;
  55913. cap?: number;
  55914. updatable?: boolean;
  55915. sideOrientation?: number;
  55916. frontUVs?: Vector4;
  55917. backUVs?: Vector4;
  55918. instance?: Mesh;
  55919. invertUV?: boolean;
  55920. }, scene?: Nullable<Scene>): Mesh;
  55921. /**
  55922. * Creates lathe mesh.
  55923. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55924. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  55925. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55926. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55927. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55928. * * The parameter `arc` (positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape
  55929. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55930. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  55931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55932. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55933. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55934. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55935. * @param name defines the name of the mesh
  55936. * @param options defines the options used to create the mesh
  55937. * @param scene defines the hosting scene
  55938. * @returns the lathe mesh
  55939. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55940. */
  55941. static CreateLathe(name: string, options: {
  55942. shape: Vector3[];
  55943. radius?: number;
  55944. tessellation?: number;
  55945. clip?: number;
  55946. arc?: number;
  55947. closed?: boolean;
  55948. updatable?: boolean;
  55949. sideOrientation?: number;
  55950. frontUVs?: Vector4;
  55951. backUVs?: Vector4;
  55952. cap?: number;
  55953. invertUV?: boolean;
  55954. }, scene?: Nullable<Scene>): Mesh;
  55955. /**
  55956. * Creates a tiled plane mesh
  55957. * * You can set a limited pattern arrangement with the tiles
  55958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55961. * @param name defines the name of the mesh
  55962. * @param options defines the options used to create the mesh
  55963. * @param scene defines the hosting scene
  55964. * @returns the plane mesh
  55965. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55966. */
  55967. static CreateTiledPlane(name: string, options: {
  55968. pattern?: number;
  55969. tileSize?: number;
  55970. tileWidth?: number;
  55971. tileHeight?: number;
  55972. size?: number;
  55973. width?: number;
  55974. height?: number;
  55975. alignHorizontal?: number;
  55976. alignVertical?: number;
  55977. sideOrientation?: number;
  55978. frontUVs?: Vector4;
  55979. backUVs?: Vector4;
  55980. updatable?: boolean;
  55981. }, scene?: Nullable<Scene>): Mesh;
  55982. /**
  55983. * Creates a plane mesh
  55984. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55985. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55986. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55988. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55990. * @param name defines the name of the mesh
  55991. * @param options defines the options used to create the mesh
  55992. * @param scene defines the hosting scene
  55993. * @returns the plane mesh
  55994. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55995. */
  55996. static CreatePlane(name: string, options: {
  55997. size?: number;
  55998. width?: number;
  55999. height?: number;
  56000. sideOrientation?: number;
  56001. frontUVs?: Vector4;
  56002. backUVs?: Vector4;
  56003. updatable?: boolean;
  56004. sourcePlane?: Plane;
  56005. }, scene?: Nullable<Scene>): Mesh;
  56006. /**
  56007. * Creates a ground mesh
  56008. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56009. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56011. * @param name defines the name of the mesh
  56012. * @param options defines the options used to create the mesh
  56013. * @param scene defines the hosting scene
  56014. * @returns the ground mesh
  56015. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56016. */
  56017. static CreateGround(name: string, options: {
  56018. width?: number;
  56019. height?: number;
  56020. subdivisions?: number;
  56021. subdivisionsX?: number;
  56022. subdivisionsY?: number;
  56023. updatable?: boolean;
  56024. }, scene?: Nullable<Scene>): Mesh;
  56025. /**
  56026. * Creates a tiled ground mesh
  56027. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56028. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56029. * * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  56030. * * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  56031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56032. * @param name defines the name of the mesh
  56033. * @param options defines the options used to create the mesh
  56034. * @param scene defines the hosting scene
  56035. * @returns the tiled ground mesh
  56036. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56037. */
  56038. static CreateTiledGround(name: string, options: {
  56039. xmin: number;
  56040. zmin: number;
  56041. xmax: number;
  56042. zmax: number;
  56043. subdivisions?: {
  56044. w: number;
  56045. h: number;
  56046. };
  56047. precision?: {
  56048. w: number;
  56049. h: number;
  56050. };
  56051. updatable?: boolean;
  56052. }, scene?: Nullable<Scene>): Mesh;
  56053. /**
  56054. * Creates a ground mesh from a height map
  56055. * * The parameter `url` sets the URL of the height map image resource.
  56056. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56057. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56058. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56059. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56060. * * The parameter `colorFilter` (optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height.
  56061. * * The parameter `onReady` is a javascript callback function that will be called once the mesh is just built (the height map download can last some time).
  56062. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56064. * @param name defines the name of the mesh
  56065. * @param url defines the url to the height map
  56066. * @param options defines the options used to create the mesh
  56067. * @param scene defines the hosting scene
  56068. * @returns the ground mesh
  56069. * @see https://doc.babylonjs.com/babylon101/height_map
  56070. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56071. */
  56072. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56073. width?: number;
  56074. height?: number;
  56075. subdivisions?: number;
  56076. minHeight?: number;
  56077. maxHeight?: number;
  56078. colorFilter?: Color3;
  56079. alphaFilter?: number;
  56080. updatable?: boolean;
  56081. onReady?: (mesh: GroundMesh) => void;
  56082. }, scene?: Nullable<Scene>): GroundMesh;
  56083. /**
  56084. * Creates a polygon mesh
  56085. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56086. * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  56087. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56090. * * Remember you can only change the shape positions, not their number when updating a polygon
  56091. * @param name defines the name of the mesh
  56092. * @param options defines the options used to create the mesh
  56093. * @param scene defines the hosting scene
  56094. * @param earcutInjection can be used to inject your own earcut reference
  56095. * @returns the polygon mesh
  56096. */
  56097. static CreatePolygon(name: string, options: {
  56098. shape: Vector3[];
  56099. holes?: Vector3[][];
  56100. depth?: number;
  56101. faceUV?: Vector4[];
  56102. faceColors?: Color4[];
  56103. updatable?: boolean;
  56104. sideOrientation?: number;
  56105. frontUVs?: Vector4;
  56106. backUVs?: Vector4;
  56107. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56108. /**
  56109. * Creates an extruded polygon mesh, with depth in the Y direction.
  56110. * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
  56111. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56112. * @param name defines the name of the mesh
  56113. * @param options defines the options used to create the mesh
  56114. * @param scene defines the hosting scene
  56115. * @param earcutInjection can be used to inject your own earcut reference
  56116. * @returns the polygon mesh
  56117. */
  56118. static ExtrudePolygon(name: string, options: {
  56119. shape: Vector3[];
  56120. holes?: Vector3[][];
  56121. depth?: number;
  56122. faceUV?: Vector4[];
  56123. faceColors?: Color4[];
  56124. updatable?: boolean;
  56125. sideOrientation?: number;
  56126. frontUVs?: Vector4;
  56127. backUVs?: Vector4;
  56128. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56129. /**
  56130. * Creates a tube mesh.
  56131. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56132. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56133. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56134. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56135. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56136. * * This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float)
  56137. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56138. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  56139. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube
  56140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56142. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56144. * @param name defines the name of the mesh
  56145. * @param options defines the options used to create the mesh
  56146. * @param scene defines the hosting scene
  56147. * @returns the tube mesh
  56148. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56149. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56150. */
  56151. static CreateTube(name: string, options: {
  56152. path: Vector3[];
  56153. radius?: number;
  56154. tessellation?: number;
  56155. radiusFunction?: {
  56156. (i: number, distance: number): number;
  56157. };
  56158. cap?: number;
  56159. arc?: number;
  56160. updatable?: boolean;
  56161. sideOrientation?: number;
  56162. frontUVs?: Vector4;
  56163. backUVs?: Vector4;
  56164. instance?: Mesh;
  56165. invertUV?: boolean;
  56166. }, scene?: Nullable<Scene>): Mesh;
  56167. /**
  56168. * Creates a polyhedron mesh
  56169. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  56170. * * The parameter `size` (positive float, default 1) sets the polygon size
  56171. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56172. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  56173. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  56174. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  56175. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56176. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  56177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56178. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56180. * @param name defines the name of the mesh
  56181. * @param options defines the options used to create the mesh
  56182. * @param scene defines the hosting scene
  56183. * @returns the polyhedron mesh
  56184. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56185. */
  56186. static CreatePolyhedron(name: string, options: {
  56187. type?: number;
  56188. size?: number;
  56189. sizeX?: number;
  56190. sizeY?: number;
  56191. sizeZ?: number;
  56192. custom?: any;
  56193. faceUV?: Vector4[];
  56194. faceColors?: Color4[];
  56195. flat?: boolean;
  56196. updatable?: boolean;
  56197. sideOrientation?: number;
  56198. frontUVs?: Vector4;
  56199. backUVs?: Vector4;
  56200. }, scene?: Nullable<Scene>): Mesh;
  56201. /**
  56202. * Creates a decal mesh.
  56203. * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
  56204. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56205. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56206. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56207. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56208. * @param name defines the name of the mesh
  56209. * @param sourceMesh defines the mesh where the decal must be applied
  56210. * @param options defines the options used to create the mesh
  56211. * @param scene defines the hosting scene
  56212. * @returns the decal mesh
  56213. * @see https://doc.babylonjs.com/how_to/decals
  56214. */
  56215. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56216. position?: Vector3;
  56217. normal?: Vector3;
  56218. size?: Vector3;
  56219. angle?: number;
  56220. }): Mesh;
  56221. }
  56222. }
  56223. declare module BABYLON {
  56224. /**
  56225. * A simplifier interface for future simplification implementations
  56226. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56227. */
  56228. export interface ISimplifier {
  56229. /**
  56230. * Simplification of a given mesh according to the given settings.
  56231. * Since this requires computation, it is assumed that the function runs async.
  56232. * @param settings The settings of the simplification, including quality and distance
  56233. * @param successCallback A callback that will be called after the mesh was simplified.
  56234. * @param errorCallback in case of an error, this callback will be called. optional.
  56235. */
  56236. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56237. }
  56238. /**
  56239. * Expected simplification settings.
  56240. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56241. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56242. */
  56243. export interface ISimplificationSettings {
  56244. /**
  56245. * Gets or sets the expected quality
  56246. */
  56247. quality: number;
  56248. /**
  56249. * Gets or sets the distance when this optimized version should be used
  56250. */
  56251. distance: number;
  56252. /**
  56253. * Gets an already optimized mesh
  56254. */
  56255. optimizeMesh?: boolean;
  56256. }
  56257. /**
  56258. * Class used to specify simplification options
  56259. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56260. */
  56261. export class SimplificationSettings implements ISimplificationSettings {
  56262. /** expected quality */
  56263. quality: number;
  56264. /** distance when this optimized version should be used */
  56265. distance: number;
  56266. /** already optimized mesh */
  56267. optimizeMesh?: boolean | undefined;
  56268. /**
  56269. * Creates a SimplificationSettings
  56270. * @param quality expected quality
  56271. * @param distance distance when this optimized version should be used
  56272. * @param optimizeMesh already optimized mesh
  56273. */
  56274. constructor(
  56275. /** expected quality */
  56276. quality: number,
  56277. /** distance when this optimized version should be used */
  56278. distance: number,
  56279. /** already optimized mesh */
  56280. optimizeMesh?: boolean | undefined);
  56281. }
  56282. /**
  56283. * Interface used to define a simplification task
  56284. */
  56285. export interface ISimplificationTask {
  56286. /**
  56287. * Array of settings
  56288. */
  56289. settings: Array<ISimplificationSettings>;
  56290. /**
  56291. * Simplification type
  56292. */
  56293. simplificationType: SimplificationType;
  56294. /**
  56295. * Mesh to simplify
  56296. */
  56297. mesh: Mesh;
  56298. /**
  56299. * Callback called on success
  56300. */
  56301. successCallback?: () => void;
  56302. /**
  56303. * Defines if parallel processing can be used
  56304. */
  56305. parallelProcessing: boolean;
  56306. }
  56307. /**
  56308. * Queue used to order the simplification tasks
  56309. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56310. */
  56311. export class SimplificationQueue {
  56312. private _simplificationArray;
  56313. /**
  56314. * Gets a boolean indicating that the process is still running
  56315. */
  56316. running: boolean;
  56317. /**
  56318. * Creates a new queue
  56319. */
  56320. constructor();
  56321. /**
  56322. * Adds a new simplification task
  56323. * @param task defines a task to add
  56324. */
  56325. addTask(task: ISimplificationTask): void;
  56326. /**
  56327. * Execute next task
  56328. */
  56329. executeNext(): void;
  56330. /**
  56331. * Execute a simplification task
  56332. * @param task defines the task to run
  56333. */
  56334. runSimplification(task: ISimplificationTask): void;
  56335. private getSimplifier;
  56336. }
  56337. /**
  56338. * The implemented types of simplification
  56339. * At the moment only Quadratic Error Decimation is implemented
  56340. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56341. */
  56342. export enum SimplificationType {
  56343. /** Quadratic error decimation */
  56344. QUADRATIC = 0
  56345. }
  56346. }
  56347. declare module BABYLON {
  56348. interface Scene {
  56349. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  56350. /**
  56351. * Gets or sets the simplification queue attached to the scene
  56352. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56353. */
  56354. simplificationQueue: SimplificationQueue;
  56355. }
  56356. interface Mesh {
  56357. /**
  56358. * Simplify the mesh according to the given array of settings.
  56359. * Function will return immediately and will simplify async
  56360. * @param settings a collection of simplification settings
  56361. * @param parallelProcessing should all levels calculate parallel or one after the other
  56362. * @param simplificationType the type of simplification to run
  56363. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56364. * @returns the current mesh
  56365. */
  56366. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56367. }
  56368. /**
  56369. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56370. * created in a scene
  56371. */
  56372. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56373. /**
  56374. * The component name helpfull to identify the component in the list of scene components.
  56375. */
  56376. readonly name: string;
  56377. /**
  56378. * The scene the component belongs to.
  56379. */
  56380. scene: Scene;
  56381. /**
  56382. * Creates a new instance of the component for the given scene
  56383. * @param scene Defines the scene to register the component in
  56384. */
  56385. constructor(scene: Scene);
  56386. /**
  56387. * Registers the component in a given scene
  56388. */
  56389. register(): void;
  56390. /**
  56391. * Rebuilds the elements related to this component in case of
  56392. * context lost for instance.
  56393. */
  56394. rebuild(): void;
  56395. /**
  56396. * Disposes the component and the associated ressources
  56397. */
  56398. dispose(): void;
  56399. private _beforeCameraUpdate;
  56400. }
  56401. }
  56402. declare module BABYLON {
  56403. /**
  56404. * Navigation plugin interface to add navigation constrained by a navigation mesh
  56405. */
  56406. export interface INavigationEnginePlugin {
  56407. /**
  56408. * plugin name
  56409. */
  56410. name: string;
  56411. /**
  56412. * Creates a navigation mesh
  56413. * @param meshes array of all the geometry used to compute the navigatio mesh
  56414. * @param parameters bunch of parameters used to filter geometry
  56415. */
  56416. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56417. /**
  56418. * Create a navigation mesh debug mesh
  56419. * @param scene is where the mesh will be added
  56420. * @returns debug display mesh
  56421. */
  56422. createDebugNavMesh(scene: Scene): Mesh;
  56423. /**
  56424. * Get a navigation mesh constrained position, closest to the parameter position
  56425. * @param position world position
  56426. * @returns the closest point to position constrained by the navigation mesh
  56427. */
  56428. getClosestPoint(position: Vector3): Vector3;
  56429. /**
  56430. * Get a navigation mesh constrained position, within a particular radius
  56431. * @param position world position
  56432. * @param maxRadius the maximum distance to the constrained world position
  56433. * @returns the closest point to position constrained by the navigation mesh
  56434. */
  56435. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56436. /**
  56437. * Compute the final position from a segment made of destination-position
  56438. * @param position world position
  56439. * @param destination world position
  56440. * @returns the resulting point along the navmesh
  56441. */
  56442. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56443. /**
  56444. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56445. * @param start world position
  56446. * @param end world position
  56447. * @returns array containing world position composing the path
  56448. */
  56449. computePath(start: Vector3, end: Vector3): Vector3[];
  56450. /**
  56451. * If this plugin is supported
  56452. * @returns true if plugin is supported
  56453. */
  56454. isSupported(): boolean;
  56455. /**
  56456. * Create a new Crowd so you can add agents
  56457. * @param maxAgents the maximum agent count in the crowd
  56458. * @param maxAgentRadius the maximum radius an agent can have
  56459. * @param scene to attach the crowd to
  56460. * @returns the crowd you can add agents to
  56461. */
  56462. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56463. /**
  56464. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56465. * The queries will try to find a solution within those bounds
  56466. * default is (1,1,1)
  56467. * @param extent x,y,z value that define the extent around the queries point of reference
  56468. */
  56469. setDefaultQueryExtent(extent: Vector3): void;
  56470. /**
  56471. * Get the Bounding box extent specified by setDefaultQueryExtent
  56472. * @returns the box extent values
  56473. */
  56474. getDefaultQueryExtent(): Vector3;
  56475. /**
  56476. * Release all resources
  56477. */
  56478. dispose(): void;
  56479. }
  56480. /**
  56481. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  56482. */
  56483. export interface ICrowd {
  56484. /**
  56485. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56486. * You can attach anything to that node. The node position is updated in the scene update tick.
  56487. * @param pos world position that will be constrained by the navigation mesh
  56488. * @param parameters agent parameters
  56489. * @param transform hooked to the agent that will be update by the scene
  56490. * @returns agent index
  56491. */
  56492. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56493. /**
  56494. * Returns the agent position in world space
  56495. * @param index agent index returned by addAgent
  56496. * @returns world space position
  56497. */
  56498. getAgentPosition(index: number): Vector3;
  56499. /**
  56500. * Gets the agent velocity in world space
  56501. * @param index agent index returned by addAgent
  56502. * @returns world space velocity
  56503. */
  56504. getAgentVelocity(index: number): Vector3;
  56505. /**
  56506. * remove a particular agent previously created
  56507. * @param index agent index returned by addAgent
  56508. */
  56509. removeAgent(index: number): void;
  56510. /**
  56511. * get the list of all agents attached to this crowd
  56512. * @returns list of agent indices
  56513. */
  56514. getAgents(): number[];
  56515. /**
  56516. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56517. * @param deltaTime in seconds
  56518. */
  56519. update(deltaTime: number): void;
  56520. /**
  56521. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56522. * @param index agent index returned by addAgent
  56523. * @param destination targeted world position
  56524. */
  56525. agentGoto(index: number, destination: Vector3): void;
  56526. /**
  56527. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56528. * The queries will try to find a solution within those bounds
  56529. * default is (1,1,1)
  56530. * @param extent x,y,z value that define the extent around the queries point of reference
  56531. */
  56532. setDefaultQueryExtent(extent: Vector3): void;
  56533. /**
  56534. * Get the Bounding box extent specified by setDefaultQueryExtent
  56535. * @returns the box extent values
  56536. */
  56537. getDefaultQueryExtent(): Vector3;
  56538. /**
  56539. * Release all resources
  56540. */
  56541. dispose(): void;
  56542. }
  56543. /**
  56544. * Configures an agent
  56545. */
  56546. export interface IAgentParameters {
  56547. /**
  56548. * Agent radius. [Limit: >= 0]
  56549. */
  56550. radius: number;
  56551. /**
  56552. * Agent height. [Limit: > 0]
  56553. */
  56554. height: number;
  56555. /**
  56556. * Maximum allowed acceleration. [Limit: >= 0]
  56557. */
  56558. maxAcceleration: number;
  56559. /**
  56560. * Maximum allowed speed. [Limit: >= 0]
  56561. */
  56562. maxSpeed: number;
  56563. /**
  56564. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  56565. */
  56566. collisionQueryRange: number;
  56567. /**
  56568. * The path visibility optimization range. [Limit: > 0]
  56569. */
  56570. pathOptimizationRange: number;
  56571. /**
  56572. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  56573. */
  56574. separationWeight: number;
  56575. }
  56576. /**
  56577. * Configures the navigation mesh creation
  56578. */
  56579. export interface INavMeshParameters {
  56580. /**
  56581. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  56582. */
  56583. cs: number;
  56584. /**
  56585. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  56586. */
  56587. ch: number;
  56588. /**
  56589. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  56590. */
  56591. walkableSlopeAngle: number;
  56592. /**
  56593. * Minimum floor to 'ceiling' height that will still allow the floor area to
  56594. * be considered walkable. [Limit: >= 3] [Units: vx]
  56595. */
  56596. walkableHeight: number;
  56597. /**
  56598. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  56599. */
  56600. walkableClimb: number;
  56601. /**
  56602. * The distance to erode/shrink the walkable area of the heightfield away from
  56603. * obstructions. [Limit: >=0] [Units: vx]
  56604. */
  56605. walkableRadius: number;
  56606. /**
  56607. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  56608. */
  56609. maxEdgeLen: number;
  56610. /**
  56611. * The maximum distance a simplfied contour's border edges should deviate
  56612. * the original raw contour. [Limit: >=0] [Units: vx]
  56613. */
  56614. maxSimplificationError: number;
  56615. /**
  56616. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  56617. */
  56618. minRegionArea: number;
  56619. /**
  56620. * Any regions with a span count smaller than this value will, if possible,
  56621. * be merged with larger regions. [Limit: >=0] [Units: vx]
  56622. */
  56623. mergeRegionArea: number;
  56624. /**
  56625. * The maximum number of vertices allowed for polygons generated during the
  56626. * contour to polygon conversion process. [Limit: >= 3]
  56627. */
  56628. maxVertsPerPoly: number;
  56629. /**
  56630. * Sets the sampling distance to use when generating the detail mesh.
  56631. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  56632. */
  56633. detailSampleDist: number;
  56634. /**
  56635. * The maximum distance the detail mesh surface should deviate from heightfield
  56636. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  56637. */
  56638. detailSampleMaxError: number;
  56639. }
  56640. }
  56641. declare module BABYLON {
  56642. /**
  56643. * RecastJS navigation plugin
  56644. */
  56645. export class RecastJSPlugin implements INavigationEnginePlugin {
  56646. /**
  56647. * Reference to the Recast library
  56648. */
  56649. bjsRECAST: any;
  56650. /**
  56651. * plugin name
  56652. */
  56653. name: string;
  56654. /**
  56655. * the first navmesh created. We might extend this to support multiple navmeshes
  56656. */
  56657. navMesh: any;
  56658. /**
  56659. * Initializes the recastJS plugin
  56660. * @param recastInjection can be used to inject your own recast reference
  56661. */
  56662. constructor(recastInjection?: any);
  56663. /**
  56664. * Creates a navigation mesh
  56665. * @param meshes array of all the geometry used to compute the navigatio mesh
  56666. * @param parameters bunch of parameters used to filter geometry
  56667. */
  56668. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  56669. /**
  56670. * Create a navigation mesh debug mesh
  56671. * @param scene is where the mesh will be added
  56672. * @returns debug display mesh
  56673. */
  56674. createDebugNavMesh(scene: Scene): Mesh;
  56675. /**
  56676. * Get a navigation mesh constrained position, closest to the parameter position
  56677. * @param position world position
  56678. * @returns the closest point to position constrained by the navigation mesh
  56679. */
  56680. getClosestPoint(position: Vector3): Vector3;
  56681. /**
  56682. * Get a navigation mesh constrained position, within a particular radius
  56683. * @param position world position
  56684. * @param maxRadius the maximum distance to the constrained world position
  56685. * @returns the closest point to position constrained by the navigation mesh
  56686. */
  56687. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  56688. /**
  56689. * Compute the final position from a segment made of destination-position
  56690. * @param position world position
  56691. * @param destination world position
  56692. * @returns the resulting point along the navmesh
  56693. */
  56694. moveAlong(position: Vector3, destination: Vector3): Vector3;
  56695. /**
  56696. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  56697. * @param start world position
  56698. * @param end world position
  56699. * @returns array containing world position composing the path
  56700. */
  56701. computePath(start: Vector3, end: Vector3): Vector3[];
  56702. /**
  56703. * Create a new Crowd so you can add agents
  56704. * @param maxAgents the maximum agent count in the crowd
  56705. * @param maxAgentRadius the maximum radius an agent can have
  56706. * @param scene to attach the crowd to
  56707. * @returns the crowd you can add agents to
  56708. */
  56709. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  56710. /**
  56711. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56712. * The queries will try to find a solution within those bounds
  56713. * default is (1,1,1)
  56714. * @param extent x,y,z value that define the extent around the queries point of reference
  56715. */
  56716. setDefaultQueryExtent(extent: Vector3): void;
  56717. /**
  56718. * Get the Bounding box extent specified by setDefaultQueryExtent
  56719. * @returns the box extent values
  56720. */
  56721. getDefaultQueryExtent(): Vector3;
  56722. /**
  56723. * Disposes
  56724. */
  56725. dispose(): void;
  56726. /**
  56727. * If this plugin is supported
  56728. * @returns true if plugin is supported
  56729. */
  56730. isSupported(): boolean;
  56731. }
  56732. /**
  56733. * Recast detour crowd implementation
  56734. */
  56735. export class RecastJSCrowd implements ICrowd {
  56736. /**
  56737. * Recast/detour plugin
  56738. */
  56739. bjsRECASTPlugin: RecastJSPlugin;
  56740. /**
  56741. * Link to the detour crowd
  56742. */
  56743. recastCrowd: any;
  56744. /**
  56745. * One transform per agent
  56746. */
  56747. transforms: TransformNode[];
  56748. /**
  56749. * All agents created
  56750. */
  56751. agents: number[];
  56752. /**
  56753. * Link to the scene is kept to unregister the crowd from the scene
  56754. */
  56755. private _scene;
  56756. /**
  56757. * Observer for crowd updates
  56758. */
  56759. private _onBeforeAnimationsObserver;
  56760. /**
  56761. * Constructor
  56762. * @param plugin recastJS plugin
  56763. * @param maxAgents the maximum agent count in the crowd
  56764. * @param maxAgentRadius the maximum radius an agent can have
  56765. * @param scene to attach the crowd to
  56766. * @returns the crowd you can add agents to
  56767. */
  56768. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  56769. /**
  56770. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  56771. * You can attach anything to that node. The node position is updated in the scene update tick.
  56772. * @param pos world position that will be constrained by the navigation mesh
  56773. * @param parameters agent parameters
  56774. * @param transform hooked to the agent that will be update by the scene
  56775. * @returns agent index
  56776. */
  56777. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  56778. /**
  56779. * Returns the agent position in world space
  56780. * @param index agent index returned by addAgent
  56781. * @returns world space position
  56782. */
  56783. getAgentPosition(index: number): Vector3;
  56784. /**
  56785. * Returns the agent velocity in world space
  56786. * @param index agent index returned by addAgent
  56787. * @returns world space velocity
  56788. */
  56789. getAgentVelocity(index: number): Vector3;
  56790. /**
  56791. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  56792. * @param index agent index returned by addAgent
  56793. * @param destination targeted world position
  56794. */
  56795. agentGoto(index: number, destination: Vector3): void;
  56796. /**
  56797. * remove a particular agent previously created
  56798. * @param index agent index returned by addAgent
  56799. */
  56800. removeAgent(index: number): void;
  56801. /**
  56802. * get the list of all agents attached to this crowd
  56803. * @returns list of agent indices
  56804. */
  56805. getAgents(): number[];
  56806. /**
  56807. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  56808. * @param deltaTime in seconds
  56809. */
  56810. update(deltaTime: number): void;
  56811. /**
  56812. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  56813. * The queries will try to find a solution within those bounds
  56814. * default is (1,1,1)
  56815. * @param extent x,y,z value that define the extent around the queries point of reference
  56816. */
  56817. setDefaultQueryExtent(extent: Vector3): void;
  56818. /**
  56819. * Get the Bounding box extent specified by setDefaultQueryExtent
  56820. * @returns the box extent values
  56821. */
  56822. getDefaultQueryExtent(): Vector3;
  56823. /**
  56824. * Release all resources
  56825. */
  56826. dispose(): void;
  56827. }
  56828. }
  56829. declare module BABYLON {
  56830. /**
  56831. * Class used to enable access to IndexedDB
  56832. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56833. */
  56834. export class Database implements IOfflineProvider {
  56835. private _callbackManifestChecked;
  56836. private _currentSceneUrl;
  56837. private _db;
  56838. private _enableSceneOffline;
  56839. private _enableTexturesOffline;
  56840. private _manifestVersionFound;
  56841. private _mustUpdateRessources;
  56842. private _hasReachedQuota;
  56843. private _isSupported;
  56844. private _idbFactory;
  56845. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56846. private static IsUASupportingBlobStorage;
  56847. /**
  56848. * Gets a boolean indicating if Database storate is enabled (off by default)
  56849. */
  56850. static IDBStorageEnabled: boolean;
  56851. /**
  56852. * Gets a boolean indicating if scene must be saved in the database
  56853. */
  56854. readonly enableSceneOffline: boolean;
  56855. /**
  56856. * Gets a boolean indicating if textures must be saved in the database
  56857. */
  56858. readonly enableTexturesOffline: boolean;
  56859. /**
  56860. * Creates a new Database
  56861. * @param urlToScene defines the url to load the scene
  56862. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56863. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56864. */
  56865. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56866. private static _ParseURL;
  56867. private static _ReturnFullUrlLocation;
  56868. private _checkManifestFile;
  56869. /**
  56870. * Open the database and make it available
  56871. * @param successCallback defines the callback to call on success
  56872. * @param errorCallback defines the callback to call on error
  56873. */
  56874. open(successCallback: () => void, errorCallback: () => void): void;
  56875. /**
  56876. * Loads an image from the database
  56877. * @param url defines the url to load from
  56878. * @param image defines the target DOM image
  56879. */
  56880. loadImage(url: string, image: HTMLImageElement): void;
  56881. private _loadImageFromDBAsync;
  56882. private _saveImageIntoDBAsync;
  56883. private _checkVersionFromDB;
  56884. private _loadVersionFromDBAsync;
  56885. private _saveVersionIntoDBAsync;
  56886. /**
  56887. * Loads a file from database
  56888. * @param url defines the URL to load from
  56889. * @param sceneLoaded defines a callback to call on success
  56890. * @param progressCallBack defines a callback to call when progress changed
  56891. * @param errorCallback defines a callback to call on error
  56892. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56893. */
  56894. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56895. private _loadFileAsync;
  56896. private _saveFileAsync;
  56897. /**
  56898. * Validates if xhr data is correct
  56899. * @param xhr defines the request to validate
  56900. * @param dataType defines the expected data type
  56901. * @returns true if data is correct
  56902. */
  56903. private static _ValidateXHRData;
  56904. }
  56905. }
  56906. declare module BABYLON {
  56907. /** @hidden */
  56908. export var gpuUpdateParticlesPixelShader: {
  56909. name: string;
  56910. shader: string;
  56911. };
  56912. }
  56913. declare module BABYLON {
  56914. /** @hidden */
  56915. export var gpuUpdateParticlesVertexShader: {
  56916. name: string;
  56917. shader: string;
  56918. };
  56919. }
  56920. declare module BABYLON {
  56921. /** @hidden */
  56922. export var clipPlaneFragmentDeclaration2: {
  56923. name: string;
  56924. shader: string;
  56925. };
  56926. }
  56927. declare module BABYLON {
  56928. /** @hidden */
  56929. export var gpuRenderParticlesPixelShader: {
  56930. name: string;
  56931. shader: string;
  56932. };
  56933. }
  56934. declare module BABYLON {
  56935. /** @hidden */
  56936. export var clipPlaneVertexDeclaration2: {
  56937. name: string;
  56938. shader: string;
  56939. };
  56940. }
  56941. declare module BABYLON {
  56942. /** @hidden */
  56943. export var gpuRenderParticlesVertexShader: {
  56944. name: string;
  56945. shader: string;
  56946. };
  56947. }
  56948. declare module BABYLON {
  56949. /**
  56950. * This represents a GPU particle system in Babylon
  56951. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56952. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56953. */
  56954. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56955. /**
  56956. * The layer mask we are rendering the particles through.
  56957. */
  56958. layerMask: number;
  56959. private _capacity;
  56960. private _activeCount;
  56961. private _currentActiveCount;
  56962. private _accumulatedCount;
  56963. private _renderEffect;
  56964. private _updateEffect;
  56965. private _buffer0;
  56966. private _buffer1;
  56967. private _spriteBuffer;
  56968. private _updateVAO;
  56969. private _renderVAO;
  56970. private _targetIndex;
  56971. private _sourceBuffer;
  56972. private _targetBuffer;
  56973. private _engine;
  56974. private _currentRenderId;
  56975. private _started;
  56976. private _stopped;
  56977. private _timeDelta;
  56978. private _randomTexture;
  56979. private _randomTexture2;
  56980. private _attributesStrideSize;
  56981. private _updateEffectOptions;
  56982. private _randomTextureSize;
  56983. private _actualFrame;
  56984. private readonly _rawTextureWidth;
  56985. /**
  56986. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56987. */
  56988. static readonly IsSupported: boolean;
  56989. /**
  56990. * An event triggered when the system is disposed.
  56991. */
  56992. onDisposeObservable: Observable<GPUParticleSystem>;
  56993. /**
  56994. * Gets the maximum number of particles active at the same time.
  56995. * @returns The max number of active particles.
  56996. */
  56997. getCapacity(): number;
  56998. /**
  56999. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57000. * to override the particles.
  57001. */
  57002. forceDepthWrite: boolean;
  57003. /**
  57004. * Gets or set the number of active particles
  57005. */
  57006. activeParticleCount: number;
  57007. private _preWarmDone;
  57008. /**
  57009. * Is this system ready to be used/rendered
  57010. * @return true if the system is ready
  57011. */
  57012. isReady(): boolean;
  57013. /**
  57014. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57015. * @returns True if it has been started, otherwise false.
  57016. */
  57017. isStarted(): boolean;
  57018. /**
  57019. * Starts the particle system and begins to emit
  57020. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57021. */
  57022. start(delay?: number): void;
  57023. /**
  57024. * Stops the particle system.
  57025. */
  57026. stop(): void;
  57027. /**
  57028. * Remove all active particles
  57029. */
  57030. reset(): void;
  57031. /**
  57032. * Returns the string "GPUParticleSystem"
  57033. * @returns a string containing the class name
  57034. */
  57035. getClassName(): string;
  57036. private _colorGradientsTexture;
  57037. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57038. /**
  57039. * Adds a new color gradient
  57040. * @param gradient defines the gradient to use (between 0 and 1)
  57041. * @param color1 defines the color to affect to the specified gradient
  57042. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57043. * @returns the current particle system
  57044. */
  57045. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57046. /**
  57047. * Remove a specific color gradient
  57048. * @param gradient defines the gradient to remove
  57049. * @returns the current particle system
  57050. */
  57051. removeColorGradient(gradient: number): GPUParticleSystem;
  57052. private _angularSpeedGradientsTexture;
  57053. private _sizeGradientsTexture;
  57054. private _velocityGradientsTexture;
  57055. private _limitVelocityGradientsTexture;
  57056. private _dragGradientsTexture;
  57057. private _addFactorGradient;
  57058. /**
  57059. * Adds a new size gradient
  57060. * @param gradient defines the gradient to use (between 0 and 1)
  57061. * @param factor defines the size factor to affect to the specified gradient
  57062. * @returns the current particle system
  57063. */
  57064. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57065. /**
  57066. * Remove a specific size gradient
  57067. * @param gradient defines the gradient to remove
  57068. * @returns the current particle system
  57069. */
  57070. removeSizeGradient(gradient: number): GPUParticleSystem;
  57071. /**
  57072. * Adds a new angular speed gradient
  57073. * @param gradient defines the gradient to use (between 0 and 1)
  57074. * @param factor defines the angular speed to affect to the specified gradient
  57075. * @returns the current particle system
  57076. */
  57077. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57078. /**
  57079. * Remove a specific angular speed gradient
  57080. * @param gradient defines the gradient to remove
  57081. * @returns the current particle system
  57082. */
  57083. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57084. /**
  57085. * Adds a new velocity gradient
  57086. * @param gradient defines the gradient to use (between 0 and 1)
  57087. * @param factor defines the velocity to affect to the specified gradient
  57088. * @returns the current particle system
  57089. */
  57090. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57091. /**
  57092. * Remove a specific velocity gradient
  57093. * @param gradient defines the gradient to remove
  57094. * @returns the current particle system
  57095. */
  57096. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57097. /**
  57098. * Adds a new limit velocity gradient
  57099. * @param gradient defines the gradient to use (between 0 and 1)
  57100. * @param factor defines the limit velocity value to affect to the specified gradient
  57101. * @returns the current particle system
  57102. */
  57103. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57104. /**
  57105. * Remove a specific limit velocity gradient
  57106. * @param gradient defines the gradient to remove
  57107. * @returns the current particle system
  57108. */
  57109. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57110. /**
  57111. * Adds a new drag gradient
  57112. * @param gradient defines the gradient to use (between 0 and 1)
  57113. * @param factor defines the drag value to affect to the specified gradient
  57114. * @returns the current particle system
  57115. */
  57116. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57117. /**
  57118. * Remove a specific drag gradient
  57119. * @param gradient defines the gradient to remove
  57120. * @returns the current particle system
  57121. */
  57122. removeDragGradient(gradient: number): GPUParticleSystem;
  57123. /**
  57124. * Not supported by GPUParticleSystem
  57125. * @param gradient defines the gradient to use (between 0 and 1)
  57126. * @param factor defines the emit rate value to affect to the specified gradient
  57127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57128. * @returns the current particle system
  57129. */
  57130. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57131. /**
  57132. * Not supported by GPUParticleSystem
  57133. * @param gradient defines the gradient to remove
  57134. * @returns the current particle system
  57135. */
  57136. removeEmitRateGradient(gradient: number): IParticleSystem;
  57137. /**
  57138. * Not supported by GPUParticleSystem
  57139. * @param gradient defines the gradient to use (between 0 and 1)
  57140. * @param factor defines the start size value to affect to the specified gradient
  57141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57142. * @returns the current particle system
  57143. */
  57144. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57145. /**
  57146. * Not supported by GPUParticleSystem
  57147. * @param gradient defines the gradient to remove
  57148. * @returns the current particle system
  57149. */
  57150. removeStartSizeGradient(gradient: number): IParticleSystem;
  57151. /**
  57152. * Not supported by GPUParticleSystem
  57153. * @param gradient defines the gradient to use (between 0 and 1)
  57154. * @param min defines the color remap minimal range
  57155. * @param max defines the color remap maximal range
  57156. * @returns the current particle system
  57157. */
  57158. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57159. /**
  57160. * Not supported by GPUParticleSystem
  57161. * @param gradient defines the gradient to remove
  57162. * @returns the current particle system
  57163. */
  57164. removeColorRemapGradient(): IParticleSystem;
  57165. /**
  57166. * Not supported by GPUParticleSystem
  57167. * @param gradient defines the gradient to use (between 0 and 1)
  57168. * @param min defines the alpha remap minimal range
  57169. * @param max defines the alpha remap maximal range
  57170. * @returns the current particle system
  57171. */
  57172. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  57173. /**
  57174. * Not supported by GPUParticleSystem
  57175. * @param gradient defines the gradient to remove
  57176. * @returns the current particle system
  57177. */
  57178. removeAlphaRemapGradient(): IParticleSystem;
  57179. /**
  57180. * Not supported by GPUParticleSystem
  57181. * @param gradient defines the gradient to use (between 0 and 1)
  57182. * @param color defines the color to affect to the specified gradient
  57183. * @returns the current particle system
  57184. */
  57185. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  57186. /**
  57187. * Not supported by GPUParticleSystem
  57188. * @param gradient defines the gradient to remove
  57189. * @returns the current particle system
  57190. */
  57191. removeRampGradient(): IParticleSystem;
  57192. /**
  57193. * Not supported by GPUParticleSystem
  57194. * @returns the list of ramp gradients
  57195. */
  57196. getRampGradients(): Nullable<Array<Color3Gradient>>;
  57197. /**
  57198. * Not supported by GPUParticleSystem
  57199. * Gets or sets a boolean indicating that ramp gradients must be used
  57200. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  57201. */
  57202. useRampGradients: boolean;
  57203. /**
  57204. * Not supported by GPUParticleSystem
  57205. * @param gradient defines the gradient to use (between 0 and 1)
  57206. * @param factor defines the life time factor to affect to the specified gradient
  57207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57208. * @returns the current particle system
  57209. */
  57210. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  57211. /**
  57212. * Not supported by GPUParticleSystem
  57213. * @param gradient defines the gradient to remove
  57214. * @returns the current particle system
  57215. */
  57216. removeLifeTimeGradient(gradient: number): IParticleSystem;
  57217. /**
  57218. * Instantiates a GPU particle system.
  57219. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  57220. * @param name The name of the particle system
  57221. * @param options The options used to create the system
  57222. * @param scene The scene the particle system belongs to
  57223. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  57224. */
  57225. constructor(name: string, options: Partial<{
  57226. capacity: number;
  57227. randomTextureSize: number;
  57228. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  57229. protected _reset(): void;
  57230. private _createUpdateVAO;
  57231. private _createRenderVAO;
  57232. private _initialize;
  57233. /** @hidden */ private _recreateUpdateEffect(): void;
  57234. /** @hidden */ private _recreateRenderEffect(): void;
  57235. /**
  57236. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  57237. * @param preWarm defines if we are in the pre-warmimg phase
  57238. */
  57239. animate(preWarm?: boolean): void;
  57240. private _createFactorGradientTexture;
  57241. private _createSizeGradientTexture;
  57242. private _createAngularSpeedGradientTexture;
  57243. private _createVelocityGradientTexture;
  57244. private _createLimitVelocityGradientTexture;
  57245. private _createDragGradientTexture;
  57246. private _createColorGradientTexture;
  57247. /**
  57248. * Renders the particle system in its current state
  57249. * @param preWarm defines if the system should only update the particles but not render them
  57250. * @returns the current number of particles
  57251. */
  57252. render(preWarm?: boolean): number;
  57253. /**
  57254. * Rebuilds the particle system
  57255. */
  57256. rebuild(): void;
  57257. private _releaseBuffers;
  57258. private _releaseVAOs;
  57259. /**
  57260. * Disposes the particle system and free the associated resources
  57261. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  57262. */
  57263. dispose(disposeTexture?: boolean): void;
  57264. /**
  57265. * Clones the particle system.
  57266. * @param name The name of the cloned object
  57267. * @param newEmitter The new emitter to use
  57268. * @returns the cloned particle system
  57269. */
  57270. clone(name: string, newEmitter: any): GPUParticleSystem;
  57271. /**
  57272. * Serializes the particle system to a JSON object.
  57273. * @returns the JSON object
  57274. */
  57275. serialize(): any;
  57276. /**
  57277. * Parses a JSON object to create a GPU particle system.
  57278. * @param parsedParticleSystem The JSON object to parse
  57279. * @param scene The scene to create the particle system in
  57280. * @param rootUrl The root url to use to load external dependencies like texture
  57281. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  57282. * @returns the parsed GPU particle system
  57283. */
  57284. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  57285. }
  57286. }
  57287. declare module BABYLON {
  57288. /**
  57289. * Represents a set of particle systems working together to create a specific effect
  57290. */
  57291. export class ParticleSystemSet implements IDisposable {
  57292. private _emitterCreationOptions;
  57293. private _emitterNode;
  57294. /**
  57295. * Gets the particle system list
  57296. */
  57297. systems: IParticleSystem[];
  57298. /**
  57299. * Gets the emitter node used with this set
  57300. */
  57301. readonly emitterNode: Nullable<TransformNode>;
  57302. /**
  57303. * Creates a new emitter mesh as a sphere
  57304. * @param options defines the options used to create the sphere
  57305. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57306. * @param scene defines the hosting scene
  57307. */
  57308. setEmitterAsSphere(options: {
  57309. diameter: number;
  57310. segments: number;
  57311. color: Color3;
  57312. }, renderingGroupId: number, scene: Scene): void;
  57313. /**
  57314. * Starts all particle systems of the set
  57315. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57316. */
  57317. start(emitter?: AbstractMesh): void;
  57318. /**
  57319. * Release all associated resources
  57320. */
  57321. dispose(): void;
  57322. /**
  57323. * Serialize the set into a JSON compatible object
  57324. * @returns a JSON compatible representation of the set
  57325. */
  57326. serialize(): any;
  57327. /**
  57328. * Parse a new ParticleSystemSet from a serialized source
  57329. * @param data defines a JSON compatible representation of the set
  57330. * @param scene defines the hosting scene
  57331. * @param gpu defines if we want GPU particles or CPU particles
  57332. * @returns a new ParticleSystemSet
  57333. */
  57334. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57335. }
  57336. }
  57337. declare module BABYLON {
  57338. /**
  57339. * This class is made for on one-liner static method to help creating particle system set.
  57340. */
  57341. export class ParticleHelper {
  57342. /**
  57343. * Gets or sets base Assets URL
  57344. */
  57345. static BaseAssetsUrl: string;
  57346. /**
  57347. * Create a default particle system that you can tweak
  57348. * @param emitter defines the emitter to use
  57349. * @param capacity defines the system capacity (default is 500 particles)
  57350. * @param scene defines the hosting scene
  57351. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57352. * @returns the new Particle system
  57353. */
  57354. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57355. /**
  57356. * This is the main static method (one-liner) of this helper to create different particle systems
  57357. * @param type This string represents the type to the particle system to create
  57358. * @param scene The scene where the particle system should live
  57359. * @param gpu If the system will use gpu
  57360. * @returns the ParticleSystemSet created
  57361. */
  57362. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57363. /**
  57364. * Static function used to export a particle system to a ParticleSystemSet variable.
  57365. * Please note that the emitter shape is not exported
  57366. * @param systems defines the particle systems to export
  57367. * @returns the created particle system set
  57368. */
  57369. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57370. }
  57371. }
  57372. declare module BABYLON {
  57373. interface Engine {
  57374. /**
  57375. * Create an effect to use with particle systems.
  57376. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57377. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57378. * @param uniformsNames defines a list of attribute names
  57379. * @param samplers defines an array of string used to represent textures
  57380. * @param defines defines the string containing the defines to use to compile the shaders
  57381. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57382. * @param onCompiled defines a function to call when the effect creation is successful
  57383. * @param onError defines a function to call when the effect creation has failed
  57384. * @returns the new Effect
  57385. */
  57386. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57387. }
  57388. interface Mesh {
  57389. /**
  57390. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57391. * @returns an array of IParticleSystem
  57392. */
  57393. getEmittedParticleSystems(): IParticleSystem[];
  57394. /**
  57395. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57396. * @returns an array of IParticleSystem
  57397. */
  57398. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57399. }
  57400. /**
  57401. * @hidden
  57402. */
  57403. export var _IDoNeedToBeInTheBuild: number;
  57404. }
  57405. declare module BABYLON {
  57406. interface Scene {
  57407. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  57408. /**
  57409. * Gets the current physics engine
  57410. * @returns a IPhysicsEngine or null if none attached
  57411. */
  57412. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57413. /**
  57414. * Enables physics to the current scene
  57415. * @param gravity defines the scene's gravity for the physics engine
  57416. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57417. * @return a boolean indicating if the physics engine was initialized
  57418. */
  57419. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57420. /**
  57421. * Disables and disposes the physics engine associated with the scene
  57422. */
  57423. disablePhysicsEngine(): void;
  57424. /**
  57425. * Gets a boolean indicating if there is an active physics engine
  57426. * @returns a boolean indicating if there is an active physics engine
  57427. */
  57428. isPhysicsEnabled(): boolean;
  57429. /**
  57430. * Deletes a physics compound impostor
  57431. * @param compound defines the compound to delete
  57432. */
  57433. deleteCompoundImpostor(compound: any): void;
  57434. /**
  57435. * An event triggered when physic simulation is about to be run
  57436. */
  57437. onBeforePhysicsObservable: Observable<Scene>;
  57438. /**
  57439. * An event triggered when physic simulation has been done
  57440. */
  57441. onAfterPhysicsObservable: Observable<Scene>;
  57442. }
  57443. interface AbstractMesh {
  57444. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  57445. /**
  57446. * Gets or sets impostor used for physic simulation
  57447. * @see http://doc.babylonjs.com/features/physics_engine
  57448. */
  57449. physicsImpostor: Nullable<PhysicsImpostor>;
  57450. /**
  57451. * Gets the current physics impostor
  57452. * @see http://doc.babylonjs.com/features/physics_engine
  57453. * @returns a physics impostor or null
  57454. */
  57455. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57456. /** Apply a physic impulse to the mesh
  57457. * @param force defines the force to apply
  57458. * @param contactPoint defines where to apply the force
  57459. * @returns the current mesh
  57460. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57461. */
  57462. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57463. /**
  57464. * Creates a physic joint between two meshes
  57465. * @param otherMesh defines the other mesh to use
  57466. * @param pivot1 defines the pivot to use on this mesh
  57467. * @param pivot2 defines the pivot to use on the other mesh
  57468. * @param options defines additional options (can be plugin dependent)
  57469. * @returns the current mesh
  57470. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57471. */
  57472. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57473. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  57474. }
  57475. /**
  57476. * Defines the physics engine scene component responsible to manage a physics engine
  57477. */
  57478. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57479. /**
  57480. * The component name helpful to identify the component in the list of scene components.
  57481. */
  57482. readonly name: string;
  57483. /**
  57484. * The scene the component belongs to.
  57485. */
  57486. scene: Scene;
  57487. /**
  57488. * Creates a new instance of the component for the given scene
  57489. * @param scene Defines the scene to register the component in
  57490. */
  57491. constructor(scene: Scene);
  57492. /**
  57493. * Registers the component in a given scene
  57494. */
  57495. register(): void;
  57496. /**
  57497. * Rebuilds the elements related to this component in case of
  57498. * context lost for instance.
  57499. */
  57500. rebuild(): void;
  57501. /**
  57502. * Disposes the component and the associated ressources
  57503. */
  57504. dispose(): void;
  57505. }
  57506. }
  57507. declare module BABYLON {
  57508. /**
  57509. * A helper for physics simulations
  57510. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57511. */
  57512. export class PhysicsHelper {
  57513. private _scene;
  57514. private _physicsEngine;
  57515. /**
  57516. * Initializes the Physics helper
  57517. * @param scene Babylon.js scene
  57518. */
  57519. constructor(scene: Scene);
  57520. /**
  57521. * Applies a radial explosion impulse
  57522. * @param origin the origin of the explosion
  57523. * @param radiusOrEventOptions the radius or the options of radial explosion
  57524. * @param strength the explosion strength
  57525. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57526. * @returns A physics radial explosion event, or null
  57527. */
  57528. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57529. /**
  57530. * Applies a radial explosion force
  57531. * @param origin the origin of the explosion
  57532. * @param radiusOrEventOptions the radius or the options of radial explosion
  57533. * @param strength the explosion strength
  57534. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57535. * @returns A physics radial explosion event, or null
  57536. */
  57537. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57538. /**
  57539. * Creates a gravitational field
  57540. * @param origin the origin of the explosion
  57541. * @param radiusOrEventOptions the radius or the options of radial explosion
  57542. * @param strength the explosion strength
  57543. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57544. * @returns A physics gravitational field event, or null
  57545. */
  57546. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57547. /**
  57548. * Creates a physics updraft event
  57549. * @param origin the origin of the updraft
  57550. * @param radiusOrEventOptions the radius or the options of the updraft
  57551. * @param strength the strength of the updraft
  57552. * @param height the height of the updraft
  57553. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57554. * @returns A physics updraft event, or null
  57555. */
  57556. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57557. /**
  57558. * Creates a physics vortex event
  57559. * @param origin the of the vortex
  57560. * @param radiusOrEventOptions the radius or the options of the vortex
  57561. * @param strength the strength of the vortex
  57562. * @param height the height of the vortex
  57563. * @returns a Physics vortex event, or null
  57564. * A physics vortex event or null
  57565. */
  57566. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57567. }
  57568. /**
  57569. * Represents a physics radial explosion event
  57570. */
  57571. class PhysicsRadialExplosionEvent {
  57572. private _scene;
  57573. private _options;
  57574. private _sphere;
  57575. private _dataFetched;
  57576. /**
  57577. * Initializes a radial explosioin event
  57578. * @param _scene BabylonJS scene
  57579. * @param _options The options for the vortex event
  57580. */
  57581. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57582. /**
  57583. * Returns the data related to the radial explosion event (sphere).
  57584. * @returns The radial explosion event data
  57585. */
  57586. getData(): PhysicsRadialExplosionEventData;
  57587. /**
  57588. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57589. * @param impostor A physics imposter
  57590. * @param origin the origin of the explosion
  57591. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57592. */
  57593. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57594. /**
  57595. * Triggers affecterd impostors callbacks
  57596. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57597. */
  57598. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57599. /**
  57600. * Disposes the sphere.
  57601. * @param force Specifies if the sphere should be disposed by force
  57602. */
  57603. dispose(force?: boolean): void;
  57604. /*** Helpers ***/
  57605. private _prepareSphere;
  57606. private _intersectsWithSphere;
  57607. }
  57608. /**
  57609. * Represents a gravitational field event
  57610. */
  57611. class PhysicsGravitationalFieldEvent {
  57612. private _physicsHelper;
  57613. private _scene;
  57614. private _origin;
  57615. private _options;
  57616. private _tickCallback;
  57617. private _sphere;
  57618. private _dataFetched;
  57619. /**
  57620. * Initializes the physics gravitational field event
  57621. * @param _physicsHelper A physics helper
  57622. * @param _scene BabylonJS scene
  57623. * @param _origin The origin position of the gravitational field event
  57624. * @param _options The options for the vortex event
  57625. */
  57626. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57627. /**
  57628. * Returns the data related to the gravitational field event (sphere).
  57629. * @returns A gravitational field event
  57630. */
  57631. getData(): PhysicsGravitationalFieldEventData;
  57632. /**
  57633. * Enables the gravitational field.
  57634. */
  57635. enable(): void;
  57636. /**
  57637. * Disables the gravitational field.
  57638. */
  57639. disable(): void;
  57640. /**
  57641. * Disposes the sphere.
  57642. * @param force The force to dispose from the gravitational field event
  57643. */
  57644. dispose(force?: boolean): void;
  57645. private _tick;
  57646. }
  57647. /**
  57648. * Represents a physics updraft event
  57649. */
  57650. class PhysicsUpdraftEvent {
  57651. private _scene;
  57652. private _origin;
  57653. private _options;
  57654. private _physicsEngine;
  57655. private _originTop;
  57656. private _originDirection;
  57657. private _tickCallback;
  57658. private _cylinder;
  57659. private _cylinderPosition;
  57660. private _dataFetched;
  57661. /**
  57662. * Initializes the physics updraft event
  57663. * @param _scene BabylonJS scene
  57664. * @param _origin The origin position of the updraft
  57665. * @param _options The options for the updraft event
  57666. */
  57667. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57668. /**
  57669. * Returns the data related to the updraft event (cylinder).
  57670. * @returns A physics updraft event
  57671. */
  57672. getData(): PhysicsUpdraftEventData;
  57673. /**
  57674. * Enables the updraft.
  57675. */
  57676. enable(): void;
  57677. /**
  57678. * Disables the updraft.
  57679. */
  57680. disable(): void;
  57681. /**
  57682. * Disposes the cylinder.
  57683. * @param force Specifies if the updraft should be disposed by force
  57684. */
  57685. dispose(force?: boolean): void;
  57686. private getImpostorHitData;
  57687. private _tick;
  57688. /*** Helpers ***/
  57689. private _prepareCylinder;
  57690. private _intersectsWithCylinder;
  57691. }
  57692. /**
  57693. * Represents a physics vortex event
  57694. */
  57695. class PhysicsVortexEvent {
  57696. private _scene;
  57697. private _origin;
  57698. private _options;
  57699. private _physicsEngine;
  57700. private _originTop;
  57701. private _tickCallback;
  57702. private _cylinder;
  57703. private _cylinderPosition;
  57704. private _dataFetched;
  57705. /**
  57706. * Initializes the physics vortex event
  57707. * @param _scene The BabylonJS scene
  57708. * @param _origin The origin position of the vortex
  57709. * @param _options The options for the vortex event
  57710. */
  57711. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57712. /**
  57713. * Returns the data related to the vortex event (cylinder).
  57714. * @returns The physics vortex event data
  57715. */
  57716. getData(): PhysicsVortexEventData;
  57717. /**
  57718. * Enables the vortex.
  57719. */
  57720. enable(): void;
  57721. /**
  57722. * Disables the cortex.
  57723. */
  57724. disable(): void;
  57725. /**
  57726. * Disposes the sphere.
  57727. * @param force
  57728. */
  57729. dispose(force?: boolean): void;
  57730. private getImpostorHitData;
  57731. private _tick;
  57732. /*** Helpers ***/
  57733. private _prepareCylinder;
  57734. private _intersectsWithCylinder;
  57735. }
  57736. /**
  57737. * Options fot the radial explosion event
  57738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57739. */
  57740. export class PhysicsRadialExplosionEventOptions {
  57741. /**
  57742. * The radius of the sphere for the radial explosion.
  57743. */
  57744. radius: number;
  57745. /**
  57746. * The strenth of the explosion.
  57747. */
  57748. strength: number;
  57749. /**
  57750. * The strenght of the force in correspondence to the distance of the affected object
  57751. */
  57752. falloff: PhysicsRadialImpulseFalloff;
  57753. /**
  57754. * Sphere options for the radial explosion.
  57755. */
  57756. sphere: {
  57757. segments: number;
  57758. diameter: number;
  57759. };
  57760. /**
  57761. * Sphere options for the radial explosion.
  57762. */
  57763. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57764. }
  57765. /**
  57766. * Options fot the updraft event
  57767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57768. */
  57769. export class PhysicsUpdraftEventOptions {
  57770. /**
  57771. * The radius of the cylinder for the vortex
  57772. */
  57773. radius: number;
  57774. /**
  57775. * The strenth of the updraft.
  57776. */
  57777. strength: number;
  57778. /**
  57779. * The height of the cylinder for the updraft.
  57780. */
  57781. height: number;
  57782. /**
  57783. * The mode for the the updraft.
  57784. */
  57785. updraftMode: PhysicsUpdraftMode;
  57786. }
  57787. /**
  57788. * Options fot the vortex event
  57789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57790. */
  57791. export class PhysicsVortexEventOptions {
  57792. /**
  57793. * The radius of the cylinder for the vortex
  57794. */
  57795. radius: number;
  57796. /**
  57797. * The strenth of the vortex.
  57798. */
  57799. strength: number;
  57800. /**
  57801. * The height of the cylinder for the vortex.
  57802. */
  57803. height: number;
  57804. /**
  57805. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57806. */
  57807. centripetalForceThreshold: number;
  57808. /**
  57809. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57810. */
  57811. centripetalForceMultiplier: number;
  57812. /**
  57813. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57814. */
  57815. centrifugalForceMultiplier: number;
  57816. /**
  57817. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57818. */
  57819. updraftForceMultiplier: number;
  57820. }
  57821. /**
  57822. * The strenght of the force in correspondence to the distance of the affected object
  57823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57824. */
  57825. export enum PhysicsRadialImpulseFalloff {
  57826. /** Defines that impulse is constant in strength across it's whole radius */
  57827. Constant = 0,
  57828. /** Defines that impulse gets weaker if it's further from the origin */
  57829. Linear = 1
  57830. }
  57831. /**
  57832. * The strength of the force in correspondence to the distance of the affected object
  57833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57834. */
  57835. export enum PhysicsUpdraftMode {
  57836. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57837. Center = 0,
  57838. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57839. Perpendicular = 1
  57840. }
  57841. /**
  57842. * Interface for a physics hit data
  57843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57844. */
  57845. export interface PhysicsHitData {
  57846. /**
  57847. * The force applied at the contact point
  57848. */
  57849. force: Vector3;
  57850. /**
  57851. * The contact point
  57852. */
  57853. contactPoint: Vector3;
  57854. /**
  57855. * The distance from the origin to the contact point
  57856. */
  57857. distanceFromOrigin: number;
  57858. }
  57859. /**
  57860. * Interface for radial explosion event data
  57861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57862. */
  57863. export interface PhysicsRadialExplosionEventData {
  57864. /**
  57865. * A sphere used for the radial explosion event
  57866. */
  57867. sphere: Mesh;
  57868. }
  57869. /**
  57870. * Interface for gravitational field event data
  57871. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57872. */
  57873. export interface PhysicsGravitationalFieldEventData {
  57874. /**
  57875. * A sphere mesh used for the gravitational field event
  57876. */
  57877. sphere: Mesh;
  57878. }
  57879. /**
  57880. * Interface for updraft event data
  57881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57882. */
  57883. export interface PhysicsUpdraftEventData {
  57884. /**
  57885. * A cylinder used for the updraft event
  57886. */
  57887. cylinder: Mesh;
  57888. }
  57889. /**
  57890. * Interface for vortex event data
  57891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57892. */
  57893. export interface PhysicsVortexEventData {
  57894. /**
  57895. * A cylinder used for the vortex event
  57896. */
  57897. cylinder: Mesh;
  57898. }
  57899. /**
  57900. * Interface for an affected physics impostor
  57901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57902. */
  57903. export interface PhysicsAffectedImpostorWithData {
  57904. /**
  57905. * The impostor affected by the effect
  57906. */
  57907. impostor: PhysicsImpostor;
  57908. /**
  57909. * The data about the hit/horce from the explosion
  57910. */
  57911. hitData: PhysicsHitData;
  57912. }
  57913. }
  57914. declare module BABYLON {
  57915. /** @hidden */
  57916. export var blackAndWhitePixelShader: {
  57917. name: string;
  57918. shader: string;
  57919. };
  57920. }
  57921. declare module BABYLON {
  57922. /**
  57923. * Post process used to render in black and white
  57924. */
  57925. export class BlackAndWhitePostProcess extends PostProcess {
  57926. /**
  57927. * Linear about to convert he result to black and white (default: 1)
  57928. */
  57929. degree: number;
  57930. /**
  57931. * Creates a black and white post process
  57932. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57933. * @param name The name of the effect.
  57934. * @param options The required width/height ratio to downsize to before computing the render pass.
  57935. * @param camera The camera to apply the render pass to.
  57936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57937. * @param engine The engine which the post process will be applied. (default: current engine)
  57938. * @param reusable If the post process can be reused on the same frame. (default: false)
  57939. */
  57940. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57941. }
  57942. }
  57943. declare module BABYLON {
  57944. /**
  57945. * This represents a set of one or more post processes in Babylon.
  57946. * A post process can be used to apply a shader to a texture after it is rendered.
  57947. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57948. */
  57949. export class PostProcessRenderEffect {
  57950. private _postProcesses;
  57951. private _getPostProcesses;
  57952. private _singleInstance;
  57953. private _cameras;
  57954. private _indicesForCamera;
  57955. /**
  57956. * Name of the effect
  57957. * @hidden
  57958. */ private _name: string;
  57959. /**
  57960. * Instantiates a post process render effect.
  57961. * A post process can be used to apply a shader to a texture after it is rendered.
  57962. * @param engine The engine the effect is tied to
  57963. * @param name The name of the effect
  57964. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57965. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57966. */
  57967. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57968. /**
  57969. * Checks if all the post processes in the effect are supported.
  57970. */
  57971. readonly isSupported: boolean;
  57972. /**
  57973. * Updates the current state of the effect
  57974. * @hidden
  57975. */ private _update(): void;
  57976. /**
  57977. * Attaches the effect on cameras
  57978. * @param cameras The camera to attach to.
  57979. * @hidden
  57980. */ private _attachCameras(cameras: Camera): void;
  57981. /**
  57982. * Attaches the effect on cameras
  57983. * @param cameras The camera to attach to.
  57984. * @hidden
  57985. */ private _attachCameras(cameras: Camera[]): void;
  57986. /**
  57987. * Detaches the effect on cameras
  57988. * @param cameras The camera to detatch from.
  57989. * @hidden
  57990. */ private _detachCameras(cameras: Camera): void;
  57991. /**
  57992. * Detatches the effect on cameras
  57993. * @param cameras The camera to detatch from.
  57994. * @hidden
  57995. */ private _detachCameras(cameras: Camera[]): void;
  57996. /**
  57997. * Enables the effect on given cameras
  57998. * @param cameras The camera to enable.
  57999. * @hidden
  58000. */ private _enable(cameras: Camera): void;
  58001. /**
  58002. * Enables the effect on given cameras
  58003. * @param cameras The camera to enable.
  58004. * @hidden
  58005. */ private _enable(cameras: Nullable<Camera[]>): void;
  58006. /**
  58007. * Disables the effect on the given cameras
  58008. * @param cameras The camera to disable.
  58009. * @hidden
  58010. */ private _disable(cameras: Camera): void;
  58011. /**
  58012. * Disables the effect on the given cameras
  58013. * @param cameras The camera to disable.
  58014. * @hidden
  58015. */ private _disable(cameras: Nullable<Camera[]>): void;
  58016. /**
  58017. * Gets a list of the post processes contained in the effect.
  58018. * @param camera The camera to get the post processes on.
  58019. * @returns The list of the post processes in the effect.
  58020. */
  58021. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58022. }
  58023. }
  58024. declare module BABYLON {
  58025. /** @hidden */
  58026. export var extractHighlightsPixelShader: {
  58027. name: string;
  58028. shader: string;
  58029. };
  58030. }
  58031. declare module BABYLON {
  58032. /**
  58033. * The extract highlights post process sets all pixels to black except pixels above the specified luminance threshold. Used as the first step for a bloom effect.
  58034. */
  58035. export class ExtractHighlightsPostProcess extends PostProcess {
  58036. /**
  58037. * The luminance threshold, pixels below this value will be set to black.
  58038. */
  58039. threshold: number;
  58040. /** @hidden */ private _exposure: number;
  58041. /**
  58042. * Post process which has the input texture to be used when performing highlight extraction
  58043. * @hidden
  58044. */ private _inputPostProcess: Nullable<PostProcess>;
  58045. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58046. }
  58047. }
  58048. declare module BABYLON {
  58049. /** @hidden */
  58050. export var bloomMergePixelShader: {
  58051. name: string;
  58052. shader: string;
  58053. };
  58054. }
  58055. declare module BABYLON {
  58056. /**
  58057. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58058. */
  58059. export class BloomMergePostProcess extends PostProcess {
  58060. /** Weight of the bloom to be added to the original input. */
  58061. weight: number;
  58062. /**
  58063. * Creates a new instance of @see BloomMergePostProcess
  58064. * @param name The name of the effect.
  58065. * @param originalFromInput Post process which's input will be used for the merge.
  58066. * @param blurred Blurred highlights post process which's output will be used.
  58067. * @param weight Weight of the bloom to be added to the original input.
  58068. * @param options The required width/height ratio to downsize to before computing the render pass.
  58069. * @param camera The camera to apply the render pass to.
  58070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58071. * @param engine The engine which the post process will be applied. (default: current engine)
  58072. * @param reusable If the post process can be reused on the same frame. (default: false)
  58073. * @param textureType Type of textures used when performing the post process. (default: 0)
  58074. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58075. */
  58076. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  58077. /** Weight of the bloom to be added to the original input. */
  58078. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58079. }
  58080. }
  58081. declare module BABYLON {
  58082. /**
  58083. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  58084. */
  58085. export class BloomEffect extends PostProcessRenderEffect {
  58086. private bloomScale;
  58087. /**
  58088. * @hidden Internal
  58089. */ private _effects: Array<PostProcess>;
  58090. /**
  58091. * @hidden Internal
  58092. */ private _downscale: ExtractHighlightsPostProcess;
  58093. private _blurX;
  58094. private _blurY;
  58095. private _merge;
  58096. /**
  58097. * The luminance threshold to find bright areas of the image to bloom.
  58098. */
  58099. threshold: number;
  58100. /**
  58101. * The strength of the bloom.
  58102. */
  58103. weight: number;
  58104. /**
  58105. * Specifies the size of the bloom blur kernel, relative to the final output size
  58106. */
  58107. kernel: number;
  58108. /**
  58109. * Creates a new instance of @see BloomEffect
  58110. * @param scene The scene the effect belongs to.
  58111. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  58112. * @param bloomKernel The size of the kernel to be used when applying the blur.
  58113. * @param bloomWeight The the strength of bloom.
  58114. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58115. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58116. */
  58117. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  58118. /**
  58119. * Disposes each of the internal effects for a given camera.
  58120. * @param camera The camera to dispose the effect on.
  58121. */
  58122. disposeEffects(camera: Camera): void;
  58123. /**
  58124. * @hidden Internal
  58125. */ private _updateEffects(): void;
  58126. /**
  58127. * Internal
  58128. * @returns if all the contained post processes are ready.
  58129. * @hidden
  58130. */ private _isReady(): boolean;
  58131. }
  58132. }
  58133. declare module BABYLON {
  58134. /** @hidden */
  58135. export var chromaticAberrationPixelShader: {
  58136. name: string;
  58137. shader: string;
  58138. };
  58139. }
  58140. declare module BABYLON {
  58141. /**
  58142. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  58143. */
  58144. export class ChromaticAberrationPostProcess extends PostProcess {
  58145. /**
  58146. * The amount of seperation of rgb channels (default: 30)
  58147. */
  58148. aberrationAmount: number;
  58149. /**
  58150. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  58151. */
  58152. radialIntensity: number;
  58153. /**
  58154. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  58155. */
  58156. direction: Vector2;
  58157. /**
  58158. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  58159. */
  58160. centerPosition: Vector2;
  58161. /**
  58162. * Creates a new instance ChromaticAberrationPostProcess
  58163. * @param name The name of the effect.
  58164. * @param screenWidth The width of the screen to apply the effect on.
  58165. * @param screenHeight The height of the screen to apply the effect on.
  58166. * @param options The required width/height ratio to downsize to before computing the render pass.
  58167. * @param camera The camera to apply the render pass to.
  58168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58169. * @param engine The engine which the post process will be applied. (default: current engine)
  58170. * @param reusable If the post process can be reused on the same frame. (default: false)
  58171. * @param textureType Type of textures used when performing the post process. (default: 0)
  58172. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58173. */
  58174. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58175. }
  58176. }
  58177. declare module BABYLON {
  58178. /** @hidden */
  58179. export var circleOfConfusionPixelShader: {
  58180. name: string;
  58181. shader: string;
  58182. };
  58183. }
  58184. declare module BABYLON {
  58185. /**
  58186. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58187. */
  58188. export class CircleOfConfusionPostProcess extends PostProcess {
  58189. /**
  58190. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  58191. */
  58192. lensSize: number;
  58193. /**
  58194. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58195. */
  58196. fStop: number;
  58197. /**
  58198. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58199. */
  58200. focusDistance: number;
  58201. /**
  58202. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58203. */
  58204. focalLength: number;
  58205. private _depthTexture;
  58206. /**
  58207. * Creates a new instance CircleOfConfusionPostProcess
  58208. * @param name The name of the effect.
  58209. * @param depthTexture The depth texture of the scene to compute the circle of confusion. This must be set in order for this to function but may be set after initialization if needed.
  58210. * @param options The required width/height ratio to downsize to before computing the render pass.
  58211. * @param camera The camera to apply the render pass to.
  58212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58213. * @param engine The engine which the post process will be applied. (default: current engine)
  58214. * @param reusable If the post process can be reused on the same frame. (default: false)
  58215. * @param textureType Type of textures used when performing the post process. (default: 0)
  58216. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58217. */
  58218. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58219. /**
  58220. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  58221. */
  58222. depthTexture: RenderTargetTexture;
  58223. }
  58224. }
  58225. declare module BABYLON {
  58226. /** @hidden */
  58227. export var colorCorrectionPixelShader: {
  58228. name: string;
  58229. shader: string;
  58230. };
  58231. }
  58232. declare module BABYLON {
  58233. /**
  58234. *
  58235. * This post-process allows the modification of rendered colors by using
  58236. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58237. *
  58238. * The object needs to be provided an url to a texture containing the color
  58239. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58240. * Use an image editing software to tweak the LUT to match your needs.
  58241. *
  58242. * For an example of a color LUT, see here:
  58243. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58244. * For explanations on color grading, see here:
  58245. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58246. *
  58247. */
  58248. export class ColorCorrectionPostProcess extends PostProcess {
  58249. private _colorTableTexture;
  58250. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58251. }
  58252. }
  58253. declare module BABYLON {
  58254. /** @hidden */
  58255. export var convolutionPixelShader: {
  58256. name: string;
  58257. shader: string;
  58258. };
  58259. }
  58260. declare module BABYLON {
  58261. /**
  58262. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58263. * input texture to perform effects such as edge detection or sharpening
  58264. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58265. */
  58266. export class ConvolutionPostProcess extends PostProcess {
  58267. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58268. kernel: number[];
  58269. /**
  58270. * Creates a new instance ConvolutionPostProcess
  58271. * @param name The name of the effect.
  58272. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58273. * @param options The required width/height ratio to downsize to before computing the render pass.
  58274. * @param camera The camera to apply the render pass to.
  58275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58276. * @param engine The engine which the post process will be applied. (default: current engine)
  58277. * @param reusable If the post process can be reused on the same frame. (default: false)
  58278. * @param textureType Type of textures used when performing the post process. (default: 0)
  58279. */
  58280. constructor(name: string,
  58281. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58282. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58283. /**
  58284. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58285. */
  58286. static EdgeDetect0Kernel: number[];
  58287. /**
  58288. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58289. */
  58290. static EdgeDetect1Kernel: number[];
  58291. /**
  58292. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58293. */
  58294. static EdgeDetect2Kernel: number[];
  58295. /**
  58296. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58297. */
  58298. static SharpenKernel: number[];
  58299. /**
  58300. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58301. */
  58302. static EmbossKernel: number[];
  58303. /**
  58304. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58305. */
  58306. static GaussianKernel: number[];
  58307. }
  58308. }
  58309. declare module BABYLON {
  58310. /**
  58311. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58312. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58313. * based on samples that have a large difference in distance than the center pixel.
  58314. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58315. */
  58316. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58317. direction: Vector2;
  58318. /**
  58319. * Creates a new instance CircleOfConfusionPostProcess
  58320. * @param name The name of the effect.
  58321. * @param scene The scene the effect belongs to.
  58322. * @param direction The direction the blur should be applied.
  58323. * @param kernel The size of the kernel used to blur.
  58324. * @param options The required width/height ratio to downsize to before computing the render pass.
  58325. * @param camera The camera to apply the render pass to.
  58326. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58327. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58329. * @param engine The engine which the post process will be applied. (default: current engine)
  58330. * @param reusable If the post process can be reused on the same frame. (default: false)
  58331. * @param textureType Type of textures used when performing the post process. (default: 0)
  58332. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58333. */
  58334. constructor(name: string, scene: Scene, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, circleOfConfusion: PostProcess, imageToBlur?: Nullable<PostProcess>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58335. }
  58336. }
  58337. declare module BABYLON {
  58338. /** @hidden */
  58339. export var depthOfFieldMergePixelShader: {
  58340. name: string;
  58341. shader: string;
  58342. };
  58343. }
  58344. declare module BABYLON {
  58345. /**
  58346. * Options to be set when merging outputs from the default pipeline.
  58347. */
  58348. export class DepthOfFieldMergePostProcessOptions {
  58349. /**
  58350. * The original image to merge on top of
  58351. */
  58352. originalFromInput: PostProcess;
  58353. /**
  58354. * Parameters to perform the merge of the depth of field effect
  58355. */
  58356. depthOfField?: {
  58357. circleOfConfusion: PostProcess;
  58358. blurSteps: Array<PostProcess>;
  58359. };
  58360. /**
  58361. * Parameters to perform the merge of bloom effect
  58362. */
  58363. bloom?: {
  58364. blurred: PostProcess;
  58365. weight: number;
  58366. };
  58367. }
  58368. /**
  58369. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58370. */
  58371. export class DepthOfFieldMergePostProcess extends PostProcess {
  58372. private blurSteps;
  58373. /**
  58374. * Creates a new instance of DepthOfFieldMergePostProcess
  58375. * @param name The name of the effect.
  58376. * @param originalFromInput Post process which's input will be used for the merge.
  58377. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58378. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58379. * @param options The required width/height ratio to downsize to before computing the render pass.
  58380. * @param camera The camera to apply the render pass to.
  58381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58382. * @param engine The engine which the post process will be applied. (default: current engine)
  58383. * @param reusable If the post process can be reused on the same frame. (default: false)
  58384. * @param textureType Type of textures used when performing the post process. (default: 0)
  58385. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58386. */
  58387. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58388. /**
  58389. * Updates the effect with the current post process compile time values and recompiles the shader.
  58390. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58391. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58392. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58393. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  58394. * @param onCompiled Called when the shader has been compiled.
  58395. * @param onError Called if there is an error when compiling a shader.
  58396. */
  58397. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58398. }
  58399. }
  58400. declare module BABYLON {
  58401. /**
  58402. * Specifies the level of max blur that should be applied when using the depth of field effect
  58403. */
  58404. export enum DepthOfFieldEffectBlurLevel {
  58405. /**
  58406. * Subtle blur
  58407. */
  58408. Low = 0,
  58409. /**
  58410. * Medium blur
  58411. */
  58412. Medium = 1,
  58413. /**
  58414. * Large blur
  58415. */
  58416. High = 2
  58417. }
  58418. /**
  58419. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58420. */
  58421. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58422. private _circleOfConfusion;
  58423. /**
  58424. * @hidden Internal, blurs from high to low
  58425. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58426. private _depthOfFieldBlurY;
  58427. private _dofMerge;
  58428. /**
  58429. * @hidden Internal post processes in depth of field effect
  58430. */ private _effects: Array<PostProcess>;
  58431. /**
  58432. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58433. */
  58434. focalLength: number;
  58435. /**
  58436. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58437. */
  58438. fStop: number;
  58439. /**
  58440. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58441. */
  58442. focusDistance: number;
  58443. /**
  58444. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  58445. */
  58446. lensSize: number;
  58447. /**
  58448. * Creates a new instance DepthOfFieldEffect
  58449. * @param scene The scene the effect belongs to.
  58450. * @param depthTexture The depth texture of the scene to compute the circle of confusion.This must be set in order for this to function but may be set after initialization if needed.
  58451. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58452. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58453. */
  58454. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58455. /**
  58456. * Get the current class name of the current effet
  58457. * @returns "DepthOfFieldEffect"
  58458. */
  58459. getClassName(): string;
  58460. /**
  58461. * Depth texture to be used to compute the circle of confusion. This must be set here or in the constructor in order for the post process to function.
  58462. */
  58463. depthTexture: RenderTargetTexture;
  58464. /**
  58465. * Disposes each of the internal effects for a given camera.
  58466. * @param camera The camera to dispose the effect on.
  58467. */
  58468. disposeEffects(camera: Camera): void;
  58469. /**
  58470. * @hidden Internal
  58471. */ private _updateEffects(): void;
  58472. /**
  58473. * Internal
  58474. * @returns if all the contained post processes are ready.
  58475. * @hidden
  58476. */ private _isReady(): boolean;
  58477. }
  58478. }
  58479. declare module BABYLON {
  58480. /** @hidden */
  58481. export var displayPassPixelShader: {
  58482. name: string;
  58483. shader: string;
  58484. };
  58485. }
  58486. declare module BABYLON {
  58487. /**
  58488. * DisplayPassPostProcess which produces an output the same as it's input
  58489. */
  58490. export class DisplayPassPostProcess extends PostProcess {
  58491. /**
  58492. * Creates the DisplayPassPostProcess
  58493. * @param name The name of the effect.
  58494. * @param options The required width/height ratio to downsize to before computing the render pass.
  58495. * @param camera The camera to apply the render pass to.
  58496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58497. * @param engine The engine which the post process will be applied. (default: current engine)
  58498. * @param reusable If the post process can be reused on the same frame. (default: false)
  58499. */
  58500. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58501. }
  58502. }
  58503. declare module BABYLON {
  58504. /** @hidden */
  58505. export var filterPixelShader: {
  58506. name: string;
  58507. shader: string;
  58508. };
  58509. }
  58510. declare module BABYLON {
  58511. /**
  58512. * Applies a kernel filter to the image
  58513. */
  58514. export class FilterPostProcess extends PostProcess {
  58515. /** The matrix to be applied to the image */
  58516. kernelMatrix: Matrix;
  58517. /**
  58518. *
  58519. * @param name The name of the effect.
  58520. * @param kernelMatrix The matrix to be applied to the image
  58521. * @param options The required width/height ratio to downsize to before computing the render pass.
  58522. * @param camera The camera to apply the render pass to.
  58523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58524. * @param engine The engine which the post process will be applied. (default: current engine)
  58525. * @param reusable If the post process can be reused on the same frame. (default: false)
  58526. */
  58527. constructor(name: string,
  58528. /** The matrix to be applied to the image */
  58529. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58530. }
  58531. }
  58532. declare module BABYLON {
  58533. /** @hidden */
  58534. export var fxaaPixelShader: {
  58535. name: string;
  58536. shader: string;
  58537. };
  58538. }
  58539. declare module BABYLON {
  58540. /** @hidden */
  58541. export var fxaaVertexShader: {
  58542. name: string;
  58543. shader: string;
  58544. };
  58545. }
  58546. declare module BABYLON {
  58547. /**
  58548. * Fxaa post process
  58549. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58550. */
  58551. export class FxaaPostProcess extends PostProcess {
  58552. /** @hidden */
  58553. texelWidth: number;
  58554. /** @hidden */
  58555. texelHeight: number;
  58556. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58557. private _getDefines;
  58558. }
  58559. }
  58560. declare module BABYLON {
  58561. /** @hidden */
  58562. export var grainPixelShader: {
  58563. name: string;
  58564. shader: string;
  58565. };
  58566. }
  58567. declare module BABYLON {
  58568. /**
  58569. * The GrainPostProcess adds noise to the image at mid luminance levels
  58570. */
  58571. export class GrainPostProcess extends PostProcess {
  58572. /**
  58573. * The intensity of the grain added (default: 30)
  58574. */
  58575. intensity: number;
  58576. /**
  58577. * If the grain should be randomized on every frame
  58578. */
  58579. animated: boolean;
  58580. /**
  58581. * Creates a new instance of @see GrainPostProcess
  58582. * @param name The name of the effect.
  58583. * @param options The required width/height ratio to downsize to before computing the render pass.
  58584. * @param camera The camera to apply the render pass to.
  58585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58586. * @param engine The engine which the post process will be applied. (default: current engine)
  58587. * @param reusable If the post process can be reused on the same frame. (default: false)
  58588. * @param textureType Type of textures used when performing the post process. (default: 0)
  58589. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58590. */
  58591. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58592. }
  58593. }
  58594. declare module BABYLON {
  58595. /** @hidden */
  58596. export var highlightsPixelShader: {
  58597. name: string;
  58598. shader: string;
  58599. };
  58600. }
  58601. declare module BABYLON {
  58602. /**
  58603. * Extracts highlights from the image
  58604. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58605. */
  58606. export class HighlightsPostProcess extends PostProcess {
  58607. /**
  58608. * Extracts highlights from the image
  58609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58610. * @param name The name of the effect.
  58611. * @param options The required width/height ratio to downsize to before computing the render pass.
  58612. * @param camera The camera to apply the render pass to.
  58613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58614. * @param engine The engine which the post process will be applied. (default: current engine)
  58615. * @param reusable If the post process can be reused on the same frame. (default: false)
  58616. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58617. */
  58618. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58619. }
  58620. }
  58621. declare module BABYLON {
  58622. /** @hidden */
  58623. export var mrtFragmentDeclaration: {
  58624. name: string;
  58625. shader: string;
  58626. };
  58627. }
  58628. declare module BABYLON {
  58629. /** @hidden */
  58630. export var geometryPixelShader: {
  58631. name: string;
  58632. shader: string;
  58633. };
  58634. }
  58635. declare module BABYLON {
  58636. /** @hidden */
  58637. export var geometryVertexShader: {
  58638. name: string;
  58639. shader: string;
  58640. };
  58641. }
  58642. declare module BABYLON {
  58643. /** @hidden */
  58644. interface ISavedTransformationMatrix {
  58645. world: Matrix;
  58646. viewProjection: Matrix;
  58647. }
  58648. /**
  58649. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58650. */
  58651. export class GeometryBufferRenderer {
  58652. /**
  58653. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58654. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58655. */
  58656. static readonly POSITION_TEXTURE_TYPE: number;
  58657. /**
  58658. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58659. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58660. */
  58661. static readonly VELOCITY_TEXTURE_TYPE: number;
  58662. /**
  58663. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58664. * in order to compute objects velocities when enableVelocity is set to "true"
  58665. * @hidden
  58666. */ private _previousTransformationMatrices: {
  58667. [index: number]: ISavedTransformationMatrix;
  58668. };
  58669. /**
  58670. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58671. * in order to compute objects velocities when enableVelocity is set to "true"
  58672. * @hidden
  58673. */ private _previousBonesTransformationMatrices: {
  58674. [index: number]: Float32Array;
  58675. };
  58676. /**
  58677. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58678. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58679. */
  58680. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58681. private _scene;
  58682. private _multiRenderTarget;
  58683. private _ratio;
  58684. private _enablePosition;
  58685. private _enableVelocity;
  58686. private _positionIndex;
  58687. private _velocityIndex;
  58688. protected _effect: Effect;
  58689. protected _cachedDefines: string;
  58690. /**
  58691. * Set the render list (meshes to be rendered) used in the G buffer.
  58692. */
  58693. renderList: Mesh[];
  58694. /**
  58695. * Gets wether or not G buffer are supported by the running hardware.
  58696. * This requires draw buffer supports
  58697. */
  58698. readonly isSupported: boolean;
  58699. /**
  58700. * Returns the index of the given texture type in the G-Buffer textures array
  58701. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58702. * @returns the index of the given texture type in the G-Buffer textures array
  58703. */
  58704. getTextureIndex(textureType: number): number;
  58705. /**
  58706. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58707. */
  58708. /**
  58709. * Sets whether or not objects positions are enabled for the G buffer.
  58710. */
  58711. enablePosition: boolean;
  58712. /**
  58713. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58714. */
  58715. /**
  58716. * Sets wether or not objects velocities are enabled for the G buffer.
  58717. */
  58718. enableVelocity: boolean;
  58719. /**
  58720. * Gets the scene associated with the buffer.
  58721. */
  58722. readonly scene: Scene;
  58723. /**
  58724. * Gets the ratio used by the buffer during its creation.
  58725. * How big is the buffer related to the main canvas.
  58726. */
  58727. readonly ratio: number;
  58728. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  58729. /**
  58730. * Creates a new G Buffer for the scene
  58731. * @param scene The scene the buffer belongs to
  58732. * @param ratio How big is the buffer related to the main canvas.
  58733. */
  58734. constructor(scene: Scene, ratio?: number);
  58735. /**
  58736. * Checks wether everything is ready to render a submesh to the G buffer.
  58737. * @param subMesh the submesh to check readiness for
  58738. * @param useInstances is the mesh drawn using instance or not
  58739. * @returns true if ready otherwise false
  58740. */
  58741. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58742. /**
  58743. * Gets the current underlying G Buffer.
  58744. * @returns the buffer
  58745. */
  58746. getGBuffer(): MultiRenderTarget;
  58747. /**
  58748. * Gets the number of samples used to render the buffer (anti aliasing).
  58749. */
  58750. /**
  58751. * Sets the number of samples used to render the buffer (anti aliasing).
  58752. */
  58753. samples: number;
  58754. /**
  58755. * Disposes the renderer and frees up associated resources.
  58756. */
  58757. dispose(): void;
  58758. protected _createRenderTargets(): void;
  58759. private _copyBonesTransformationMatrices;
  58760. }
  58761. }
  58762. declare module BABYLON {
  58763. interface Scene {
  58764. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58765. /**
  58766. * Gets or Sets the current geometry buffer associated to the scene.
  58767. */
  58768. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58769. /**
  58770. * Enables a GeometryBufferRender and associates it with the scene
  58771. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58772. * @returns the GeometryBufferRenderer
  58773. */
  58774. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58775. /**
  58776. * Disables the GeometryBufferRender associated with the scene
  58777. */
  58778. disableGeometryBufferRenderer(): void;
  58779. }
  58780. /**
  58781. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58782. * in several rendering techniques.
  58783. */
  58784. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58785. /**
  58786. * The component name helpful to identify the component in the list of scene components.
  58787. */
  58788. readonly name: string;
  58789. /**
  58790. * The scene the component belongs to.
  58791. */
  58792. scene: Scene;
  58793. /**
  58794. * Creates a new instance of the component for the given scene
  58795. * @param scene Defines the scene to register the component in
  58796. */
  58797. constructor(scene: Scene);
  58798. /**
  58799. * Registers the component in a given scene
  58800. */
  58801. register(): void;
  58802. /**
  58803. * Rebuilds the elements related to this component in case of
  58804. * context lost for instance.
  58805. */
  58806. rebuild(): void;
  58807. /**
  58808. * Disposes the component and the associated ressources
  58809. */
  58810. dispose(): void;
  58811. private _gatherRenderTargets;
  58812. }
  58813. }
  58814. declare module BABYLON {
  58815. /** @hidden */
  58816. export var motionBlurPixelShader: {
  58817. name: string;
  58818. shader: string;
  58819. };
  58820. }
  58821. declare module BABYLON {
  58822. /**
  58823. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58824. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58825. * As an example, all you have to do is to create the post-process:
  58826. * var mb = new BABYLON.MotionBlurPostProcess(
  58827. * 'mb', // The name of the effect.
  58828. * scene, // The scene containing the objects to blur according to their velocity.
  58829. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58830. * camera // The camera to apply the render pass to.
  58831. * );
  58832. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58833. */
  58834. export class MotionBlurPostProcess extends PostProcess {
  58835. /**
  58836. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58837. */
  58838. motionStrength: number;
  58839. /**
  58840. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58841. */
  58842. /**
  58843. * Sets the number of iterations to be used for motion blur quality
  58844. */
  58845. motionBlurSamples: number;
  58846. private _motionBlurSamples;
  58847. private _geometryBufferRenderer;
  58848. /**
  58849. * Creates a new instance MotionBlurPostProcess
  58850. * @param name The name of the effect.
  58851. * @param scene The scene containing the objects to blur according to their velocity.
  58852. * @param options The required width/height ratio to downsize to before computing the render pass.
  58853. * @param camera The camera to apply the render pass to.
  58854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58855. * @param engine The engine which the post process will be applied. (default: current engine)
  58856. * @param reusable If the post process can be reused on the same frame. (default: false)
  58857. * @param textureType Type of textures used when performing the post process. (default: 0)
  58858. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58859. */
  58860. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58861. /**
  58862. * Excludes the given skinned mesh from computing bones velocities.
  58863. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  58864. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58865. */
  58866. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58867. /**
  58868. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58869. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58870. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58871. */
  58872. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58873. /**
  58874. * Disposes the post process.
  58875. * @param camera The camera to dispose the post process on.
  58876. */
  58877. dispose(camera?: Camera): void;
  58878. }
  58879. }
  58880. declare module BABYLON {
  58881. /** @hidden */
  58882. export var refractionPixelShader: {
  58883. name: string;
  58884. shader: string;
  58885. };
  58886. }
  58887. declare module BABYLON {
  58888. /**
  58889. * Post process which applies a refractin texture
  58890. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58891. */
  58892. export class RefractionPostProcess extends PostProcess {
  58893. /** the base color of the refraction (used to taint the rendering) */
  58894. color: Color3;
  58895. /** simulated refraction depth */
  58896. depth: number;
  58897. /** the coefficient of the base color (0 to remove base color tainting) */
  58898. colorLevel: number;
  58899. private _refTexture;
  58900. private _ownRefractionTexture;
  58901. /**
  58902. * Gets or sets the refraction texture
  58903. * Please note that you are responsible for disposing the texture if you set it manually
  58904. */
  58905. refractionTexture: Texture;
  58906. /**
  58907. * Initializes the RefractionPostProcess
  58908. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58909. * @param name The name of the effect.
  58910. * @param refractionTextureUrl Url of the refraction texture to use
  58911. * @param color the base color of the refraction (used to taint the rendering)
  58912. * @param depth simulated refraction depth
  58913. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58914. * @param camera The camera to apply the render pass to.
  58915. * @param options The required width/height ratio to downsize to before computing the render pass.
  58916. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58917. * @param engine The engine which the post process will be applied. (default: current engine)
  58918. * @param reusable If the post process can be reused on the same frame. (default: false)
  58919. */
  58920. constructor(name: string, refractionTextureUrl: string,
  58921. /** the base color of the refraction (used to taint the rendering) */
  58922. color: Color3,
  58923. /** simulated refraction depth */
  58924. depth: number,
  58925. /** the coefficient of the base color (0 to remove base color tainting) */
  58926. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58927. /**
  58928. * Disposes of the post process
  58929. * @param camera Camera to dispose post process on
  58930. */
  58931. dispose(camera: Camera): void;
  58932. }
  58933. }
  58934. declare module BABYLON {
  58935. /** @hidden */
  58936. export var sharpenPixelShader: {
  58937. name: string;
  58938. shader: string;
  58939. };
  58940. }
  58941. declare module BABYLON {
  58942. /**
  58943. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58944. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58945. */
  58946. export class SharpenPostProcess extends PostProcess {
  58947. /**
  58948. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58949. */
  58950. colorAmount: number;
  58951. /**
  58952. * How much sharpness should be applied (default: 0.3)
  58953. */
  58954. edgeAmount: number;
  58955. /**
  58956. * Creates a new instance ConvolutionPostProcess
  58957. * @param name The name of the effect.
  58958. * @param options The required width/height ratio to downsize to before computing the render pass.
  58959. * @param camera The camera to apply the render pass to.
  58960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58961. * @param engine The engine which the post process will be applied. (default: current engine)
  58962. * @param reusable If the post process can be reused on the same frame. (default: false)
  58963. * @param textureType Type of textures used when performing the post process. (default: 0)
  58964. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  58965. */
  58966. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58967. }
  58968. }
  58969. declare module BABYLON {
  58970. /**
  58971. * PostProcessRenderPipeline
  58972. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58973. */
  58974. export class PostProcessRenderPipeline {
  58975. private engine;
  58976. private _renderEffects;
  58977. private _renderEffectsForIsolatedPass;
  58978. /**
  58979. * List of inspectable custom properties (used by the Inspector)
  58980. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58981. */
  58982. inspectableCustomProperties: IInspectable[];
  58983. /**
  58984. * @hidden
  58985. */
  58986. protected _cameras: Camera[];
  58987. /** @hidden */ private _name: string;
  58988. /**
  58989. * Gets pipeline name
  58990. */
  58991. readonly name: string;
  58992. /**
  58993. * Initializes a PostProcessRenderPipeline
  58994. * @param engine engine to add the pipeline to
  58995. * @param name name of the pipeline
  58996. */
  58997. constructor(engine: Engine, name: string);
  58998. /**
  58999. * Gets the class name
  59000. * @returns "PostProcessRenderPipeline"
  59001. */
  59002. getClassName(): string;
  59003. /**
  59004. * If all the render effects in the pipeline are supported
  59005. */
  59006. readonly isSupported: boolean;
  59007. /**
  59008. * Adds an effect to the pipeline
  59009. * @param renderEffect the effect to add
  59010. */
  59011. addEffect(renderEffect: PostProcessRenderEffect): void;
  59012. /** @hidden */ private _rebuild(): void;
  59013. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  59014. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  59015. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59016. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  59017. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  59018. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  59019. /** @hidden */ private _detachCameras(cameras: Camera): void;
  59020. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  59021. /** @hidden */ private _update(): void;
  59022. /** @hidden */ private _reset(): void;
  59023. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  59024. /**
  59025. * Disposes of the pipeline
  59026. */
  59027. dispose(): void;
  59028. }
  59029. }
  59030. declare module BABYLON {
  59031. /**
  59032. * PostProcessRenderPipelineManager class
  59033. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59034. */
  59035. export class PostProcessRenderPipelineManager {
  59036. private _renderPipelines;
  59037. /**
  59038. * Initializes a PostProcessRenderPipelineManager
  59039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59040. */
  59041. constructor();
  59042. /**
  59043. * Gets the list of supported render pipelines
  59044. */
  59045. readonly supportedPipelines: PostProcessRenderPipeline[];
  59046. /**
  59047. * Adds a pipeline to the manager
  59048. * @param renderPipeline The pipeline to add
  59049. */
  59050. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59051. /**
  59052. * Attaches a camera to the pipeline
  59053. * @param renderPipelineName The name of the pipeline to attach to
  59054. * @param cameras the camera to attach
  59055. * @param unique if the camera can be attached multiple times to the pipeline
  59056. */
  59057. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59058. /**
  59059. * Detaches a camera from the pipeline
  59060. * @param renderPipelineName The name of the pipeline to detach from
  59061. * @param cameras the camera to detach
  59062. */
  59063. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59064. /**
  59065. * Enables an effect by name on a pipeline
  59066. * @param renderPipelineName the name of the pipeline to enable the effect in
  59067. * @param renderEffectName the name of the effect to enable
  59068. * @param cameras the cameras that the effect should be enabled on
  59069. */
  59070. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59071. /**
  59072. * Disables an effect by name on a pipeline
  59073. * @param renderPipelineName the name of the pipeline to disable the effect in
  59074. * @param renderEffectName the name of the effect to disable
  59075. * @param cameras the cameras that the effect should be disabled on
  59076. */
  59077. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59078. /**
  59079. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59080. */
  59081. update(): void;
  59082. /** @hidden */ private _rebuild(): void;
  59083. /**
  59084. * Disposes of the manager and pipelines
  59085. */
  59086. dispose(): void;
  59087. }
  59088. }
  59089. declare module BABYLON {
  59090. interface Scene {
  59091. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59092. /**
  59093. * Gets the postprocess render pipeline manager
  59094. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59095. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59096. */
  59097. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59098. }
  59099. /**
  59100. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59101. */
  59102. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59103. /**
  59104. * The component name helpfull to identify the component in the list of scene components.
  59105. */
  59106. readonly name: string;
  59107. /**
  59108. * The scene the component belongs to.
  59109. */
  59110. scene: Scene;
  59111. /**
  59112. * Creates a new instance of the component for the given scene
  59113. * @param scene Defines the scene to register the component in
  59114. */
  59115. constructor(scene: Scene);
  59116. /**
  59117. * Registers the component in a given scene
  59118. */
  59119. register(): void;
  59120. /**
  59121. * Rebuilds the elements related to this component in case of
  59122. * context lost for instance.
  59123. */
  59124. rebuild(): void;
  59125. /**
  59126. * Disposes the component and the associated ressources
  59127. */
  59128. dispose(): void;
  59129. private _gatherRenderTargets;
  59130. }
  59131. }
  59132. declare module BABYLON {
  59133. /**
  59134. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59135. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59136. */
  59137. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59138. private _scene;
  59139. private _camerasToBeAttached;
  59140. /**
  59141. * ID of the sharpen post process,
  59142. */
  59143. private readonly SharpenPostProcessId;
  59144. /**
  59145. * @ignore
  59146. * ID of the image processing post process;
  59147. */
  59148. readonly ImageProcessingPostProcessId: string;
  59149. /**
  59150. * @ignore
  59151. * ID of the Fast Approximate Anti-Aliasing post process;
  59152. */
  59153. readonly FxaaPostProcessId: string;
  59154. /**
  59155. * ID of the chromatic aberration post process,
  59156. */
  59157. private readonly ChromaticAberrationPostProcessId;
  59158. /**
  59159. * ID of the grain post process
  59160. */
  59161. private readonly GrainPostProcessId;
  59162. /**
  59163. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59164. */
  59165. sharpen: SharpenPostProcess;
  59166. private _sharpenEffect;
  59167. private bloom;
  59168. /**
  59169. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59170. */
  59171. depthOfField: DepthOfFieldEffect;
  59172. /**
  59173. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59174. */
  59175. fxaa: FxaaPostProcess;
  59176. /**
  59177. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59178. */
  59179. imageProcessing: ImageProcessingPostProcess;
  59180. /**
  59181. * Chromatic aberration post process which will shift rgb colors in the image
  59182. */
  59183. chromaticAberration: ChromaticAberrationPostProcess;
  59184. private _chromaticAberrationEffect;
  59185. /**
  59186. * Grain post process which add noise to the image
  59187. */
  59188. grain: GrainPostProcess;
  59189. private _grainEffect;
  59190. /**
  59191. * Glow post process which adds a glow to emissive areas of the image
  59192. */
  59193. private _glowLayer;
  59194. /**
  59195. * Animations which can be used to tweak settings over a period of time
  59196. */
  59197. animations: Animation[];
  59198. private _imageProcessingConfigurationObserver;
  59199. private _sharpenEnabled;
  59200. private _bloomEnabled;
  59201. private _depthOfFieldEnabled;
  59202. private _depthOfFieldBlurLevel;
  59203. private _fxaaEnabled;
  59204. private _imageProcessingEnabled;
  59205. private _defaultPipelineTextureType;
  59206. private _bloomScale;
  59207. private _chromaticAberrationEnabled;
  59208. private _grainEnabled;
  59209. private _buildAllowed;
  59210. /**
  59211. * Gets active scene
  59212. */
  59213. readonly scene: Scene;
  59214. /**
  59215. * Enable or disable the sharpen process from the pipeline
  59216. */
  59217. sharpenEnabled: boolean;
  59218. private _resizeObserver;
  59219. private _hardwareScaleLevel;
  59220. private _bloomKernel;
  59221. /**
  59222. * Specifies the size of the bloom blur kernel, relative to the final output size
  59223. */
  59224. bloomKernel: number;
  59225. /**
  59226. * Specifies the weight of the bloom in the final rendering
  59227. */
  59228. private _bloomWeight;
  59229. /**
  59230. * Specifies the luma threshold for the area that will be blurred by the bloom
  59231. */
  59232. private _bloomThreshold;
  59233. private _hdr;
  59234. /**
  59235. * The strength of the bloom.
  59236. */
  59237. bloomWeight: number;
  59238. /**
  59239. * The strength of the bloom.
  59240. */
  59241. bloomThreshold: number;
  59242. /**
  59243. * The scale of the bloom, lower value will provide better performance.
  59244. */
  59245. bloomScale: number;
  59246. /**
  59247. * Enable or disable the bloom from the pipeline
  59248. */
  59249. bloomEnabled: boolean;
  59250. private _rebuildBloom;
  59251. /**
  59252. * If the depth of field is enabled.
  59253. */
  59254. depthOfFieldEnabled: boolean;
  59255. /**
  59256. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59257. */
  59258. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59259. /**
  59260. * If the anti aliasing is enabled.
  59261. */
  59262. fxaaEnabled: boolean;
  59263. private _samples;
  59264. /**
  59265. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59266. */
  59267. samples: number;
  59268. /**
  59269. * If image processing is enabled.
  59270. */
  59271. imageProcessingEnabled: boolean;
  59272. /**
  59273. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59274. */
  59275. glowLayerEnabled: boolean;
  59276. /**
  59277. * Gets the glow layer (or null if not defined)
  59278. */
  59279. readonly glowLayer: Nullable<GlowLayer>;
  59280. /**
  59281. * Enable or disable the chromaticAberration process from the pipeline
  59282. */
  59283. chromaticAberrationEnabled: boolean;
  59284. /**
  59285. * Enable or disable the grain process from the pipeline
  59286. */
  59287. grainEnabled: boolean;
  59288. /**
  59289. * @constructor
  59290. * @param name - The rendering pipeline name (default: "")
  59291. * @param hdr - If high dynamic range textures should be used (default: true)
  59292. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59293. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59294. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59295. */
  59296. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59297. /**
  59298. * Get the class name
  59299. * @returns "DefaultRenderingPipeline"
  59300. */
  59301. getClassName(): string;
  59302. /**
  59303. * Force the compilation of the entire pipeline.
  59304. */
  59305. prepare(): void;
  59306. private _hasCleared;
  59307. private _prevPostProcess;
  59308. private _prevPrevPostProcess;
  59309. private _setAutoClearAndTextureSharing;
  59310. private _depthOfFieldSceneObserver;
  59311. private _buildPipeline;
  59312. private _disposePostProcesses;
  59313. /**
  59314. * Adds a camera to the pipeline
  59315. * @param camera the camera to be added
  59316. */
  59317. addCamera(camera: Camera): void;
  59318. /**
  59319. * Removes a camera from the pipeline
  59320. * @param camera the camera to remove
  59321. */
  59322. removeCamera(camera: Camera): void;
  59323. /**
  59324. * Dispose of the pipeline and stop all post processes
  59325. */
  59326. dispose(): void;
  59327. /**
  59328. * Serialize the rendering pipeline (Used when exporting)
  59329. * @returns the serialized object
  59330. */
  59331. serialize(): any;
  59332. /**
  59333. * Parse the serialized pipeline
  59334. * @param source Source pipeline.
  59335. * @param scene The scene to load the pipeline to.
  59336. * @param rootUrl The URL of the serialized pipeline.
  59337. * @returns An instantiated pipeline from the serialized object.
  59338. */
  59339. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59340. }
  59341. }
  59342. declare module BABYLON {
  59343. /** @hidden */
  59344. export var lensHighlightsPixelShader: {
  59345. name: string;
  59346. shader: string;
  59347. };
  59348. }
  59349. declare module BABYLON {
  59350. /** @hidden */
  59351. export var depthOfFieldPixelShader: {
  59352. name: string;
  59353. shader: string;
  59354. };
  59355. }
  59356. declare module BABYLON {
  59357. /**
  59358. * BABYLON.JS Chromatic Aberration GLSL Shader
  59359. * Author: Olivier Guyot
  59360. * Separates very slightly R, G and B colors on the edges of the screen
  59361. * Inspired by Francois Tarlier & Martins Upitis
  59362. */
  59363. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59364. /**
  59365. * @ignore
  59366. * The chromatic aberration PostProcess id in the pipeline
  59367. */
  59368. LensChromaticAberrationEffect: string;
  59369. /**
  59370. * @ignore
  59371. * The highlights enhancing PostProcess id in the pipeline
  59372. */
  59373. HighlightsEnhancingEffect: string;
  59374. /**
  59375. * @ignore
  59376. * The depth-of-field PostProcess id in the pipeline
  59377. */
  59378. LensDepthOfFieldEffect: string;
  59379. private _scene;
  59380. private _depthTexture;
  59381. private _grainTexture;
  59382. private _chromaticAberrationPostProcess;
  59383. private _highlightsPostProcess;
  59384. private _depthOfFieldPostProcess;
  59385. private _edgeBlur;
  59386. private _grainAmount;
  59387. private _chromaticAberration;
  59388. private _distortion;
  59389. private _highlightsGain;
  59390. private _highlightsThreshold;
  59391. private _dofDistance;
  59392. private _dofAperture;
  59393. private _dofDarken;
  59394. private _dofPentagon;
  59395. private _blurNoise;
  59396. /**
  59397. * @constructor
  59398. *
  59399. * Effect parameters are as follow:
  59400. * {
  59401. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59402. * edge_blur: number; // from 0 to x (1 for realism)
  59403. * distortion: number; // from 0 to x (1 for realism)
  59404. * grain_amount: number; // from 0 to 1
  59405. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59406. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59407. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59408. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59409. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59410. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59411. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59412. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59413. * }
  59414. * Note: if an effect parameter is unset, effect is disabled
  59415. *
  59416. * @param name The rendering pipeline name
  59417. * @param parameters - An object containing all parameters (see above)
  59418. * @param scene The scene linked to this pipeline
  59419. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  59420. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59421. */
  59422. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59423. /**
  59424. * Get the class name
  59425. * @returns "LensRenderingPipeline"
  59426. */
  59427. getClassName(): string;
  59428. /**
  59429. * Gets associated scene
  59430. */
  59431. readonly scene: Scene;
  59432. /**
  59433. * Gets or sets the edge blur
  59434. */
  59435. edgeBlur: number;
  59436. /**
  59437. * Gets or sets the grain amount
  59438. */
  59439. grainAmount: number;
  59440. /**
  59441. * Gets or sets the chromatic aberration amount
  59442. */
  59443. chromaticAberration: number;
  59444. /**
  59445. * Gets or sets the depth of field aperture
  59446. */
  59447. dofAperture: number;
  59448. /**
  59449. * Gets or sets the edge distortion
  59450. */
  59451. edgeDistortion: number;
  59452. /**
  59453. * Gets or sets the depth of field distortion
  59454. */
  59455. dofDistortion: number;
  59456. /**
  59457. * Gets or sets the darken out of focus amount
  59458. */
  59459. darkenOutOfFocus: number;
  59460. /**
  59461. * Gets or sets a boolean indicating if blur noise is enabled
  59462. */
  59463. blurNoise: boolean;
  59464. /**
  59465. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59466. */
  59467. pentagonBokeh: boolean;
  59468. /**
  59469. * Gets or sets the highlight grain amount
  59470. */
  59471. highlightsGain: number;
  59472. /**
  59473. * Gets or sets the highlight threshold
  59474. */
  59475. highlightsThreshold: number;
  59476. /**
  59477. * Sets the amount of blur at the edges
  59478. * @param amount blur amount
  59479. */
  59480. setEdgeBlur(amount: number): void;
  59481. /**
  59482. * Sets edge blur to 0
  59483. */
  59484. disableEdgeBlur(): void;
  59485. /**
  59486. * Sets the amout of grain
  59487. * @param amount Amount of grain
  59488. */
  59489. setGrainAmount(amount: number): void;
  59490. /**
  59491. * Set grain amount to 0
  59492. */
  59493. disableGrain(): void;
  59494. /**
  59495. * Sets the chromatic aberration amount
  59496. * @param amount amount of chromatic aberration
  59497. */
  59498. setChromaticAberration(amount: number): void;
  59499. /**
  59500. * Sets chromatic aberration amount to 0
  59501. */
  59502. disableChromaticAberration(): void;
  59503. /**
  59504. * Sets the EdgeDistortion amount
  59505. * @param amount amount of EdgeDistortion
  59506. */
  59507. setEdgeDistortion(amount: number): void;
  59508. /**
  59509. * Sets edge distortion to 0
  59510. */
  59511. disableEdgeDistortion(): void;
  59512. /**
  59513. * Sets the FocusDistance amount
  59514. * @param amount amount of FocusDistance
  59515. */
  59516. setFocusDistance(amount: number): void;
  59517. /**
  59518. * Disables depth of field
  59519. */
  59520. disableDepthOfField(): void;
  59521. /**
  59522. * Sets the Aperture amount
  59523. * @param amount amount of Aperture
  59524. */
  59525. setAperture(amount: number): void;
  59526. /**
  59527. * Sets the DarkenOutOfFocus amount
  59528. * @param amount amount of DarkenOutOfFocus
  59529. */
  59530. setDarkenOutOfFocus(amount: number): void;
  59531. private _pentagonBokehIsEnabled;
  59532. /**
  59533. * Creates a pentagon bokeh effect
  59534. */
  59535. enablePentagonBokeh(): void;
  59536. /**
  59537. * Disables the pentagon bokeh effect
  59538. */
  59539. disablePentagonBokeh(): void;
  59540. /**
  59541. * Enables noise blur
  59542. */
  59543. enableNoiseBlur(): void;
  59544. /**
  59545. * Disables noise blur
  59546. */
  59547. disableNoiseBlur(): void;
  59548. /**
  59549. * Sets the HighlightsGain amount
  59550. * @param amount amount of HighlightsGain
  59551. */
  59552. setHighlightsGain(amount: number): void;
  59553. /**
  59554. * Sets the HighlightsThreshold amount
  59555. * @param amount amount of HighlightsThreshold
  59556. */
  59557. setHighlightsThreshold(amount: number): void;
  59558. /**
  59559. * Disables highlights
  59560. */
  59561. disableHighlights(): void;
  59562. /**
  59563. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59564. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59565. */
  59566. dispose(disableDepthRender?: boolean): void;
  59567. private _createChromaticAberrationPostProcess;
  59568. private _createHighlightsPostProcess;
  59569. private _createDepthOfFieldPostProcess;
  59570. private _createGrainTexture;
  59571. }
  59572. }
  59573. declare module BABYLON {
  59574. /** @hidden */
  59575. export var ssao2PixelShader: {
  59576. name: string;
  59577. shader: string;
  59578. };
  59579. }
  59580. declare module BABYLON {
  59581. /** @hidden */
  59582. export var ssaoCombinePixelShader: {
  59583. name: string;
  59584. shader: string;
  59585. };
  59586. }
  59587. declare module BABYLON {
  59588. /**
  59589. * Render pipeline to produce ssao effect
  59590. */
  59591. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59592. /**
  59593. * @ignore
  59594. * The PassPostProcess id in the pipeline that contains the original scene color
  59595. */
  59596. SSAOOriginalSceneColorEffect: string;
  59597. /**
  59598. * @ignore
  59599. * The SSAO PostProcess id in the pipeline
  59600. */
  59601. SSAORenderEffect: string;
  59602. /**
  59603. * @ignore
  59604. * The horizontal blur PostProcess id in the pipeline
  59605. */
  59606. SSAOBlurHRenderEffect: string;
  59607. /**
  59608. * @ignore
  59609. * The vertical blur PostProcess id in the pipeline
  59610. */
  59611. SSAOBlurVRenderEffect: string;
  59612. /**
  59613. * @ignore
  59614. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59615. */
  59616. SSAOCombineRenderEffect: string;
  59617. /**
  59618. * The output strength of the SSAO post-process. Default value is 1.0.
  59619. */
  59620. totalStrength: number;
  59621. /**
  59622. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59623. */
  59624. maxZ: number;
  59625. /**
  59626. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59627. */
  59628. minZAspect: number;
  59629. private _samples;
  59630. /**
  59631. * Number of samples used for the SSAO calculations. Default value is 8
  59632. */
  59633. samples: number;
  59634. private _textureSamples;
  59635. /**
  59636. * Number of samples to use for antialiasing
  59637. */
  59638. textureSamples: number;
  59639. /**
  59640. * Ratio object used for SSAO ratio and blur ratio
  59641. */
  59642. private _ratio;
  59643. /**
  59644. * Dynamically generated sphere sampler.
  59645. */
  59646. private _sampleSphere;
  59647. /**
  59648. * Blur filter offsets
  59649. */
  59650. private _samplerOffsets;
  59651. private _expensiveBlur;
  59652. /**
  59653. * If bilateral blur should be used
  59654. */
  59655. expensiveBlur: boolean;
  59656. /**
  59657. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59658. */
  59659. radius: number;
  59660. /**
  59661. * The base color of the SSAO post-process
  59662. * The final result is "base + ssao" between [0, 1]
  59663. */
  59664. base: number;
  59665. /**
  59666. * Support test.
  59667. */
  59668. static readonly IsSupported: boolean;
  59669. private _scene;
  59670. private _depthTexture;
  59671. private _normalTexture;
  59672. private _randomTexture;
  59673. private _originalColorPostProcess;
  59674. private _ssaoPostProcess;
  59675. private _blurHPostProcess;
  59676. private _blurVPostProcess;
  59677. private _ssaoCombinePostProcess;
  59678. private _firstUpdate;
  59679. /**
  59680. * Gets active scene
  59681. */
  59682. readonly scene: Scene;
  59683. /**
  59684. * @constructor
  59685. * @param name The rendering pipeline name
  59686. * @param scene The scene linked to this pipeline
  59687. * @param ratio The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, blurRatio: 1.0 }
  59688. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59689. */
  59690. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59691. /**
  59692. * Get the class name
  59693. * @returns "SSAO2RenderingPipeline"
  59694. */
  59695. getClassName(): string;
  59696. /**
  59697. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59698. */
  59699. dispose(disableGeometryBufferRenderer?: boolean): void;
  59700. private _createBlurPostProcess;
  59701. /** @hidden */ private _rebuild(): void;
  59702. private _bits;
  59703. private _radicalInverse_VdC;
  59704. private _hammersley;
  59705. private _hemisphereSample_uniform;
  59706. private _generateHemisphere;
  59707. private _createSSAOPostProcess;
  59708. private _createSSAOCombinePostProcess;
  59709. private _createRandomTexture;
  59710. /**
  59711. * Serialize the rendering pipeline (Used when exporting)
  59712. * @returns the serialized object
  59713. */
  59714. serialize(): any;
  59715. /**
  59716. * Parse the serialized pipeline
  59717. * @param source Source pipeline.
  59718. * @param scene The scene to load the pipeline to.
  59719. * @param rootUrl The URL of the serialized pipeline.
  59720. * @returns An instantiated pipeline from the serialized object.
  59721. */
  59722. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59723. }
  59724. }
  59725. declare module BABYLON {
  59726. /** @hidden */
  59727. export var ssaoPixelShader: {
  59728. name: string;
  59729. shader: string;
  59730. };
  59731. }
  59732. declare module BABYLON {
  59733. /**
  59734. * Render pipeline to produce ssao effect
  59735. */
  59736. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59737. /**
  59738. * @ignore
  59739. * The PassPostProcess id in the pipeline that contains the original scene color
  59740. */
  59741. SSAOOriginalSceneColorEffect: string;
  59742. /**
  59743. * @ignore
  59744. * The SSAO PostProcess id in the pipeline
  59745. */
  59746. SSAORenderEffect: string;
  59747. /**
  59748. * @ignore
  59749. * The horizontal blur PostProcess id in the pipeline
  59750. */
  59751. SSAOBlurHRenderEffect: string;
  59752. /**
  59753. * @ignore
  59754. * The vertical blur PostProcess id in the pipeline
  59755. */
  59756. SSAOBlurVRenderEffect: string;
  59757. /**
  59758. * @ignore
  59759. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59760. */
  59761. SSAOCombineRenderEffect: string;
  59762. /**
  59763. * The output strength of the SSAO post-process. Default value is 1.0.
  59764. */
  59765. totalStrength: number;
  59766. /**
  59767. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59768. */
  59769. radius: number;
  59770. /**
  59771. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59772. * Must not be equal to fallOff and superior to fallOff.
  59773. * Default value is 0.0075
  59774. */
  59775. area: number;
  59776. /**
  59777. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59778. * Must not be equal to area and inferior to area.
  59779. * Default value is 0.000001
  59780. */
  59781. fallOff: number;
  59782. /**
  59783. * The base color of the SSAO post-process
  59784. * The final result is "base + ssao" between [0, 1]
  59785. */
  59786. base: number;
  59787. private _scene;
  59788. private _depthTexture;
  59789. private _randomTexture;
  59790. private _originalColorPostProcess;
  59791. private _ssaoPostProcess;
  59792. private _blurHPostProcess;
  59793. private _blurVPostProcess;
  59794. private _ssaoCombinePostProcess;
  59795. private _firstUpdate;
  59796. /**
  59797. * Gets active scene
  59798. */
  59799. readonly scene: Scene;
  59800. /**
  59801. * @constructor
  59802. * @param name - The rendering pipeline name
  59803. * @param scene - The scene linked to this pipeline
  59804. * @param ratio - The size of the postprocesses. Can be a number shared between passes or an object for more precision: { ssaoRatio: 0.5, combineRatio: 1.0 }
  59805. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59806. */
  59807. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59808. /**
  59809. * Get the class name
  59810. * @returns "SSAORenderingPipeline"
  59811. */
  59812. getClassName(): string;
  59813. /**
  59814. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59815. */
  59816. dispose(disableDepthRender?: boolean): void;
  59817. private _createBlurPostProcess;
  59818. /** @hidden */ private _rebuild(): void;
  59819. private _createSSAOPostProcess;
  59820. private _createSSAOCombinePostProcess;
  59821. private _createRandomTexture;
  59822. }
  59823. }
  59824. declare module BABYLON {
  59825. /** @hidden */
  59826. export var standardPixelShader: {
  59827. name: string;
  59828. shader: string;
  59829. };
  59830. }
  59831. declare module BABYLON {
  59832. /**
  59833. * Standard rendering pipeline
  59834. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59835. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59836. */
  59837. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59838. /**
  59839. * Public members
  59840. */
  59841. /**
  59842. * Post-process which contains the original scene color before the pipeline applies all the effects
  59843. */
  59844. originalPostProcess: Nullable<PostProcess>;
  59845. /**
  59846. * Post-process used to down scale an image x4
  59847. */
  59848. downSampleX4PostProcess: Nullable<PostProcess>;
  59849. /**
  59850. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59851. */
  59852. brightPassPostProcess: Nullable<PostProcess>;
  59853. /**
  59854. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59855. */
  59856. blurHPostProcesses: PostProcess[];
  59857. /**
  59858. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59859. */
  59860. blurVPostProcesses: PostProcess[];
  59861. /**
  59862. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59863. */
  59864. textureAdderPostProcess: Nullable<PostProcess>;
  59865. /**
  59866. * Post-process used to create volumetric lighting effect
  59867. */
  59868. volumetricLightPostProcess: Nullable<PostProcess>;
  59869. /**
  59870. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59871. */
  59872. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59873. /**
  59874. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59875. */
  59876. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59877. /**
  59878. * Post-process used to merge the volumetric light effect and the real scene color
  59879. */
  59880. volumetricLightMergePostProces: Nullable<PostProcess>;
  59881. /**
  59882. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59883. */
  59884. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59885. /**
  59886. * Base post-process used to calculate the average luminance of the final image for HDR
  59887. */
  59888. luminancePostProcess: Nullable<PostProcess>;
  59889. /**
  59890. * Post-processes used to create down sample post-processes in order to get
  59891. * the average luminance of the final image for HDR
  59892. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59893. */
  59894. luminanceDownSamplePostProcesses: PostProcess[];
  59895. /**
  59896. * Post-process used to create a HDR effect (light adaptation)
  59897. */
  59898. hdrPostProcess: Nullable<PostProcess>;
  59899. /**
  59900. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59901. */
  59902. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59903. /**
  59904. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59905. */
  59906. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59907. /**
  59908. * Post-process used to merge the final HDR post-process and the real scene color
  59909. */
  59910. hdrFinalPostProcess: Nullable<PostProcess>;
  59911. /**
  59912. * Post-process used to create a lens flare effect
  59913. */
  59914. lensFlarePostProcess: Nullable<PostProcess>;
  59915. /**
  59916. * Post-process that merges the result of the lens flare post-process and the real scene color
  59917. */
  59918. lensFlareComposePostProcess: Nullable<PostProcess>;
  59919. /**
  59920. * Post-process used to create a motion blur effect
  59921. */
  59922. motionBlurPostProcess: Nullable<PostProcess>;
  59923. /**
  59924. * Post-process used to create a depth of field effect
  59925. */
  59926. depthOfFieldPostProcess: Nullable<PostProcess>;
  59927. /**
  59928. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59929. */
  59930. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59931. /**
  59932. * Represents the brightness threshold in order to configure the illuminated surfaces
  59933. */
  59934. brightThreshold: number;
  59935. /**
  59936. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59937. */
  59938. blurWidth: number;
  59939. /**
  59940. * Sets if the blur for highlighted surfaces must be only horizontal
  59941. */
  59942. horizontalBlur: boolean;
  59943. /**
  59944. * Gets the overall exposure used by the pipeline
  59945. */
  59946. /**
  59947. * Sets the overall exposure used by the pipeline
  59948. */
  59949. exposure: number;
  59950. /**
  59951. * Texture used typically to simulate "dirty" on camera lens
  59952. */
  59953. lensTexture: Nullable<Texture>;
  59954. /**
  59955. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59956. */
  59957. volumetricLightCoefficient: number;
  59958. /**
  59959. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59960. */
  59961. volumetricLightPower: number;
  59962. /**
  59963. * Used the set the blur intensity to smooth the volumetric lights
  59964. */
  59965. volumetricLightBlurScale: number;
  59966. /**
  59967. * Light (spot or directional) used to generate the volumetric lights rays
  59968. * The source light must have a shadow generate so the pipeline can get its
  59969. * depth map
  59970. */
  59971. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59972. /**
  59973. * For eye adaptation, represents the minimum luminance the eye can see
  59974. */
  59975. hdrMinimumLuminance: number;
  59976. /**
  59977. * For eye adaptation, represents the decrease luminance speed
  59978. */
  59979. hdrDecreaseRate: number;
  59980. /**
  59981. * For eye adaptation, represents the increase luminance speed
  59982. */
  59983. hdrIncreaseRate: number;
  59984. /**
  59985. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59986. */
  59987. /**
  59988. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59989. */
  59990. hdrAutoExposure: boolean;
  59991. /**
  59992. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59993. */
  59994. lensColorTexture: Nullable<Texture>;
  59995. /**
  59996. * The overall strengh for the lens flare effect
  59997. */
  59998. lensFlareStrength: number;
  59999. /**
  60000. * Dispersion coefficient for lens flare ghosts
  60001. */
  60002. lensFlareGhostDispersal: number;
  60003. /**
  60004. * Main lens flare halo width
  60005. */
  60006. lensFlareHaloWidth: number;
  60007. /**
  60008. * Based on the lens distortion effect, defines how much the lens flare result
  60009. * is distorted
  60010. */
  60011. lensFlareDistortionStrength: number;
  60012. /**
  60013. * Configures the blur intensity used for for lens flare (halo)
  60014. */
  60015. lensFlareBlurWidth: number;
  60016. /**
  60017. * Lens star texture must be used to simulate rays on the flares and is available
  60018. * in the documentation
  60019. */
  60020. lensStarTexture: Nullable<Texture>;
  60021. /**
  60022. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60023. * flare effect by taking account of the dirt texture
  60024. */
  60025. lensFlareDirtTexture: Nullable<Texture>;
  60026. /**
  60027. * Represents the focal length for the depth of field effect
  60028. */
  60029. depthOfFieldDistance: number;
  60030. /**
  60031. * Represents the blur intensity for the blurred part of the depth of field effect
  60032. */
  60033. depthOfFieldBlurWidth: number;
  60034. /**
  60035. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60036. */
  60037. /**
  60038. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60039. */
  60040. motionStrength: number;
  60041. /**
  60042. * Gets wether or not the motion blur post-process is object based or screen based.
  60043. */
  60044. /**
  60045. * Sets wether or not the motion blur post-process should be object based or screen based
  60046. */
  60047. objectBasedMotionBlur: boolean;
  60048. /**
  60049. * List of animations for the pipeline (IAnimatable implementation)
  60050. */
  60051. animations: Animation[];
  60052. /**
  60053. * Private members
  60054. */
  60055. private _scene;
  60056. private _currentDepthOfFieldSource;
  60057. private _basePostProcess;
  60058. private _fixedExposure;
  60059. private _currentExposure;
  60060. private _hdrAutoExposure;
  60061. private _hdrCurrentLuminance;
  60062. private _motionStrength;
  60063. private _isObjectBasedMotionBlur;
  60064. private _floatTextureType;
  60065. private _camerasToBeAttached;
  60066. private _ratio;
  60067. private _bloomEnabled;
  60068. private _depthOfFieldEnabled;
  60069. private _vlsEnabled;
  60070. private _lensFlareEnabled;
  60071. private _hdrEnabled;
  60072. private _motionBlurEnabled;
  60073. private _fxaaEnabled;
  60074. private _motionBlurSamples;
  60075. private _volumetricLightStepsCount;
  60076. private _samples;
  60077. /**
  60078. * @ignore
  60079. * Specifies if the bloom pipeline is enabled
  60080. */
  60081. BloomEnabled: boolean;
  60082. /**
  60083. * @ignore
  60084. * Specifies if the depth of field pipeline is enabed
  60085. */
  60086. DepthOfFieldEnabled: boolean;
  60087. /**
  60088. * @ignore
  60089. * Specifies if the lens flare pipeline is enabed
  60090. */
  60091. LensFlareEnabled: boolean;
  60092. /**
  60093. * @ignore
  60094. * Specifies if the HDR pipeline is enabled
  60095. */
  60096. HDREnabled: boolean;
  60097. /**
  60098. * @ignore
  60099. * Specifies if the volumetric lights scattering effect is enabled
  60100. */
  60101. VLSEnabled: boolean;
  60102. /**
  60103. * @ignore
  60104. * Specifies if the motion blur effect is enabled
  60105. */
  60106. MotionBlurEnabled: boolean;
  60107. /**
  60108. * Specifies if anti-aliasing is enabled
  60109. */
  60110. fxaaEnabled: boolean;
  60111. /**
  60112. * Specifies the number of steps used to calculate the volumetric lights
  60113. * Typically in interval [50, 200]
  60114. */
  60115. volumetricLightStepsCount: number;
  60116. /**
  60117. * Specifies the number of samples used for the motion blur effect
  60118. * Typically in interval [16, 64]
  60119. */
  60120. motionBlurSamples: number;
  60121. /**
  60122. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60123. */
  60124. samples: number;
  60125. /**
  60126. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60127. * @constructor
  60128. * @param name The rendering pipeline name
  60129. * @param scene The scene linked to this pipeline
  60130. * @param ratio The size of the postprocesses (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  60131. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60132. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60133. */
  60134. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60135. private _buildPipeline;
  60136. private _createDownSampleX4PostProcess;
  60137. private _createBrightPassPostProcess;
  60138. private _createBlurPostProcesses;
  60139. private _createTextureAdderPostProcess;
  60140. private _createVolumetricLightPostProcess;
  60141. private _createLuminancePostProcesses;
  60142. private _createHdrPostProcess;
  60143. private _createLensFlarePostProcess;
  60144. private _createDepthOfFieldPostProcess;
  60145. private _createMotionBlurPostProcess;
  60146. private _getDepthTexture;
  60147. private _disposePostProcesses;
  60148. /**
  60149. * Dispose of the pipeline and stop all post processes
  60150. */
  60151. dispose(): void;
  60152. /**
  60153. * Serialize the rendering pipeline (Used when exporting)
  60154. * @returns the serialized object
  60155. */
  60156. serialize(): any;
  60157. /**
  60158. * Parse the serialized pipeline
  60159. * @param source Source pipeline.
  60160. * @param scene The scene to load the pipeline to.
  60161. * @param rootUrl The URL of the serialized pipeline.
  60162. * @returns An instantiated pipeline from the serialized object.
  60163. */
  60164. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60165. /**
  60166. * Luminance steps
  60167. */
  60168. static LuminanceSteps: number;
  60169. }
  60170. }
  60171. declare module BABYLON {
  60172. /** @hidden */
  60173. export var tonemapPixelShader: {
  60174. name: string;
  60175. shader: string;
  60176. };
  60177. }
  60178. declare module BABYLON {
  60179. /** Defines operator used for tonemapping */
  60180. export enum TonemappingOperator {
  60181. /** Hable */
  60182. Hable = 0,
  60183. /** Reinhard */
  60184. Reinhard = 1,
  60185. /** HejiDawson */
  60186. HejiDawson = 2,
  60187. /** Photographic */
  60188. Photographic = 3
  60189. }
  60190. /**
  60191. * Defines a post process to apply tone mapping
  60192. */
  60193. export class TonemapPostProcess extends PostProcess {
  60194. private _operator;
  60195. /** Defines the required exposure adjustement */
  60196. exposureAdjustment: number;
  60197. /**
  60198. * Creates a new TonemapPostProcess
  60199. * @param name defines the name of the postprocess
  60200. * @param _operator defines the operator to use
  60201. * @param exposureAdjustment defines the required exposure adjustement
  60202. * @param camera defines the camera to use (can be null)
  60203. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60204. * @param engine defines the hosting engine (can be ignore if camera is set)
  60205. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60206. */
  60207. constructor(name: string, _operator: TonemappingOperator,
  60208. /** Defines the required exposure adjustement */
  60209. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60210. }
  60211. }
  60212. declare module BABYLON {
  60213. /** @hidden */
  60214. export var depthVertexShader: {
  60215. name: string;
  60216. shader: string;
  60217. };
  60218. }
  60219. declare module BABYLON {
  60220. /** @hidden */
  60221. export var volumetricLightScatteringPixelShader: {
  60222. name: string;
  60223. shader: string;
  60224. };
  60225. }
  60226. declare module BABYLON {
  60227. /** @hidden */
  60228. export var volumetricLightScatteringPassVertexShader: {
  60229. name: string;
  60230. shader: string;
  60231. };
  60232. }
  60233. declare module BABYLON {
  60234. /** @hidden */
  60235. export var volumetricLightScatteringPassPixelShader: {
  60236. name: string;
  60237. shader: string;
  60238. };
  60239. }
  60240. declare module BABYLON {
  60241. /**
  60242. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60243. */
  60244. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60245. private _volumetricLightScatteringPass;
  60246. private _volumetricLightScatteringRTT;
  60247. private _viewPort;
  60248. private _screenCoordinates;
  60249. private _cachedDefines;
  60250. /**
  60251. * If not undefined, the mesh position is computed from the attached node position
  60252. */
  60253. attachedNode: {
  60254. position: Vector3;
  60255. };
  60256. /**
  60257. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60258. */
  60259. customMeshPosition: Vector3;
  60260. /**
  60261. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60262. */
  60263. useCustomMeshPosition: boolean;
  60264. /**
  60265. * If the post-process should inverse the light scattering direction
  60266. */
  60267. invert: boolean;
  60268. /**
  60269. * The internal mesh used by the post-process
  60270. */
  60271. mesh: Mesh;
  60272. /**
  60273. * @hidden
  60274. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60275. */
  60276. useDiffuseColor: boolean;
  60277. /**
  60278. * Array containing the excluded meshes not rendered in the internal pass
  60279. */
  60280. excludedMeshes: AbstractMesh[];
  60281. /**
  60282. * Controls the overall intensity of the post-process
  60283. */
  60284. exposure: number;
  60285. /**
  60286. * Dissipates each sample's contribution in range [0, 1]
  60287. */
  60288. decay: number;
  60289. /**
  60290. * Controls the overall intensity of each sample
  60291. */
  60292. weight: number;
  60293. /**
  60294. * Controls the density of each sample
  60295. */
  60296. density: number;
  60297. /**
  60298. * @constructor
  60299. * @param name The post-process name
  60300. * @param ratio The size of the post-process and/or internal pass (0.5 means that your postprocess will have a width = canvas.width 0.5 and a height = canvas.height 0.5)
  60301. * @param camera The camera that the post-process will be attached to
  60302. * @param mesh The mesh used to create the light scattering
  60303. * @param samples The post-process quality, default 100
  60304. * @param samplingModeThe post-process filtering mode
  60305. * @param engine The babylon engine
  60306. * @param reusable If the post-process is reusable
  60307. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60308. */
  60309. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60310. /**
  60311. * Returns the string "VolumetricLightScatteringPostProcess"
  60312. * @returns "VolumetricLightScatteringPostProcess"
  60313. */
  60314. getClassName(): string;
  60315. private _isReady;
  60316. /**
  60317. * Sets the new light position for light scattering effect
  60318. * @param position The new custom light position
  60319. */
  60320. setCustomMeshPosition(position: Vector3): void;
  60321. /**
  60322. * Returns the light position for light scattering effect
  60323. * @return Vector3 The custom light position
  60324. */
  60325. getCustomMeshPosition(): Vector3;
  60326. /**
  60327. * Disposes the internal assets and detaches the post-process from the camera
  60328. */
  60329. dispose(camera: Camera): void;
  60330. /**
  60331. * Returns the render target texture used by the post-process
  60332. * @return the render target texture used by the post-process
  60333. */
  60334. getPass(): RenderTargetTexture;
  60335. private _meshExcluded;
  60336. private _createPass;
  60337. private _updateMeshScreenCoordinates;
  60338. /**
  60339. * Creates a default mesh for the Volumeric Light Scattering post-process
  60340. * @param name The mesh name
  60341. * @param scene The scene where to create the mesh
  60342. * @return the default mesh
  60343. */
  60344. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60345. }
  60346. }
  60347. declare module BABYLON {
  60348. interface Scene {
  60349. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  60350. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  60351. /**
  60352. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60353. */
  60354. forceShowBoundingBoxes: boolean;
  60355. /**
  60356. * Gets the bounding box renderer associated with the scene
  60357. * @returns a BoundingBoxRenderer
  60358. */
  60359. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60360. }
  60361. interface AbstractMesh {
  60362. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  60363. /**
  60364. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60365. */
  60366. showBoundingBox: boolean;
  60367. }
  60368. /**
  60369. * Component responsible of rendering the bounding box of the meshes in a scene.
  60370. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60371. */
  60372. export class BoundingBoxRenderer implements ISceneComponent {
  60373. /**
  60374. * The component name helpfull to identify the component in the list of scene components.
  60375. */
  60376. readonly name: string;
  60377. /**
  60378. * The scene the component belongs to.
  60379. */
  60380. scene: Scene;
  60381. /**
  60382. * Color of the bounding box lines placed in front of an object
  60383. */
  60384. frontColor: Color3;
  60385. /**
  60386. * Color of the bounding box lines placed behind an object
  60387. */
  60388. backColor: Color3;
  60389. /**
  60390. * Defines if the renderer should show the back lines or not
  60391. */
  60392. showBackLines: boolean;
  60393. /**
  60394. * @hidden
  60395. */
  60396. renderList: SmartArray<BoundingBox>;
  60397. private _colorShader;
  60398. private _vertexBuffers;
  60399. private _indexBuffer;
  60400. private _fillIndexBuffer;
  60401. private _fillIndexData;
  60402. /**
  60403. * Instantiates a new bounding box renderer in a scene.
  60404. * @param scene the scene the renderer renders in
  60405. */
  60406. constructor(scene: Scene);
  60407. /**
  60408. * Registers the component in a given scene
  60409. */
  60410. register(): void;
  60411. private _evaluateSubMesh;
  60412. private _activeMesh;
  60413. private _prepareRessources;
  60414. private _createIndexBuffer;
  60415. /**
  60416. * Rebuilds the elements related to this component in case of
  60417. * context lost for instance.
  60418. */
  60419. rebuild(): void;
  60420. /**
  60421. * @hidden
  60422. */
  60423. reset(): void;
  60424. /**
  60425. * Render the bounding boxes of a specific rendering group
  60426. * @param renderingGroupId defines the rendering group to render
  60427. */
  60428. render(renderingGroupId: number): void;
  60429. /**
  60430. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60431. * @param mesh Define the mesh to render the occlusion bounding box for
  60432. */
  60433. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60434. /**
  60435. * Dispose and release the resources attached to this renderer.
  60436. */
  60437. dispose(): void;
  60438. }
  60439. }
  60440. declare module BABYLON {
  60441. /** @hidden */
  60442. export var depthPixelShader: {
  60443. name: string;
  60444. shader: string;
  60445. };
  60446. }
  60447. declare module BABYLON {
  60448. /**
  60449. * This represents a depth renderer in Babylon.
  60450. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60451. */
  60452. export class DepthRenderer {
  60453. private _scene;
  60454. private _depthMap;
  60455. private _effect;
  60456. private readonly _storeNonLinearDepth;
  60457. private readonly _clearColor;
  60458. /** Get if the depth renderer is using packed depth or not */
  60459. readonly isPacked: boolean;
  60460. private _cachedDefines;
  60461. private _camera;
  60462. /**
  60463. * Specifiess that the depth renderer will only be used within
  60464. * the camera it is created for.
  60465. * This can help forcing its rendering during the camera processing.
  60466. */
  60467. useOnlyInActiveCamera: boolean;
  60468. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  60469. /**
  60470. * Instantiates a depth renderer
  60471. * @param scene The scene the renderer belongs to
  60472. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60473. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60474. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60475. */
  60476. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60477. /**
  60478. * Creates the depth rendering effect and checks if the effect is ready.
  60479. * @param subMesh The submesh to be used to render the depth map of
  60480. * @param useInstances If multiple world instances should be used
  60481. * @returns if the depth renderer is ready to render the depth map
  60482. */
  60483. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60484. /**
  60485. * Gets the texture which the depth map will be written to.
  60486. * @returns The depth map texture
  60487. */
  60488. getDepthMap(): RenderTargetTexture;
  60489. /**
  60490. * Disposes of the depth renderer.
  60491. */
  60492. dispose(): void;
  60493. }
  60494. }
  60495. declare module BABYLON {
  60496. interface Scene {
  60497. /** @hidden (Backing field) */ private _depthRenderer: {
  60498. [id: string]: DepthRenderer;
  60499. };
  60500. /**
  60501. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60502. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60503. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60504. * @returns the created depth renderer
  60505. */
  60506. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  60507. /**
  60508. * Disables a depth renderer for a given camera
  60509. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60510. */
  60511. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60512. }
  60513. /**
  60514. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60515. * in several rendering techniques.
  60516. */
  60517. export class DepthRendererSceneComponent implements ISceneComponent {
  60518. /**
  60519. * The component name helpfull to identify the component in the list of scene components.
  60520. */
  60521. readonly name: string;
  60522. /**
  60523. * The scene the component belongs to.
  60524. */
  60525. scene: Scene;
  60526. /**
  60527. * Creates a new instance of the component for the given scene
  60528. * @param scene Defines the scene to register the component in
  60529. */
  60530. constructor(scene: Scene);
  60531. /**
  60532. * Registers the component in a given scene
  60533. */
  60534. register(): void;
  60535. /**
  60536. * Rebuilds the elements related to this component in case of
  60537. * context lost for instance.
  60538. */
  60539. rebuild(): void;
  60540. /**
  60541. * Disposes the component and the associated ressources
  60542. */
  60543. dispose(): void;
  60544. private _gatherRenderTargets;
  60545. private _gatherActiveCameraRenderTargets;
  60546. }
  60547. }
  60548. declare module BABYLON {
  60549. /** @hidden */
  60550. export var outlinePixelShader: {
  60551. name: string;
  60552. shader: string;
  60553. };
  60554. }
  60555. declare module BABYLON {
  60556. /** @hidden */
  60557. export var outlineVertexShader: {
  60558. name: string;
  60559. shader: string;
  60560. };
  60561. }
  60562. declare module BABYLON {
  60563. interface Scene {
  60564. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  60565. /**
  60566. * Gets the outline renderer associated with the scene
  60567. * @returns a OutlineRenderer
  60568. */
  60569. getOutlineRenderer(): OutlineRenderer;
  60570. }
  60571. interface AbstractMesh {
  60572. /** @hidden (Backing field) */ private _renderOutline: boolean;
  60573. /**
  60574. * Gets or sets a boolean indicating if the outline must be rendered as well
  60575. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60576. */
  60577. renderOutline: boolean;
  60578. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  60579. /**
  60580. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60581. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60582. */
  60583. renderOverlay: boolean;
  60584. }
  60585. /**
  60586. * This class is responsible to draw bothe outline/overlay of meshes.
  60587. * It should not be used directly but through the available method on mesh.
  60588. */
  60589. export class OutlineRenderer implements ISceneComponent {
  60590. /**
  60591. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60592. */
  60593. private static _StencilReference;
  60594. /**
  60595. * The name of the component. Each component must have a unique name.
  60596. */
  60597. name: string;
  60598. /**
  60599. * The scene the component belongs to.
  60600. */
  60601. scene: Scene;
  60602. /**
  60603. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60604. */
  60605. zOffset: number;
  60606. private _engine;
  60607. private _effect;
  60608. private _cachedDefines;
  60609. private _savedDepthWrite;
  60610. /**
  60611. * Instantiates a new outline renderer. (There could be only one per scene).
  60612. * @param scene Defines the scene it belongs to
  60613. */
  60614. constructor(scene: Scene);
  60615. /**
  60616. * Register the component to one instance of a scene.
  60617. */
  60618. register(): void;
  60619. /**
  60620. * Rebuilds the elements related to this component in case of
  60621. * context lost for instance.
  60622. */
  60623. rebuild(): void;
  60624. /**
  60625. * Disposes the component and the associated ressources.
  60626. */
  60627. dispose(): void;
  60628. /**
  60629. * Renders the outline in the canvas.
  60630. * @param subMesh Defines the sumesh to render
  60631. * @param batch Defines the batch of meshes in case of instances
  60632. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60633. */
  60634. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60635. /**
  60636. * Returns whether or not the outline renderer is ready for a given submesh.
  60637. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60638. * @param subMesh Defines the submesh to check readyness for
  60639. * @param useInstances Defines wheter wee are trying to render instances or not
  60640. * @returns true if ready otherwise false
  60641. */
  60642. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60643. private _beforeRenderingMesh;
  60644. private _afterRenderingMesh;
  60645. }
  60646. }
  60647. declare module BABYLON {
  60648. /**
  60649. * Class used to manage multiple sprites of different sizes on the same spritesheet
  60650. * @see http://doc.babylonjs.com/babylon101/sprites
  60651. */
  60652. export class SpritePackedManager extends SpriteManager {
  60653. /** defines the packed manager's name */
  60654. name: string;
  60655. /**
  60656. * Creates a new sprite manager from a packed sprite sheet
  60657. * @param name defines the manager's name
  60658. * @param imgUrl defines the sprite sheet url
  60659. * @param capacity defines the maximum allowed number of sprites
  60660. * @param scene defines the hosting scene
  60661. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  60662. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  60663. * @param samplingMode defines the smapling mode to use with spritesheet
  60664. * @param fromPacked set to true; do not alter
  60665. */
  60666. constructor(
  60667. /** defines the packed manager's name */
  60668. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  60669. }
  60670. }
  60671. declare module BABYLON {
  60672. /**
  60673. * Defines the list of states available for a task inside a AssetsManager
  60674. */
  60675. export enum AssetTaskState {
  60676. /**
  60677. * Initialization
  60678. */
  60679. INIT = 0,
  60680. /**
  60681. * Running
  60682. */
  60683. RUNNING = 1,
  60684. /**
  60685. * Done
  60686. */
  60687. DONE = 2,
  60688. /**
  60689. * Error
  60690. */
  60691. ERROR = 3
  60692. }
  60693. /**
  60694. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60695. */
  60696. export abstract class AbstractAssetTask {
  60697. /**
  60698. * Task name
  60699. */ name: string;
  60700. /**
  60701. * Callback called when the task is successful
  60702. */
  60703. onSuccess: (task: any) => void;
  60704. /**
  60705. * Callback called when the task is not successful
  60706. */
  60707. onError: (task: any, message?: string, exception?: any) => void;
  60708. /**
  60709. * Creates a new AssetsManager
  60710. * @param name defines the name of the task
  60711. */
  60712. constructor(
  60713. /**
  60714. * Task name
  60715. */ name: string);
  60716. private _isCompleted;
  60717. private _taskState;
  60718. private _errorObject;
  60719. /**
  60720. * Get if the task is completed
  60721. */
  60722. readonly isCompleted: boolean;
  60723. /**
  60724. * Gets the current state of the task
  60725. */
  60726. readonly taskState: AssetTaskState;
  60727. /**
  60728. * Gets the current error object (if task is in error)
  60729. */
  60730. readonly errorObject: {
  60731. message?: string;
  60732. exception?: any;
  60733. };
  60734. /**
  60735. * Internal only
  60736. * @hidden
  60737. */ private _setErrorObject(message?: string, exception?: any): void;
  60738. /**
  60739. * Execute the current task
  60740. * @param scene defines the scene where you want your assets to be loaded
  60741. * @param onSuccess is a callback called when the task is successfully executed
  60742. * @param onError is a callback called if an error occurs
  60743. */
  60744. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60745. /**
  60746. * Execute the current task
  60747. * @param scene defines the scene where you want your assets to be loaded
  60748. * @param onSuccess is a callback called when the task is successfully executed
  60749. * @param onError is a callback called if an error occurs
  60750. */
  60751. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60752. /**
  60753. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60754. * This can be used with failed tasks that have the reason for failure fixed.
  60755. */
  60756. reset(): void;
  60757. private onErrorCallback;
  60758. private onDoneCallback;
  60759. }
  60760. /**
  60761. * Define the interface used by progress events raised during assets loading
  60762. */
  60763. export interface IAssetsProgressEvent {
  60764. /**
  60765. * Defines the number of remaining tasks to process
  60766. */
  60767. remainingCount: number;
  60768. /**
  60769. * Defines the total number of tasks
  60770. */
  60771. totalCount: number;
  60772. /**
  60773. * Defines the task that was just processed
  60774. */
  60775. task: AbstractAssetTask;
  60776. }
  60777. /**
  60778. * Class used to share progress information about assets loading
  60779. */
  60780. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60781. /**
  60782. * Defines the number of remaining tasks to process
  60783. */
  60784. remainingCount: number;
  60785. /**
  60786. * Defines the total number of tasks
  60787. */
  60788. totalCount: number;
  60789. /**
  60790. * Defines the task that was just processed
  60791. */
  60792. task: AbstractAssetTask;
  60793. /**
  60794. * Creates a AssetsProgressEvent
  60795. * @param remainingCount defines the number of remaining tasks to process
  60796. * @param totalCount defines the total number of tasks
  60797. * @param task defines the task that was just processed
  60798. */
  60799. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60800. }
  60801. /**
  60802. * Define a task used by AssetsManager to load meshes
  60803. */
  60804. export class MeshAssetTask extends AbstractAssetTask {
  60805. /**
  60806. * Defines the name of the task
  60807. */
  60808. name: string;
  60809. /**
  60810. * Defines the list of mesh's names you want to load
  60811. */
  60812. meshesNames: any;
  60813. /**
  60814. * Defines the root url to use as a base to load your meshes and associated resources
  60815. */
  60816. rootUrl: string;
  60817. /**
  60818. * Defines the filename of the scene to load from
  60819. */
  60820. sceneFilename: string;
  60821. /**
  60822. * Gets the list of loaded meshes
  60823. */
  60824. loadedMeshes: Array<AbstractMesh>;
  60825. /**
  60826. * Gets the list of loaded particle systems
  60827. */
  60828. loadedParticleSystems: Array<IParticleSystem>;
  60829. /**
  60830. * Gets the list of loaded skeletons
  60831. */
  60832. loadedSkeletons: Array<Skeleton>;
  60833. /**
  60834. * Gets the list of loaded animation groups
  60835. */
  60836. loadedAnimationGroups: Array<AnimationGroup>;
  60837. /**
  60838. * Callback called when the task is successful
  60839. */
  60840. onSuccess: (task: MeshAssetTask) => void;
  60841. /**
  60842. * Callback called when the task is successful
  60843. */
  60844. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60845. /**
  60846. * Creates a new MeshAssetTask
  60847. * @param name defines the name of the task
  60848. * @param meshesNames defines the list of mesh's names you want to load
  60849. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60850. * @param sceneFilename defines the filename of the scene to load from
  60851. */
  60852. constructor(
  60853. /**
  60854. * Defines the name of the task
  60855. */
  60856. name: string,
  60857. /**
  60858. * Defines the list of mesh's names you want to load
  60859. */
  60860. meshesNames: any,
  60861. /**
  60862. * Defines the root url to use as a base to load your meshes and associated resources
  60863. */
  60864. rootUrl: string,
  60865. /**
  60866. * Defines the filename of the scene to load from
  60867. */
  60868. sceneFilename: string);
  60869. /**
  60870. * Execute the current task
  60871. * @param scene defines the scene where you want your assets to be loaded
  60872. * @param onSuccess is a callback called when the task is successfully executed
  60873. * @param onError is a callback called if an error occurs
  60874. */
  60875. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60876. }
  60877. /**
  60878. * Define a task used by AssetsManager to load text content
  60879. */
  60880. export class TextFileAssetTask extends AbstractAssetTask {
  60881. /**
  60882. * Defines the name of the task
  60883. */
  60884. name: string;
  60885. /**
  60886. * Defines the location of the file to load
  60887. */
  60888. url: string;
  60889. /**
  60890. * Gets the loaded text string
  60891. */
  60892. text: string;
  60893. /**
  60894. * Callback called when the task is successful
  60895. */
  60896. onSuccess: (task: TextFileAssetTask) => void;
  60897. /**
  60898. * Callback called when the task is successful
  60899. */
  60900. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60901. /**
  60902. * Creates a new TextFileAssetTask object
  60903. * @param name defines the name of the task
  60904. * @param url defines the location of the file to load
  60905. */
  60906. constructor(
  60907. /**
  60908. * Defines the name of the task
  60909. */
  60910. name: string,
  60911. /**
  60912. * Defines the location of the file to load
  60913. */
  60914. url: string);
  60915. /**
  60916. * Execute the current task
  60917. * @param scene defines the scene where you want your assets to be loaded
  60918. * @param onSuccess is a callback called when the task is successfully executed
  60919. * @param onError is a callback called if an error occurs
  60920. */
  60921. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60922. }
  60923. /**
  60924. * Define a task used by AssetsManager to load binary data
  60925. */
  60926. export class BinaryFileAssetTask extends AbstractAssetTask {
  60927. /**
  60928. * Defines the name of the task
  60929. */
  60930. name: string;
  60931. /**
  60932. * Defines the location of the file to load
  60933. */
  60934. url: string;
  60935. /**
  60936. * Gets the lodaded data (as an array buffer)
  60937. */
  60938. data: ArrayBuffer;
  60939. /**
  60940. * Callback called when the task is successful
  60941. */
  60942. onSuccess: (task: BinaryFileAssetTask) => void;
  60943. /**
  60944. * Callback called when the task is successful
  60945. */
  60946. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60947. /**
  60948. * Creates a new BinaryFileAssetTask object
  60949. * @param name defines the name of the new task
  60950. * @param url defines the location of the file to load
  60951. */
  60952. constructor(
  60953. /**
  60954. * Defines the name of the task
  60955. */
  60956. name: string,
  60957. /**
  60958. * Defines the location of the file to load
  60959. */
  60960. url: string);
  60961. /**
  60962. * Execute the current task
  60963. * @param scene defines the scene where you want your assets to be loaded
  60964. * @param onSuccess is a callback called when the task is successfully executed
  60965. * @param onError is a callback called if an error occurs
  60966. */
  60967. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60968. }
  60969. /**
  60970. * Define a task used by AssetsManager to load images
  60971. */
  60972. export class ImageAssetTask extends AbstractAssetTask {
  60973. /**
  60974. * Defines the name of the task
  60975. */
  60976. name: string;
  60977. /**
  60978. * Defines the location of the image to load
  60979. */
  60980. url: string;
  60981. /**
  60982. * Gets the loaded images
  60983. */
  60984. image: HTMLImageElement;
  60985. /**
  60986. * Callback called when the task is successful
  60987. */
  60988. onSuccess: (task: ImageAssetTask) => void;
  60989. /**
  60990. * Callback called when the task is successful
  60991. */
  60992. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60993. /**
  60994. * Creates a new ImageAssetTask
  60995. * @param name defines the name of the task
  60996. * @param url defines the location of the image to load
  60997. */
  60998. constructor(
  60999. /**
  61000. * Defines the name of the task
  61001. */
  61002. name: string,
  61003. /**
  61004. * Defines the location of the image to load
  61005. */
  61006. url: string);
  61007. /**
  61008. * Execute the current task
  61009. * @param scene defines the scene where you want your assets to be loaded
  61010. * @param onSuccess is a callback called when the task is successfully executed
  61011. * @param onError is a callback called if an error occurs
  61012. */
  61013. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61014. }
  61015. /**
  61016. * Defines the interface used by texture loading tasks
  61017. */
  61018. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61019. /**
  61020. * Gets the loaded texture
  61021. */
  61022. texture: TEX;
  61023. }
  61024. /**
  61025. * Define a task used by AssetsManager to load 2D textures
  61026. */
  61027. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61028. /**
  61029. * Defines the name of the task
  61030. */
  61031. name: string;
  61032. /**
  61033. * Defines the location of the file to load
  61034. */
  61035. url: string;
  61036. /**
  61037. * Defines if mipmap should not be generated (default is false)
  61038. */
  61039. noMipmap?: boolean | undefined;
  61040. /**
  61041. * Defines if texture must be inverted on Y axis (default is false)
  61042. */
  61043. invertY?: boolean | undefined;
  61044. /**
  61045. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61046. */
  61047. samplingMode: number;
  61048. /**
  61049. * Gets the loaded texture
  61050. */
  61051. texture: Texture;
  61052. /**
  61053. * Callback called when the task is successful
  61054. */
  61055. onSuccess: (task: TextureAssetTask) => void;
  61056. /**
  61057. * Callback called when the task is successful
  61058. */
  61059. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61060. /**
  61061. * Creates a new TextureAssetTask object
  61062. * @param name defines the name of the task
  61063. * @param url defines the location of the file to load
  61064. * @param noMipmap defines if mipmap should not be generated (default is false)
  61065. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61066. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61067. */
  61068. constructor(
  61069. /**
  61070. * Defines the name of the task
  61071. */
  61072. name: string,
  61073. /**
  61074. * Defines the location of the file to load
  61075. */
  61076. url: string,
  61077. /**
  61078. * Defines if mipmap should not be generated (default is false)
  61079. */
  61080. noMipmap?: boolean | undefined,
  61081. /**
  61082. * Defines if texture must be inverted on Y axis (default is false)
  61083. */
  61084. invertY?: boolean | undefined,
  61085. /**
  61086. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61087. */
  61088. samplingMode?: number);
  61089. /**
  61090. * Execute the current task
  61091. * @param scene defines the scene where you want your assets to be loaded
  61092. * @param onSuccess is a callback called when the task is successfully executed
  61093. * @param onError is a callback called if an error occurs
  61094. */
  61095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61096. }
  61097. /**
  61098. * Define a task used by AssetsManager to load cube textures
  61099. */
  61100. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61101. /**
  61102. * Defines the name of the task
  61103. */
  61104. name: string;
  61105. /**
  61106. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61107. */
  61108. url: string;
  61109. /**
  61110. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61111. */
  61112. extensions?: string[] | undefined;
  61113. /**
  61114. * Defines if mipmaps should not be generated (default is false)
  61115. */
  61116. noMipmap?: boolean | undefined;
  61117. /**
  61118. * Defines the explicit list of files (undefined by default)
  61119. */
  61120. files?: string[] | undefined;
  61121. /**
  61122. * Gets the loaded texture
  61123. */
  61124. texture: CubeTexture;
  61125. /**
  61126. * Callback called when the task is successful
  61127. */
  61128. onSuccess: (task: CubeTextureAssetTask) => void;
  61129. /**
  61130. * Callback called when the task is successful
  61131. */
  61132. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61133. /**
  61134. * Creates a new CubeTextureAssetTask
  61135. * @param name defines the name of the task
  61136. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61137. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61138. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61139. * @param files defines the explicit list of files (undefined by default)
  61140. */
  61141. constructor(
  61142. /**
  61143. * Defines the name of the task
  61144. */
  61145. name: string,
  61146. /**
  61147. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61148. */
  61149. url: string,
  61150. /**
  61151. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61152. */
  61153. extensions?: string[] | undefined,
  61154. /**
  61155. * Defines if mipmaps should not be generated (default is false)
  61156. */
  61157. noMipmap?: boolean | undefined,
  61158. /**
  61159. * Defines the explicit list of files (undefined by default)
  61160. */
  61161. files?: string[] | undefined);
  61162. /**
  61163. * Execute the current task
  61164. * @param scene defines the scene where you want your assets to be loaded
  61165. * @param onSuccess is a callback called when the task is successfully executed
  61166. * @param onError is a callback called if an error occurs
  61167. */
  61168. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61169. }
  61170. /**
  61171. * Define a task used by AssetsManager to load HDR cube textures
  61172. */
  61173. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61174. /**
  61175. * Defines the name of the task
  61176. */
  61177. name: string;
  61178. /**
  61179. * Defines the location of the file to load
  61180. */
  61181. url: string;
  61182. /**
  61183. * Defines the desired size (the more it increases the longer the generation will be)
  61184. */
  61185. size: number;
  61186. /**
  61187. * Defines if mipmaps should not be generated (default is false)
  61188. */
  61189. noMipmap: boolean;
  61190. /**
  61191. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61192. */
  61193. generateHarmonics: boolean;
  61194. /**
  61195. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  61196. */
  61197. gammaSpace: boolean;
  61198. /**
  61199. * Internal Use Only
  61200. */
  61201. reserved: boolean;
  61202. /**
  61203. * Gets the loaded texture
  61204. */
  61205. texture: HDRCubeTexture;
  61206. /**
  61207. * Callback called when the task is successful
  61208. */
  61209. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61210. /**
  61211. * Callback called when the task is successful
  61212. */
  61213. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61214. /**
  61215. * Creates a new HDRCubeTextureAssetTask object
  61216. * @param name defines the name of the task
  61217. * @param url defines the location of the file to load
  61218. * @param size defines the desired size (the more it increases the longer the generation will be) If the size is omitted this implies you are using a preprocessed cubemap.
  61219. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61220. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61221. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  61222. * @param reserved Internal use only
  61223. */
  61224. constructor(
  61225. /**
  61226. * Defines the name of the task
  61227. */
  61228. name: string,
  61229. /**
  61230. * Defines the location of the file to load
  61231. */
  61232. url: string,
  61233. /**
  61234. * Defines the desired size (the more it increases the longer the generation will be)
  61235. */
  61236. size: number,
  61237. /**
  61238. * Defines if mipmaps should not be generated (default is false)
  61239. */
  61240. noMipmap?: boolean,
  61241. /**
  61242. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61243. */
  61244. generateHarmonics?: boolean,
  61245. /**
  61246. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  61247. */
  61248. gammaSpace?: boolean,
  61249. /**
  61250. * Internal Use Only
  61251. */
  61252. reserved?: boolean);
  61253. /**
  61254. * Execute the current task
  61255. * @param scene defines the scene where you want your assets to be loaded
  61256. * @param onSuccess is a callback called when the task is successfully executed
  61257. * @param onError is a callback called if an error occurs
  61258. */
  61259. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61260. }
  61261. /**
  61262. * Define a task used by AssetsManager to load Equirectangular cube textures
  61263. */
  61264. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61265. /**
  61266. * Defines the name of the task
  61267. */
  61268. name: string;
  61269. /**
  61270. * Defines the location of the file to load
  61271. */
  61272. url: string;
  61273. /**
  61274. * Defines the desired size (the more it increases the longer the generation will be)
  61275. */
  61276. size: number;
  61277. /**
  61278. * Defines if mipmaps should not be generated (default is false)
  61279. */
  61280. noMipmap: boolean;
  61281. /**
  61282. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61283. * but the standard material would require them in Gamma space) (default is true)
  61284. */
  61285. gammaSpace: boolean;
  61286. /**
  61287. * Gets the loaded texture
  61288. */
  61289. texture: EquiRectangularCubeTexture;
  61290. /**
  61291. * Callback called when the task is successful
  61292. */
  61293. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61294. /**
  61295. * Callback called when the task is successful
  61296. */
  61297. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61298. /**
  61299. * Creates a new EquiRectangularCubeTextureAssetTask object
  61300. * @param name defines the name of the task
  61301. * @param url defines the location of the file to load
  61302. * @param size defines the desired size (the more it increases the longer the generation will be)
  61303. * If the size is omitted this implies you are using a preprocessed cubemap.
  61304. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61305. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61306. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61307. * (default is true)
  61308. */
  61309. constructor(
  61310. /**
  61311. * Defines the name of the task
  61312. */
  61313. name: string,
  61314. /**
  61315. * Defines the location of the file to load
  61316. */
  61317. url: string,
  61318. /**
  61319. * Defines the desired size (the more it increases the longer the generation will be)
  61320. */
  61321. size: number,
  61322. /**
  61323. * Defines if mipmaps should not be generated (default is false)
  61324. */
  61325. noMipmap?: boolean,
  61326. /**
  61327. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61328. * but the standard material would require them in Gamma space) (default is true)
  61329. */
  61330. gammaSpace?: boolean);
  61331. /**
  61332. * Execute the current task
  61333. * @param scene defines the scene where you want your assets to be loaded
  61334. * @param onSuccess is a callback called when the task is successfully executed
  61335. * @param onError is a callback called if an error occurs
  61336. */
  61337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61338. }
  61339. /**
  61340. * This class can be used to easily import assets into a scene
  61341. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61342. */
  61343. export class AssetsManager {
  61344. private _scene;
  61345. private _isLoading;
  61346. protected _tasks: AbstractAssetTask[];
  61347. protected _waitingTasksCount: number;
  61348. protected _totalTasksCount: number;
  61349. /**
  61350. * Callback called when all tasks are processed
  61351. */
  61352. onFinish: (tasks: AbstractAssetTask[]) => void;
  61353. /**
  61354. * Callback called when a task is successful
  61355. */
  61356. onTaskSuccess: (task: AbstractAssetTask) => void;
  61357. /**
  61358. * Callback called when a task had an error
  61359. */
  61360. onTaskError: (task: AbstractAssetTask) => void;
  61361. /**
  61362. * Callback called when a task is done (whatever the result is)
  61363. */
  61364. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61365. /**
  61366. * Observable called when all tasks are processed
  61367. */
  61368. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61369. /**
  61370. * Observable called when a task had an error
  61371. */
  61372. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61373. /**
  61374. * Observable called when all tasks were executed
  61375. */
  61376. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61377. /**
  61378. * Observable called when a task is done (whatever the result is)
  61379. */
  61380. onProgressObservable: Observable<IAssetsProgressEvent>;
  61381. /**
  61382. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61383. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61384. */
  61385. useDefaultLoadingScreen: boolean;
  61386. /**
  61387. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61388. * when all assets have been downloaded.
  61389. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61390. */
  61391. autoHideLoadingUI: boolean;
  61392. /**
  61393. * Creates a new AssetsManager
  61394. * @param scene defines the scene to work on
  61395. */
  61396. constructor(scene: Scene);
  61397. /**
  61398. * Add a MeshAssetTask to the list of active tasks
  61399. * @param taskName defines the name of the new task
  61400. * @param meshesNames defines the name of meshes to load
  61401. * @param rootUrl defines the root url to use to locate files
  61402. * @param sceneFilename defines the filename of the scene file
  61403. * @returns a new MeshAssetTask object
  61404. */
  61405. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61406. /**
  61407. * Add a TextFileAssetTask to the list of active tasks
  61408. * @param taskName defines the name of the new task
  61409. * @param url defines the url of the file to load
  61410. * @returns a new TextFileAssetTask object
  61411. */
  61412. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61413. /**
  61414. * Add a BinaryFileAssetTask to the list of active tasks
  61415. * @param taskName defines the name of the new task
  61416. * @param url defines the url of the file to load
  61417. * @returns a new BinaryFileAssetTask object
  61418. */
  61419. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61420. /**
  61421. * Add a ImageAssetTask to the list of active tasks
  61422. * @param taskName defines the name of the new task
  61423. * @param url defines the url of the file to load
  61424. * @returns a new ImageAssetTask object
  61425. */
  61426. addImageTask(taskName: string, url: string): ImageAssetTask;
  61427. /**
  61428. * Add a TextureAssetTask to the list of active tasks
  61429. * @param taskName defines the name of the new task
  61430. * @param url defines the url of the file to load
  61431. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61432. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61433. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61434. * @returns a new TextureAssetTask object
  61435. */
  61436. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61437. /**
  61438. * Add a CubeTextureAssetTask to the list of active tasks
  61439. * @param taskName defines the name of the new task
  61440. * @param url defines the url of the file to load
  61441. * @param extensions defines the extension to use to load the cube map (can be null)
  61442. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61443. * @param files defines the list of files to load (can be null)
  61444. * @returns a new CubeTextureAssetTask object
  61445. */
  61446. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61447. /**
  61448. *
  61449. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61450. * @param taskName defines the name of the new task
  61451. * @param url defines the url of the file to load
  61452. * @param size defines the size you want for the cubemap (can be null)
  61453. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61454. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61455. * @param gammaSpace specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space) (default is false)
  61456. * @param reserved Internal use only
  61457. * @returns a new HDRCubeTextureAssetTask object
  61458. */
  61459. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61460. /**
  61461. *
  61462. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61463. * @param taskName defines the name of the new task
  61464. * @param url defines the url of the file to load
  61465. * @param size defines the size you want for the cubemap (can be null)
  61466. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61467. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61468. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61469. * @returns a new EquiRectangularCubeTextureAssetTask object
  61470. */
  61471. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61472. /**
  61473. * Remove a task from the assets manager.
  61474. * @param task the task to remove
  61475. */
  61476. removeTask(task: AbstractAssetTask): void;
  61477. private _decreaseWaitingTasksCount;
  61478. private _runTask;
  61479. /**
  61480. * Reset the AssetsManager and remove all tasks
  61481. * @return the current instance of the AssetsManager
  61482. */
  61483. reset(): AssetsManager;
  61484. /**
  61485. * Start the loading process
  61486. * @return the current instance of the AssetsManager
  61487. */
  61488. load(): AssetsManager;
  61489. /**
  61490. * Start the loading process as an async operation
  61491. * @return a promise returning the list of failed tasks
  61492. */
  61493. loadAsync(): Promise<void>;
  61494. }
  61495. }
  61496. declare module BABYLON {
  61497. /**
  61498. * Wrapper class for promise with external resolve and reject.
  61499. */
  61500. export class Deferred<T> {
  61501. /**
  61502. * The promise associated with this deferred object.
  61503. */
  61504. readonly promise: Promise<T>;
  61505. private _resolve;
  61506. private _reject;
  61507. /**
  61508. * The resolve method of the promise associated with this deferred object.
  61509. */
  61510. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61511. /**
  61512. * The reject method of the promise associated with this deferred object.
  61513. */
  61514. readonly reject: (reason?: any) => void;
  61515. /**
  61516. * Constructor for this deferred object.
  61517. */
  61518. constructor();
  61519. }
  61520. }
  61521. declare module BABYLON {
  61522. /**
  61523. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61524. */
  61525. export class MeshExploder {
  61526. private _centerMesh;
  61527. private _meshes;
  61528. private _meshesOrigins;
  61529. private _toCenterVectors;
  61530. private _scaledDirection;
  61531. private _newPosition;
  61532. private _centerPosition;
  61533. /**
  61534. * Explodes meshes from a center mesh.
  61535. * @param meshes The meshes to explode.
  61536. * @param centerMesh The mesh to be center of explosion.
  61537. */
  61538. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61539. private _setCenterMesh;
  61540. /**
  61541. * Get class name
  61542. * @returns "MeshExploder"
  61543. */
  61544. getClassName(): string;
  61545. /**
  61546. * "Exploded meshes"
  61547. * @returns Array of meshes with the centerMesh at index 0.
  61548. */
  61549. getMeshes(): Array<Mesh>;
  61550. /**
  61551. * Explodes meshes giving a specific direction
  61552. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61553. */
  61554. explode(direction?: number): void;
  61555. }
  61556. }
  61557. declare module BABYLON {
  61558. /**
  61559. * Class used to help managing file picking and drag'n'drop
  61560. */
  61561. export class FilesInput {
  61562. /**
  61563. * List of files ready to be loaded
  61564. */
  61565. static readonly FilesToLoad: {
  61566. [key: string]: File;
  61567. };
  61568. /**
  61569. * Callback called when a file is processed
  61570. */
  61571. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61572. private _engine;
  61573. private _currentScene;
  61574. private _sceneLoadedCallback;
  61575. private _progressCallback;
  61576. private _additionalRenderLoopLogicCallback;
  61577. private _textureLoadingCallback;
  61578. private _startingProcessingFilesCallback;
  61579. private _onReloadCallback;
  61580. private _errorCallback;
  61581. private _elementToMonitor;
  61582. private _sceneFileToLoad;
  61583. private _filesToLoad;
  61584. /**
  61585. * Creates a new FilesInput
  61586. * @param engine defines the rendering engine
  61587. * @param scene defines the hosting scene
  61588. * @param sceneLoadedCallback callback called when scene is loaded
  61589. * @param progressCallback callback called to track progress
  61590. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61591. * @param textureLoadingCallback callback called when a texture is loading
  61592. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61593. * @param onReloadCallback callback called when a reload is requested
  61594. * @param errorCallback callback call if an error occurs
  61595. */
  61596. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: (files?: File[]) => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  61597. private _dragEnterHandler;
  61598. private _dragOverHandler;
  61599. private _dropHandler;
  61600. /**
  61601. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61602. * @param elementToMonitor defines the DOM element to track
  61603. */
  61604. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61605. /**
  61606. * Release all associated resources
  61607. */
  61608. dispose(): void;
  61609. private renderFunction;
  61610. private drag;
  61611. private drop;
  61612. private _traverseFolder;
  61613. private _processFiles;
  61614. /**
  61615. * Load files from a drop event
  61616. * @param event defines the drop event to use as source
  61617. */
  61618. loadFiles(event: any): void;
  61619. private _processReload;
  61620. /**
  61621. * Reload the current scene from the loaded files
  61622. */
  61623. reload(): void;
  61624. }
  61625. }
  61626. declare module BABYLON {
  61627. /**
  61628. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61629. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61630. */
  61631. export class SceneOptimization {
  61632. /**
  61633. * Defines the priority of this optimization (0 by default which means first in the list)
  61634. */
  61635. priority: number;
  61636. /**
  61637. * Gets a string describing the action executed by the current optimization
  61638. * @returns description string
  61639. */
  61640. getDescription(): string;
  61641. /**
  61642. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61643. * @param scene defines the current scene where to apply this optimization
  61644. * @param optimizer defines the current optimizer
  61645. * @returns true if everything that can be done was applied
  61646. */
  61647. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61648. /**
  61649. * Creates the SceneOptimization object
  61650. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61651. * @param desc defines the description associated with the optimization
  61652. */
  61653. constructor(
  61654. /**
  61655. * Defines the priority of this optimization (0 by default which means first in the list)
  61656. */
  61657. priority?: number);
  61658. }
  61659. /**
  61660. * Defines an optimization used to reduce the size of render target textures
  61661. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61662. */
  61663. export class TextureOptimization extends SceneOptimization {
  61664. /**
  61665. * Defines the priority of this optimization (0 by default which means first in the list)
  61666. */
  61667. priority: number;
  61668. /**
  61669. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  61670. */
  61671. maximumSize: number;
  61672. /**
  61673. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61674. */
  61675. step: number;
  61676. /**
  61677. * Gets a string describing the action executed by the current optimization
  61678. * @returns description string
  61679. */
  61680. getDescription(): string;
  61681. /**
  61682. * Creates the TextureOptimization object
  61683. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61684. * @param maximumSize defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  61685. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61686. */
  61687. constructor(
  61688. /**
  61689. * Defines the priority of this optimization (0 by default which means first in the list)
  61690. */
  61691. priority?: number,
  61692. /**
  61693. * Defines the maximum sized allowed for textures (1024 is the default value). If a texture is bigger, it will be scaled down using a factor defined by the step parameter
  61694. */
  61695. maximumSize?: number,
  61696. /**
  61697. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61698. */
  61699. step?: number);
  61700. /**
  61701. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61702. * @param scene defines the current scene where to apply this optimization
  61703. * @param optimizer defines the current optimizer
  61704. * @returns true if everything that can be done was applied
  61705. */
  61706. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61707. }
  61708. /**
  61709. * Defines an optimization used to increase or decrease the rendering resolution
  61710. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61711. */
  61712. export class HardwareScalingOptimization extends SceneOptimization {
  61713. /**
  61714. * Defines the priority of this optimization (0 by default which means first in the list)
  61715. */
  61716. priority: number;
  61717. /**
  61718. * Defines the maximum scale to use (2 by default)
  61719. */
  61720. maximumScale: number;
  61721. /**
  61722. * Defines the step to use between two passes (0.5 by default)
  61723. */
  61724. step: number;
  61725. private _currentScale;
  61726. private _directionOffset;
  61727. /**
  61728. * Gets a string describing the action executed by the current optimization
  61729. * @return description string
  61730. */
  61731. getDescription(): string;
  61732. /**
  61733. * Creates the HardwareScalingOptimization object
  61734. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61735. * @param maximumScale defines the maximum scale to use (2 by default)
  61736. * @param step defines the step to use between two passes (0.5 by default)
  61737. */
  61738. constructor(
  61739. /**
  61740. * Defines the priority of this optimization (0 by default which means first in the list)
  61741. */
  61742. priority?: number,
  61743. /**
  61744. * Defines the maximum scale to use (2 by default)
  61745. */
  61746. maximumScale?: number,
  61747. /**
  61748. * Defines the step to use between two passes (0.5 by default)
  61749. */
  61750. step?: number);
  61751. /**
  61752. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61753. * @param scene defines the current scene where to apply this optimization
  61754. * @param optimizer defines the current optimizer
  61755. * @returns true if everything that can be done was applied
  61756. */
  61757. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61758. }
  61759. /**
  61760. * Defines an optimization used to remove shadows
  61761. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61762. */
  61763. export class ShadowsOptimization extends SceneOptimization {
  61764. /**
  61765. * Gets a string describing the action executed by the current optimization
  61766. * @return description string
  61767. */
  61768. getDescription(): string;
  61769. /**
  61770. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61771. * @param scene defines the current scene where to apply this optimization
  61772. * @param optimizer defines the current optimizer
  61773. * @returns true if everything that can be done was applied
  61774. */
  61775. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61776. }
  61777. /**
  61778. * Defines an optimization used to turn post-processes off
  61779. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61780. */
  61781. export class PostProcessesOptimization extends SceneOptimization {
  61782. /**
  61783. * Gets a string describing the action executed by the current optimization
  61784. * @return description string
  61785. */
  61786. getDescription(): string;
  61787. /**
  61788. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61789. * @param scene defines the current scene where to apply this optimization
  61790. * @param optimizer defines the current optimizer
  61791. * @returns true if everything that can be done was applied
  61792. */
  61793. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61794. }
  61795. /**
  61796. * Defines an optimization used to turn lens flares off
  61797. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61798. */
  61799. export class LensFlaresOptimization extends SceneOptimization {
  61800. /**
  61801. * Gets a string describing the action executed by the current optimization
  61802. * @return description string
  61803. */
  61804. getDescription(): string;
  61805. /**
  61806. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61807. * @param scene defines the current scene where to apply this optimization
  61808. * @param optimizer defines the current optimizer
  61809. * @returns true if everything that can be done was applied
  61810. */
  61811. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61812. }
  61813. /**
  61814. * Defines an optimization based on user defined callback.
  61815. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61816. */
  61817. export class CustomOptimization extends SceneOptimization {
  61818. /**
  61819. * Callback called to apply the custom optimization.
  61820. */
  61821. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61822. /**
  61823. * Callback called to get custom description
  61824. */
  61825. onGetDescription: () => string;
  61826. /**
  61827. * Gets a string describing the action executed by the current optimization
  61828. * @returns description string
  61829. */
  61830. getDescription(): string;
  61831. /**
  61832. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61833. * @param scene defines the current scene where to apply this optimization
  61834. * @param optimizer defines the current optimizer
  61835. * @returns true if everything that can be done was applied
  61836. */
  61837. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61838. }
  61839. /**
  61840. * Defines an optimization used to turn particles off
  61841. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61842. */
  61843. export class ParticlesOptimization extends SceneOptimization {
  61844. /**
  61845. * Gets a string describing the action executed by the current optimization
  61846. * @return description string
  61847. */
  61848. getDescription(): string;
  61849. /**
  61850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61851. * @param scene defines the current scene where to apply this optimization
  61852. * @param optimizer defines the current optimizer
  61853. * @returns true if everything that can be done was applied
  61854. */
  61855. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61856. }
  61857. /**
  61858. * Defines an optimization used to turn render targets off
  61859. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61860. */
  61861. export class RenderTargetsOptimization extends SceneOptimization {
  61862. /**
  61863. * Gets a string describing the action executed by the current optimization
  61864. * @return description string
  61865. */
  61866. getDescription(): string;
  61867. /**
  61868. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61869. * @param scene defines the current scene where to apply this optimization
  61870. * @param optimizer defines the current optimizer
  61871. * @returns true if everything that can be done was applied
  61872. */
  61873. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61874. }
  61875. /**
  61876. * Defines an optimization used to merge meshes with compatible materials
  61877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61878. */
  61879. export class MergeMeshesOptimization extends SceneOptimization {
  61880. private static _UpdateSelectionTree;
  61881. /**
  61882. * Gets or sets a boolean which defines if optimization octree has to be updated
  61883. */
  61884. /**
  61885. * Gets or sets a boolean which defines if optimization octree has to be updated
  61886. */
  61887. static UpdateSelectionTree: boolean;
  61888. /**
  61889. * Gets a string describing the action executed by the current optimization
  61890. * @return description string
  61891. */
  61892. getDescription(): string;
  61893. private _canBeMerged;
  61894. /**
  61895. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61896. * @param scene defines the current scene where to apply this optimization
  61897. * @param optimizer defines the current optimizer
  61898. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61899. * @returns true if everything that can be done was applied
  61900. */
  61901. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61902. }
  61903. /**
  61904. * Defines a list of options used by SceneOptimizer
  61905. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61906. */
  61907. export class SceneOptimizerOptions {
  61908. /**
  61909. * Defines the target frame rate to reach (60 by default)
  61910. */
  61911. targetFrameRate: number;
  61912. /**
  61913. * Defines the interval between two checkes (2000ms by default)
  61914. */
  61915. trackerDuration: number;
  61916. /**
  61917. * Gets the list of optimizations to apply
  61918. */
  61919. optimizations: SceneOptimization[];
  61920. /**
  61921. * Creates a new list of options used by SceneOptimizer
  61922. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61923. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61924. */
  61925. constructor(
  61926. /**
  61927. * Defines the target frame rate to reach (60 by default)
  61928. */
  61929. targetFrameRate?: number,
  61930. /**
  61931. * Defines the interval between two checkes (2000ms by default)
  61932. */
  61933. trackerDuration?: number);
  61934. /**
  61935. * Add a new optimization
  61936. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61937. * @returns the current SceneOptimizerOptions
  61938. */
  61939. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61940. /**
  61941. * Add a new custom optimization
  61942. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61943. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61944. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61945. * @returns the current SceneOptimizerOptions
  61946. */
  61947. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61948. /**
  61949. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61950. * @param targetFrameRate defines the target frame rate (60 by default)
  61951. * @returns a SceneOptimizerOptions object
  61952. */
  61953. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61954. /**
  61955. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61956. * @param targetFrameRate defines the target frame rate (60 by default)
  61957. * @returns a SceneOptimizerOptions object
  61958. */
  61959. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61960. /**
  61961. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61962. * @param targetFrameRate defines the target frame rate (60 by default)
  61963. * @returns a SceneOptimizerOptions object
  61964. */
  61965. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61966. }
  61967. /**
  61968. * Class used to run optimizations in order to reach a target frame rate
  61969. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61970. */
  61971. export class SceneOptimizer implements IDisposable {
  61972. private _isRunning;
  61973. private _options;
  61974. private _scene;
  61975. private _currentPriorityLevel;
  61976. private _targetFrameRate;
  61977. private _trackerDuration;
  61978. private _currentFrameRate;
  61979. private _sceneDisposeObserver;
  61980. private _improvementMode;
  61981. /**
  61982. * Defines an observable called when the optimizer reaches the target frame rate
  61983. */
  61984. onSuccessObservable: Observable<SceneOptimizer>;
  61985. /**
  61986. * Defines an observable called when the optimizer enables an optimization
  61987. */
  61988. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61989. /**
  61990. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61991. */
  61992. onFailureObservable: Observable<SceneOptimizer>;
  61993. /**
  61994. * Gets a boolean indicating if the optimizer is in improvement mode
  61995. */
  61996. readonly isInImprovementMode: boolean;
  61997. /**
  61998. * Gets the current priority level (0 at start)
  61999. */
  62000. readonly currentPriorityLevel: number;
  62001. /**
  62002. * Gets the current frame rate checked by the SceneOptimizer
  62003. */
  62004. readonly currentFrameRate: number;
  62005. /**
  62006. * Gets or sets the current target frame rate (60 by default)
  62007. */
  62008. /**
  62009. * Gets or sets the current target frame rate (60 by default)
  62010. */
  62011. targetFrameRate: number;
  62012. /**
  62013. * Gets or sets the current interval between two checks (every 2000ms by default)
  62014. */
  62015. /**
  62016. * Gets or sets the current interval between two checks (every 2000ms by default)
  62017. */
  62018. trackerDuration: number;
  62019. /**
  62020. * Gets the list of active optimizations
  62021. */
  62022. readonly optimizations: SceneOptimization[];
  62023. /**
  62024. * Creates a new SceneOptimizer
  62025. * @param scene defines the scene to work on
  62026. * @param options defines the options to use with the SceneOptimizer
  62027. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62028. * @param improvementMode defines if the scene optimizer must run the maximum optimization while staying over a target frame instead of trying to reach the target framerate (false by default)
  62029. */
  62030. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62031. /**
  62032. * Stops the current optimizer
  62033. */
  62034. stop(): void;
  62035. /**
  62036. * Reset the optimizer to initial step (current priority level = 0)
  62037. */
  62038. reset(): void;
  62039. /**
  62040. * Start the optimizer. By default it will try to reach a specific framerate
  62041. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62042. */
  62043. start(): void;
  62044. private _checkCurrentState;
  62045. /**
  62046. * Release all resources
  62047. */
  62048. dispose(): void;
  62049. /**
  62050. * Helper function to create a SceneOptimizer with one single line of code
  62051. * @param scene defines the scene to work on
  62052. * @param options defines the options to use with the SceneOptimizer
  62053. * @param onSuccess defines a callback to call on success
  62054. * @param onFailure defines a callback to call on failure
  62055. * @returns the new SceneOptimizer object
  62056. */
  62057. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62058. }
  62059. }
  62060. declare module BABYLON {
  62061. /**
  62062. * Class used to serialize a scene into a string
  62063. */
  62064. export class SceneSerializer {
  62065. /**
  62066. * Clear cache used by a previous serialization
  62067. */
  62068. static ClearCache(): void;
  62069. /**
  62070. * Serialize a scene into a JSON compatible object
  62071. * @param scene defines the scene to serialize
  62072. * @returns a JSON compatible object
  62073. */
  62074. static Serialize(scene: Scene): any;
  62075. /**
  62076. * Serialize a mesh into a JSON compatible object
  62077. * @param toSerialize defines the mesh to serialize
  62078. * @param withParents defines if parents must be serialized as well
  62079. * @param withChildren defines if children must be serialized as well
  62080. * @returns a JSON compatible object
  62081. */
  62082. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62083. }
  62084. }
  62085. declare module BABYLON {
  62086. /**
  62087. * Class used to host texture specific utilities
  62088. */
  62089. export class TextureTools {
  62090. /**
  62091. * Uses the GPU to create a copy texture rescaled at a given size
  62092. * @param texture Texture to copy from
  62093. * @param width defines the desired width
  62094. * @param height defines the desired height
  62095. * @param useBilinearMode defines if bilinear mode has to be used
  62096. * @return the generated texture
  62097. */
  62098. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62099. }
  62100. }
  62101. declare module BABYLON {
  62102. /**
  62103. * This represents the different options available for the video capture.
  62104. */
  62105. export interface VideoRecorderOptions {
  62106. /** Defines the mime type of the video. */
  62107. mimeType: string;
  62108. /** Defines the FPS the video should be recorded at. */
  62109. fps: number;
  62110. /** Defines the chunk size for the recording data. */
  62111. recordChunckSize: number;
  62112. /** The audio tracks to attach to the recording. */
  62113. audioTracks?: MediaStreamTrack[];
  62114. }
  62115. /**
  62116. * This can help with recording videos from BabylonJS.
  62117. * This is based on the available WebRTC functionalities of the browser.
  62118. *
  62119. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62120. */
  62121. export class VideoRecorder {
  62122. private static readonly _defaultOptions;
  62123. /**
  62124. * Returns whether or not the VideoRecorder is available in your browser.
  62125. * @param engine Defines the Babylon Engine.
  62126. * @returns true if supported otherwise false.
  62127. */
  62128. static IsSupported(engine: Engine): boolean;
  62129. private readonly _options;
  62130. private _canvas;
  62131. private _mediaRecorder;
  62132. private _recordedChunks;
  62133. private _fileName;
  62134. private _resolve;
  62135. private _reject;
  62136. /**
  62137. * True when a recording is already in progress.
  62138. */
  62139. readonly isRecording: boolean;
  62140. /**
  62141. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62142. * @param engine Defines the BabylonJS Engine you wish to record.
  62143. * @param options Defines options that can be used to customize the capture.
  62144. */
  62145. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62146. /**
  62147. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62148. */
  62149. stopRecording(): void;
  62150. /**
  62151. * Starts recording the canvas for a max duration specified in parameters.
  62152. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62153. * If null no automatic download will start and you can rely on the promise to get the data back.
  62154. * @param maxDuration Defines the maximum recording time in seconds.
  62155. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62156. * @return A promise callback at the end of the recording with the video data in Blob.
  62157. */
  62158. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62159. /**
  62160. * Releases internal resources used during the recording.
  62161. */
  62162. dispose(): void;
  62163. private _handleDataAvailable;
  62164. private _handleError;
  62165. private _handleStop;
  62166. }
  62167. }
  62168. declare module BABYLON {
  62169. /**
  62170. * Class containing a set of static utilities functions for screenshots
  62171. */
  62172. export class ScreenshotTools {
  62173. /**
  62174. * Captures a screenshot of the current rendering
  62175. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62176. * @param engine defines the rendering engine
  62177. * @param camera defines the source camera
  62178. * @param size This parameter can be set to a single number or to an object with the
  62179. * following (optional) properties: precision, width, height. If a single number is passed,
  62180. * it will be used for both width and height. If an object is passed, the screenshot size
  62181. * will be derived from the parameters. The precision property is a multiplier allowing
  62182. * rendering at a higher or lower resolution
  62183. * @param successCallback defines the callback receives a single parameter which contains the
  62184. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62185. * src parameter of an <img> to display it
  62186. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62187. * Check your browser for supported MIME types
  62188. */
  62189. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  62190. /**
  62191. * Captures a screenshot of the current rendering
  62192. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62193. * @param engine defines the rendering engine
  62194. * @param camera defines the source camera
  62195. * @param size This parameter can be set to a single number or to an object with the
  62196. * following (optional) properties: precision, width, height. If a single number is passed,
  62197. * it will be used for both width and height. If an object is passed, the screenshot size
  62198. * will be derived from the parameters. The precision property is a multiplier allowing
  62199. * rendering at a higher or lower resolution
  62200. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62201. * Check your browser for supported MIME types
  62202. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62203. * to the src parameter of an <img> to display it
  62204. */
  62205. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  62206. /**
  62207. * Generates an image screenshot from the specified camera.
  62208. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62209. * @param engine The engine to use for rendering
  62210. * @param camera The camera to use for rendering
  62211. * @param size This parameter can be set to a single number or to an object with the
  62212. * following (optional) properties: precision, width, height. If a single number is passed,
  62213. * it will be used for both width and height. If an object is passed, the screenshot size
  62214. * will be derived from the parameters. The precision property is a multiplier allowing
  62215. * rendering at a higher or lower resolution
  62216. * @param successCallback The callback receives a single parameter which contains the
  62217. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62218. * src parameter of an <img> to display it
  62219. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62220. * Check your browser for supported MIME types
  62221. * @param samples Texture samples (default: 1)
  62222. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62223. * @param fileName A name for for the downloaded file.
  62224. */
  62225. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62226. /**
  62227. * Generates an image screenshot from the specified camera.
  62228. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62229. * @param engine The engine to use for rendering
  62230. * @param camera The camera to use for rendering
  62231. * @param size This parameter can be set to a single number or to an object with the
  62232. * following (optional) properties: precision, width, height. If a single number is passed,
  62233. * it will be used for both width and height. If an object is passed, the screenshot size
  62234. * will be derived from the parameters. The precision property is a multiplier allowing
  62235. * rendering at a higher or lower resolution
  62236. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62237. * Check your browser for supported MIME types
  62238. * @param samples Texture samples (default: 1)
  62239. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62240. * @param fileName A name for for the downloaded file.
  62241. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  62242. * to the src parameter of an <img> to display it
  62243. */
  62244. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  62245. /**
  62246. * Gets height and width for screenshot size
  62247. * @private
  62248. */
  62249. private static _getScreenshotSize;
  62250. }
  62251. }
  62252. declare module BABYLON {
  62253. /**
  62254. * A cursor which tracks a point on a path
  62255. */
  62256. export class PathCursor {
  62257. private path;
  62258. /**
  62259. * Stores path cursor callbacks for when an onchange event is triggered
  62260. */
  62261. private _onchange;
  62262. /**
  62263. * The value of the path cursor
  62264. */
  62265. value: number;
  62266. /**
  62267. * The animation array of the path cursor
  62268. */
  62269. animations: Animation[];
  62270. /**
  62271. * Initializes the path cursor
  62272. * @param path The path to track
  62273. */
  62274. constructor(path: Path2);
  62275. /**
  62276. * Gets the cursor point on the path
  62277. * @returns A point on the path cursor at the cursor location
  62278. */
  62279. getPoint(): Vector3;
  62280. /**
  62281. * Moves the cursor ahead by the step amount
  62282. * @param step The amount to move the cursor forward
  62283. * @returns This path cursor
  62284. */
  62285. moveAhead(step?: number): PathCursor;
  62286. /**
  62287. * Moves the cursor behind by the step amount
  62288. * @param step The amount to move the cursor back
  62289. * @returns This path cursor
  62290. */
  62291. moveBack(step?: number): PathCursor;
  62292. /**
  62293. * Moves the cursor by the step amount
  62294. * If the step amount is greater than one, an exception is thrown
  62295. * @param step The amount to move the cursor
  62296. * @returns This path cursor
  62297. */
  62298. move(step: number): PathCursor;
  62299. /**
  62300. * Ensures that the value is limited between zero and one
  62301. * @returns This path cursor
  62302. */
  62303. private ensureLimits;
  62304. /**
  62305. * Runs onchange callbacks on change (used by the animation engine)
  62306. * @returns This path cursor
  62307. */
  62308. private raiseOnChange;
  62309. /**
  62310. * Executes a function on change
  62311. * @param f A path cursor onchange callback
  62312. * @returns This path cursor
  62313. */
  62314. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62315. }
  62316. }
  62317. declare module BABYLON {
  62318. /** @hidden */
  62319. export var blurPixelShader: {
  62320. name: string;
  62321. shader: string;
  62322. };
  62323. }
  62324. declare module BABYLON {
  62325. /** @hidden */
  62326. export var pointCloudVertexDeclaration: {
  62327. name: string;
  62328. shader: string;
  62329. };
  62330. }
  62331. // Mixins
  62332. interface Window {
  62333. mozIndexedDB: IDBFactory;
  62334. webkitIndexedDB: IDBFactory;
  62335. msIndexedDB: IDBFactory;
  62336. webkitURL: typeof URL;
  62337. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  62338. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  62339. WebGLRenderingContext: WebGLRenderingContext;
  62340. MSGesture: MSGesture;
  62341. CANNON: any;
  62342. AudioContext: AudioContext;
  62343. webkitAudioContext: AudioContext;
  62344. PointerEvent: any;
  62345. Math: Math;
  62346. Uint8Array: Uint8ArrayConstructor;
  62347. Float32Array: Float32ArrayConstructor;
  62348. mozURL: typeof URL;
  62349. msURL: typeof URL;
  62350. VRFrameData: any; // WebVR, from specs 1.1
  62351. DracoDecoderModule: any;
  62352. setImmediate(handler: (...args: any[]) => void): number;
  62353. }
  62354. interface HTMLCanvasElement {
  62355. requestPointerLock(): void;
  62356. msRequestPointerLock?(): void;
  62357. mozRequestPointerLock?(): void;
  62358. webkitRequestPointerLock?(): void;
  62359. /** Track wether a record is in progress */
  62360. isRecording: boolean;
  62361. /** Capture Stream method defined by some browsers */
  62362. captureStream(fps?: number): MediaStream;
  62363. }
  62364. interface CanvasRenderingContext2D {
  62365. msImageSmoothingEnabled: boolean;
  62366. }
  62367. interface MouseEvent {
  62368. mozMovementX: number;
  62369. mozMovementY: number;
  62370. webkitMovementX: number;
  62371. webkitMovementY: number;
  62372. msMovementX: number;
  62373. msMovementY: number;
  62374. }
  62375. interface Navigator {
  62376. mozGetVRDevices: (any: any) => any;
  62377. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62378. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62379. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  62380. webkitGetGamepads(): Gamepad[];
  62381. msGetGamepads(): Gamepad[];
  62382. webkitGamepads(): Gamepad[];
  62383. }
  62384. interface HTMLVideoElement {
  62385. mozSrcObject: any;
  62386. }
  62387. interface Math {
  62388. fround(x: number): number;
  62389. imul(a: number, b: number): number;
  62390. }
  62391. interface WebGLRenderingContext {
  62392. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  62393. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  62394. vertexAttribDivisor(index: number, divisor: number): void;
  62395. createVertexArray(): any;
  62396. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  62397. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  62398. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  62399. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  62400. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  62401. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  62402. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  62403. // Queries
  62404. createQuery(): WebGLQuery;
  62405. deleteQuery(query: WebGLQuery): void;
  62406. beginQuery(target: number, query: WebGLQuery): void;
  62407. endQuery(target: number): void;
  62408. getQueryParameter(query: WebGLQuery, pname: number): any;
  62409. getQuery(target: number, pname: number): any;
  62410. MAX_SAMPLES: number;
  62411. RGBA8: number;
  62412. READ_FRAMEBUFFER: number;
  62413. DRAW_FRAMEBUFFER: number;
  62414. UNIFORM_BUFFER: number;
  62415. HALF_FLOAT_OES: number;
  62416. RGBA16F: number;
  62417. RGBA32F: number;
  62418. R32F: number;
  62419. RG32F: number;
  62420. RGB32F: number;
  62421. R16F: number;
  62422. RG16F: number;
  62423. RGB16F: number;
  62424. RED: number;
  62425. RG: number;
  62426. R8: number;
  62427. RG8: number;
  62428. UNSIGNED_INT_24_8: number;
  62429. DEPTH24_STENCIL8: number;
  62430. MIN: number;
  62431. MAX: number;
  62432. /* Multiple Render Targets */
  62433. drawBuffers(buffers: number[]): void;
  62434. readBuffer(src: number): void;
  62435. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  62436. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  62437. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  62438. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  62439. // Occlusion Query
  62440. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  62441. ANY_SAMPLES_PASSED: number;
  62442. QUERY_RESULT_AVAILABLE: number;
  62443. QUERY_RESULT: number;
  62444. }
  62445. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  62446. }
  62447. interface EXT_disjoint_timer_query {
  62448. QUERY_COUNTER_BITS_EXT: number;
  62449. TIME_ELAPSED_EXT: number;
  62450. TIMESTAMP_EXT: number;
  62451. GPU_DISJOINT_EXT: number;
  62452. QUERY_RESULT_EXT: number;
  62453. QUERY_RESULT_AVAILABLE_EXT: number;
  62454. queryCounterEXT(query: WebGLQuery, target: number): void;
  62455. createQueryEXT(): WebGLQuery;
  62456. beginQueryEXT(target: number, query: WebGLQuery): void;
  62457. endQueryEXT(target: number): void;
  62458. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  62459. deleteQueryEXT(query: WebGLQuery): void;
  62460. }
  62461. interface WebGLUniformLocation { private _currentState: any;
  62462. }
  62463. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  62464. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  62465. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  62466. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62467. interface WebGLRenderingContext {
  62468. readonly RASTERIZER_DISCARD: number;
  62469. readonly DEPTH_COMPONENT24: number;
  62470. readonly TEXTURE_3D: number;
  62471. readonly TEXTURE_2D_ARRAY: number;
  62472. readonly TEXTURE_COMPARE_FUNC: number;
  62473. readonly TEXTURE_COMPARE_MODE: number;
  62474. readonly COMPARE_REF_TO_TEXTURE: number;
  62475. readonly TEXTURE_WRAP_R: number;
  62476. readonly HALF_FLOAT: number;
  62477. readonly RGB8: number;
  62478. readonly RED_INTEGER: number;
  62479. readonly RG_INTEGER: number;
  62480. readonly RGB_INTEGER: number;
  62481. readonly RGBA_INTEGER: number;
  62482. readonly R8_SNORM: number;
  62483. readonly RG8_SNORM: number;
  62484. readonly RGB8_SNORM: number;
  62485. readonly RGBA8_SNORM: number;
  62486. readonly R8I: number;
  62487. readonly RG8I: number;
  62488. readonly RGB8I: number;
  62489. readonly RGBA8I: number;
  62490. readonly R8UI: number;
  62491. readonly RG8UI: number;
  62492. readonly RGB8UI: number;
  62493. readonly RGBA8UI: number;
  62494. readonly R16I: number;
  62495. readonly RG16I: number;
  62496. readonly RGB16I: number;
  62497. readonly RGBA16I: number;
  62498. readonly R16UI: number;
  62499. readonly RG16UI: number;
  62500. readonly RGB16UI: number;
  62501. readonly RGBA16UI: number;
  62502. readonly R32I: number;
  62503. readonly RG32I: number;
  62504. readonly RGB32I: number;
  62505. readonly RGBA32I: number;
  62506. readonly R32UI: number;
  62507. readonly RG32UI: number;
  62508. readonly RGB32UI: number;
  62509. readonly RGBA32UI: number;
  62510. readonly RGB10_A2UI: number;
  62511. readonly R11F_G11F_B10F: number;
  62512. readonly RGB9_E5: number;
  62513. readonly RGB10_A2: number;
  62514. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  62515. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  62516. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  62517. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  62518. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  62519. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  62520. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
  62521. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  62522. readonly TRANSFORM_FEEDBACK: number;
  62523. readonly INTERLEAVED_ATTRIBS: number;
  62524. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  62525. createTransformFeedback(): WebGLTransformFeedback;
  62526. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  62527. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  62528. beginTransformFeedback(primitiveMode: number): void;
  62529. endTransformFeedback(): void;
  62530. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  62531. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62532. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62533. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  62534. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  62535. }
  62536. interface ImageBitmap {
  62537. readonly width: number;
  62538. readonly height: number;
  62539. close(): void;
  62540. }
  62541. interface WebGLQuery extends WebGLObject {
  62542. }
  62543. declare var WebGLQuery: {
  62544. prototype: WebGLQuery;
  62545. new(): WebGLQuery;
  62546. };
  62547. interface WebGLSampler extends WebGLObject {
  62548. }
  62549. declare var WebGLSampler: {
  62550. prototype: WebGLSampler;
  62551. new(): WebGLSampler;
  62552. };
  62553. interface WebGLSync extends WebGLObject {
  62554. }
  62555. declare var WebGLSync: {
  62556. prototype: WebGLSync;
  62557. new(): WebGLSync;
  62558. };
  62559. interface WebGLTransformFeedback extends WebGLObject {
  62560. }
  62561. declare var WebGLTransformFeedback: {
  62562. prototype: WebGLTransformFeedback;
  62563. new(): WebGLTransformFeedback;
  62564. };
  62565. interface WebGLVertexArrayObject extends WebGLObject {
  62566. }
  62567. declare var WebGLVertexArrayObject: {
  62568. prototype: WebGLVertexArrayObject;
  62569. new(): WebGLVertexArrayObject;
  62570. };
  62571. // Type definitions for WebVR API
  62572. // Project: https://w3c.github.io/webvr/
  62573. // Definitions by: six a <https://github.com/lostfictions>
  62574. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  62575. interface VRDisplay extends EventTarget {
  62576. /**
  62577. * Dictionary of capabilities describing the VRDisplay.
  62578. */
  62579. readonly capabilities: VRDisplayCapabilities;
  62580. /**
  62581. * z-depth defining the far plane of the eye view frustum
  62582. * enables mapping of values in the render target depth
  62583. * attachment to scene coordinates. Initially set to 10000.0.
  62584. */
  62585. depthFar: number;
  62586. /**
  62587. * z-depth defining the near plane of the eye view frustum
  62588. * enables mapping of values in the render target depth
  62589. * attachment to scene coordinates. Initially set to 0.01.
  62590. */
  62591. depthNear: number;
  62592. /**
  62593. * An identifier for this distinct VRDisplay. Used as an
  62594. * association point in the Gamepad API.
  62595. */
  62596. readonly displayId: number;
  62597. /**
  62598. * A display name, a user-readable name identifying it.
  62599. */
  62600. readonly displayName: string;
  62601. readonly isConnected: boolean;
  62602. readonly isPresenting: boolean;
  62603. /**
  62604. * If this VRDisplay supports room-scale experiences, the optional
  62605. * stage attribute contains details on the room-scale parameters.
  62606. */
  62607. readonly stageParameters: VRStageParameters | null;
  62608. /**
  62609. * Passing the value returned by `requestAnimationFrame` to
  62610. * `cancelAnimationFrame` will unregister the callback.
  62611. * @param handle Define the hanle of the request to cancel
  62612. */
  62613. cancelAnimationFrame(handle: number): void;
  62614. /**
  62615. * Stops presenting to the VRDisplay.
  62616. * @returns a promise to know when it stopped
  62617. */
  62618. exitPresent(): Promise<void>;
  62619. /**
  62620. * Return the current VREyeParameters for the given eye.
  62621. * @param whichEye Define the eye we want the parameter for
  62622. * @returns the eye parameters
  62623. */
  62624. getEyeParameters(whichEye: string): VREyeParameters;
  62625. /**
  62626. * Populates the passed VRFrameData with the information required to render
  62627. * the current frame.
  62628. * @param frameData Define the data structure to populate
  62629. * @returns true if ok otherwise false
  62630. */
  62631. getFrameData(frameData: VRFrameData): boolean;
  62632. /**
  62633. * Get the layers currently being presented.
  62634. * @returns the list of VR layers
  62635. */
  62636. getLayers(): VRLayer[];
  62637. /**
  62638. * Return a VRPose containing the future predicted pose of the VRDisplay
  62639. * when the current frame will be presented. The value returned will not
  62640. * change until JavaScript has returned control to the browser.
  62641. *
  62642. * The VRPose will contain the position, orientation, velocity,
  62643. * and acceleration of each of these properties.
  62644. * @returns the pose object
  62645. */
  62646. getPose(): VRPose;
  62647. /**
  62648. * Return the current instantaneous pose of the VRDisplay, with no
  62649. * prediction applied.
  62650. * @returns the current instantaneous pose
  62651. */
  62652. getImmediatePose(): VRPose;
  62653. /**
  62654. * The callback passed to `requestAnimationFrame` will be called
  62655. * any time a new frame should be rendered. When the VRDisplay is
  62656. * presenting the callback will be called at the native refresh
  62657. * rate of the HMD. When not presenting this function acts
  62658. * identically to how window.requestAnimationFrame acts. Content should
  62659. * make no assumptions of frame rate or vsync behavior as the HMD runs
  62660. * asynchronously from other displays and at differing refresh rates.
  62661. * @param callback Define the eaction to run next frame
  62662. * @returns the request handle it
  62663. */
  62664. requestAnimationFrame(callback: FrameRequestCallback): number;
  62665. /**
  62666. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  62667. * Repeat calls while already presenting will update the VRLayers being displayed.
  62668. * @param layers Define the list of layer to present
  62669. * @returns a promise to know when the request has been fulfilled
  62670. */
  62671. requestPresent(layers: VRLayer[]): Promise<void>;
  62672. /**
  62673. * Reset the pose for this display, treating its current position and
  62674. * orientation as the "origin/zero" values. VRPose.position,
  62675. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  62676. * updated when calling resetPose(). This should be called in only
  62677. * sitting-space experiences.
  62678. */
  62679. resetPose(): void;
  62680. /**
  62681. * The VRLayer provided to the VRDisplay will be captured and presented
  62682. * in the HMD. Calling this function has the same effect on the source
  62683. * canvas as any other operation that uses its source image, and canvases
  62684. * created without preserveDrawingBuffer set to true will be cleared.
  62685. * @param pose Define the pose to submit
  62686. */
  62687. submitFrame(pose?: VRPose): void;
  62688. }
  62689. declare var VRDisplay: {
  62690. prototype: VRDisplay;
  62691. new(): VRDisplay;
  62692. };
  62693. interface VRLayer {
  62694. leftBounds?: number[] | Float32Array | null;
  62695. rightBounds?: number[] | Float32Array | null;
  62696. source?: HTMLCanvasElement | null;
  62697. }
  62698. interface VRDisplayCapabilities {
  62699. readonly canPresent: boolean;
  62700. readonly hasExternalDisplay: boolean;
  62701. readonly hasOrientation: boolean;
  62702. readonly hasPosition: boolean;
  62703. readonly maxLayers: number;
  62704. }
  62705. interface VREyeParameters {
  62706. /** @deprecated */
  62707. readonly fieldOfView: VRFieldOfView;
  62708. readonly offset: Float32Array;
  62709. readonly renderHeight: number;
  62710. readonly renderWidth: number;
  62711. }
  62712. interface VRFieldOfView {
  62713. readonly downDegrees: number;
  62714. readonly leftDegrees: number;
  62715. readonly rightDegrees: number;
  62716. readonly upDegrees: number;
  62717. }
  62718. interface VRFrameData {
  62719. readonly leftProjectionMatrix: Float32Array;
  62720. readonly leftViewMatrix: Float32Array;
  62721. readonly pose: VRPose;
  62722. readonly rightProjectionMatrix: Float32Array;
  62723. readonly rightViewMatrix: Float32Array;
  62724. readonly timestamp: number;
  62725. }
  62726. interface VRPose {
  62727. readonly angularAcceleration: Float32Array | null;
  62728. readonly angularVelocity: Float32Array | null;
  62729. readonly linearAcceleration: Float32Array | null;
  62730. readonly linearVelocity: Float32Array | null;
  62731. readonly orientation: Float32Array | null;
  62732. readonly position: Float32Array | null;
  62733. readonly timestamp: number;
  62734. }
  62735. interface VRStageParameters {
  62736. sittingToStandingTransform?: Float32Array;
  62737. sizeX?: number;
  62738. sizeY?: number;
  62739. }
  62740. interface Navigator {
  62741. getVRDisplays(): Promise<VRDisplay[]>;
  62742. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62743. }
  62744. interface Window {
  62745. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62746. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62747. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62748. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62749. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62750. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62751. }
  62752. interface Gamepad {
  62753. readonly displayId: number;
  62754. }
  62755. type XRSessionMode =
  62756. | "inline"
  62757. | "immersive-vr"
  62758. | "immersive-ar";
  62759. type XRReferenceSpaceType =
  62760. | "viewer"
  62761. | "local"
  62762. | "local-floor"
  62763. | "bounded-floor"
  62764. | "unbounded";
  62765. type XREnvironmentBlendMode =
  62766. | "opaque"
  62767. | "additive"
  62768. | "alpha-blend";
  62769. type XRVisibilityState =
  62770. | "visible"
  62771. | "visible-blurred"
  62772. | "hidden";
  62773. type XRHandedness =
  62774. | "none"
  62775. | "left"
  62776. | "right";
  62777. type XRTargetRayMode =
  62778. | "gaze"
  62779. | "tracked-pointer"
  62780. | "screen";
  62781. type XREye =
  62782. | "none"
  62783. | "left"
  62784. | "right";
  62785. interface XRSpace extends EventTarget {
  62786. }
  62787. interface XRRenderState {
  62788. depthNear?: number;
  62789. depthFar?: number;
  62790. inlineVerticalFieldOfView?: number;
  62791. baseLayer?: XRWebGLLayer;
  62792. }
  62793. interface XRInputSource {
  62794. handedness: XRHandedness;
  62795. targetRayMode: XRTargetRayMode;
  62796. targetRaySpace: XRSpace;
  62797. gripSpace: XRSpace | undefined;
  62798. gamepad: Gamepad | undefined;
  62799. profiles: Array<string>;
  62800. }
  62801. interface XRSession {
  62802. addEventListener: Function;
  62803. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  62804. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  62805. requestAnimationFrame: Function;
  62806. end(): Promise<void>;
  62807. renderState: XRRenderState;
  62808. inputSources: Array<XRInputSource>;
  62809. }
  62810. interface XRReferenceSpace extends XRSpace {
  62811. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  62812. onreset: any;
  62813. }
  62814. interface XRFrame {
  62815. session: XRSession;
  62816. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  62817. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  62818. }
  62819. interface XRViewerPose extends XRPose {
  62820. views: Array<XRView>;
  62821. }
  62822. interface XRPose {
  62823. transform: XRRigidTransform;
  62824. emulatedPosition: boolean;
  62825. }
  62826. declare var XRWebGLLayer: {
  62827. prototype: XRWebGLLayer;
  62828. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  62829. };
  62830. interface XRWebGLLayer {
  62831. framebuffer: WebGLFramebuffer;
  62832. framebufferWidth: number;
  62833. framebufferHeight: number;
  62834. getViewport: Function;
  62835. }
  62836. interface XRRigidTransform {
  62837. position: DOMPointReadOnly;
  62838. orientation: DOMPointReadOnly;
  62839. matrix: Float32Array;
  62840. inverse: XRRigidTransform;
  62841. }
  62842. interface XRView {
  62843. eye: XREye;
  62844. projectionMatrix: Float32Array;
  62845. transform: XRRigidTransform;
  62846. }
  62847. interface XRInputSourceChangeEvent {
  62848. session: XRSession;
  62849. removed: Array<XRInputSource>;
  62850. added: Array<XRInputSource>;
  62851. }
  62852. /**
  62853. * @ignore
  62854. */
  62855. declare module BABYLON.GLTF2.Exporter {
  62856. }
  62857. /**
  62858. * @ignore
  62859. */
  62860. declare module BABYLON.GLTF1 {
  62861. }
  62862. declare module BABYLON.GUI {
  62863. /**
  62864. * Class used to specific a value and its associated unit
  62865. */
  62866. export class ValueAndUnit {
  62867. /** defines the unit to store */
  62868. unit: number;
  62869. /** defines a boolean indicating if the value can be negative */
  62870. negativeValueAllowed: boolean;
  62871. private _value;
  62872. private _originalUnit;
  62873. /**
  62874. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  62875. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  62876. */
  62877. ignoreAdaptiveScaling: boolean;
  62878. /**
  62879. * Creates a new ValueAndUnit
  62880. * @param value defines the value to store
  62881. * @param unit defines the unit to store
  62882. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  62883. */
  62884. constructor(value: number,
  62885. /** defines the unit to store */
  62886. unit?: number,
  62887. /** defines a boolean indicating if the value can be negative */
  62888. negativeValueAllowed?: boolean);
  62889. /** Gets a boolean indicating if the value is a percentage */
  62890. readonly isPercentage: boolean;
  62891. /** Gets a boolean indicating if the value is store as pixel */
  62892. readonly isPixel: boolean;
  62893. /** Gets direct internal value */
  62894. readonly internalValue: number;
  62895. /**
  62896. * Gets value as pixel
  62897. * @param host defines the root host
  62898. * @param refValue defines the reference value for percentages
  62899. * @returns the value as pixel
  62900. */
  62901. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  62902. /**
  62903. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  62904. * @param value defines the value to store
  62905. * @param unit defines the unit to store
  62906. * @returns the current ValueAndUnit
  62907. */
  62908. updateInPlace(value: number, unit?: number): ValueAndUnit;
  62909. /**
  62910. * Gets the value accordingly to its unit
  62911. * @param host defines the root host
  62912. * @returns the value
  62913. */
  62914. getValue(host: AdvancedDynamicTexture): number;
  62915. /**
  62916. * Gets a string representation of the value
  62917. * @param host defines the root host
  62918. * @param decimals defines an optional number of decimals to display
  62919. * @returns a string
  62920. */
  62921. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  62922. /**
  62923. * Store a value parsed from a string
  62924. * @param source defines the source string
  62925. * @returns true if the value was successfully parsed
  62926. */
  62927. fromString(source: string | number): boolean;
  62928. private static _Regex;
  62929. private static _UNITMODE_PERCENTAGE;
  62930. private static _UNITMODE_PIXEL;
  62931. /** UNITMODE_PERCENTAGE */
  62932. static readonly UNITMODE_PERCENTAGE: number;
  62933. /** UNITMODE_PIXEL */
  62934. static readonly UNITMODE_PIXEL: number;
  62935. }
  62936. }
  62937. declare module BABYLON.GUI {
  62938. /**
  62939. * Define a style used by control to automatically setup properties based on a template.
  62940. * Only support font related properties so far
  62941. */
  62942. export class Style implements BABYLON.IDisposable {
  62943. private _fontFamily;
  62944. private _fontStyle;
  62945. private _fontWeight;
  62946. /** @hidden */ private _host: AdvancedDynamicTexture;
  62947. /** @hidden */ private _fontSize: ValueAndUnit;
  62948. /**
  62949. * BABYLON.Observable raised when the style values are changed
  62950. */
  62951. onChangedObservable: BABYLON.Observable<Style>;
  62952. /**
  62953. * Creates a new style object
  62954. * @param host defines the AdvancedDynamicTexture which hosts this style
  62955. */
  62956. constructor(host: AdvancedDynamicTexture);
  62957. /**
  62958. * Gets or sets the font size
  62959. */
  62960. fontSize: string | number;
  62961. /**
  62962. * Gets or sets the font family
  62963. */
  62964. fontFamily: string;
  62965. /**
  62966. * Gets or sets the font style
  62967. */
  62968. fontStyle: string;
  62969. /** Gets or sets font weight */
  62970. fontWeight: string;
  62971. /** Dispose all associated resources */
  62972. dispose(): void;
  62973. }
  62974. }
  62975. declare module BABYLON.GUI {
  62976. /**
  62977. * Class used to transport BABYLON.Vector2 information for pointer events
  62978. */
  62979. export class Vector2WithInfo extends BABYLON.Vector2 {
  62980. /** defines the current mouse button index */
  62981. buttonIndex: number;
  62982. /**
  62983. * Creates a new Vector2WithInfo
  62984. * @param source defines the vector2 data to transport
  62985. * @param buttonIndex defines the current mouse button index
  62986. */
  62987. constructor(source: BABYLON.Vector2,
  62988. /** defines the current mouse button index */
  62989. buttonIndex?: number);
  62990. }
  62991. /** Class used to provide 2D matrix features */
  62992. export class Matrix2D {
  62993. /** Gets the internal array of 6 floats used to store matrix data */
  62994. m: Float32Array;
  62995. /**
  62996. * Creates a new matrix
  62997. * @param m00 defines value for (0, 0)
  62998. * @param m01 defines value for (0, 1)
  62999. * @param m10 defines value for (1, 0)
  63000. * @param m11 defines value for (1, 1)
  63001. * @param m20 defines value for (2, 0)
  63002. * @param m21 defines value for (2, 1)
  63003. */
  63004. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  63005. /**
  63006. * Fills the matrix from direct values
  63007. * @param m00 defines value for (0, 0)
  63008. * @param m01 defines value for (0, 1)
  63009. * @param m10 defines value for (1, 0)
  63010. * @param m11 defines value for (1, 1)
  63011. * @param m20 defines value for (2, 0)
  63012. * @param m21 defines value for (2, 1)
  63013. * @returns the current modified matrix
  63014. */
  63015. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  63016. /**
  63017. * Gets matrix determinant
  63018. * @returns the determinant
  63019. */
  63020. determinant(): number;
  63021. /**
  63022. * Inverses the matrix and stores it in a target matrix
  63023. * @param result defines the target matrix
  63024. * @returns the current matrix
  63025. */
  63026. invertToRef(result: Matrix2D): Matrix2D;
  63027. /**
  63028. * Multiplies the current matrix with another one
  63029. * @param other defines the second operand
  63030. * @param result defines the target matrix
  63031. * @returns the current matrix
  63032. */
  63033. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  63034. /**
  63035. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  63036. * @param x defines the x coordinate to transform
  63037. * @param y defines the x coordinate to transform
  63038. * @param result defines the target vector2
  63039. * @returns the current matrix
  63040. */
  63041. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  63042. /**
  63043. * Creates an identity matrix
  63044. * @returns a new matrix
  63045. */
  63046. static Identity(): Matrix2D;
  63047. /**
  63048. * Creates a translation matrix and stores it in a target matrix
  63049. * @param x defines the x coordinate of the translation
  63050. * @param y defines the y coordinate of the translation
  63051. * @param result defines the target matrix
  63052. */
  63053. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  63054. /**
  63055. * Creates a scaling matrix and stores it in a target matrix
  63056. * @param x defines the x coordinate of the scaling
  63057. * @param y defines the y coordinate of the scaling
  63058. * @param result defines the target matrix
  63059. */
  63060. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  63061. /**
  63062. * Creates a rotation matrix and stores it in a target matrix
  63063. * @param angle defines the rotation angle
  63064. * @param result defines the target matrix
  63065. */
  63066. static RotationToRef(angle: number, result: Matrix2D): void;
  63067. private static _TempPreTranslationMatrix;
  63068. private static _TempPostTranslationMatrix;
  63069. private static _TempRotationMatrix;
  63070. private static _TempScalingMatrix;
  63071. private static _TempCompose0;
  63072. private static _TempCompose1;
  63073. private static _TempCompose2;
  63074. /**
  63075. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  63076. * @param tx defines the x coordinate of the translation
  63077. * @param ty defines the y coordinate of the translation
  63078. * @param angle defines the rotation angle
  63079. * @param scaleX defines the x coordinate of the scaling
  63080. * @param scaleY defines the y coordinate of the scaling
  63081. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  63082. * @param result defines the target matrix
  63083. */
  63084. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  63085. }
  63086. }
  63087. declare module BABYLON.GUI {
  63088. /**
  63089. * Class used to store 2D control sizes
  63090. */
  63091. export class Measure {
  63092. /** defines left coordinate */
  63093. left: number;
  63094. /** defines top coordinate */
  63095. top: number;
  63096. /** defines width dimension */
  63097. width: number;
  63098. /** defines height dimension */
  63099. height: number;
  63100. /**
  63101. * Creates a new measure
  63102. * @param left defines left coordinate
  63103. * @param top defines top coordinate
  63104. * @param width defines width dimension
  63105. * @param height defines height dimension
  63106. */
  63107. constructor(
  63108. /** defines left coordinate */
  63109. left: number,
  63110. /** defines top coordinate */
  63111. top: number,
  63112. /** defines width dimension */
  63113. width: number,
  63114. /** defines height dimension */
  63115. height: number);
  63116. /**
  63117. * Copy from another measure
  63118. * @param other defines the other measure to copy from
  63119. */
  63120. copyFrom(other: Measure): void;
  63121. /**
  63122. * Copy from a group of 4 floats
  63123. * @param left defines left coordinate
  63124. * @param top defines top coordinate
  63125. * @param width defines width dimension
  63126. * @param height defines height dimension
  63127. */
  63128. copyFromFloats(left: number, top: number, width: number, height: number): void;
  63129. /**
  63130. * Computes the axis aligned bounding box measure for two given measures
  63131. * @param a Input measure
  63132. * @param b Input measure
  63133. * @param result the resulting bounding measure
  63134. */
  63135. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  63136. /**
  63137. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  63138. * @param transform the matrix to transform the measure before computing the AABB
  63139. * @param result the resulting AABB
  63140. */
  63141. transformToRef(transform: Matrix2D, result: Measure): void;
  63142. /**
  63143. * Check equality between this measure and another one
  63144. * @param other defines the other measures
  63145. * @returns true if both measures are equals
  63146. */
  63147. isEqualsTo(other: Measure): boolean;
  63148. /**
  63149. * Creates an empty measure
  63150. * @returns a new measure
  63151. */
  63152. static Empty(): Measure;
  63153. }
  63154. }
  63155. declare module BABYLON.GUI {
  63156. /**
  63157. * Interface used to define a control that can receive focus
  63158. */
  63159. export interface IFocusableControl {
  63160. /**
  63161. * Function called when the control receives the focus
  63162. */
  63163. onFocus(): void;
  63164. /**
  63165. * Function called when the control loses the focus
  63166. */
  63167. onBlur(): void;
  63168. /**
  63169. * Function called to let the control handle keyboard events
  63170. * @param evt defines the current keyboard event
  63171. */
  63172. processKeyboard(evt: KeyboardEvent): void;
  63173. /**
  63174. * Function called to get the list of controls that should not steal the focus from this control
  63175. * @returns an array of controls
  63176. */
  63177. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  63178. }
  63179. /**
  63180. * Class used to create texture to support 2D GUI elements
  63181. * @see http://doc.babylonjs.com/how_to/gui
  63182. */
  63183. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  63184. private _isDirty;
  63185. private _renderObserver;
  63186. private _resizeObserver;
  63187. private _preKeyboardObserver;
  63188. private _pointerMoveObserver;
  63189. private _pointerObserver;
  63190. private _canvasPointerOutObserver;
  63191. private _background;
  63192. /** @hidden */ private _rootContainer: Container;
  63193. /** @hidden */ private _lastPickedControl: Control;
  63194. /** @hidden */ private _lastControlOver: {
  63195. [pointerId: number]: Control;
  63196. };
  63197. /** @hidden */ private _lastControlDown: {
  63198. [pointerId: number]: Control;
  63199. };
  63200. /** @hidden */ private _capturingControl: {
  63201. [pointerId: number]: Control;
  63202. };
  63203. /** @hidden */ private _shouldBlockPointer: boolean;
  63204. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  63205. /** @hidden */ private _linkedControls: Control[];
  63206. private _isFullscreen;
  63207. private _fullscreenViewport;
  63208. private _idealWidth;
  63209. private _idealHeight;
  63210. private _useSmallestIdeal;
  63211. private _renderAtIdealSize;
  63212. private _focusedControl;
  63213. private _blockNextFocusCheck;
  63214. private _renderScale;
  63215. private _rootCanvas;
  63216. private _cursorChanged;
  63217. /**
  63218. * Define type to string to ensure compatibility across browsers
  63219. * Safari doesn't support DataTransfer constructor
  63220. */
  63221. private _clipboardData;
  63222. /**
  63223. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  63224. */
  63225. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  63226. /**
  63227. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  63228. */
  63229. onControlPickedObservable: BABYLON.Observable<Control>;
  63230. /**
  63231. * BABYLON.Observable event triggered before layout is evaluated
  63232. */
  63233. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63234. /**
  63235. * BABYLON.Observable event triggered after the layout was evaluated
  63236. */
  63237. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63238. /**
  63239. * BABYLON.Observable event triggered before the texture is rendered
  63240. */
  63241. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63242. /**
  63243. * BABYLON.Observable event triggered after the texture was rendered
  63244. */
  63245. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  63246. /**
  63247. * Gets or sets a boolean defining if alpha is stored as premultiplied
  63248. */
  63249. premulAlpha: boolean;
  63250. /**
  63251. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  63252. * Useful when you want more antialiasing
  63253. */
  63254. renderScale: number;
  63255. /** Gets or sets the background color */
  63256. background: string;
  63257. /**
  63258. * Gets or sets the ideal width used to design controls.
  63259. * The GUI will then rescale everything accordingly
  63260. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63261. */
  63262. idealWidth: number;
  63263. /**
  63264. * Gets or sets the ideal height used to design controls.
  63265. * The GUI will then rescale everything accordingly
  63266. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63267. */
  63268. idealHeight: number;
  63269. /**
  63270. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  63271. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63272. */
  63273. useSmallestIdeal: boolean;
  63274. /**
  63275. * Gets or sets a boolean indicating if adaptive scaling must be used
  63276. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  63277. */
  63278. renderAtIdealSize: boolean;
  63279. /**
  63280. * Gets the underlying layer used to render the texture when in fullscreen mode
  63281. */
  63282. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  63283. /**
  63284. * Gets the root container control
  63285. */
  63286. readonly rootContainer: Container;
  63287. /**
  63288. * Returns an array containing the root container.
  63289. * This is mostly used to let the Inspector introspects the ADT
  63290. * @returns an array containing the rootContainer
  63291. */
  63292. getChildren(): Array<Container>;
  63293. /**
  63294. * Will return all controls that are inside this texture
  63295. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  63296. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  63297. * @return all child controls
  63298. */
  63299. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63300. /**
  63301. * Gets or sets the current focused control
  63302. */
  63303. focusedControl: BABYLON.Nullable<IFocusableControl>;
  63304. /**
  63305. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  63306. */
  63307. isForeground: boolean;
  63308. /**
  63309. * Gets or set information about clipboardData
  63310. */
  63311. clipboardData: string;
  63312. /**
  63313. * Creates a new AdvancedDynamicTexture
  63314. * @param name defines the name of the texture
  63315. * @param width defines the width of the texture
  63316. * @param height defines the height of the texture
  63317. * @param scene defines the hosting scene
  63318. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  63319. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  63320. */
  63321. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  63322. /**
  63323. * Get the current class name of the texture useful for serialization or dynamic coding.
  63324. * @returns "AdvancedDynamicTexture"
  63325. */
  63326. getClassName(): string;
  63327. /**
  63328. * Function used to execute a function on all controls
  63329. * @param func defines the function to execute
  63330. * @param container defines the container where controls belong. If null the root container will be used
  63331. */
  63332. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  63333. private _useInvalidateRectOptimization;
  63334. /**
  63335. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  63336. */
  63337. useInvalidateRectOptimization: boolean;
  63338. private _invalidatedRectangle;
  63339. /**
  63340. * Invalidates a rectangle area on the gui texture
  63341. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  63342. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  63343. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  63344. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  63345. */
  63346. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  63347. /**
  63348. * Marks the texture as dirty forcing a complete update
  63349. */
  63350. markAsDirty(): void;
  63351. /**
  63352. * Helper function used to create a new style
  63353. * @returns a new style
  63354. * @see http://doc.babylonjs.com/how_to/gui#styles
  63355. */
  63356. createStyle(): Style;
  63357. /**
  63358. * Adds a new control to the root container
  63359. * @param control defines the control to add
  63360. * @returns the current texture
  63361. */
  63362. addControl(control: Control): AdvancedDynamicTexture;
  63363. /**
  63364. * Removes a control from the root container
  63365. * @param control defines the control to remove
  63366. * @returns the current texture
  63367. */
  63368. removeControl(control: Control): AdvancedDynamicTexture;
  63369. /**
  63370. * Release all resources
  63371. */
  63372. dispose(): void;
  63373. private _onResize;
  63374. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  63375. /**
  63376. * Get screen coordinates for a vector3
  63377. * @param position defines the position to project
  63378. * @param worldMatrix defines the world matrix to use
  63379. * @returns the projected position
  63380. */
  63381. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  63382. private _checkUpdate;
  63383. private _clearMeasure;
  63384. private _render;
  63385. /** @hidden */ private _changeCursor(cursor: string): void;
  63386. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  63387. private _doPicking;
  63388. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  63389. [pointerId: number]: Control;
  63390. }, control: Control): void;
  63391. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  63392. /** Attach to all scene events required to support pointer events */
  63393. attach(): void;
  63394. /** @hidden */
  63395. private onClipboardCopy;
  63396. /** @hidden */
  63397. private onClipboardCut;
  63398. /** @hidden */
  63399. private onClipboardPaste;
  63400. /**
  63401. * Register the clipboard Events onto the canvas
  63402. */
  63403. registerClipboardEvents(): void;
  63404. /**
  63405. * Unregister the clipboard Events from the canvas
  63406. */
  63407. unRegisterClipboardEvents(): void;
  63408. /**
  63409. * Connect the texture to a hosting mesh to enable interactions
  63410. * @param mesh defines the mesh to attach to
  63411. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  63412. */
  63413. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  63414. /**
  63415. * Move the focus to a specific control
  63416. * @param control defines the control which will receive the focus
  63417. */
  63418. moveFocusToControl(control: IFocusableControl): void;
  63419. private _manageFocus;
  63420. private _attachToOnPointerOut;
  63421. /**
  63422. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  63423. * @param mesh defines the mesh which will receive the texture
  63424. * @param width defines the texture width (1024 by default)
  63425. * @param height defines the texture height (1024 by default)
  63426. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  63427. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  63428. * @returns a new AdvancedDynamicTexture
  63429. */
  63430. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  63431. /**
  63432. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  63433. * In this mode the texture will rely on a layer for its rendering.
  63434. * This allows it to be treated like any other layer.
  63435. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  63436. * LayerMask is set through advancedTexture.layer.layerMask
  63437. * @param name defines name for the texture
  63438. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  63439. * @param scene defines the hsoting scene
  63440. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  63441. * @returns a new AdvancedDynamicTexture
  63442. */
  63443. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  63444. }
  63445. }
  63446. declare module BABYLON.GUI {
  63447. /**
  63448. * Root class used for all 2D controls
  63449. * @see http://doc.babylonjs.com/how_to/gui#controls
  63450. */
  63451. export class Control {
  63452. /** defines the name of the control */
  63453. name?: string | undefined;
  63454. /**
  63455. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  63456. */
  63457. static AllowAlphaInheritance: boolean;
  63458. private _alpha;
  63459. private _alphaSet;
  63460. private _zIndex;
  63461. /** @hidden */ private _host: AdvancedDynamicTexture;
  63462. /** Gets or sets the control parent */
  63463. parent: BABYLON.Nullable<Container>;
  63464. /** @hidden */ private _currentMeasure: Measure;
  63465. private _fontFamily;
  63466. private _fontStyle;
  63467. private _fontWeight;
  63468. private _fontSize;
  63469. private _font;
  63470. /** @hidden */ private _width: ValueAndUnit;
  63471. /** @hidden */ private _height: ValueAndUnit;
  63472. /** @hidden */
  63473. protected _fontOffset: {
  63474. ascent: number;
  63475. height: number;
  63476. descent: number;
  63477. };
  63478. private _color;
  63479. private _style;
  63480. private _styleObserver;
  63481. /** @hidden */
  63482. protected _horizontalAlignment: number;
  63483. /** @hidden */
  63484. protected _verticalAlignment: number;
  63485. /** @hidden */
  63486. protected _isDirty: boolean;
  63487. /** @hidden */
  63488. protected _wasDirty: boolean;
  63489. /** @hidden */ private _tempParentMeasure: Measure;
  63490. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  63491. /** @hidden */
  63492. protected _cachedParentMeasure: Measure;
  63493. private _paddingLeft;
  63494. private _paddingRight;
  63495. private _paddingTop;
  63496. private _paddingBottom;
  63497. /** @hidden */ private _left: ValueAndUnit;
  63498. /** @hidden */ private _top: ValueAndUnit;
  63499. private _scaleX;
  63500. private _scaleY;
  63501. private _rotation;
  63502. private _transformCenterX;
  63503. private _transformCenterY;
  63504. /** @hidden */ private _transformMatrix: Matrix2D;
  63505. /** @hidden */
  63506. protected _invertTransformMatrix: Matrix2D;
  63507. /** @hidden */
  63508. protected _transformedPosition: BABYLON.Vector2;
  63509. private _isMatrixDirty;
  63510. private _cachedOffsetX;
  63511. private _cachedOffsetY;
  63512. private _isVisible;
  63513. private _isHighlighted;
  63514. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63515. private _fontSet;
  63516. private _dummyVector2;
  63517. private _downCount;
  63518. private _enterCount;
  63519. private _doNotRender;
  63520. private _downPointerIds;
  63521. protected _isEnabled: boolean;
  63522. protected _disabledColor: string;
  63523. /** @hidden */
  63524. protected _rebuildLayout: boolean;
  63525. /** @hidden */ private _isClipped: boolean;
  63526. /** @hidden */ private _tag: any;
  63527. /**
  63528. * Gets or sets the unique id of the node. Please note that this number will be updated when the control is added to a container
  63529. */
  63530. uniqueId: number;
  63531. /**
  63532. * Gets or sets an object used to store user defined information for the node
  63533. */
  63534. metadata: any;
  63535. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  63536. isHitTestVisible: boolean;
  63537. /** Gets or sets a boolean indicating if the control can block pointer events */
  63538. isPointerBlocker: boolean;
  63539. /** Gets or sets a boolean indicating if the control can be focusable */
  63540. isFocusInvisible: boolean;
  63541. /**
  63542. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  63543. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  63544. */
  63545. clipChildren: boolean;
  63546. /**
  63547. * Gets or sets a boolean indicating that control content must be clipped
  63548. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  63549. */
  63550. clipContent: boolean;
  63551. /**
  63552. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  63553. */
  63554. useBitmapCache: boolean;
  63555. private _cacheData;
  63556. private _shadowOffsetX;
  63557. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  63558. shadowOffsetX: number;
  63559. private _shadowOffsetY;
  63560. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  63561. shadowOffsetY: number;
  63562. private _shadowBlur;
  63563. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  63564. shadowBlur: number;
  63565. private _shadowColor;
  63566. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  63567. shadowColor: string;
  63568. /** Gets or sets the cursor to use when the control is hovered */
  63569. hoverCursor: string;
  63570. /** @hidden */
  63571. protected _linkOffsetX: ValueAndUnit;
  63572. /** @hidden */
  63573. protected _linkOffsetY: ValueAndUnit;
  63574. /** Gets the control type name */
  63575. readonly typeName: string;
  63576. /**
  63577. * Get the current class name of the control.
  63578. * @returns current class name
  63579. */
  63580. getClassName(): string;
  63581. /**
  63582. * An event triggered when the pointer move over the control.
  63583. */
  63584. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  63585. /**
  63586. * An event triggered when the pointer move out of the control.
  63587. */
  63588. onPointerOutObservable: BABYLON.Observable<Control>;
  63589. /**
  63590. * An event triggered when the pointer taps the control
  63591. */
  63592. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  63593. /**
  63594. * An event triggered when pointer up
  63595. */
  63596. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  63597. /**
  63598. * An event triggered when a control is clicked on
  63599. */
  63600. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  63601. /**
  63602. * An event triggered when pointer enters the control
  63603. */
  63604. onPointerEnterObservable: BABYLON.Observable<Control>;
  63605. /**
  63606. * An event triggered when the control is marked as dirty
  63607. */
  63608. onDirtyObservable: BABYLON.Observable<Control>;
  63609. /**
  63610. * An event triggered before drawing the control
  63611. */
  63612. onBeforeDrawObservable: BABYLON.Observable<Control>;
  63613. /**
  63614. * An event triggered after the control was drawn
  63615. */
  63616. onAfterDrawObservable: BABYLON.Observable<Control>;
  63617. /**
  63618. * Get the hosting AdvancedDynamicTexture
  63619. */
  63620. readonly host: AdvancedDynamicTexture;
  63621. /** Gets or set information about font offsets (used to render and align text) */
  63622. fontOffset: {
  63623. ascent: number;
  63624. height: number;
  63625. descent: number;
  63626. };
  63627. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  63628. alpha: number;
  63629. /**
  63630. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  63631. */
  63632. isHighlighted: boolean;
  63633. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  63634. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63635. */
  63636. scaleX: number;
  63637. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  63638. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63639. */
  63640. scaleY: number;
  63641. /** Gets or sets the rotation angle (0 by default)
  63642. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63643. */
  63644. rotation: number;
  63645. /** Gets or sets the transformation center on Y axis (0 by default)
  63646. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63647. */
  63648. transformCenterY: number;
  63649. /** Gets or sets the transformation center on X axis (0 by default)
  63650. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  63651. */
  63652. transformCenterX: number;
  63653. /**
  63654. * Gets or sets the horizontal alignment
  63655. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63656. */
  63657. horizontalAlignment: number;
  63658. /**
  63659. * Gets or sets the vertical alignment
  63660. * @see http://doc.babylonjs.com/how_to/gui#alignments
  63661. */
  63662. verticalAlignment: number;
  63663. /**
  63664. * Gets or sets control width
  63665. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63666. */
  63667. width: string | number;
  63668. /**
  63669. * Gets or sets the control width in pixel
  63670. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63671. */
  63672. widthInPixels: number;
  63673. /**
  63674. * Gets or sets control height
  63675. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63676. */
  63677. height: string | number;
  63678. /**
  63679. * Gets or sets control height in pixel
  63680. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63681. */
  63682. heightInPixels: number;
  63683. /** Gets or set font family */
  63684. fontFamily: string;
  63685. /** Gets or sets font style */
  63686. fontStyle: string;
  63687. /** Gets or sets font weight */
  63688. fontWeight: string;
  63689. /**
  63690. * Gets or sets style
  63691. * @see http://doc.babylonjs.com/how_to/gui#styles
  63692. */
  63693. style: BABYLON.Nullable<Style>;
  63694. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  63695. /** Gets or sets font size in pixels */
  63696. fontSizeInPixels: number;
  63697. /** Gets or sets font size */
  63698. fontSize: string | number;
  63699. /** Gets or sets foreground color */
  63700. color: string;
  63701. /** Gets or sets z index which is used to reorder controls on the z axis */
  63702. zIndex: number;
  63703. /** Gets or sets a boolean indicating if the control can be rendered */
  63704. notRenderable: boolean;
  63705. /** Gets or sets a boolean indicating if the control is visible */
  63706. isVisible: boolean;
  63707. /** Gets a boolean indicating that the control needs to update its rendering */
  63708. readonly isDirty: boolean;
  63709. /**
  63710. * Gets the current linked mesh (or null if none)
  63711. */
  63712. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63713. /**
  63714. * Gets or sets a value indicating the padding to use on the left of the control
  63715. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63716. */
  63717. paddingLeft: string | number;
  63718. /**
  63719. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  63720. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63721. */
  63722. paddingLeftInPixels: number;
  63723. /**
  63724. * Gets or sets a value indicating the padding to use on the right of the control
  63725. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63726. */
  63727. paddingRight: string | number;
  63728. /**
  63729. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  63730. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63731. */
  63732. paddingRightInPixels: number;
  63733. /**
  63734. * Gets or sets a value indicating the padding to use on the top of the control
  63735. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63736. */
  63737. paddingTop: string | number;
  63738. /**
  63739. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  63740. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63741. */
  63742. paddingTopInPixels: number;
  63743. /**
  63744. * Gets or sets a value indicating the padding to use on the bottom of the control
  63745. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63746. */
  63747. paddingBottom: string | number;
  63748. /**
  63749. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  63750. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63751. */
  63752. paddingBottomInPixels: number;
  63753. /**
  63754. * Gets or sets a value indicating the left coordinate of the control
  63755. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63756. */
  63757. left: string | number;
  63758. /**
  63759. * Gets or sets a value indicating the left coordinate in pixels of the control
  63760. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63761. */
  63762. leftInPixels: number;
  63763. /**
  63764. * Gets or sets a value indicating the top coordinate of the control
  63765. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63766. */
  63767. top: string | number;
  63768. /**
  63769. * Gets or sets a value indicating the top coordinate in pixels of the control
  63770. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  63771. */
  63772. topInPixels: number;
  63773. /**
  63774. * Gets or sets a value indicating the offset on X axis to the linked mesh
  63775. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63776. */
  63777. linkOffsetX: string | number;
  63778. /**
  63779. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  63780. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63781. */
  63782. linkOffsetXInPixels: number;
  63783. /**
  63784. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  63785. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63786. */
  63787. linkOffsetY: string | number;
  63788. /**
  63789. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  63790. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63791. */
  63792. linkOffsetYInPixels: number;
  63793. /** Gets the center coordinate on X axis */
  63794. readonly centerX: number;
  63795. /** Gets the center coordinate on Y axis */
  63796. readonly centerY: number;
  63797. /** Gets or sets if control is Enabled*/
  63798. isEnabled: boolean;
  63799. /** Gets or sets background color of control if it's disabled*/
  63800. disabledColor: string;
  63801. /**
  63802. * Creates a new control
  63803. * @param name defines the name of the control
  63804. */
  63805. constructor(
  63806. /** defines the name of the control */
  63807. name?: string | undefined);
  63808. /** @hidden */
  63809. protected _getTypeName(): string;
  63810. /**
  63811. * Gets the first ascendant in the hierarchy of the given type
  63812. * @param className defines the required type
  63813. * @returns the ascendant or null if not found
  63814. */
  63815. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  63816. /** @hidden */ private _resetFontCache(): void;
  63817. /**
  63818. * Determines if a container is an ascendant of the current control
  63819. * @param container defines the container to look for
  63820. * @returns true if the container is one of the ascendant of the control
  63821. */
  63822. isAscendant(container: Control): boolean;
  63823. /**
  63824. * Gets coordinates in local control space
  63825. * @param globalCoordinates defines the coordinates to transform
  63826. * @returns the new coordinates in local space
  63827. */
  63828. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63829. /**
  63830. * Gets coordinates in local control space
  63831. * @param globalCoordinates defines the coordinates to transform
  63832. * @param result defines the target vector2 where to store the result
  63833. * @returns the current control
  63834. */
  63835. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  63836. /**
  63837. * Gets coordinates in parent local control space
  63838. * @param globalCoordinates defines the coordinates to transform
  63839. * @returns the new coordinates in parent local space
  63840. */
  63841. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  63842. /**
  63843. * Move the current control to a vector3 position projected onto the screen.
  63844. * @param position defines the target position
  63845. * @param scene defines the hosting scene
  63846. */
  63847. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  63848. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  63849. /**
  63850. * Will return all controls that have this control as ascendant
  63851. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  63852. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  63853. * @return all child controls
  63854. */
  63855. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  63856. /**
  63857. * Link current control with a target mesh
  63858. * @param mesh defines the mesh to link with
  63859. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  63860. */
  63861. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  63862. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  63863. /** @hidden */ private _offsetLeft(offset: number): void;
  63864. /** @hidden */ private _offsetTop(offset: number): void;
  63865. /** @hidden */ private _markMatrixAsDirty(): void;
  63866. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  63867. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  63868. /** @hidden */
  63869. protected invalidateRect(): void;
  63870. /** @hidden */ private _markAsDirty(force?: boolean): void;
  63871. /** @hidden */ private _markAllAsDirty(): void;
  63872. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  63873. /** @hidden */
  63874. protected _transform(context?: CanvasRenderingContext2D): void;
  63875. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  63876. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63877. /** @hidden */
  63878. protected _applyStates(context: CanvasRenderingContext2D): void;
  63879. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  63880. /** @hidden */
  63881. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63882. protected _evaluateClippingState(parentMeasure: Measure): void;
  63883. /** @hidden */ private _measure(): void;
  63884. /** @hidden */
  63885. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63886. /** @hidden */
  63887. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63888. /** @hidden */
  63889. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63890. /** @hidden */
  63891. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  63892. private static _ClipMeasure;
  63893. private _tmpMeasureA;
  63894. private _clip;
  63895. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  63896. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  63897. /**
  63898. * Tests if a given coordinates belong to the current control
  63899. * @param x defines x coordinate to test
  63900. * @param y defines y coordinate to test
  63901. * @returns true if the coordinates are inside the control
  63902. */
  63903. contains(x: number, y: number): boolean;
  63904. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  63905. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  63906. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  63907. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  63908. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63909. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63910. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63911. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  63912. private _prepareFont;
  63913. /** Releases associated resources */
  63914. dispose(): void;
  63915. private static _HORIZONTAL_ALIGNMENT_LEFT;
  63916. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  63917. private static _HORIZONTAL_ALIGNMENT_CENTER;
  63918. private static _VERTICAL_ALIGNMENT_TOP;
  63919. private static _VERTICAL_ALIGNMENT_BOTTOM;
  63920. private static _VERTICAL_ALIGNMENT_CENTER;
  63921. /** HORIZONTAL_ALIGNMENT_LEFT */
  63922. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  63923. /** HORIZONTAL_ALIGNMENT_RIGHT */
  63924. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  63925. /** HORIZONTAL_ALIGNMENT_CENTER */
  63926. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  63927. /** VERTICAL_ALIGNMENT_TOP */
  63928. static readonly VERTICAL_ALIGNMENT_TOP: number;
  63929. /** VERTICAL_ALIGNMENT_BOTTOM */
  63930. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  63931. /** VERTICAL_ALIGNMENT_CENTER */
  63932. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  63933. private static _FontHeightSizes;
  63934. /** @hidden */ private static _GetFontOffset(font: string): {
  63935. ascent: number;
  63936. height: number;
  63937. descent: number;
  63938. };
  63939. /**
  63940. * Creates a stack panel that can be used to render headers
  63941. * @param control defines the control to associate with the header
  63942. * @param text defines the text of the header
  63943. * @param size defines the size of the header
  63944. * @param options defines options used to configure the header
  63945. * @returns a new StackPanel
  63946. * @ignore
  63947. * @hidden
  63948. */
  63949. static AddHeader: (control: Control, text: string, size: string | number, options: {
  63950. isHorizontal: boolean;
  63951. controlFirst: boolean;
  63952. }) => any;
  63953. /** @hidden */
  63954. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  63955. }
  63956. }
  63957. declare module BABYLON.GUI {
  63958. /**
  63959. * Root class for 2D containers
  63960. * @see http://doc.babylonjs.com/how_to/gui#containers
  63961. */
  63962. export class Container extends Control {
  63963. name?: string | undefined;
  63964. /** @hidden */
  63965. protected _children: Control[];
  63966. /** @hidden */
  63967. protected _measureForChildren: Measure;
  63968. /** @hidden */
  63969. protected _background: string;
  63970. /** @hidden */
  63971. protected _adaptWidthToChildren: boolean;
  63972. /** @hidden */
  63973. protected _adaptHeightToChildren: boolean;
  63974. /**
  63975. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  63976. */
  63977. logLayoutCycleErrors: boolean;
  63978. /**
  63979. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  63980. */
  63981. maxLayoutCycle: number;
  63982. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  63983. adaptHeightToChildren: boolean;
  63984. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  63985. adaptWidthToChildren: boolean;
  63986. /** Gets or sets background color */
  63987. background: string;
  63988. /** Gets the list of children */
  63989. readonly children: Control[];
  63990. /**
  63991. * Creates a new Container
  63992. * @param name defines the name of the container
  63993. */
  63994. constructor(name?: string | undefined);
  63995. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  63996. /**
  63997. * Gets a child using its name
  63998. * @param name defines the child name to look for
  63999. * @returns the child control if found
  64000. */
  64001. getChildByName(name: string): BABYLON.Nullable<Control>;
  64002. /**
  64003. * Gets a child using its type and its name
  64004. * @param name defines the child name to look for
  64005. * @param type defines the child type to look for
  64006. * @returns the child control if found
  64007. */
  64008. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  64009. /**
  64010. * Search for a specific control in children
  64011. * @param control defines the control to look for
  64012. * @returns true if the control is in child list
  64013. */
  64014. containsControl(control: Control): boolean;
  64015. /**
  64016. * Adds a new control to the current container
  64017. * @param control defines the control to add
  64018. * @returns the current container
  64019. */
  64020. addControl(control: BABYLON.Nullable<Control>): Container;
  64021. /**
  64022. * Removes all controls from the current container
  64023. * @returns the current container
  64024. */
  64025. clearControls(): Container;
  64026. /**
  64027. * Removes a control from the current container
  64028. * @param control defines the control to remove
  64029. * @returns the current container
  64030. */
  64031. removeControl(control: Control): Container;
  64032. /** @hidden */ private _reOrderControl(control: Control): void;
  64033. /** @hidden */ private _offsetLeft(offset: number): void;
  64034. /** @hidden */ private _offsetTop(offset: number): void;
  64035. /** @hidden */ private _markAllAsDirty(): void;
  64036. /** @hidden */
  64037. protected _localDraw(context: CanvasRenderingContext2D): void;
  64038. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  64039. /** @hidden */
  64040. protected _beforeLayout(): void;
  64041. /** @hidden */
  64042. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64043. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  64044. protected _postMeasure(): void;
  64045. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  64046. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  64047. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64048. /** @hidden */
  64049. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64050. /** Releases associated resources */
  64051. dispose(): void;
  64052. }
  64053. }
  64054. declare module BABYLON.GUI {
  64055. /** Class used to create rectangle container */
  64056. export class Rectangle extends Container {
  64057. name?: string | undefined;
  64058. private _thickness;
  64059. private _cornerRadius;
  64060. /** Gets or sets border thickness */
  64061. thickness: number;
  64062. /** Gets or sets the corner radius angle */
  64063. cornerRadius: number;
  64064. /**
  64065. * Creates a new Rectangle
  64066. * @param name defines the control name
  64067. */
  64068. constructor(name?: string | undefined);
  64069. protected _getTypeName(): string;
  64070. protected _localDraw(context: CanvasRenderingContext2D): void;
  64071. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64072. private _drawRoundedRect;
  64073. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64074. }
  64075. }
  64076. declare module BABYLON.GUI {
  64077. /**
  64078. * Enum that determines the text-wrapping mode to use.
  64079. */
  64080. export enum TextWrapping {
  64081. /**
  64082. * Clip the text when it's larger than Control.width; this is the default mode.
  64083. */
  64084. Clip = 0,
  64085. /**
  64086. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  64087. */
  64088. WordWrap = 1,
  64089. /**
  64090. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  64091. */
  64092. Ellipsis = 2
  64093. }
  64094. /**
  64095. * Class used to create text block control
  64096. */
  64097. export class TextBlock extends Control {
  64098. /**
  64099. * Defines the name of the control
  64100. */
  64101. name?: string | undefined;
  64102. private _text;
  64103. private _textWrapping;
  64104. private _textHorizontalAlignment;
  64105. private _textVerticalAlignment;
  64106. private _lines;
  64107. private _resizeToFit;
  64108. private _lineSpacing;
  64109. private _outlineWidth;
  64110. private _outlineColor;
  64111. /**
  64112. * An event triggered after the text is changed
  64113. */
  64114. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  64115. /**
  64116. * An event triggered after the text was broken up into lines
  64117. */
  64118. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  64119. /**
  64120. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  64121. */
  64122. readonly lines: any[];
  64123. /**
  64124. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64125. */
  64126. /**
  64127. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  64128. */
  64129. resizeToFit: boolean;
  64130. /**
  64131. * Gets or sets a boolean indicating if text must be wrapped
  64132. */
  64133. /**
  64134. * Gets or sets a boolean indicating if text must be wrapped
  64135. */
  64136. textWrapping: TextWrapping | boolean;
  64137. /**
  64138. * Gets or sets text to display
  64139. */
  64140. /**
  64141. * Gets or sets text to display
  64142. */
  64143. text: string;
  64144. /**
  64145. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64146. */
  64147. /**
  64148. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  64149. */
  64150. textHorizontalAlignment: number;
  64151. /**
  64152. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64153. */
  64154. /**
  64155. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  64156. */
  64157. textVerticalAlignment: number;
  64158. /**
  64159. * Gets or sets line spacing value
  64160. */
  64161. /**
  64162. * Gets or sets line spacing value
  64163. */
  64164. lineSpacing: string | number;
  64165. /**
  64166. * Gets or sets outlineWidth of the text to display
  64167. */
  64168. /**
  64169. * Gets or sets outlineWidth of the text to display
  64170. */
  64171. outlineWidth: number;
  64172. /**
  64173. * Gets or sets outlineColor of the text to display
  64174. */
  64175. /**
  64176. * Gets or sets outlineColor of the text to display
  64177. */
  64178. outlineColor: string;
  64179. /**
  64180. * Creates a new TextBlock object
  64181. * @param name defines the name of the control
  64182. * @param text defines the text to display (emptry string by default)
  64183. */
  64184. constructor(
  64185. /**
  64186. * Defines the name of the control
  64187. */
  64188. name?: string | undefined, text?: string);
  64189. protected _getTypeName(): string;
  64190. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64191. private _drawText;
  64192. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64193. protected _applyStates(context: CanvasRenderingContext2D): void;
  64194. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  64195. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  64196. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  64197. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  64198. protected _renderLines(context: CanvasRenderingContext2D): void;
  64199. /**
  64200. * Given a width constraint applied on the text block, find the expected height
  64201. * @returns expected height
  64202. */
  64203. computeExpectedHeight(): number;
  64204. dispose(): void;
  64205. }
  64206. }
  64207. declare module BABYLON.GUI {
  64208. /**
  64209. * Class used to create 2D images
  64210. */
  64211. export class Image extends Control {
  64212. name?: string | undefined;
  64213. private static _WorkingCanvas;
  64214. private _domImage;
  64215. private _imageWidth;
  64216. private _imageHeight;
  64217. private _loaded;
  64218. private _stretch;
  64219. private _source;
  64220. private _autoScale;
  64221. private _sourceLeft;
  64222. private _sourceTop;
  64223. private _sourceWidth;
  64224. private _sourceHeight;
  64225. private _cellWidth;
  64226. private _cellHeight;
  64227. private _cellId;
  64228. private _populateNinePatchSlicesFromImage;
  64229. private _sliceLeft;
  64230. private _sliceRight;
  64231. private _sliceTop;
  64232. private _sliceBottom;
  64233. private _detectPointerOnOpaqueOnly;
  64234. /**
  64235. * BABYLON.Observable notified when the content is loaded
  64236. */
  64237. onImageLoadedObservable: BABYLON.Observable<Image>;
  64238. /**
  64239. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  64240. */
  64241. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  64242. /**
  64243. * Gets a boolean indicating that the content is loaded
  64244. */
  64245. readonly isLoaded: boolean;
  64246. /**
  64247. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  64248. */
  64249. populateNinePatchSlicesFromImage: boolean;
  64250. /**
  64251. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  64252. * Beware using this as this will comsume more memory as the image has to be stored twice
  64253. */
  64254. detectPointerOnOpaqueOnly: boolean;
  64255. /**
  64256. * Gets or sets the left value for slicing (9-patch)
  64257. */
  64258. sliceLeft: number;
  64259. /**
  64260. * Gets or sets the right value for slicing (9-patch)
  64261. */
  64262. sliceRight: number;
  64263. /**
  64264. * Gets or sets the top value for slicing (9-patch)
  64265. */
  64266. sliceTop: number;
  64267. /**
  64268. * Gets or sets the bottom value for slicing (9-patch)
  64269. */
  64270. sliceBottom: number;
  64271. /**
  64272. * Gets or sets the left coordinate in the source image
  64273. */
  64274. sourceLeft: number;
  64275. /**
  64276. * Gets or sets the top coordinate in the source image
  64277. */
  64278. sourceTop: number;
  64279. /**
  64280. * Gets or sets the width to capture in the source image
  64281. */
  64282. sourceWidth: number;
  64283. /**
  64284. * Gets or sets the height to capture in the source image
  64285. */
  64286. sourceHeight: number;
  64287. /**
  64288. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  64289. * @see http://doc.babylonjs.com/how_to/gui#image
  64290. */
  64291. autoScale: boolean;
  64292. /** Gets or sets the streching mode used by the image */
  64293. stretch: number;
  64294. /**
  64295. * Gets or sets the internal DOM image used to render the control
  64296. */
  64297. domImage: HTMLImageElement;
  64298. private _onImageLoaded;
  64299. private _extractNinePatchSliceDataFromImage;
  64300. /**
  64301. * Gets or sets image source url
  64302. */
  64303. source: BABYLON.Nullable<string>;
  64304. /**
  64305. * Checks for svg document with icon id present
  64306. */
  64307. private _svgCheck;
  64308. /**
  64309. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  64310. * given external svg file and icon id
  64311. */
  64312. private _getSVGAttribs;
  64313. /**
  64314. * Gets or sets the cell width to use when animation sheet is enabled
  64315. * @see http://doc.babylonjs.com/how_to/gui#image
  64316. */
  64317. cellWidth: number;
  64318. /**
  64319. * Gets or sets the cell height to use when animation sheet is enabled
  64320. * @see http://doc.babylonjs.com/how_to/gui#image
  64321. */
  64322. cellHeight: number;
  64323. /**
  64324. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  64325. * @see http://doc.babylonjs.com/how_to/gui#image
  64326. */
  64327. cellId: number;
  64328. /**
  64329. * Creates a new Image
  64330. * @param name defines the control name
  64331. * @param url defines the image url
  64332. */
  64333. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  64334. /**
  64335. * Tests if a given coordinates belong to the current control
  64336. * @param x defines x coordinate to test
  64337. * @param y defines y coordinate to test
  64338. * @returns true if the coordinates are inside the control
  64339. */
  64340. contains(x: number, y: number): boolean;
  64341. protected _getTypeName(): string;
  64342. /** Force the control to synchronize with its content */
  64343. synchronizeSizeWithContent(): void;
  64344. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64345. private _prepareWorkingCanvasForOpaqueDetection;
  64346. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  64347. private _renderCornerPatch;
  64348. private _renderNinePatch;
  64349. dispose(): void;
  64350. /** STRETCH_NONE */
  64351. static readonly STRETCH_NONE: number;
  64352. /** STRETCH_FILL */
  64353. static readonly STRETCH_FILL: number;
  64354. /** STRETCH_UNIFORM */
  64355. static readonly STRETCH_UNIFORM: number;
  64356. /** STRETCH_EXTEND */
  64357. static readonly STRETCH_EXTEND: number;
  64358. /** NINE_PATCH */
  64359. static readonly STRETCH_NINE_PATCH: number;
  64360. }
  64361. }
  64362. declare module BABYLON.GUI {
  64363. /**
  64364. * Class used to create 2D buttons
  64365. */
  64366. export class Button extends Rectangle {
  64367. name?: string | undefined;
  64368. /**
  64369. * Function called to generate a pointer enter animation
  64370. */
  64371. pointerEnterAnimation: () => void;
  64372. /**
  64373. * Function called to generate a pointer out animation
  64374. */
  64375. pointerOutAnimation: () => void;
  64376. /**
  64377. * Function called to generate a pointer down animation
  64378. */
  64379. pointerDownAnimation: () => void;
  64380. /**
  64381. * Function called to generate a pointer up animation
  64382. */
  64383. pointerUpAnimation: () => void;
  64384. /**
  64385. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  64386. */
  64387. delegatePickingToChildren: boolean;
  64388. private _image;
  64389. /**
  64390. * Returns the image part of the button (if any)
  64391. */
  64392. readonly image: BABYLON.Nullable<Image>;
  64393. private _textBlock;
  64394. /**
  64395. * Returns the image part of the button (if any)
  64396. */
  64397. readonly textBlock: BABYLON.Nullable<TextBlock>;
  64398. /**
  64399. * Creates a new Button
  64400. * @param name defines the name of the button
  64401. */
  64402. constructor(name?: string | undefined);
  64403. protected _getTypeName(): string;
  64404. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  64405. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  64406. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  64407. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64408. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64409. /**
  64410. * Creates a new button made with an image and a text
  64411. * @param name defines the name of the button
  64412. * @param text defines the text of the button
  64413. * @param imageUrl defines the url of the image
  64414. * @returns a new Button
  64415. */
  64416. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  64417. /**
  64418. * Creates a new button made with an image
  64419. * @param name defines the name of the button
  64420. * @param imageUrl defines the url of the image
  64421. * @returns a new Button
  64422. */
  64423. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  64424. /**
  64425. * Creates a new button made with a text
  64426. * @param name defines the name of the button
  64427. * @param text defines the text of the button
  64428. * @returns a new Button
  64429. */
  64430. static CreateSimpleButton(name: string, text: string): Button;
  64431. /**
  64432. * Creates a new button made with an image and a centered text
  64433. * @param name defines the name of the button
  64434. * @param text defines the text of the button
  64435. * @param imageUrl defines the url of the image
  64436. * @returns a new Button
  64437. */
  64438. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  64439. }
  64440. }
  64441. declare module BABYLON.GUI {
  64442. /**
  64443. * Class used to create a 2D stack panel container
  64444. */
  64445. export class StackPanel extends Container {
  64446. name?: string | undefined;
  64447. private _isVertical;
  64448. private _manualWidth;
  64449. private _manualHeight;
  64450. private _doNotTrackManualChanges;
  64451. /**
  64452. * Gets or sets a boolean indicating that layou warnings should be ignored
  64453. */
  64454. ignoreLayoutWarnings: boolean;
  64455. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  64456. isVertical: boolean;
  64457. /**
  64458. * Gets or sets panel width.
  64459. * This value should not be set when in horizontal mode as it will be computed automatically
  64460. */
  64461. width: string | number;
  64462. /**
  64463. * Gets or sets panel height.
  64464. * This value should not be set when in vertical mode as it will be computed automatically
  64465. */
  64466. height: string | number;
  64467. /**
  64468. * Creates a new StackPanel
  64469. * @param name defines control name
  64470. */
  64471. constructor(name?: string | undefined);
  64472. protected _getTypeName(): string;
  64473. /** @hidden */
  64474. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64475. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64476. protected _postMeasure(): void;
  64477. }
  64478. }
  64479. declare module BABYLON.GUI {
  64480. /**
  64481. * Class used to represent a 2D checkbox
  64482. */
  64483. export class Checkbox extends Control {
  64484. name?: string | undefined;
  64485. private _isChecked;
  64486. private _background;
  64487. private _checkSizeRatio;
  64488. private _thickness;
  64489. /** Gets or sets border thickness */
  64490. thickness: number;
  64491. /**
  64492. * BABYLON.Observable raised when isChecked property changes
  64493. */
  64494. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  64495. /** Gets or sets a value indicating the ratio between overall size and check size */
  64496. checkSizeRatio: number;
  64497. /** Gets or sets background color */
  64498. background: string;
  64499. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  64500. isChecked: boolean;
  64501. /**
  64502. * Creates a new CheckBox
  64503. * @param name defines the control name
  64504. */
  64505. constructor(name?: string | undefined);
  64506. protected _getTypeName(): string;
  64507. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64508. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  64509. /**
  64510. * Utility function to easily create a checkbox with a header
  64511. * @param title defines the label to use for the header
  64512. * @param onValueChanged defines the callback to call when value changes
  64513. * @returns a StackPanel containing the checkbox and a textBlock
  64514. */
  64515. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  64516. }
  64517. }
  64518. declare module BABYLON.GUI {
  64519. /**
  64520. * Class used to store key control properties
  64521. */
  64522. export class KeyPropertySet {
  64523. /** Width */
  64524. width?: string;
  64525. /** Height */
  64526. height?: string;
  64527. /** Left padding */
  64528. paddingLeft?: string;
  64529. /** Right padding */
  64530. paddingRight?: string;
  64531. /** Top padding */
  64532. paddingTop?: string;
  64533. /** Bottom padding */
  64534. paddingBottom?: string;
  64535. /** Foreground color */
  64536. color?: string;
  64537. /** Background color */
  64538. background?: string;
  64539. }
  64540. /**
  64541. * Class used to create virtual keyboard
  64542. */
  64543. export class VirtualKeyboard extends StackPanel {
  64544. /** BABYLON.Observable raised when a key is pressed */
  64545. onKeyPressObservable: BABYLON.Observable<string>;
  64546. /** Gets or sets default key button width */
  64547. defaultButtonWidth: string;
  64548. /** Gets or sets default key button height */
  64549. defaultButtonHeight: string;
  64550. /** Gets or sets default key button left padding */
  64551. defaultButtonPaddingLeft: string;
  64552. /** Gets or sets default key button right padding */
  64553. defaultButtonPaddingRight: string;
  64554. /** Gets or sets default key button top padding */
  64555. defaultButtonPaddingTop: string;
  64556. /** Gets or sets default key button bottom padding */
  64557. defaultButtonPaddingBottom: string;
  64558. /** Gets or sets default key button foreground color */
  64559. defaultButtonColor: string;
  64560. /** Gets or sets default key button background color */
  64561. defaultButtonBackground: string;
  64562. /** Gets or sets shift button foreground color */
  64563. shiftButtonColor: string;
  64564. /** Gets or sets shift button thickness*/
  64565. selectedShiftThickness: number;
  64566. /** Gets shift key state */
  64567. shiftState: number;
  64568. protected _getTypeName(): string;
  64569. private _createKey;
  64570. /**
  64571. * Adds a new row of keys
  64572. * @param keys defines the list of keys to add
  64573. * @param propertySets defines the associated property sets
  64574. */
  64575. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  64576. /**
  64577. * Set the shift key to a specific state
  64578. * @param shiftState defines the new shift state
  64579. */
  64580. applyShiftState(shiftState: number): void;
  64581. private _currentlyConnectedInputText;
  64582. private _connectedInputTexts;
  64583. private _onKeyPressObserver;
  64584. /** Gets the input text control currently attached to the keyboard */
  64585. readonly connectedInputText: BABYLON.Nullable<InputText>;
  64586. /**
  64587. * Connects the keyboard with an input text control
  64588. *
  64589. * @param input defines the target control
  64590. */
  64591. connect(input: InputText): void;
  64592. /**
  64593. * Disconnects the keyboard from connected InputText controls
  64594. *
  64595. * @param input optionally defines a target control, otherwise all are disconnected
  64596. */
  64597. disconnect(input?: InputText): void;
  64598. private _removeConnectedInputObservables;
  64599. /**
  64600. * Release all resources
  64601. */
  64602. dispose(): void;
  64603. /**
  64604. * Creates a new keyboard using a default layout
  64605. *
  64606. * @param name defines control name
  64607. * @returns a new VirtualKeyboard
  64608. */
  64609. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  64610. }
  64611. }
  64612. declare module BABYLON.GUI {
  64613. /**
  64614. * Class used to create input text control
  64615. */
  64616. export class InputText extends Control implements IFocusableControl {
  64617. name?: string | undefined;
  64618. private _text;
  64619. private _placeholderText;
  64620. private _background;
  64621. private _focusedBackground;
  64622. private _focusedColor;
  64623. private _placeholderColor;
  64624. private _thickness;
  64625. private _margin;
  64626. private _autoStretchWidth;
  64627. private _maxWidth;
  64628. private _isFocused;
  64629. private _blinkTimeout;
  64630. private _blinkIsEven;
  64631. private _cursorOffset;
  64632. private _scrollLeft;
  64633. private _textWidth;
  64634. private _clickedCoordinate;
  64635. private _deadKey;
  64636. private _addKey;
  64637. private _currentKey;
  64638. private _isTextHighlightOn;
  64639. private _textHighlightColor;
  64640. private _highligherOpacity;
  64641. private _highlightedText;
  64642. private _startHighlightIndex;
  64643. private _endHighlightIndex;
  64644. private _cursorIndex;
  64645. private _onFocusSelectAll;
  64646. private _isPointerDown;
  64647. private _onClipboardObserver;
  64648. private _onPointerDblTapObserver;
  64649. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  64650. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  64651. promptMessage: string;
  64652. /** Force disable prompt on mobile device */
  64653. disableMobilePrompt: boolean;
  64654. /** BABYLON.Observable raised when the text changes */
  64655. onTextChangedObservable: BABYLON.Observable<InputText>;
  64656. /** BABYLON.Observable raised just before an entered character is to be added */
  64657. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  64658. /** BABYLON.Observable raised when the control gets the focus */
  64659. onFocusObservable: BABYLON.Observable<InputText>;
  64660. /** BABYLON.Observable raised when the control loses the focus */
  64661. onBlurObservable: BABYLON.Observable<InputText>;
  64662. /**Observable raised when the text is highlighted */
  64663. onTextHighlightObservable: BABYLON.Observable<InputText>;
  64664. /**Observable raised when copy event is triggered */
  64665. onTextCopyObservable: BABYLON.Observable<InputText>;
  64666. /** BABYLON.Observable raised when cut event is triggered */
  64667. onTextCutObservable: BABYLON.Observable<InputText>;
  64668. /** BABYLON.Observable raised when paste event is triggered */
  64669. onTextPasteObservable: BABYLON.Observable<InputText>;
  64670. /** BABYLON.Observable raised when a key event was processed */
  64671. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  64672. /** Gets or sets the maximum width allowed by the control */
  64673. maxWidth: string | number;
  64674. /** Gets the maximum width allowed by the control in pixels */
  64675. readonly maxWidthInPixels: number;
  64676. /** Gets or sets the text highlighter transparency; default: 0.4 */
  64677. highligherOpacity: number;
  64678. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  64679. onFocusSelectAll: boolean;
  64680. /** Gets or sets the text hightlight color */
  64681. textHighlightColor: string;
  64682. /** Gets or sets control margin */
  64683. margin: string;
  64684. /** Gets control margin in pixels */
  64685. readonly marginInPixels: number;
  64686. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  64687. autoStretchWidth: boolean;
  64688. /** Gets or sets border thickness */
  64689. thickness: number;
  64690. /** Gets or sets the background color when focused */
  64691. focusedBackground: string;
  64692. /** Gets or sets the background color when focused */
  64693. focusedColor: string;
  64694. /** Gets or sets the background color */
  64695. background: string;
  64696. /** Gets or sets the placeholder color */
  64697. placeholderColor: string;
  64698. /** Gets or sets the text displayed when the control is empty */
  64699. placeholderText: string;
  64700. /** Gets or sets the dead key flag */
  64701. deadKey: boolean;
  64702. /** Gets or sets the highlight text */
  64703. highlightedText: string;
  64704. /** Gets or sets if the current key should be added */
  64705. addKey: boolean;
  64706. /** Gets or sets the value of the current key being entered */
  64707. currentKey: string;
  64708. /** Gets or sets the text displayed in the control */
  64709. text: string;
  64710. /** Gets or sets control width */
  64711. width: string | number;
  64712. /**
  64713. * Creates a new InputText
  64714. * @param name defines the control name
  64715. * @param text defines the text of the control
  64716. */
  64717. constructor(name?: string | undefined, text?: string);
  64718. /** @hidden */
  64719. onBlur(): void;
  64720. /** @hidden */
  64721. onFocus(): void;
  64722. protected _getTypeName(): string;
  64723. /**
  64724. * Function called to get the list of controls that should not steal the focus from this control
  64725. * @returns an array of controls
  64726. */
  64727. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  64728. /** @hidden */
  64729. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  64730. /** @hidden */
  64731. private _updateValueFromCursorIndex;
  64732. /** @hidden */
  64733. private _processDblClick;
  64734. /** @hidden */
  64735. private _selectAllText;
  64736. /**
  64737. * Handles the keyboard event
  64738. * @param evt Defines the KeyboardEvent
  64739. */
  64740. processKeyboard(evt: KeyboardEvent): void;
  64741. /** @hidden */
  64742. private _onCopyText;
  64743. /** @hidden */
  64744. private _onCutText;
  64745. /** @hidden */
  64746. private _onPasteText; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64747. protected _beforeRenderText(text: string): string;
  64748. dispose(): void;
  64749. }
  64750. }
  64751. declare module BABYLON.GUI {
  64752. /**
  64753. * Class used to create a 2D grid container
  64754. */
  64755. export class Grid extends Container {
  64756. name?: string | undefined;
  64757. private _rowDefinitions;
  64758. private _columnDefinitions;
  64759. private _cells;
  64760. private _childControls;
  64761. /**
  64762. * Gets the number of columns
  64763. */
  64764. readonly columnCount: number;
  64765. /**
  64766. * Gets the number of rows
  64767. */
  64768. readonly rowCount: number;
  64769. /** Gets the list of children */
  64770. readonly children: Control[];
  64771. /** Gets the list of cells (e.g. the containers) */
  64772. readonly cells: {
  64773. [key: string]: Container;
  64774. };
  64775. /**
  64776. * Gets the definition of a specific row
  64777. * @param index defines the index of the row
  64778. * @returns the row definition
  64779. */
  64780. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64781. /**
  64782. * Gets the definition of a specific column
  64783. * @param index defines the index of the column
  64784. * @returns the column definition
  64785. */
  64786. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  64787. /**
  64788. * Adds a new row to the grid
  64789. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64790. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  64791. * @returns the current grid
  64792. */
  64793. addRowDefinition(height: number, isPixel?: boolean): Grid;
  64794. /**
  64795. * Adds a new column to the grid
  64796. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64797. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64798. * @returns the current grid
  64799. */
  64800. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  64801. /**
  64802. * Update a row definition
  64803. * @param index defines the index of the row to update
  64804. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  64805. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  64806. * @returns the current grid
  64807. */
  64808. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  64809. /**
  64810. * Update a column definition
  64811. * @param index defines the index of the column to update
  64812. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  64813. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  64814. * @returns the current grid
  64815. */
  64816. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  64817. /**
  64818. * Gets the list of children stored in a specific cell
  64819. * @param row defines the row to check
  64820. * @param column defines the column to check
  64821. * @returns the list of controls
  64822. */
  64823. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  64824. /**
  64825. * Gets a string representing the child cell info (row x column)
  64826. * @param child defines the control to get info from
  64827. * @returns a string containing the child cell info (row x column)
  64828. */
  64829. getChildCellInfo(child: Control): string;
  64830. private _removeCell;
  64831. private _offsetCell;
  64832. /**
  64833. * Remove a column definition at specified index
  64834. * @param index defines the index of the column to remove
  64835. * @returns the current grid
  64836. */
  64837. removeColumnDefinition(index: number): Grid;
  64838. /**
  64839. * Remove a row definition at specified index
  64840. * @param index defines the index of the row to remove
  64841. * @returns the current grid
  64842. */
  64843. removeRowDefinition(index: number): Grid;
  64844. /**
  64845. * Adds a new control to the current grid
  64846. * @param control defines the control to add
  64847. * @param row defines the row where to add the control (0 by default)
  64848. * @param column defines the column where to add the control (0 by default)
  64849. * @returns the current grid
  64850. */
  64851. addControl(control: Control, row?: number, column?: number): Grid;
  64852. /**
  64853. * Removes a control from the current container
  64854. * @param control defines the control to remove
  64855. * @returns the current container
  64856. */
  64857. removeControl(control: Control): Container;
  64858. /**
  64859. * Creates a new Grid
  64860. * @param name defines control name
  64861. */
  64862. constructor(name?: string | undefined);
  64863. protected _getTypeName(): string;
  64864. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  64865. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  64866. /** Releases associated resources */
  64867. dispose(): void;
  64868. }
  64869. }
  64870. declare module BABYLON.GUI {
  64871. /** Class used to create color pickers */
  64872. export class ColorPicker extends Control {
  64873. name?: string | undefined;
  64874. private static _Epsilon;
  64875. private _colorWheelCanvas;
  64876. private _value;
  64877. private _tmpColor;
  64878. private _pointerStartedOnSquare;
  64879. private _pointerStartedOnWheel;
  64880. private _squareLeft;
  64881. private _squareTop;
  64882. private _squareSize;
  64883. private _h;
  64884. private _s;
  64885. private _v;
  64886. private _lastPointerDownID;
  64887. /**
  64888. * BABYLON.Observable raised when the value changes
  64889. */
  64890. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  64891. /** Gets or sets the color of the color picker */
  64892. value: BABYLON.Color3;
  64893. /**
  64894. * Gets or sets control width
  64895. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64896. */
  64897. width: string | number;
  64898. /**
  64899. * Gets or sets control height
  64900. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  64901. */
  64902. /** Gets or sets control height */
  64903. height: string | number;
  64904. /** Gets or sets control size */
  64905. size: string | number;
  64906. /**
  64907. * Creates a new ColorPicker
  64908. * @param name defines the control name
  64909. */
  64910. constructor(name?: string | undefined);
  64911. protected _getTypeName(): string;
  64912. /** @hidden */
  64913. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64914. private _updateSquareProps;
  64915. private _drawGradientSquare;
  64916. private _drawCircle;
  64917. private _createColorWheelCanvas;
  64918. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  64919. private _pointerIsDown;
  64920. private _updateValueFromPointer;
  64921. private _isPointOnSquare;
  64922. private _isPointOnWheel; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  64923. /**
  64924. * This function expands the color picker by creating a color picker dialog with manual
  64925. * color value input and the ability to save colors into an array to be used later in
  64926. * subsequent launches of the dialogue.
  64927. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  64928. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  64929. * @returns picked color as a hex string and the saved colors array as hex strings.
  64930. */
  64931. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  64932. pickerWidth?: string;
  64933. pickerHeight?: string;
  64934. headerHeight?: string;
  64935. lastColor?: string;
  64936. swatchLimit?: number;
  64937. numSwatchesPerLine?: number;
  64938. savedColors?: Array<string>;
  64939. }): Promise<{
  64940. savedColors?: string[];
  64941. pickedColor: string;
  64942. }>;
  64943. }
  64944. }
  64945. declare module BABYLON.GUI {
  64946. /** Class used to create 2D ellipse containers */
  64947. export class Ellipse extends Container {
  64948. name?: string | undefined;
  64949. private _thickness;
  64950. /** Gets or sets border thickness */
  64951. thickness: number;
  64952. /**
  64953. * Creates a new Ellipse
  64954. * @param name defines the control name
  64955. */
  64956. constructor(name?: string | undefined);
  64957. protected _getTypeName(): string;
  64958. protected _localDraw(context: CanvasRenderingContext2D): void;
  64959. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  64960. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  64961. }
  64962. }
  64963. declare module BABYLON.GUI {
  64964. /**
  64965. * Class used to create a password control
  64966. */
  64967. export class InputPassword extends InputText {
  64968. protected _beforeRenderText(text: string): string;
  64969. }
  64970. }
  64971. declare module BABYLON.GUI {
  64972. /** Class used to render 2D lines */
  64973. export class Line extends Control {
  64974. name?: string | undefined;
  64975. private _lineWidth;
  64976. private _x1;
  64977. private _y1;
  64978. private _x2;
  64979. private _y2;
  64980. private _dash;
  64981. private _connectedControl;
  64982. private _connectedControlDirtyObserver;
  64983. /** Gets or sets the dash pattern */
  64984. dash: Array<number>;
  64985. /** Gets or sets the control connected with the line end */
  64986. connectedControl: Control;
  64987. /** Gets or sets start coordinates on X axis */
  64988. x1: string | number;
  64989. /** Gets or sets start coordinates on Y axis */
  64990. y1: string | number;
  64991. /** Gets or sets end coordinates on X axis */
  64992. x2: string | number;
  64993. /** Gets or sets end coordinates on Y axis */
  64994. y2: string | number;
  64995. /** Gets or sets line width */
  64996. lineWidth: number;
  64997. /** Gets or sets horizontal alignment */
  64998. horizontalAlignment: number;
  64999. /** Gets or sets vertical alignment */
  65000. verticalAlignment: number;
  65001. private readonly _effectiveX2;
  65002. private readonly _effectiveY2;
  65003. /**
  65004. * Creates a new Line
  65005. * @param name defines the control name
  65006. */
  65007. constructor(name?: string | undefined);
  65008. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  65009. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65010. /**
  65011. * Move one end of the line given 3D cartesian coordinates.
  65012. * @param position Targeted world position
  65013. * @param scene BABYLON.Scene
  65014. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65015. */
  65016. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  65017. /**
  65018. * Move one end of the line to a position in screen absolute space.
  65019. * @param projectedPosition Position in screen absolute space (X, Y)
  65020. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  65021. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  65022. }
  65023. }
  65024. declare module BABYLON.GUI {
  65025. /**
  65026. * Class used to store a point for a MultiLine object.
  65027. * The point can be pure 2D coordinates, a mesh or a control
  65028. */
  65029. export class MultiLinePoint {
  65030. private _multiLine;
  65031. private _x;
  65032. private _y;
  65033. private _control;
  65034. private _mesh;
  65035. private _controlObserver;
  65036. private _meshObserver;
  65037. /** @hidden */ private _point: BABYLON.Vector2;
  65038. /**
  65039. * Creates a new MultiLinePoint
  65040. * @param multiLine defines the source MultiLine object
  65041. */
  65042. constructor(multiLine: MultiLine);
  65043. /** Gets or sets x coordinate */
  65044. x: string | number;
  65045. /** Gets or sets y coordinate */
  65046. y: string | number;
  65047. /** Gets or sets the control associated with this point */
  65048. control: BABYLON.Nullable<Control>;
  65049. /** Gets or sets the mesh associated with this point */
  65050. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  65051. /** Resets links */
  65052. resetLinks(): void;
  65053. /**
  65054. * Gets a translation vector
  65055. * @returns the translation vector
  65056. */
  65057. translate(): BABYLON.Vector2;
  65058. private _translatePoint;
  65059. /** Release associated resources */
  65060. dispose(): void;
  65061. }
  65062. }
  65063. declare module BABYLON.GUI {
  65064. /**
  65065. * Class used to create multi line control
  65066. */
  65067. export class MultiLine extends Control {
  65068. name?: string | undefined;
  65069. private _lineWidth;
  65070. private _dash;
  65071. private _points;
  65072. private _minX;
  65073. private _minY;
  65074. private _maxX;
  65075. private _maxY;
  65076. /**
  65077. * Creates a new MultiLine
  65078. * @param name defines the control name
  65079. */
  65080. constructor(name?: string | undefined);
  65081. /** Gets or sets dash pattern */
  65082. dash: Array<number>;
  65083. /**
  65084. * Gets point stored at specified index
  65085. * @param index defines the index to look for
  65086. * @returns the requested point if found
  65087. */
  65088. getAt(index: number): MultiLinePoint;
  65089. /** Function called when a point is updated */
  65090. onPointUpdate: () => void;
  65091. /**
  65092. * Adds new points to the point collection
  65093. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  65094. * @returns the list of created MultiLinePoint
  65095. */
  65096. add(...items: (AbstractMesh | Control | {
  65097. x: string | number;
  65098. y: string | number;
  65099. })[]): MultiLinePoint[];
  65100. /**
  65101. * Adds a new point to the point collection
  65102. * @param item defines the item (mesh, control or 2d coordiantes) to add
  65103. * @returns the created MultiLinePoint
  65104. */
  65105. push(item?: (AbstractMesh | Control | {
  65106. x: string | number;
  65107. y: string | number;
  65108. })): MultiLinePoint;
  65109. /**
  65110. * Remove a specific value or point from the active point collection
  65111. * @param value defines the value or point to remove
  65112. */
  65113. remove(value: number | MultiLinePoint): void;
  65114. /**
  65115. * Resets this object to initial state (no point)
  65116. */
  65117. reset(): void;
  65118. /**
  65119. * Resets all links
  65120. */
  65121. resetLinks(): void;
  65122. /** Gets or sets line width */
  65123. lineWidth: number;
  65124. horizontalAlignment: number;
  65125. verticalAlignment: number;
  65126. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65127. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  65128. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65129. dispose(): void;
  65130. }
  65131. }
  65132. declare module BABYLON.GUI {
  65133. /**
  65134. * Class used to create radio button controls
  65135. */
  65136. export class RadioButton extends Control {
  65137. name?: string | undefined;
  65138. private _isChecked;
  65139. private _background;
  65140. private _checkSizeRatio;
  65141. private _thickness;
  65142. /** Gets or sets border thickness */
  65143. thickness: number;
  65144. /** Gets or sets group name */
  65145. group: string;
  65146. /** BABYLON.Observable raised when isChecked is changed */
  65147. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  65148. /** Gets or sets a value indicating the ratio between overall size and check size */
  65149. checkSizeRatio: number;
  65150. /** Gets or sets background color */
  65151. background: string;
  65152. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  65153. isChecked: boolean;
  65154. /**
  65155. * Creates a new RadioButton
  65156. * @param name defines the control name
  65157. */
  65158. constructor(name?: string | undefined);
  65159. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65160. /**
  65161. * Utility function to easily create a radio button with a header
  65162. * @param title defines the label to use for the header
  65163. * @param group defines the group to use for the radio button
  65164. * @param isChecked defines the initial state of the radio button
  65165. * @param onValueChanged defines the callback to call when value changes
  65166. * @returns a StackPanel containing the radio button and a textBlock
  65167. */
  65168. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  65169. }
  65170. }
  65171. declare module BABYLON.GUI {
  65172. /**
  65173. * Class used to create slider controls
  65174. */
  65175. export class BaseSlider extends Control {
  65176. name?: string | undefined;
  65177. protected _thumbWidth: ValueAndUnit;
  65178. private _minimum;
  65179. private _maximum;
  65180. private _value;
  65181. private _isVertical;
  65182. protected _barOffset: ValueAndUnit;
  65183. private _isThumbClamped;
  65184. protected _displayThumb: boolean;
  65185. private _step;
  65186. private _lastPointerDownID;
  65187. protected _effectiveBarOffset: number;
  65188. protected _renderLeft: number;
  65189. protected _renderTop: number;
  65190. protected _renderWidth: number;
  65191. protected _renderHeight: number;
  65192. protected _backgroundBoxLength: number;
  65193. protected _backgroundBoxThickness: number;
  65194. protected _effectiveThumbThickness: number;
  65195. /** BABYLON.Observable raised when the sldier value changes */
  65196. onValueChangedObservable: BABYLON.Observable<number>;
  65197. /** Gets or sets a boolean indicating if the thumb must be rendered */
  65198. displayThumb: boolean;
  65199. /** Gets or sets a step to apply to values (0 by default) */
  65200. step: number;
  65201. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  65202. barOffset: string | number;
  65203. /** Gets main bar offset in pixels*/
  65204. readonly barOffsetInPixels: number;
  65205. /** Gets or sets thumb width */
  65206. thumbWidth: string | number;
  65207. /** Gets thumb width in pixels */
  65208. readonly thumbWidthInPixels: number;
  65209. /** Gets or sets minimum value */
  65210. minimum: number;
  65211. /** Gets or sets maximum value */
  65212. maximum: number;
  65213. /** Gets or sets current value */
  65214. value: number;
  65215. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  65216. isVertical: boolean;
  65217. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  65218. isThumbClamped: boolean;
  65219. /**
  65220. * Creates a new BaseSlider
  65221. * @param name defines the control name
  65222. */
  65223. constructor(name?: string | undefined);
  65224. protected _getTypeName(): string;
  65225. protected _getThumbPosition(): number;
  65226. protected _getThumbThickness(type: string): number;
  65227. protected _prepareRenderingData(type: string): void;
  65228. private _pointerIsDown;
  65229. /** @hidden */
  65230. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  65231. }
  65232. }
  65233. declare module BABYLON.GUI {
  65234. /**
  65235. * Class used to create slider controls
  65236. */
  65237. export class Slider extends BaseSlider {
  65238. name?: string | undefined;
  65239. private _background;
  65240. private _borderColor;
  65241. private _isThumbCircle;
  65242. protected _displayValueBar: boolean;
  65243. /** Gets or sets a boolean indicating if the value bar must be rendered */
  65244. displayValueBar: boolean;
  65245. /** Gets or sets border color */
  65246. borderColor: string;
  65247. /** Gets or sets background color */
  65248. background: string;
  65249. /** Gets or sets a boolean indicating if the thumb should be round or square */
  65250. isThumbCircle: boolean;
  65251. /**
  65252. * Creates a new Slider
  65253. * @param name defines the control name
  65254. */
  65255. constructor(name?: string | undefined);
  65256. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65257. }
  65258. }
  65259. declare module BABYLON.GUI {
  65260. /** Class used to create a RadioGroup
  65261. * which contains groups of radio buttons
  65262. */
  65263. export class SelectorGroup {
  65264. /** name of SelectorGroup */
  65265. name: string;
  65266. private _groupPanel;
  65267. private _selectors;
  65268. private _groupHeader;
  65269. /**
  65270. * Creates a new SelectorGroup
  65271. * @param name of group, used as a group heading
  65272. */
  65273. constructor(
  65274. /** name of SelectorGroup */
  65275. name: string);
  65276. /** Gets the groupPanel of the SelectorGroup */
  65277. readonly groupPanel: StackPanel;
  65278. /** Gets the selectors array */
  65279. readonly selectors: StackPanel[];
  65280. /** Gets and sets the group header */
  65281. header: string;
  65282. /** @hidden */
  65283. private _addGroupHeader;
  65284. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  65285. /** Removes the selector at the given position
  65286. * @param selectorNb the position of the selector within the group
  65287. */
  65288. removeSelector(selectorNb: number): void;
  65289. }
  65290. /** Class used to create a CheckboxGroup
  65291. * which contains groups of checkbox buttons
  65292. */
  65293. export class CheckboxGroup extends SelectorGroup {
  65294. /** Adds a checkbox as a control
  65295. * @param text is the label for the selector
  65296. * @param func is the function called when the Selector is checked
  65297. * @param checked is true when Selector is checked
  65298. */
  65299. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  65300. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  65301. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  65302. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  65303. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65304. }
  65305. /** Class used to create a RadioGroup
  65306. * which contains groups of radio buttons
  65307. */
  65308. export class RadioGroup extends SelectorGroup {
  65309. private _selectNb;
  65310. /** Adds a radio button as a control
  65311. * @param label is the label for the selector
  65312. * @param func is the function called when the Selector is checked
  65313. * @param checked is true when Selector is checked
  65314. */
  65315. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  65316. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  65317. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  65318. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  65319. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65320. }
  65321. /** Class used to create a SliderGroup
  65322. * which contains groups of slider buttons
  65323. */
  65324. export class SliderGroup extends SelectorGroup {
  65325. /**
  65326. * Adds a slider to the SelectorGroup
  65327. * @param label is the label for the SliderBar
  65328. * @param func is the function called when the Slider moves
  65329. * @param unit is a string describing the units used, eg degrees or metres
  65330. * @param min is the minimum value for the Slider
  65331. * @param max is the maximum value for the Slider
  65332. * @param value is the start value for the Slider between min and max
  65333. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  65334. */
  65335. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  65336. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  65337. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  65338. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  65339. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  65340. }
  65341. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  65342. * @see http://doc.babylonjs.com/how_to/selector
  65343. */
  65344. export class SelectionPanel extends Rectangle {
  65345. /** name of SelectionPanel */
  65346. name: string;
  65347. /** an array of SelectionGroups */
  65348. groups: SelectorGroup[];
  65349. private _panel;
  65350. private _buttonColor;
  65351. private _buttonBackground;
  65352. private _headerColor;
  65353. private _barColor;
  65354. private _barHeight;
  65355. private _spacerHeight;
  65356. private _labelColor;
  65357. private _groups;
  65358. private _bars;
  65359. /**
  65360. * Creates a new SelectionPanel
  65361. * @param name of SelectionPanel
  65362. * @param groups is an array of SelectionGroups
  65363. */
  65364. constructor(
  65365. /** name of SelectionPanel */
  65366. name: string,
  65367. /** an array of SelectionGroups */
  65368. groups?: SelectorGroup[]);
  65369. protected _getTypeName(): string;
  65370. /** Gets or sets the headerColor */
  65371. headerColor: string;
  65372. private _setHeaderColor;
  65373. /** Gets or sets the button color */
  65374. buttonColor: string;
  65375. private _setbuttonColor;
  65376. /** Gets or sets the label color */
  65377. labelColor: string;
  65378. private _setLabelColor;
  65379. /** Gets or sets the button background */
  65380. buttonBackground: string;
  65381. private _setButtonBackground;
  65382. /** Gets or sets the color of separator bar */
  65383. barColor: string;
  65384. private _setBarColor;
  65385. /** Gets or sets the height of separator bar */
  65386. barHeight: string;
  65387. private _setBarHeight;
  65388. /** Gets or sets the height of spacers*/
  65389. spacerHeight: string;
  65390. private _setSpacerHeight;
  65391. /** Adds a bar between groups */
  65392. private _addSpacer;
  65393. /** Add a group to the selection panel
  65394. * @param group is the selector group to add
  65395. */
  65396. addGroup(group: SelectorGroup): void;
  65397. /** Remove the group from the given position
  65398. * @param groupNb is the position of the group in the list
  65399. */
  65400. removeGroup(groupNb: number): void;
  65401. /** Change a group header label
  65402. * @param label is the new group header label
  65403. * @param groupNb is the number of the group to relabel
  65404. * */
  65405. setHeaderName(label: string, groupNb: number): void;
  65406. /** Change selector label to the one given
  65407. * @param label is the new selector label
  65408. * @param groupNb is the number of the groupcontaining the selector
  65409. * @param selectorNb is the number of the selector within a group to relabel
  65410. * */
  65411. relabel(label: string, groupNb: number, selectorNb: number): void;
  65412. /** For a given group position remove the selector at the given position
  65413. * @param groupNb is the number of the group to remove the selector from
  65414. * @param selectorNb is the number of the selector within the group
  65415. */
  65416. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  65417. /** For a given group position of correct type add a checkbox button
  65418. * @param groupNb is the number of the group to remove the selector from
  65419. * @param label is the label for the selector
  65420. * @param func is the function called when the Selector is checked
  65421. * @param checked is true when Selector is checked
  65422. */
  65423. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65424. /** For a given group position of correct type add a radio button
  65425. * @param groupNb is the number of the group to remove the selector from
  65426. * @param label is the label for the selector
  65427. * @param func is the function called when the Selector is checked
  65428. * @param checked is true when Selector is checked
  65429. */
  65430. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  65431. /**
  65432. * For a given slider group add a slider
  65433. * @param groupNb is the number of the group to add the slider to
  65434. * @param label is the label for the Slider
  65435. * @param func is the function called when the Slider moves
  65436. * @param unit is a string describing the units used, eg degrees or metres
  65437. * @param min is the minimum value for the Slider
  65438. * @param max is the maximum value for the Slider
  65439. * @param value is the start value for the Slider between min and max
  65440. * @param onVal is the function used to format the value displayed, eg radians to degrees
  65441. */
  65442. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  65443. }
  65444. }
  65445. declare module BABYLON.GUI {
  65446. /**
  65447. * Class used to hold a the container for ScrollViewer
  65448. * @hidden
  65449. */
  65450. export class _ScrollViewerWindow extends Container {
  65451. parentClientWidth: number;
  65452. parentClientHeight: number;
  65453. /**
  65454. * Creates a new ScrollViewerWindow
  65455. * @param name of ScrollViewerWindow
  65456. */
  65457. constructor(name?: string);
  65458. protected _getTypeName(): string;
  65459. /** @hidden */
  65460. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65461. protected _postMeasure(): void;
  65462. }
  65463. }
  65464. declare module BABYLON.GUI {
  65465. /**
  65466. * Class used to create slider controls
  65467. */
  65468. export class ScrollBar extends BaseSlider {
  65469. name?: string | undefined;
  65470. private _background;
  65471. private _borderColor;
  65472. private _thumbMeasure;
  65473. /** Gets or sets border color */
  65474. borderColor: string;
  65475. /** Gets or sets background color */
  65476. background: string;
  65477. /**
  65478. * Creates a new Slider
  65479. * @param name defines the control name
  65480. */
  65481. constructor(name?: string | undefined);
  65482. protected _getTypeName(): string;
  65483. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  65484. private _first;
  65485. private _originX;
  65486. private _originY;
  65487. /** @hidden */
  65488. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  65489. }
  65490. }
  65491. declare module BABYLON.GUI {
  65492. /**
  65493. * Class used to hold a viewer window and sliders in a grid
  65494. */
  65495. export class ScrollViewer extends Rectangle {
  65496. private _grid;
  65497. private _horizontalBarSpace;
  65498. private _verticalBarSpace;
  65499. private _dragSpace;
  65500. private _horizontalBar;
  65501. private _verticalBar;
  65502. private _barColor;
  65503. private _barBackground;
  65504. private _barSize;
  65505. private _endLeft;
  65506. private _endTop;
  65507. private _window;
  65508. private _pointerIsOver;
  65509. private _wheelPrecision;
  65510. private _onPointerObserver;
  65511. private _clientWidth;
  65512. private _clientHeight;
  65513. /**
  65514. * Gets the horizontal scrollbar
  65515. */
  65516. readonly horizontalBar: ScrollBar;
  65517. /**
  65518. * Gets the vertical scrollbar
  65519. */
  65520. readonly verticalBar: ScrollBar;
  65521. /**
  65522. * Adds a new control to the current container
  65523. * @param control defines the control to add
  65524. * @returns the current container
  65525. */
  65526. addControl(control: BABYLON.Nullable<Control>): Container;
  65527. /**
  65528. * Removes a control from the current container
  65529. * @param control defines the control to remove
  65530. * @returns the current container
  65531. */
  65532. removeControl(control: Control): Container;
  65533. /** Gets the list of children */
  65534. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  65535. /**
  65536. * Creates a new ScrollViewer
  65537. * @param name of ScrollViewer
  65538. */
  65539. constructor(name?: string);
  65540. /** Reset the scroll viewer window to initial size */
  65541. resetWindow(): void;
  65542. protected _getTypeName(): string;
  65543. private _buildClientSizes;
  65544. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  65545. protected _postMeasure(): void;
  65546. /**
  65547. * Gets or sets the mouse wheel precision
  65548. * from 0 to 1 with a default value of 0.05
  65549. * */
  65550. wheelPrecision: number;
  65551. /** Gets or sets the bar color */
  65552. barColor: string;
  65553. /** Gets or sets the size of the bar */
  65554. barSize: number;
  65555. /** Gets or sets the bar background */
  65556. barBackground: string;
  65557. /** @hidden */
  65558. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  65559. /** @hidden */
  65560. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  65561. /** Releases associated resources */
  65562. dispose(): void;
  65563. }
  65564. }
  65565. declare module BABYLON.GUI {
  65566. /** Class used to render a grid */
  65567. export class DisplayGrid extends Control {
  65568. name?: string | undefined;
  65569. private _cellWidth;
  65570. private _cellHeight;
  65571. private _minorLineTickness;
  65572. private _minorLineColor;
  65573. private _majorLineTickness;
  65574. private _majorLineColor;
  65575. private _majorLineFrequency;
  65576. private _background;
  65577. private _displayMajorLines;
  65578. private _displayMinorLines;
  65579. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  65580. displayMinorLines: boolean;
  65581. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  65582. displayMajorLines: boolean;
  65583. /** Gets or sets background color (Black by default) */
  65584. background: string;
  65585. /** Gets or sets the width of each cell (20 by default) */
  65586. cellWidth: number;
  65587. /** Gets or sets the height of each cell (20 by default) */
  65588. cellHeight: number;
  65589. /** Gets or sets the tickness of minor lines (1 by default) */
  65590. minorLineTickness: number;
  65591. /** Gets or sets the color of minor lines (DarkGray by default) */
  65592. minorLineColor: string;
  65593. /** Gets or sets the tickness of major lines (2 by default) */
  65594. majorLineTickness: number;
  65595. /** Gets or sets the color of major lines (White by default) */
  65596. majorLineColor: string;
  65597. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  65598. majorLineFrequency: number;
  65599. /**
  65600. * Creates a new GridDisplayRectangle
  65601. * @param name defines the control name
  65602. */
  65603. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  65604. protected _getTypeName(): string;
  65605. }
  65606. }
  65607. declare module BABYLON.GUI {
  65608. /**
  65609. * Class used to create slider controls based on images
  65610. */
  65611. export class ImageBasedSlider extends BaseSlider {
  65612. name?: string | undefined;
  65613. private _backgroundImage;
  65614. private _thumbImage;
  65615. private _valueBarImage;
  65616. private _tempMeasure;
  65617. displayThumb: boolean;
  65618. /**
  65619. * Gets or sets the image used to render the background
  65620. */
  65621. backgroundImage: Image;
  65622. /**
  65623. * Gets or sets the image used to render the value bar
  65624. */
  65625. valueBarImage: Image;
  65626. /**
  65627. * Gets or sets the image used to render the thumb
  65628. */
  65629. thumbImage: Image;
  65630. /**
  65631. * Creates a new ImageBasedSlider
  65632. * @param name defines the control name
  65633. */
  65634. constructor(name?: string | undefined);
  65635. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  65636. }
  65637. }
  65638. declare module BABYLON.GUI {
  65639. /**
  65640. * Forcing an export so that this code will execute
  65641. * @hidden
  65642. */
  65643. const name = "Statics";
  65644. }
  65645. declare module BABYLON.GUI {
  65646. /**
  65647. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  65648. */
  65649. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  65650. /**
  65651. * Define the instrumented AdvancedDynamicTexture.
  65652. */
  65653. texture: AdvancedDynamicTexture;
  65654. private _captureRenderTime;
  65655. private _renderTime;
  65656. private _captureLayoutTime;
  65657. private _layoutTime;
  65658. private _onBeginRenderObserver;
  65659. private _onEndRenderObserver;
  65660. private _onBeginLayoutObserver;
  65661. private _onEndLayoutObserver;
  65662. /**
  65663. * Gets the perf counter used to capture render time
  65664. */
  65665. readonly renderTimeCounter: BABYLON.PerfCounter;
  65666. /**
  65667. * Gets the perf counter used to capture layout time
  65668. */
  65669. readonly layoutTimeCounter: BABYLON.PerfCounter;
  65670. /**
  65671. * Enable or disable the render time capture
  65672. */
  65673. captureRenderTime: boolean;
  65674. /**
  65675. * Enable or disable the layout time capture
  65676. */
  65677. captureLayoutTime: boolean;
  65678. /**
  65679. * Instantiates a new advanced dynamic texture instrumentation.
  65680. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  65681. * @param texture Defines the AdvancedDynamicTexture to instrument
  65682. */
  65683. constructor(
  65684. /**
  65685. * Define the instrumented AdvancedDynamicTexture.
  65686. */
  65687. texture: AdvancedDynamicTexture);
  65688. /**
  65689. * Dispose and release associated resources.
  65690. */
  65691. dispose(): void;
  65692. }
  65693. }
  65694. declare module BABYLON.GUI {
  65695. /**
  65696. * Class used to load GUI via XML.
  65697. */
  65698. export class XmlLoader {
  65699. private _nodes;
  65700. private _nodeTypes;
  65701. private _isLoaded;
  65702. private _objectAttributes;
  65703. private _parentClass;
  65704. /**
  65705. * Create a new xml loader
  65706. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  65707. */
  65708. constructor(parentClass?: null);
  65709. private _getChainElement;
  65710. private _getClassAttribute;
  65711. private _createGuiElement;
  65712. private _parseGrid;
  65713. private _parseElement;
  65714. private _prepareSourceElement;
  65715. private _parseElementsFromSource;
  65716. private _parseXml;
  65717. /**
  65718. * Gets if the loading has finished.
  65719. * @returns whether the loading has finished or not
  65720. */
  65721. isLoaded(): boolean;
  65722. /**
  65723. * Gets a loaded node / control by id.
  65724. * @param id the Controls id set in the xml
  65725. * @returns element of type Control
  65726. */
  65727. getNodeById(id: string): any;
  65728. /**
  65729. * Gets all loaded nodes / controls
  65730. * @returns Array of controls
  65731. */
  65732. getNodes(): any;
  65733. /**
  65734. * Initiates the xml layout loading
  65735. * @param xmlFile defines the xml layout to load
  65736. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  65737. * @param callback defines the callback called on layout load.
  65738. */
  65739. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  65740. }
  65741. }
  65742. declare module BABYLON.GUI {
  65743. /**
  65744. * Class used to create containers for controls
  65745. */
  65746. export class Container3D extends Control3D {
  65747. private _blockLayout;
  65748. /**
  65749. * Gets the list of child controls
  65750. */
  65751. protected _children: Control3D[];
  65752. /**
  65753. * Gets the list of child controls
  65754. */
  65755. readonly children: Array<Control3D>;
  65756. /**
  65757. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  65758. * This is helpful to optimize layout operation when adding multiple children in a row
  65759. */
  65760. blockLayout: boolean;
  65761. /**
  65762. * Creates a new container
  65763. * @param name defines the container name
  65764. */
  65765. constructor(name?: string);
  65766. /**
  65767. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  65768. * @returns the current container
  65769. */
  65770. updateLayout(): Container3D;
  65771. /**
  65772. * Gets a boolean indicating if the given control is in the children of this control
  65773. * @param control defines the control to check
  65774. * @returns true if the control is in the child list
  65775. */
  65776. containsControl(control: Control3D): boolean;
  65777. /**
  65778. * Adds a control to the children of this control
  65779. * @param control defines the control to add
  65780. * @returns the current container
  65781. */
  65782. addControl(control: Control3D): Container3D;
  65783. /**
  65784. * This function will be called everytime a new control is added
  65785. */
  65786. protected _arrangeChildren(): void;
  65787. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  65788. /**
  65789. * Removes a control from the children of this control
  65790. * @param control defines the control to remove
  65791. * @returns the current container
  65792. */
  65793. removeControl(control: Control3D): Container3D;
  65794. protected _getTypeName(): string;
  65795. /**
  65796. * Releases all associated resources
  65797. */
  65798. dispose(): void;
  65799. /** Control rotation will remain unchanged */
  65800. static readonly UNSET_ORIENTATION: number;
  65801. /** Control will rotate to make it look at sphere central axis */
  65802. static readonly FACEORIGIN_ORIENTATION: number;
  65803. /** Control will rotate to make it look back at sphere central axis */
  65804. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  65805. /** Control will rotate to look at z axis (0, 0, 1) */
  65806. static readonly FACEFORWARD_ORIENTATION: number;
  65807. /** Control will rotate to look at negative z axis (0, 0, -1) */
  65808. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  65809. }
  65810. }
  65811. declare module BABYLON.GUI {
  65812. /**
  65813. * Class used to manage 3D user interface
  65814. * @see http://doc.babylonjs.com/how_to/gui3d
  65815. */
  65816. export class GUI3DManager implements BABYLON.IDisposable {
  65817. private _scene;
  65818. private _sceneDisposeObserver;
  65819. private _utilityLayer;
  65820. private _rootContainer;
  65821. private _pointerObserver;
  65822. private _pointerOutObserver;
  65823. /** @hidden */ private _lastPickedControl: Control3D;
  65824. /** @hidden */ private _lastControlOver: {
  65825. [pointerId: number]: Control3D;
  65826. };
  65827. /** @hidden */ private _lastControlDown: {
  65828. [pointerId: number]: Control3D;
  65829. };
  65830. /**
  65831. * BABYLON.Observable raised when the point picked by the pointer events changed
  65832. */
  65833. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  65834. /** @hidden */ private _sharedMaterials: {
  65835. [key: string]: BABYLON.Material;
  65836. };
  65837. /** Gets the hosting scene */
  65838. readonly scene: BABYLON.Scene;
  65839. /** Gets associated utility layer */
  65840. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  65841. /**
  65842. * Creates a new GUI3DManager
  65843. * @param scene
  65844. */
  65845. constructor(scene?: BABYLON.Scene);
  65846. private _handlePointerOut;
  65847. private _doPicking;
  65848. /**
  65849. * Gets the root container
  65850. */
  65851. readonly rootContainer: Container3D;
  65852. /**
  65853. * Gets a boolean indicating if the given control is in the root child list
  65854. * @param control defines the control to check
  65855. * @returns true if the control is in the root child list
  65856. */
  65857. containsControl(control: Control3D): boolean;
  65858. /**
  65859. * Adds a control to the root child list
  65860. * @param control defines the control to add
  65861. * @returns the current manager
  65862. */
  65863. addControl(control: Control3D): GUI3DManager;
  65864. /**
  65865. * Removes a control from the root child list
  65866. * @param control defines the control to remove
  65867. * @returns the current container
  65868. */
  65869. removeControl(control: Control3D): GUI3DManager;
  65870. /**
  65871. * Releases all associated resources
  65872. */
  65873. dispose(): void;
  65874. }
  65875. }
  65876. declare module BABYLON.GUI {
  65877. /**
  65878. * Class used to transport BABYLON.Vector3 information for pointer events
  65879. */
  65880. export class Vector3WithInfo extends BABYLON.Vector3 {
  65881. /** defines the current mouse button index */
  65882. buttonIndex: number;
  65883. /**
  65884. * Creates a new Vector3WithInfo
  65885. * @param source defines the vector3 data to transport
  65886. * @param buttonIndex defines the current mouse button index
  65887. */
  65888. constructor(source: BABYLON.Vector3,
  65889. /** defines the current mouse button index */
  65890. buttonIndex?: number);
  65891. }
  65892. }
  65893. declare module BABYLON.GUI {
  65894. /**
  65895. * Class used as base class for controls
  65896. */
  65897. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  65898. /** Defines the control name */
  65899. name?: string | undefined;
  65900. /** @hidden */ private _host: GUI3DManager;
  65901. private _node;
  65902. private _downCount;
  65903. private _enterCount;
  65904. private _downPointerIds;
  65905. private _isVisible;
  65906. /** Gets or sets the control position in world space */
  65907. position: BABYLON.Vector3;
  65908. /** Gets or sets the control scaling in world space */
  65909. scaling: BABYLON.Vector3;
  65910. /** Callback used to start pointer enter animation */
  65911. pointerEnterAnimation: () => void;
  65912. /** Callback used to start pointer out animation */
  65913. pointerOutAnimation: () => void;
  65914. /** Callback used to start pointer down animation */
  65915. pointerDownAnimation: () => void;
  65916. /** Callback used to start pointer up animation */
  65917. pointerUpAnimation: () => void;
  65918. /**
  65919. * An event triggered when the pointer move over the control
  65920. */
  65921. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  65922. /**
  65923. * An event triggered when the pointer move out of the control
  65924. */
  65925. onPointerOutObservable: BABYLON.Observable<Control3D>;
  65926. /**
  65927. * An event triggered when the pointer taps the control
  65928. */
  65929. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  65930. /**
  65931. * An event triggered when pointer is up
  65932. */
  65933. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  65934. /**
  65935. * An event triggered when a control is clicked on (with a mouse)
  65936. */
  65937. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  65938. /**
  65939. * An event triggered when pointer enters the control
  65940. */
  65941. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  65942. /**
  65943. * Gets or sets the parent container
  65944. */
  65945. parent: BABYLON.Nullable<Container3D>;
  65946. private _behaviors;
  65947. /**
  65948. * Gets the list of attached behaviors
  65949. * @see http://doc.babylonjs.com/features/behaviour
  65950. */
  65951. readonly behaviors: BABYLON.Behavior<Control3D>[];
  65952. /**
  65953. * Attach a behavior to the control
  65954. * @see http://doc.babylonjs.com/features/behaviour
  65955. * @param behavior defines the behavior to attach
  65956. * @returns the current control
  65957. */
  65958. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65959. /**
  65960. * Remove an attached behavior
  65961. * @see http://doc.babylonjs.com/features/behaviour
  65962. * @param behavior defines the behavior to attach
  65963. * @returns the current control
  65964. */
  65965. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  65966. /**
  65967. * Gets an attached behavior by name
  65968. * @param name defines the name of the behavior to look for
  65969. * @see http://doc.babylonjs.com/features/behaviour
  65970. * @returns null if behavior was not found else the requested behavior
  65971. */
  65972. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  65973. /** Gets or sets a boolean indicating if the control is visible */
  65974. isVisible: boolean;
  65975. /**
  65976. * Creates a new control
  65977. * @param name defines the control name
  65978. */
  65979. constructor(
  65980. /** Defines the control name */
  65981. name?: string | undefined);
  65982. /**
  65983. * Gets a string representing the class name
  65984. */
  65985. readonly typeName: string;
  65986. /**
  65987. * Get the current class name of the control.
  65988. * @returns current class name
  65989. */
  65990. getClassName(): string;
  65991. protected _getTypeName(): string;
  65992. /**
  65993. * Gets the transform node used by this control
  65994. */
  65995. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  65996. /**
  65997. * Gets the mesh used to render this control
  65998. */
  65999. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  66000. /**
  66001. * Link the control as child of the given node
  66002. * @param node defines the node to link to. Use null to unlink the control
  66003. * @returns the current control
  66004. */
  66005. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  66006. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  66007. /**
  66008. * Node creation.
  66009. * Can be overriden by children
  66010. * @param scene defines the scene where the node must be attached
  66011. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  66012. */
  66013. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  66014. /**
  66015. * Affect a material to the given mesh
  66016. * @param mesh defines the mesh which will represent the control
  66017. */
  66018. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66019. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  66020. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  66021. /** @hidden */ private _onPointerOut(target: Control3D): void;
  66022. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66023. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  66024. /** @hidden */
  66025. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  66026. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  66027. /** @hidden */ private _disposeNode(): void;
  66028. /**
  66029. * Releases all associated resources
  66030. */
  66031. dispose(): void;
  66032. }
  66033. }
  66034. declare module BABYLON.GUI {
  66035. /**
  66036. * Class used as a root to all buttons
  66037. */
  66038. export class AbstractButton3D extends Control3D {
  66039. /**
  66040. * Creates a new button
  66041. * @param name defines the control name
  66042. */
  66043. constructor(name?: string);
  66044. protected _getTypeName(): string;
  66045. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66046. }
  66047. }
  66048. declare module BABYLON.GUI {
  66049. /**
  66050. * Class used to create a button in 3D
  66051. */
  66052. export class Button3D extends AbstractButton3D {
  66053. /** @hidden */
  66054. protected _currentMaterial: BABYLON.Material;
  66055. private _facadeTexture;
  66056. private _content;
  66057. private _contentResolution;
  66058. private _contentScaleRatio;
  66059. /**
  66060. * Gets or sets the texture resolution used to render content (512 by default)
  66061. */
  66062. contentResolution: BABYLON.int;
  66063. /**
  66064. * Gets or sets the texture scale ratio used to render content (2 by default)
  66065. */
  66066. contentScaleRatio: number;
  66067. protected _disposeFacadeTexture(): void;
  66068. protected _resetContent(): void;
  66069. /**
  66070. * Creates a new button
  66071. * @param name defines the control name
  66072. */
  66073. constructor(name?: string);
  66074. /**
  66075. * Gets or sets the GUI 2D content used to display the button's facade
  66076. */
  66077. content: Control;
  66078. /**
  66079. * Apply the facade texture (created from the content property).
  66080. * This function can be overloaded by child classes
  66081. * @param facadeTexture defines the AdvancedDynamicTexture to use
  66082. */
  66083. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66084. protected _getTypeName(): string;
  66085. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66086. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66087. /**
  66088. * Releases all associated resources
  66089. */
  66090. dispose(): void;
  66091. }
  66092. }
  66093. declare module BABYLON.GUI {
  66094. /**
  66095. * Abstract class used to create a container panel deployed on the surface of a volume
  66096. */
  66097. export abstract class VolumeBasedPanel extends Container3D {
  66098. private _columns;
  66099. private _rows;
  66100. private _rowThenColum;
  66101. private _orientation;
  66102. protected _cellWidth: number;
  66103. protected _cellHeight: number;
  66104. /**
  66105. * Gets or sets the distance between elements
  66106. */
  66107. margin: number;
  66108. /**
  66109. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  66110. * | Value | Type | Description |
  66111. * | ----- | ----------------------------------- | ----------- |
  66112. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  66113. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  66114. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  66115. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  66116. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  66117. */
  66118. orientation: number;
  66119. /**
  66120. * Gets or sets the number of columns requested (10 by default).
  66121. * The panel will automatically compute the number of rows based on number of child controls.
  66122. */
  66123. columns: BABYLON.int;
  66124. /**
  66125. * Gets or sets a the number of rows requested.
  66126. * The panel will automatically compute the number of columns based on number of child controls.
  66127. */
  66128. rows: BABYLON.int;
  66129. /**
  66130. * Creates new VolumeBasedPanel
  66131. */
  66132. constructor();
  66133. protected _arrangeChildren(): void;
  66134. /** Child classes must implement this function to provide correct control positioning */
  66135. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66136. /** Child classes can implement this function to provide additional processing */
  66137. protected _finalProcessing(): void;
  66138. }
  66139. }
  66140. declare module BABYLON.GUI {
  66141. /**
  66142. * Class used to create a container panel deployed on the surface of a cylinder
  66143. */
  66144. export class CylinderPanel extends VolumeBasedPanel {
  66145. private _radius;
  66146. /**
  66147. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  66148. */
  66149. radius: BABYLON.float;
  66150. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66151. private _cylindricalMapping;
  66152. }
  66153. }
  66154. declare module BABYLON.GUI {
  66155. /** @hidden */
  66156. export var fluentVertexShader: {
  66157. name: string;
  66158. shader: string;
  66159. };
  66160. }
  66161. declare module BABYLON.GUI {
  66162. /** @hidden */
  66163. export var fluentPixelShader: {
  66164. name: string;
  66165. shader: string;
  66166. };
  66167. }
  66168. declare module BABYLON.GUI {
  66169. /** @hidden */
  66170. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  66171. INNERGLOW: boolean;
  66172. BORDER: boolean;
  66173. HOVERLIGHT: boolean;
  66174. TEXTURE: boolean;
  66175. constructor();
  66176. }
  66177. /**
  66178. * Class used to render controls with fluent desgin
  66179. */
  66180. export class FluentMaterial extends BABYLON.PushMaterial {
  66181. /**
  66182. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  66183. */
  66184. innerGlowColorIntensity: number;
  66185. /**
  66186. * Gets or sets the inner glow color (white by default)
  66187. */
  66188. innerGlowColor: BABYLON.Color3;
  66189. /**
  66190. * Gets or sets alpha value (default is 1.0)
  66191. */
  66192. alpha: number;
  66193. /**
  66194. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  66195. */
  66196. albedoColor: BABYLON.Color3;
  66197. /**
  66198. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  66199. */
  66200. renderBorders: boolean;
  66201. /**
  66202. * Gets or sets border width (default is 0.5)
  66203. */
  66204. borderWidth: number;
  66205. /**
  66206. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  66207. */
  66208. edgeSmoothingValue: number;
  66209. /**
  66210. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  66211. */
  66212. borderMinValue: number;
  66213. /**
  66214. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  66215. */
  66216. renderHoverLight: boolean;
  66217. /**
  66218. * Gets or sets the radius used to render the hover light (default is 1.0)
  66219. */
  66220. hoverRadius: number;
  66221. /**
  66222. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  66223. */
  66224. hoverColor: BABYLON.Color4;
  66225. /**
  66226. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  66227. */
  66228. hoverPosition: BABYLON.Vector3;
  66229. private _albedoTexture;
  66230. /** Gets or sets the texture to use for albedo color */
  66231. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  66232. /**
  66233. * Creates a new Fluent material
  66234. * @param name defines the name of the material
  66235. * @param scene defines the hosting scene
  66236. */
  66237. constructor(name: string, scene: BABYLON.Scene);
  66238. needAlphaBlending(): boolean;
  66239. needAlphaTesting(): boolean;
  66240. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66241. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66242. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66243. getActiveTextures(): BABYLON.BaseTexture[];
  66244. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66245. dispose(forceDisposeEffect?: boolean): void;
  66246. clone(name: string): FluentMaterial;
  66247. serialize(): any;
  66248. getClassName(): string;
  66249. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  66250. }
  66251. }
  66252. declare module BABYLON.GUI {
  66253. /**
  66254. * Class used to create a holographic button in 3D
  66255. */
  66256. export class HolographicButton extends Button3D {
  66257. private _backPlate;
  66258. private _textPlate;
  66259. private _frontPlate;
  66260. private _text;
  66261. private _imageUrl;
  66262. private _shareMaterials;
  66263. private _frontMaterial;
  66264. private _backMaterial;
  66265. private _plateMaterial;
  66266. private _pickedPointObserver;
  66267. private _tooltipFade;
  66268. private _tooltipTextBlock;
  66269. private _tooltipTexture;
  66270. private _tooltipMesh;
  66271. private _tooltipHoverObserver;
  66272. private _tooltipOutObserver;
  66273. private _disposeTooltip;
  66274. /**
  66275. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  66276. */
  66277. tooltipText: BABYLON.Nullable<string>;
  66278. /**
  66279. * Gets or sets text for the button
  66280. */
  66281. text: string;
  66282. /**
  66283. * Gets or sets the image url for the button
  66284. */
  66285. imageUrl: string;
  66286. /**
  66287. * Gets the back material used by this button
  66288. */
  66289. readonly backMaterial: FluentMaterial;
  66290. /**
  66291. * Gets the front material used by this button
  66292. */
  66293. readonly frontMaterial: FluentMaterial;
  66294. /**
  66295. * Gets the plate material used by this button
  66296. */
  66297. readonly plateMaterial: BABYLON.StandardMaterial;
  66298. /**
  66299. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  66300. */
  66301. readonly shareMaterials: boolean;
  66302. /**
  66303. * Creates a new button
  66304. * @param name defines the control name
  66305. */
  66306. constructor(name?: string, shareMaterials?: boolean);
  66307. protected _getTypeName(): string;
  66308. private _rebuildContent;
  66309. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66310. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  66311. private _createBackMaterial;
  66312. private _createFrontMaterial;
  66313. private _createPlateMaterial;
  66314. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  66315. /**
  66316. * Releases all associated resources
  66317. */
  66318. dispose(): void;
  66319. }
  66320. }
  66321. declare module BABYLON.GUI {
  66322. /**
  66323. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  66324. */
  66325. export class MeshButton3D extends Button3D {
  66326. /** @hidden */
  66327. protected _currentMesh: BABYLON.Mesh;
  66328. /**
  66329. * Creates a new 3D button based on a mesh
  66330. * @param mesh mesh to become a 3D button
  66331. * @param name defines the control name
  66332. */
  66333. constructor(mesh: BABYLON.Mesh, name?: string);
  66334. protected _getTypeName(): string;
  66335. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  66336. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  66337. }
  66338. }
  66339. declare module BABYLON.GUI {
  66340. /**
  66341. * Class used to create a container panel deployed on the surface of a plane
  66342. */
  66343. export class PlanePanel extends VolumeBasedPanel {
  66344. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66345. }
  66346. }
  66347. declare module BABYLON.GUI {
  66348. /**
  66349. * Class used to create a container panel where items get randomized planar mapping
  66350. */
  66351. export class ScatterPanel extends VolumeBasedPanel {
  66352. private _iteration;
  66353. /**
  66354. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  66355. */
  66356. iteration: BABYLON.float;
  66357. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66358. private _scatterMapping;
  66359. protected _finalProcessing(): void;
  66360. }
  66361. }
  66362. declare module BABYLON.GUI {
  66363. /**
  66364. * Class used to create a container panel deployed on the surface of a sphere
  66365. */
  66366. export class SpherePanel extends VolumeBasedPanel {
  66367. private _radius;
  66368. /**
  66369. * Gets or sets the radius of the sphere where to project controls (5 by default)
  66370. */
  66371. radius: BABYLON.float;
  66372. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  66373. private _sphericalMapping;
  66374. }
  66375. }
  66376. declare module BABYLON.GUI {
  66377. /**
  66378. * Class used to create a stack panel in 3D on XY plane
  66379. */
  66380. export class StackPanel3D extends Container3D {
  66381. private _isVertical;
  66382. /**
  66383. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  66384. */
  66385. isVertical: boolean;
  66386. /**
  66387. * Gets or sets the distance between elements
  66388. */
  66389. margin: number;
  66390. /**
  66391. * Creates new StackPanel
  66392. * @param isVertical
  66393. */
  66394. constructor(isVertical?: boolean);
  66395. protected _arrangeChildren(): void;
  66396. }
  66397. }
  66398. declare module BABYLON {
  66399. /**
  66400. * Mode that determines the coordinate system to use.
  66401. */
  66402. export enum GLTFLoaderCoordinateSystemMode {
  66403. /**
  66404. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  66405. */
  66406. AUTO = 0,
  66407. /**
  66408. * Sets the useRightHandedSystem flag on the scene.
  66409. */
  66410. FORCE_RIGHT_HANDED = 1
  66411. }
  66412. /**
  66413. * Mode that determines what animations will start.
  66414. */
  66415. export enum GLTFLoaderAnimationStartMode {
  66416. /**
  66417. * No animation will start.
  66418. */
  66419. NONE = 0,
  66420. /**
  66421. * The first animation will start.
  66422. */
  66423. FIRST = 1,
  66424. /**
  66425. * All animations will start.
  66426. */
  66427. ALL = 2
  66428. }
  66429. /**
  66430. * Interface that contains the data for the glTF asset.
  66431. */
  66432. export interface IGLTFLoaderData {
  66433. /**
  66434. * Object that represents the glTF JSON.
  66435. */
  66436. json: Object;
  66437. /**
  66438. * The BIN chunk of a binary glTF.
  66439. */
  66440. bin: Nullable<ArrayBufferView>;
  66441. }
  66442. /**
  66443. * Interface for extending the loader.
  66444. */
  66445. export interface IGLTFLoaderExtension {
  66446. /**
  66447. * The name of this extension.
  66448. */
  66449. readonly name: string;
  66450. /**
  66451. * Defines whether this extension is enabled.
  66452. */
  66453. enabled: boolean;
  66454. }
  66455. /**
  66456. * Loader state.
  66457. */
  66458. export enum GLTFLoaderState {
  66459. /**
  66460. * The asset is loading.
  66461. */
  66462. LOADING = 0,
  66463. /**
  66464. * The asset is ready for rendering.
  66465. */
  66466. READY = 1,
  66467. /**
  66468. * The asset is completely loaded.
  66469. */
  66470. COMPLETE = 2
  66471. }
  66472. /** @hidden */
  66473. export interface IGLTFLoader extends IDisposable {
  66474. readonly state: Nullable<GLTFLoaderState>;
  66475. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  66476. meshes: AbstractMesh[];
  66477. particleSystems: IParticleSystem[];
  66478. skeletons: Skeleton[];
  66479. animationGroups: AnimationGroup[];
  66480. }>;
  66481. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  66482. }
  66483. /**
  66484. * File loader for loading glTF files into a scene.
  66485. */
  66486. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66487. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66488. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  66489. /**
  66490. * Raised when the asset has been parsed
  66491. */
  66492. onParsedObservable: Observable<IGLTFLoaderData>;
  66493. private _onParsedObserver;
  66494. /**
  66495. * Raised when the asset has been parsed
  66496. */
  66497. onParsed: (loaderData: IGLTFLoaderData) => void;
  66498. /**
  66499. * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
  66500. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  66501. * Defaults to true.
  66502. * @hidden
  66503. */
  66504. static IncrementalLoading: boolean;
  66505. /**
  66506. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  66507. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  66508. * @hidden
  66509. */
  66510. static HomogeneousCoordinates: boolean;
  66511. /**
  66512. * The coordinate system mode. Defaults to AUTO.
  66513. */
  66514. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  66515. /**
  66516. * The animation start mode. Defaults to FIRST.
  66517. */
  66518. animationStartMode: GLTFLoaderAnimationStartMode;
  66519. /**
  66520. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  66521. */
  66522. compileMaterials: boolean;
  66523. /**
  66524. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  66525. */
  66526. useClipPlane: boolean;
  66527. /**
  66528. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  66529. */
  66530. compileShadowGenerators: boolean;
  66531. /**
  66532. * Defines if the Alpha blended materials are only applied as coverage.
  66533. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  66534. * If true, no extra effects are applied to transparent pixels.
  66535. */
  66536. transparencyAsCoverage: boolean;
  66537. /**
  66538. * Function called before loading a url referenced by the asset.
  66539. */
  66540. preprocessUrlAsync: (url: string) => Promise<string>;
  66541. /**
  66542. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66543. */
  66544. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  66545. private _onMeshLoadedObserver;
  66546. /**
  66547. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  66548. */
  66549. onMeshLoaded: (mesh: AbstractMesh) => void;
  66550. /**
  66551. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  66552. */
  66553. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  66554. private _onTextureLoadedObserver;
  66555. /**
  66556. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  66557. */
  66558. onTextureLoaded: (texture: BaseTexture) => void;
  66559. /**
  66560. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  66561. */
  66562. readonly onMaterialLoadedObservable: Observable<Material>;
  66563. private _onMaterialLoadedObserver;
  66564. /**
  66565. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  66566. */
  66567. onMaterialLoaded: (material: Material) => void;
  66568. /**
  66569. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  66570. */
  66571. readonly onCameraLoadedObservable: Observable<Camera>;
  66572. private _onCameraLoadedObserver;
  66573. /**
  66574. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  66575. */
  66576. onCameraLoaded: (camera: Camera) => void;
  66577. /**
  66578. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  66579. * For assets with LODs, raised when all of the LODs are complete.
  66580. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66581. */
  66582. readonly onCompleteObservable: Observable<void>;
  66583. private _onCompleteObserver;
  66584. /**
  66585. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  66586. * For assets with LODs, raised when all of the LODs are complete.
  66587. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  66588. */
  66589. onComplete: () => void;
  66590. /**
  66591. * Observable raised when an error occurs.
  66592. */
  66593. readonly onErrorObservable: Observable<any>;
  66594. private _onErrorObserver;
  66595. /**
  66596. * Callback raised when an error occurs.
  66597. */
  66598. onError: (reason: any) => void;
  66599. /**
  66600. * Observable raised after the loader is disposed.
  66601. */
  66602. readonly onDisposeObservable: Observable<void>;
  66603. private _onDisposeObserver;
  66604. /**
  66605. * Callback raised after the loader is disposed.
  66606. */
  66607. onDispose: () => void;
  66608. /**
  66609. * Observable raised after a loader extension is created.
  66610. * Set additional options for a loader extension in this event.
  66611. */
  66612. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  66613. private _onExtensionLoadedObserver;
  66614. /**
  66615. * Callback raised after a loader extension is created.
  66616. */
  66617. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  66618. /**
  66619. * Defines if the loader logging is enabled.
  66620. */
  66621. loggingEnabled: boolean;
  66622. /**
  66623. * Defines if the loader should capture performance counters.
  66624. */
  66625. capturePerformanceCounters: boolean;
  66626. /**
  66627. * Defines if the loader should validate the asset.
  66628. */
  66629. validate: boolean;
  66630. /**
  66631. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  66632. */
  66633. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  66634. private _onValidatedObserver;
  66635. /**
  66636. * Callback raised after a loader extension is created.
  66637. */
  66638. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  66639. private _loader;
  66640. /**
  66641. * Name of the loader ("gltf")
  66642. */
  66643. name: string;
  66644. /**
  66645. * Supported file extensions of the loader (.gltf, .glb)
  66646. */
  66647. extensions: ISceneLoaderPluginExtensions;
  66648. /**
  66649. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  66650. */
  66651. dispose(): void;
  66652. /** @hidden */ private _clear(): void;
  66653. /**
  66654. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  66655. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66656. * @param scene the scene the meshes should be added to
  66657. * @param data the glTF data to load
  66658. * @param rootUrl root url to load from
  66659. * @param onProgress event that fires when loading progress has occured
  66660. * @param fileName Defines the name of the file to load
  66661. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66662. */
  66663. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66664. meshes: AbstractMesh[];
  66665. particleSystems: IParticleSystem[];
  66666. skeletons: Skeleton[];
  66667. animationGroups: AnimationGroup[];
  66668. }>;
  66669. /**
  66670. * Imports all objects from the loaded glTF data and adds them to the scene
  66671. * @param scene the scene the objects should be added to
  66672. * @param data the glTF data to load
  66673. * @param rootUrl root url to load from
  66674. * @param onProgress event that fires when loading progress has occured
  66675. * @param fileName Defines the name of the file to load
  66676. * @returns a promise which completes when objects have been loaded to the scene
  66677. */
  66678. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66679. /**
  66680. * Load into an asset container.
  66681. * @param scene The scene to load into
  66682. * @param data The data to import
  66683. * @param rootUrl The root url for scene and resources
  66684. * @param onProgress The callback when the load progresses
  66685. * @param fileName Defines the name of the file to load
  66686. * @returns The loaded asset container
  66687. */
  66688. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66689. /**
  66690. * If the data string can be loaded directly.
  66691. * @param data string contianing the file data
  66692. * @returns if the data can be loaded directly
  66693. */
  66694. canDirectLoad(data: string): boolean;
  66695. /**
  66696. * Rewrites a url by combining a root url and response url.
  66697. */
  66698. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  66699. /**
  66700. * Instantiates a glTF file loader plugin.
  66701. * @returns the created plugin
  66702. */
  66703. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  66704. /**
  66705. * The loader state or null if the loader is not active.
  66706. */
  66707. readonly loaderState: Nullable<GLTFLoaderState>;
  66708. /**
  66709. * Returns a promise that resolves when the asset is completely loaded.
  66710. * @returns a promise that resolves when the asset is completely loaded.
  66711. */
  66712. whenCompleteAsync(): Promise<void>;
  66713. private _parseAsync;
  66714. private _validateAsync;
  66715. private _getLoader;
  66716. private _unpackBinary;
  66717. private _unpackBinaryV1;
  66718. private _unpackBinaryV2;
  66719. private static _parseVersion;
  66720. private static _compareVersion;
  66721. private static _decodeBufferToText;
  66722. private static readonly _logSpaces;
  66723. private _logIndentLevel;
  66724. private _loggingEnabled;
  66725. /** @hidden */ private _log: (message: string) => void;
  66726. /** @hidden */ private _logOpen(message: string): void;
  66727. /** @hidden */ private _logClose(): void;
  66728. private _logEnabled;
  66729. private _logDisabled;
  66730. private _capturePerformanceCounters;
  66731. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  66732. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  66733. private _startPerformanceCounterEnabled;
  66734. private _startPerformanceCounterDisabled;
  66735. private _endPerformanceCounterEnabled;
  66736. private _endPerformanceCounterDisabled;
  66737. }
  66738. }
  66739. declare module BABYLON.GLTF1 {
  66740. /**
  66741. * Enums
  66742. * @hidden
  66743. */
  66744. export enum EComponentType {
  66745. BYTE = 5120,
  66746. UNSIGNED_BYTE = 5121,
  66747. SHORT = 5122,
  66748. UNSIGNED_SHORT = 5123,
  66749. FLOAT = 5126
  66750. }
  66751. /** @hidden */
  66752. export enum EShaderType {
  66753. FRAGMENT = 35632,
  66754. VERTEX = 35633
  66755. }
  66756. /** @hidden */
  66757. export enum EParameterType {
  66758. BYTE = 5120,
  66759. UNSIGNED_BYTE = 5121,
  66760. SHORT = 5122,
  66761. UNSIGNED_SHORT = 5123,
  66762. INT = 5124,
  66763. UNSIGNED_INT = 5125,
  66764. FLOAT = 5126,
  66765. FLOAT_VEC2 = 35664,
  66766. FLOAT_VEC3 = 35665,
  66767. FLOAT_VEC4 = 35666,
  66768. INT_VEC2 = 35667,
  66769. INT_VEC3 = 35668,
  66770. INT_VEC4 = 35669,
  66771. BOOL = 35670,
  66772. BOOL_VEC2 = 35671,
  66773. BOOL_VEC3 = 35672,
  66774. BOOL_VEC4 = 35673,
  66775. FLOAT_MAT2 = 35674,
  66776. FLOAT_MAT3 = 35675,
  66777. FLOAT_MAT4 = 35676,
  66778. SAMPLER_2D = 35678
  66779. }
  66780. /** @hidden */
  66781. export enum ETextureWrapMode {
  66782. CLAMP_TO_EDGE = 33071,
  66783. MIRRORED_REPEAT = 33648,
  66784. REPEAT = 10497
  66785. }
  66786. /** @hidden */
  66787. export enum ETextureFilterType {
  66788. NEAREST = 9728,
  66789. LINEAR = 9728,
  66790. NEAREST_MIPMAP_NEAREST = 9984,
  66791. LINEAR_MIPMAP_NEAREST = 9985,
  66792. NEAREST_MIPMAP_LINEAR = 9986,
  66793. LINEAR_MIPMAP_LINEAR = 9987
  66794. }
  66795. /** @hidden */
  66796. export enum ETextureFormat {
  66797. ALPHA = 6406,
  66798. RGB = 6407,
  66799. RGBA = 6408,
  66800. LUMINANCE = 6409,
  66801. LUMINANCE_ALPHA = 6410
  66802. }
  66803. /** @hidden */
  66804. export enum ECullingType {
  66805. FRONT = 1028,
  66806. BACK = 1029,
  66807. FRONT_AND_BACK = 1032
  66808. }
  66809. /** @hidden */
  66810. export enum EBlendingFunction {
  66811. ZERO = 0,
  66812. ONE = 1,
  66813. SRC_COLOR = 768,
  66814. ONE_MINUS_SRC_COLOR = 769,
  66815. DST_COLOR = 774,
  66816. ONE_MINUS_DST_COLOR = 775,
  66817. SRC_ALPHA = 770,
  66818. ONE_MINUS_SRC_ALPHA = 771,
  66819. DST_ALPHA = 772,
  66820. ONE_MINUS_DST_ALPHA = 773,
  66821. CONSTANT_COLOR = 32769,
  66822. ONE_MINUS_CONSTANT_COLOR = 32770,
  66823. CONSTANT_ALPHA = 32771,
  66824. ONE_MINUS_CONSTANT_ALPHA = 32772,
  66825. SRC_ALPHA_SATURATE = 776
  66826. }
  66827. /** @hidden */
  66828. export interface IGLTFProperty {
  66829. extensions?: {
  66830. [key: string]: any;
  66831. };
  66832. extras?: Object;
  66833. }
  66834. /** @hidden */
  66835. export interface IGLTFChildRootProperty extends IGLTFProperty {
  66836. name?: string;
  66837. }
  66838. /** @hidden */
  66839. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  66840. bufferView: string;
  66841. byteOffset: number;
  66842. byteStride: number;
  66843. count: number;
  66844. type: string;
  66845. componentType: EComponentType;
  66846. max?: number[];
  66847. min?: number[];
  66848. name?: string;
  66849. }
  66850. /** @hidden */
  66851. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  66852. buffer: string;
  66853. byteOffset: number;
  66854. byteLength: number;
  66855. byteStride: number;
  66856. target?: number;
  66857. }
  66858. /** @hidden */
  66859. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  66860. uri: string;
  66861. byteLength?: number;
  66862. type?: string;
  66863. }
  66864. /** @hidden */
  66865. export interface IGLTFShader extends IGLTFChildRootProperty {
  66866. uri: string;
  66867. type: EShaderType;
  66868. }
  66869. /** @hidden */
  66870. export interface IGLTFProgram extends IGLTFChildRootProperty {
  66871. attributes: string[];
  66872. fragmentShader: string;
  66873. vertexShader: string;
  66874. }
  66875. /** @hidden */
  66876. export interface IGLTFTechniqueParameter {
  66877. type: number;
  66878. count?: number;
  66879. semantic?: string;
  66880. node?: string;
  66881. value?: number | boolean | string | Array<any>;
  66882. source?: string;
  66883. babylonValue?: any;
  66884. }
  66885. /** @hidden */
  66886. export interface IGLTFTechniqueCommonProfile {
  66887. lightingModel: string;
  66888. texcoordBindings: Object;
  66889. parameters?: Array<any>;
  66890. }
  66891. /** @hidden */
  66892. export interface IGLTFTechniqueStatesFunctions {
  66893. blendColor?: number[];
  66894. blendEquationSeparate?: number[];
  66895. blendFuncSeparate?: number[];
  66896. colorMask: boolean[];
  66897. cullFace: number[];
  66898. }
  66899. /** @hidden */
  66900. export interface IGLTFTechniqueStates {
  66901. enable: number[];
  66902. functions: IGLTFTechniqueStatesFunctions;
  66903. }
  66904. /** @hidden */
  66905. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  66906. parameters: {
  66907. [key: string]: IGLTFTechniqueParameter;
  66908. };
  66909. program: string;
  66910. attributes: {
  66911. [key: string]: string;
  66912. };
  66913. uniforms: {
  66914. [key: string]: string;
  66915. };
  66916. states: IGLTFTechniqueStates;
  66917. }
  66918. /** @hidden */
  66919. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  66920. technique?: string;
  66921. values: string[];
  66922. }
  66923. /** @hidden */
  66924. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  66925. attributes: {
  66926. [key: string]: string;
  66927. };
  66928. indices: string;
  66929. material: string;
  66930. mode?: number;
  66931. }
  66932. /** @hidden */
  66933. export interface IGLTFMesh extends IGLTFChildRootProperty {
  66934. primitives: IGLTFMeshPrimitive[];
  66935. }
  66936. /** @hidden */
  66937. export interface IGLTFImage extends IGLTFChildRootProperty {
  66938. uri: string;
  66939. }
  66940. /** @hidden */
  66941. export interface IGLTFSampler extends IGLTFChildRootProperty {
  66942. magFilter?: number;
  66943. minFilter?: number;
  66944. wrapS?: number;
  66945. wrapT?: number;
  66946. }
  66947. /** @hidden */
  66948. export interface IGLTFTexture extends IGLTFChildRootProperty {
  66949. sampler: string;
  66950. source: string;
  66951. format?: ETextureFormat;
  66952. internalFormat?: ETextureFormat;
  66953. target?: number;
  66954. type?: number;
  66955. babylonTexture?: Texture;
  66956. }
  66957. /** @hidden */
  66958. export interface IGLTFAmbienLight {
  66959. color?: number[];
  66960. }
  66961. /** @hidden */
  66962. export interface IGLTFDirectionalLight {
  66963. color?: number[];
  66964. }
  66965. /** @hidden */
  66966. export interface IGLTFPointLight {
  66967. color?: number[];
  66968. constantAttenuation?: number;
  66969. linearAttenuation?: number;
  66970. quadraticAttenuation?: number;
  66971. }
  66972. /** @hidden */
  66973. export interface IGLTFSpotLight {
  66974. color?: number[];
  66975. constantAttenuation?: number;
  66976. fallOfAngle?: number;
  66977. fallOffExponent?: number;
  66978. linearAttenuation?: number;
  66979. quadraticAttenuation?: number;
  66980. }
  66981. /** @hidden */
  66982. export interface IGLTFLight extends IGLTFChildRootProperty {
  66983. type: string;
  66984. }
  66985. /** @hidden */
  66986. export interface IGLTFCameraOrthographic {
  66987. xmag: number;
  66988. ymag: number;
  66989. zfar: number;
  66990. znear: number;
  66991. }
  66992. /** @hidden */
  66993. export interface IGLTFCameraPerspective {
  66994. aspectRatio: number;
  66995. yfov: number;
  66996. zfar: number;
  66997. znear: number;
  66998. }
  66999. /** @hidden */
  67000. export interface IGLTFCamera extends IGLTFChildRootProperty {
  67001. type: string;
  67002. }
  67003. /** @hidden */
  67004. export interface IGLTFAnimationChannelTarget {
  67005. id: string;
  67006. path: string;
  67007. }
  67008. /** @hidden */
  67009. export interface IGLTFAnimationChannel {
  67010. sampler: string;
  67011. target: IGLTFAnimationChannelTarget;
  67012. }
  67013. /** @hidden */
  67014. export interface IGLTFAnimationSampler {
  67015. input: string;
  67016. output: string;
  67017. interpolation?: string;
  67018. }
  67019. /** @hidden */
  67020. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  67021. channels?: IGLTFAnimationChannel[];
  67022. parameters?: {
  67023. [key: string]: string;
  67024. };
  67025. samplers?: {
  67026. [key: string]: IGLTFAnimationSampler;
  67027. };
  67028. }
  67029. /** @hidden */
  67030. export interface IGLTFNodeInstanceSkin {
  67031. skeletons: string[];
  67032. skin: string;
  67033. meshes: string[];
  67034. }
  67035. /** @hidden */
  67036. export interface IGLTFSkins extends IGLTFChildRootProperty {
  67037. bindShapeMatrix: number[];
  67038. inverseBindMatrices: string;
  67039. jointNames: string[];
  67040. babylonSkeleton?: Skeleton;
  67041. }
  67042. /** @hidden */
  67043. export interface IGLTFNode extends IGLTFChildRootProperty {
  67044. camera?: string;
  67045. children: string[];
  67046. skin?: string;
  67047. jointName?: string;
  67048. light?: string;
  67049. matrix: number[];
  67050. mesh?: string;
  67051. meshes?: string[];
  67052. rotation?: number[];
  67053. scale?: number[];
  67054. translation?: number[];
  67055. babylonNode?: Node;
  67056. }
  67057. /** @hidden */
  67058. export interface IGLTFScene extends IGLTFChildRootProperty {
  67059. nodes: string[];
  67060. }
  67061. /** @hidden */
  67062. export interface IGLTFRuntime {
  67063. extensions: {
  67064. [key: string]: any;
  67065. };
  67066. accessors: {
  67067. [key: string]: IGLTFAccessor;
  67068. };
  67069. buffers: {
  67070. [key: string]: IGLTFBuffer;
  67071. };
  67072. bufferViews: {
  67073. [key: string]: IGLTFBufferView;
  67074. };
  67075. meshes: {
  67076. [key: string]: IGLTFMesh;
  67077. };
  67078. lights: {
  67079. [key: string]: IGLTFLight;
  67080. };
  67081. cameras: {
  67082. [key: string]: IGLTFCamera;
  67083. };
  67084. nodes: {
  67085. [key: string]: IGLTFNode;
  67086. };
  67087. images: {
  67088. [key: string]: IGLTFImage;
  67089. };
  67090. textures: {
  67091. [key: string]: IGLTFTexture;
  67092. };
  67093. shaders: {
  67094. [key: string]: IGLTFShader;
  67095. };
  67096. programs: {
  67097. [key: string]: IGLTFProgram;
  67098. };
  67099. samplers: {
  67100. [key: string]: IGLTFSampler;
  67101. };
  67102. techniques: {
  67103. [key: string]: IGLTFTechnique;
  67104. };
  67105. materials: {
  67106. [key: string]: IGLTFMaterial;
  67107. };
  67108. animations: {
  67109. [key: string]: IGLTFAnimation;
  67110. };
  67111. skins: {
  67112. [key: string]: IGLTFSkins;
  67113. };
  67114. currentScene?: Object;
  67115. scenes: {
  67116. [key: string]: IGLTFScene;
  67117. };
  67118. extensionsUsed: string[];
  67119. extensionsRequired?: string[];
  67120. buffersCount: number;
  67121. shaderscount: number;
  67122. scene: Scene;
  67123. rootUrl: string;
  67124. loadedBufferCount: number;
  67125. loadedBufferViews: {
  67126. [name: string]: ArrayBufferView;
  67127. };
  67128. loadedShaderCount: number;
  67129. importOnlyMeshes: boolean;
  67130. importMeshesNames?: string[];
  67131. dummyNodes: Node[];
  67132. }
  67133. /** @hidden */
  67134. export interface INodeToRoot {
  67135. bone: Bone;
  67136. node: IGLTFNode;
  67137. id: string;
  67138. }
  67139. /** @hidden */
  67140. export interface IJointNode {
  67141. node: IGLTFNode;
  67142. id: string;
  67143. }
  67144. }
  67145. declare module BABYLON.GLTF1 {
  67146. /**
  67147. * Utils functions for GLTF
  67148. * @hidden
  67149. */
  67150. export class GLTFUtils {
  67151. /**
  67152. * Sets the given "parameter" matrix
  67153. * @param scene: the Scene object
  67154. * @param source: the source node where to pick the matrix
  67155. * @param parameter: the GLTF technique parameter
  67156. * @param uniformName: the name of the shader's uniform
  67157. * @param shaderMaterial: the shader material
  67158. */
  67159. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  67160. /**
  67161. * Sets the given "parameter" matrix
  67162. * @param shaderMaterial: the shader material
  67163. * @param uniform: the name of the shader's uniform
  67164. * @param value: the value of the uniform
  67165. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  67166. */
  67167. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  67168. /**
  67169. * Returns the wrap mode of the texture
  67170. * @param mode: the mode value
  67171. */
  67172. static GetWrapMode(mode: number): number;
  67173. /**
  67174. * Returns the byte stride giving an accessor
  67175. * @param accessor: the GLTF accessor objet
  67176. */
  67177. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  67178. /**
  67179. * Returns the texture filter mode giving a mode value
  67180. * @param mode: the filter mode value
  67181. */
  67182. static GetTextureFilterMode(mode: number): ETextureFilterType;
  67183. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  67184. /**
  67185. * Returns a buffer from its accessor
  67186. * @param gltfRuntime: the GLTF runtime
  67187. * @param accessor: the GLTF accessor
  67188. */
  67189. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  67190. /**
  67191. * Decodes a buffer view into a string
  67192. * @param view: the buffer view
  67193. */
  67194. static DecodeBufferToText(view: ArrayBufferView): string;
  67195. /**
  67196. * Returns the default material of gltf. Related to
  67197. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  67198. * @param scene: the Babylon.js scene
  67199. */
  67200. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  67201. private static _DefaultMaterial;
  67202. }
  67203. }
  67204. declare module BABYLON.GLTF1 {
  67205. /**
  67206. * Implementation of the base glTF spec
  67207. * @hidden
  67208. */
  67209. export class GLTFLoaderBase {
  67210. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  67211. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67212. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  67213. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67214. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  67215. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67216. }
  67217. /**
  67218. * glTF V1 Loader
  67219. * @hidden
  67220. */
  67221. export class GLTFLoader implements IGLTFLoader {
  67222. static Extensions: {
  67223. [name: string]: GLTFLoaderExtension;
  67224. };
  67225. static RegisterExtension(extension: GLTFLoaderExtension): void;
  67226. state: Nullable<GLTFLoaderState>;
  67227. dispose(): void;
  67228. private _importMeshAsync;
  67229. /**
  67230. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  67231. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  67232. * @param scene the scene the meshes should be added to
  67233. * @param data gltf data containing information of the meshes in a loaded file
  67234. * @param rootUrl root url to load from
  67235. * @param onProgress event that fires when loading progress has occured
  67236. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  67237. */
  67238. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  67239. meshes: AbstractMesh[];
  67240. particleSystems: IParticleSystem[];
  67241. skeletons: Skeleton[];
  67242. animationGroups: AnimationGroup[];
  67243. }>;
  67244. private _loadAsync;
  67245. /**
  67246. * Imports all objects from a loaded gltf file and adds them to the scene
  67247. * @param scene the scene the objects should be added to
  67248. * @param data gltf data containing information of the meshes in a loaded file
  67249. * @param rootUrl root url to load from
  67250. * @param onProgress event that fires when loading progress has occured
  67251. * @returns a promise which completes when objects have been loaded to the scene
  67252. */
  67253. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  67254. private _loadShadersAsync;
  67255. private _loadBuffersAsync;
  67256. private _createNodes;
  67257. }
  67258. /** @hidden */
  67259. export abstract class GLTFLoaderExtension {
  67260. private _name;
  67261. constructor(name: string);
  67262. readonly name: string;
  67263. /**
  67264. * Defines an override for loading the runtime
  67265. * Return true to stop further extensions from loading the runtime
  67266. */
  67267. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  67268. /**
  67269. * Defines an onverride for creating gltf runtime
  67270. * Return true to stop further extensions from creating the runtime
  67271. */
  67272. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  67273. /**
  67274. * Defines an override for loading buffers
  67275. * Return true to stop further extensions from loading this buffer
  67276. */
  67277. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  67278. /**
  67279. * Defines an override for loading texture buffers
  67280. * Return true to stop further extensions from loading this texture data
  67281. */
  67282. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67283. /**
  67284. * Defines an override for creating textures
  67285. * Return true to stop further extensions from loading this texture
  67286. */
  67287. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  67288. /**
  67289. * Defines an override for loading shader strings
  67290. * Return true to stop further extensions from loading this shader data
  67291. */
  67292. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67293. /**
  67294. * Defines an override for loading materials
  67295. * Return true to stop further extensions from loading this material
  67296. */
  67297. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67298. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  67299. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  67300. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  67301. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  67302. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  67303. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  67304. private static LoadTextureBufferAsync;
  67305. private static CreateTextureAsync;
  67306. private static ApplyExtensions;
  67307. }
  67308. }
  67309. declare module BABYLON.GLTF1 {
  67310. /** @hidden */
  67311. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  67312. private _bin;
  67313. constructor();
  67314. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  67315. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67316. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  67317. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  67318. }
  67319. }
  67320. declare module BABYLON.GLTF1 {
  67321. /** @hidden */
  67322. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  67323. constructor();
  67324. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  67325. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  67326. private _loadTexture;
  67327. }
  67328. }
  67329. declare module BABYLON.GLTF2.Loader {
  67330. /**
  67331. * Loader interface with an index field.
  67332. */
  67333. export interface IArrayItem {
  67334. /**
  67335. * The index of this item in the array.
  67336. */
  67337. index: number;
  67338. }
  67339. /**
  67340. * Loader interface with additional members.
  67341. */
  67342. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  67343. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  67344. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  67345. }
  67346. /**
  67347. * Loader interface with additional members.
  67348. */
  67349. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  67350. }
  67351. /** @hidden */
  67352. export interface _IAnimationSamplerData {
  67353. input: Float32Array;
  67354. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  67355. output: Float32Array;
  67356. }
  67357. /**
  67358. * Loader interface with additional members.
  67359. */
  67360. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  67361. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  67362. }
  67363. /**
  67364. * Loader interface with additional members.
  67365. */
  67366. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  67367. channels: IAnimationChannel[];
  67368. samplers: IAnimationSampler[];
  67369. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  67370. }
  67371. /**
  67372. * Loader interface with additional members.
  67373. */
  67374. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  67375. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  67376. }
  67377. /**
  67378. * Loader interface with additional members.
  67379. */
  67380. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  67381. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  67382. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  67383. }
  67384. /**
  67385. * Loader interface with additional members.
  67386. */
  67387. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  67388. }
  67389. /**
  67390. * Loader interface with additional members.
  67391. */
  67392. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  67393. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  67394. }
  67395. /**
  67396. * Loader interface with additional members.
  67397. */
  67398. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  67399. }
  67400. /**
  67401. * Loader interface with additional members.
  67402. */
  67403. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  67404. }
  67405. /**
  67406. * Loader interface with additional members.
  67407. */
  67408. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  67409. baseColorTexture?: ITextureInfo;
  67410. metallicRoughnessTexture?: ITextureInfo;
  67411. }
  67412. /**
  67413. * Loader interface with additional members.
  67414. */
  67415. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  67416. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  67417. normalTexture?: IMaterialNormalTextureInfo;
  67418. occlusionTexture?: IMaterialOcclusionTextureInfo;
  67419. emissiveTexture?: ITextureInfo;
  67420. /** @hidden */ private _data?: {
  67421. [babylonDrawMode: number]: {
  67422. babylonMaterial: Material;
  67423. babylonMeshes: AbstractMesh[];
  67424. promise: Promise<void>;
  67425. };
  67426. };
  67427. }
  67428. /**
  67429. * Loader interface with additional members.
  67430. */
  67431. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  67432. primitives: IMeshPrimitive[];
  67433. }
  67434. /**
  67435. * Loader interface with additional members.
  67436. */
  67437. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  67438. /** @hidden */ private _instanceData?: {
  67439. babylonSourceMesh: Mesh;
  67440. promise: Promise<any>;
  67441. };
  67442. }
  67443. /**
  67444. * Loader interface with additional members.
  67445. */
  67446. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  67447. /**
  67448. * The parent glTF node.
  67449. */
  67450. parent?: INode;
  67451. /** @hidden */ private _babylonTransformNode?: TransformNode;
  67452. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  67453. /** @hidden */ private _babylonBones?: Bone[];
  67454. /** @hidden */ private _numMorphTargets?: number;
  67455. }
  67456. /** @hidden */
  67457. export interface _ISamplerData {
  67458. noMipMaps: boolean;
  67459. samplingMode: number;
  67460. wrapU: number;
  67461. wrapV: number;
  67462. }
  67463. /**
  67464. * Loader interface with additional members.
  67465. */
  67466. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  67467. /** @hidden */ private _data?: _ISamplerData;
  67468. }
  67469. /**
  67470. * Loader interface with additional members.
  67471. */
  67472. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  67473. }
  67474. /**
  67475. * Loader interface with additional members.
  67476. */
  67477. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  67478. /** @hidden */ private _data?: {
  67479. babylonSkeleton: Skeleton;
  67480. promise: Promise<void>;
  67481. };
  67482. }
  67483. /**
  67484. * Loader interface with additional members.
  67485. */
  67486. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  67487. }
  67488. /**
  67489. * Loader interface with additional members.
  67490. */
  67491. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  67492. }
  67493. /**
  67494. * Loader interface with additional members.
  67495. */
  67496. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  67497. accessors?: IAccessor[];
  67498. animations?: IAnimation[];
  67499. buffers?: IBuffer[];
  67500. bufferViews?: IBufferView[];
  67501. cameras?: ICamera[];
  67502. images?: IImage[];
  67503. materials?: IMaterial[];
  67504. meshes?: IMesh[];
  67505. nodes?: INode[];
  67506. samplers?: ISampler[];
  67507. scenes?: IScene[];
  67508. skins?: ISkin[];
  67509. textures?: ITexture[];
  67510. }
  67511. }
  67512. declare module BABYLON.GLTF2 {
  67513. /**
  67514. * Interface for a glTF loader extension.
  67515. */
  67516. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  67517. /**
  67518. * Called after the loader state changes to LOADING.
  67519. */
  67520. onLoading?(): void;
  67521. /**
  67522. * Called after the loader state changes to READY.
  67523. */
  67524. onReady?(): void;
  67525. /**
  67526. * Define this method to modify the default behavior when loading scenes.
  67527. * @param context The context when loading the asset
  67528. * @param scene The glTF scene property
  67529. * @returns A promise that resolves when the load is complete or null if not handled
  67530. */
  67531. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  67532. /**
  67533. * Define this method to modify the default behavior when loading nodes.
  67534. * @param context The context when loading the asset
  67535. * @param node The glTF node property
  67536. * @param assign A function called synchronously after parsing the glTF properties
  67537. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  67538. */
  67539. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67540. /**
  67541. * Define this method to modify the default behavior when loading cameras.
  67542. * @param context The context when loading the asset
  67543. * @param camera The glTF camera property
  67544. * @param assign A function called synchronously after parsing the glTF properties
  67545. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  67546. */
  67547. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  67548. /**
  67549. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  67550. * @param context The context when loading the asset
  67551. * @param primitive The glTF mesh primitive property
  67552. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  67553. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67554. /**
  67555. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67556. * @param context The context when loading the asset
  67557. * @param name The mesh name when loading the asset
  67558. * @param node The glTF node when loading the asset
  67559. * @param mesh The glTF mesh when loading the asset
  67560. * @param primitive The glTF mesh primitive property
  67561. * @param assign A function called synchronously after parsing the glTF properties
  67562. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67563. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67564. /**
  67565. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  67566. * @param context The context when loading the asset
  67567. * @param material The glTF material property
  67568. * @param assign A function called synchronously after parsing the glTF properties
  67569. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  67570. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  67571. /**
  67572. * Define this method to modify the default behavior when creating materials.
  67573. * @param context The context when loading the asset
  67574. * @param material The glTF material property
  67575. * @param babylonDrawMode The draw mode for the Babylon material
  67576. * @returns The Babylon material or null if not handled
  67577. */
  67578. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  67579. /**
  67580. * Define this method to modify the default behavior when loading material properties.
  67581. * @param context The context when loading the asset
  67582. * @param material The glTF material property
  67583. * @param babylonMaterial The Babylon material
  67584. * @returns A promise that resolves when the load is complete or null if not handled
  67585. */
  67586. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  67587. /**
  67588. * Define this method to modify the default behavior when loading texture infos.
  67589. * @param context The context when loading the asset
  67590. * @param textureInfo The glTF texture info property
  67591. * @param assign A function called synchronously after parsing the glTF properties
  67592. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  67593. */
  67594. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  67595. /**
  67596. * Define this method to modify the default behavior when loading animations.
  67597. * @param context The context when loading the asset
  67598. * @param animation The glTF animation property
  67599. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  67600. */
  67601. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  67602. /**
  67603. * @hidden Define this method to modify the default behavior when loading skins.
  67604. * @param context The context when loading the asset
  67605. * @param node The glTF node property
  67606. * @param skin The glTF skin property
  67607. * @returns A promise that resolves when the load is complete or null if not handled
  67608. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  67609. /**
  67610. * @hidden Define this method to modify the default behavior when loading uris.
  67611. * @param context The context when loading the asset
  67612. * @param property The glTF property associated with the uri
  67613. * @param uri The uri to load
  67614. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  67615. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  67616. }
  67617. }
  67618. declare module BABYLON.GLTF2 {
  67619. /**
  67620. * Helper class for working with arrays when loading the glTF asset
  67621. */
  67622. export class ArrayItem {
  67623. /**
  67624. * Gets an item from the given array.
  67625. * @param context The context when loading the asset
  67626. * @param array The array to get the item from
  67627. * @param index The index to the array
  67628. * @returns The array item
  67629. */
  67630. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  67631. /**
  67632. * Assign an `index` field to each item of the given array.
  67633. * @param array The array of items
  67634. */
  67635. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  67636. }
  67637. /**
  67638. * The glTF 2.0 loader
  67639. */
  67640. export class GLTFLoader implements IGLTFLoader {
  67641. /** @hidden */ private _completePromises: Promise<any>[];
  67642. private _disposed;
  67643. private _parent;
  67644. private _state;
  67645. private _extensions;
  67646. private _rootUrl;
  67647. private _fileName;
  67648. private _uniqueRootUrl;
  67649. private _gltf;
  67650. private _babylonScene;
  67651. private _rootBabylonMesh;
  67652. private _defaultBabylonMaterialData;
  67653. private _progressCallback?;
  67654. private _requests;
  67655. private static readonly _DefaultSampler;
  67656. private static _ExtensionNames;
  67657. private static _ExtensionFactories;
  67658. /**
  67659. * Registers a loader extension.
  67660. * @param name The name of the loader extension.
  67661. * @param factory The factory function that creates the loader extension.
  67662. */
  67663. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  67664. /**
  67665. * Unregisters a loader extension.
  67666. * @param name The name of the loader extenion.
  67667. * @returns A boolean indicating whether the extension has been unregistered
  67668. */
  67669. static UnregisterExtension(name: string): boolean;
  67670. /**
  67671. * Gets the loader state.
  67672. */
  67673. readonly state: Nullable<GLTFLoaderState>;
  67674. /**
  67675. * The glTF object parsed from the JSON.
  67676. */
  67677. readonly gltf: IGLTF;
  67678. /**
  67679. * The Babylon scene when loading the asset.
  67680. */
  67681. readonly babylonScene: Scene;
  67682. /**
  67683. * The root Babylon mesh when loading the asset.
  67684. */
  67685. readonly rootBabylonMesh: Mesh;
  67686. /** @hidden */
  67687. constructor(parent: GLTFFileLoader);
  67688. /** @hidden */
  67689. dispose(): void;
  67690. /** @hidden */
  67691. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  67692. meshes: AbstractMesh[];
  67693. particleSystems: IParticleSystem[];
  67694. skeletons: Skeleton[];
  67695. animationGroups: AnimationGroup[];
  67696. }>;
  67697. /** @hidden */
  67698. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  67699. private _loadAsync;
  67700. private _loadData;
  67701. private _setupData;
  67702. private _loadExtensions;
  67703. private _checkExtensions;
  67704. private _setState;
  67705. private _createRootNode;
  67706. /**
  67707. * Loads a glTF scene.
  67708. * @param context The context when loading the asset
  67709. * @param scene The glTF scene property
  67710. * @returns A promise that resolves when the load is complete
  67711. */
  67712. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  67713. private _forEachPrimitive;
  67714. private _getMeshes;
  67715. private _getSkeletons;
  67716. private _getAnimationGroups;
  67717. private _startAnimations;
  67718. /**
  67719. * Loads a glTF node.
  67720. * @param context The context when loading the asset
  67721. * @param node The glTF node property
  67722. * @param assign A function called synchronously after parsing the glTF properties
  67723. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  67724. */
  67725. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  67726. private _loadMeshAsync;
  67727. /**
  67728. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  67729. * @param context The context when loading the asset
  67730. * @param name The mesh name when loading the asset
  67731. * @param node The glTF node when loading the asset
  67732. * @param mesh The glTF mesh when loading the asset
  67733. * @param primitive The glTF mesh primitive property
  67734. * @param assign A function called synchronously after parsing the glTF properties
  67735. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  67736. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  67737. private _loadVertexDataAsync;
  67738. private _createMorphTargets;
  67739. private _loadMorphTargetsAsync;
  67740. private _loadMorphTargetVertexDataAsync;
  67741. private static _LoadTransform;
  67742. private _loadSkinAsync;
  67743. private _loadBones;
  67744. private _loadBone;
  67745. private _loadSkinInverseBindMatricesDataAsync;
  67746. private _updateBoneMatrices;
  67747. private _getNodeMatrix;
  67748. /**
  67749. * Loads a glTF camera.
  67750. * @param context The context when loading the asset
  67751. * @param camera The glTF camera property
  67752. * @param assign A function called synchronously after parsing the glTF properties
  67753. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  67754. */
  67755. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  67756. private _loadAnimationsAsync;
  67757. /**
  67758. * Loads a glTF animation.
  67759. * @param context The context when loading the asset
  67760. * @param animation The glTF animation property
  67761. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  67762. */
  67763. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  67764. /**
  67765. * @hidden Loads a glTF animation channel.
  67766. * @param context The context when loading the asset
  67767. * @param animationContext The context of the animation when loading the asset
  67768. * @param animation The glTF animation property
  67769. * @param channel The glTF animation channel property
  67770. * @param babylonAnimationGroup The babylon animation group property
  67771. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  67772. * @returns A void promise when the channel load is complete
  67773. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  67774. private _loadAnimationSamplerAsync;
  67775. private _loadBufferAsync;
  67776. /**
  67777. * Loads a glTF buffer view.
  67778. * @param context The context when loading the asset
  67779. * @param bufferView The glTF buffer view property
  67780. * @returns A promise that resolves with the loaded data when the load is complete
  67781. */
  67782. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  67783. private _loadAccessorAsync;
  67784. private _loadFloatAccessorAsync;
  67785. private _loadIndicesAccessorAsync;
  67786. private _loadVertexBufferViewAsync;
  67787. private _loadVertexAccessorAsync;
  67788. private _loadMaterialMetallicRoughnessPropertiesAsync;
  67789. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  67790. private _createDefaultMaterial;
  67791. /**
  67792. * Creates a Babylon material from a glTF material.
  67793. * @param context The context when loading the asset
  67794. * @param material The glTF material property
  67795. * @param babylonDrawMode The draw mode for the Babylon material
  67796. * @returns The Babylon material
  67797. */
  67798. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  67799. /**
  67800. * Loads properties from a glTF material into a Babylon material.
  67801. * @param context The context when loading the asset
  67802. * @param material The glTF material property
  67803. * @param babylonMaterial The Babylon material
  67804. * @returns A promise that resolves when the load is complete
  67805. */
  67806. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67807. /**
  67808. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  67809. * @param context The context when loading the asset
  67810. * @param material The glTF material property
  67811. * @param babylonMaterial The Babylon material
  67812. * @returns A promise that resolves when the load is complete
  67813. */
  67814. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  67815. /**
  67816. * Loads the alpha properties from a glTF material into a Babylon material.
  67817. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  67818. * @param context The context when loading the asset
  67819. * @param material The glTF material property
  67820. * @param babylonMaterial The Babylon material
  67821. */
  67822. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  67823. /**
  67824. * Loads a glTF texture info.
  67825. * @param context The context when loading the asset
  67826. * @param textureInfo The glTF texture info property
  67827. * @param assign A function called synchronously after parsing the glTF properties
  67828. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  67829. */
  67830. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  67831. private _loadTextureAsync;
  67832. private _loadSampler;
  67833. /**
  67834. * Loads a glTF image.
  67835. * @param context The context when loading the asset
  67836. * @param image The glTF image property
  67837. * @returns A promise that resolves with the loaded data when the load is complete
  67838. */
  67839. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  67840. /**
  67841. * Loads a glTF uri.
  67842. * @param context The context when loading the asset
  67843. * @param property The glTF property associated with the uri
  67844. * @param uri The base64 or relative uri
  67845. * @returns A promise that resolves with the loaded data when the load is complete
  67846. */
  67847. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  67848. private _onProgress;
  67849. /**
  67850. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  67851. * @param babylonObject the Babylon object with metadata
  67852. * @param pointer the JSON pointer
  67853. */
  67854. static AddPointerMetadata(babylonObject: {
  67855. metadata: any;
  67856. }, pointer: string): void;
  67857. private static _GetTextureWrapMode;
  67858. private static _GetTextureSamplingMode;
  67859. private static _GetTypedArrayConstructor;
  67860. private static _GetTypedArray;
  67861. private static _GetNumComponents;
  67862. private static _ValidateUri;
  67863. private static _GetDrawMode;
  67864. private _compileMaterialsAsync;
  67865. private _compileShadowGeneratorsAsync;
  67866. private _forEachExtensions;
  67867. private _applyExtensions;
  67868. private _extensionsOnLoading;
  67869. private _extensionsOnReady;
  67870. private _extensionsLoadSceneAsync;
  67871. private _extensionsLoadNodeAsync;
  67872. private _extensionsLoadCameraAsync;
  67873. private _extensionsLoadVertexDataAsync;
  67874. private _extensionsLoadMeshPrimitiveAsync;
  67875. private _extensionsLoadMaterialAsync;
  67876. private _extensionsCreateMaterial;
  67877. private _extensionsLoadMaterialPropertiesAsync;
  67878. private _extensionsLoadTextureInfoAsync;
  67879. private _extensionsLoadAnimationAsync;
  67880. private _extensionsLoadSkinAsync;
  67881. private _extensionsLoadUriAsync;
  67882. /**
  67883. * Helper method called by a loader extension to load an glTF extension.
  67884. * @param context The context when loading the asset
  67885. * @param property The glTF property to load the extension from
  67886. * @param extensionName The name of the extension to load
  67887. * @param actionAsync The action to run
  67888. * @returns The promise returned by actionAsync or null if the extension does not exist
  67889. */
  67890. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67891. /**
  67892. * Helper method called by a loader extension to load a glTF extra.
  67893. * @param context The context when loading the asset
  67894. * @param property The glTF property to load the extra from
  67895. * @param extensionName The name of the extension to load
  67896. * @param actionAsync The action to run
  67897. * @returns The promise returned by actionAsync or null if the extra does not exist
  67898. */
  67899. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  67900. /**
  67901. * Increments the indentation level and logs a message.
  67902. * @param message The message to log
  67903. */
  67904. logOpen(message: string): void;
  67905. /**
  67906. * Decrements the indentation level.
  67907. */
  67908. logClose(): void;
  67909. /**
  67910. * Logs a message
  67911. * @param message The message to log
  67912. */
  67913. log(message: string): void;
  67914. /**
  67915. * Starts a performance counter.
  67916. * @param counterName The name of the performance counter
  67917. */
  67918. startPerformanceCounter(counterName: string): void;
  67919. /**
  67920. * Ends a performance counter.
  67921. * @param counterName The name of the performance counter
  67922. */
  67923. endPerformanceCounter(counterName: string): void;
  67924. }
  67925. }
  67926. declare module BABYLON.GLTF2.Loader.Extensions {
  67927. /**
  67928. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  67929. */
  67930. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  67931. /** The name of this extension. */
  67932. readonly name: string;
  67933. /** Defines whether this extension is enabled. */
  67934. enabled: boolean;
  67935. private _loader;
  67936. private _lights?;
  67937. /** @hidden */
  67938. constructor(loader: GLTFLoader);
  67939. /** @hidden */
  67940. dispose(): void;
  67941. /** @hidden */
  67942. onLoading(): void;
  67943. /** @hidden */
  67944. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  67945. private _loadLightAsync;
  67946. }
  67947. }
  67948. declare module BABYLON.GLTF2.Loader.Extensions {
  67949. /**
  67950. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  67951. */
  67952. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  67953. /** The name of this extension. */
  67954. readonly name: string;
  67955. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  67956. dracoCompression?: DracoCompression;
  67957. /** Defines whether this extension is enabled. */
  67958. enabled: boolean;
  67959. private _loader;
  67960. /** @hidden */
  67961. constructor(loader: GLTFLoader);
  67962. /** @hidden */
  67963. dispose(): void;
  67964. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  67965. }
  67966. }
  67967. declare module BABYLON.GLTF2.Loader.Extensions {
  67968. /**
  67969. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  67970. */
  67971. export class KHR_lights implements IGLTFLoaderExtension {
  67972. /** The name of this extension. */
  67973. readonly name: string;
  67974. /** Defines whether this extension is enabled. */
  67975. enabled: boolean;
  67976. private _loader;
  67977. private _lights?;
  67978. /** @hidden */
  67979. constructor(loader: GLTFLoader);
  67980. /** @hidden */
  67981. dispose(): void;
  67982. /** @hidden */
  67983. onLoading(): void;
  67984. /** @hidden */
  67985. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  67986. }
  67987. }
  67988. declare module BABYLON.GLTF2.Loader.Extensions {
  67989. /**
  67990. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  67991. */
  67992. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  67993. /** The name of this extension. */
  67994. readonly name: string;
  67995. /** Defines whether this extension is enabled. */
  67996. enabled: boolean;
  67997. private _loader;
  67998. /** @hidden */
  67999. constructor(loader: GLTFLoader);
  68000. /** @hidden */
  68001. dispose(): void;
  68002. /** @hidden */
  68003. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68004. private _loadSpecularGlossinessPropertiesAsync;
  68005. }
  68006. }
  68007. declare module BABYLON.GLTF2.Loader.Extensions {
  68008. /**
  68009. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  68010. */
  68011. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  68012. /** The name of this extension. */
  68013. readonly name: string;
  68014. /** Defines whether this extension is enabled. */
  68015. enabled: boolean;
  68016. private _loader;
  68017. /** @hidden */
  68018. constructor(loader: GLTFLoader);
  68019. /** @hidden */
  68020. dispose(): void;
  68021. /** @hidden */
  68022. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68023. private _loadUnlitPropertiesAsync;
  68024. }
  68025. }
  68026. declare module BABYLON.GLTF2.Loader.Extensions {
  68027. /**
  68028. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  68029. */
  68030. export class KHR_texture_transform implements IGLTFLoaderExtension {
  68031. /** The name of this extension. */
  68032. readonly name: string;
  68033. /** Defines whether this extension is enabled. */
  68034. enabled: boolean;
  68035. private _loader;
  68036. /** @hidden */
  68037. constructor(loader: GLTFLoader);
  68038. /** @hidden */
  68039. dispose(): void;
  68040. /** @hidden */
  68041. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  68042. }
  68043. }
  68044. declare module BABYLON.GLTF2.Loader.Extensions {
  68045. /**
  68046. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  68047. */
  68048. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  68049. /** The name of this extension. */
  68050. readonly name: string;
  68051. /** Defines whether this extension is enabled. */
  68052. enabled: boolean;
  68053. private _loader;
  68054. private _clips;
  68055. private _emitters;
  68056. /** @hidden */
  68057. constructor(loader: GLTFLoader);
  68058. /** @hidden */
  68059. dispose(): void;
  68060. /** @hidden */
  68061. onLoading(): void;
  68062. /** @hidden */
  68063. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  68064. /** @hidden */
  68065. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68066. /** @hidden */
  68067. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  68068. private _loadClipAsync;
  68069. private _loadEmitterAsync;
  68070. private _getEventAction;
  68071. private _loadAnimationEventAsync;
  68072. }
  68073. }
  68074. declare module BABYLON.GLTF2.Loader.Extensions {
  68075. /**
  68076. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  68077. */
  68078. export class MSFT_lod implements IGLTFLoaderExtension {
  68079. /** The name of this extension. */
  68080. readonly name: string;
  68081. /** Defines whether this extension is enabled. */
  68082. enabled: boolean;
  68083. /**
  68084. * Maximum number of LODs to load, starting from the lowest LOD.
  68085. */
  68086. maxLODsToLoad: number;
  68087. /**
  68088. * Observable raised when all node LODs of one level are loaded.
  68089. * The event data is the index of the loaded LOD starting from zero.
  68090. * Dispose the loader to cancel the loading of the next level of LODs.
  68091. */
  68092. onNodeLODsLoadedObservable: Observable<number>;
  68093. /**
  68094. * Observable raised when all material LODs of one level are loaded.
  68095. * The event data is the index of the loaded LOD starting from zero.
  68096. * Dispose the loader to cancel the loading of the next level of LODs.
  68097. */
  68098. onMaterialLODsLoadedObservable: Observable<number>;
  68099. private _loader;
  68100. private _nodeIndexLOD;
  68101. private _nodeSignalLODs;
  68102. private _nodePromiseLODs;
  68103. private _materialIndexLOD;
  68104. private _materialSignalLODs;
  68105. private _materialPromiseLODs;
  68106. /** @hidden */
  68107. constructor(loader: GLTFLoader);
  68108. /** @hidden */
  68109. dispose(): void;
  68110. /** @hidden */
  68111. onReady(): void;
  68112. /** @hidden */
  68113. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68114. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  68115. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  68116. /**
  68117. * Gets an array of LOD properties from lowest to highest.
  68118. */
  68119. private _getLODs;
  68120. private _disposeUnusedMaterials;
  68121. }
  68122. }
  68123. declare module BABYLON.GLTF2.Loader.Extensions {
  68124. /** @hidden */
  68125. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  68126. readonly name: string;
  68127. enabled: boolean;
  68128. private _loader;
  68129. constructor(loader: GLTFLoader);
  68130. dispose(): void;
  68131. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68132. }
  68133. }
  68134. declare module BABYLON.GLTF2.Loader.Extensions {
  68135. /** @hidden */
  68136. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  68137. readonly name: string;
  68138. enabled: boolean;
  68139. private _loader;
  68140. constructor(loader: GLTFLoader);
  68141. dispose(): void;
  68142. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  68143. }
  68144. }
  68145. declare module BABYLON.GLTF2.Loader.Extensions {
  68146. /**
  68147. * Store glTF extras (if present) in BJS objects' metadata
  68148. */
  68149. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  68150. /** The name of this extension. */
  68151. readonly name: string;
  68152. /** Defines whether this extension is enabled. */
  68153. enabled: boolean;
  68154. private _loader;
  68155. private _assignExtras;
  68156. /** @hidden */
  68157. constructor(loader: GLTFLoader);
  68158. /** @hidden */
  68159. dispose(): void;
  68160. /** @hidden */
  68161. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  68162. /** @hidden */
  68163. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  68164. /** @hidden */
  68165. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  68166. }
  68167. }
  68168. declare module BABYLON {
  68169. /**
  68170. * Class reading and parsing the MTL file bundled with the obj file.
  68171. */
  68172. export class MTLFileLoader {
  68173. /**
  68174. * All material loaded from the mtl will be set here
  68175. */
  68176. materials: StandardMaterial[];
  68177. /**
  68178. * This function will read the mtl file and create each material described inside
  68179. * This function could be improve by adding :
  68180. * -some component missing (Ni, Tf...)
  68181. * -including the specific options available
  68182. *
  68183. * @param scene defines the scene the material will be created in
  68184. * @param data defines the mtl data to parse
  68185. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  68186. */
  68187. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  68188. /**
  68189. * Gets the texture for the material.
  68190. *
  68191. * If the material is imported from input file,
  68192. * We sanitize the url to ensure it takes the textre from aside the material.
  68193. *
  68194. * @param rootUrl The root url to load from
  68195. * @param value The value stored in the mtl
  68196. * @return The Texture
  68197. */
  68198. private static _getTexture;
  68199. }
  68200. /**
  68201. * Options for loading OBJ/MTL files
  68202. */
  68203. type MeshLoadOptions = {
  68204. /**
  68205. * Defines if UVs are optimized by default during load.
  68206. */
  68207. OptimizeWithUV: boolean;
  68208. /**
  68209. * Defines custom scaling of UV coordinates of loaded meshes.
  68210. */
  68211. UVScaling: Vector2;
  68212. /**
  68213. * Invert model on y-axis (does a model scaling inversion)
  68214. */
  68215. InvertY: boolean;
  68216. /**
  68217. * Invert Y-Axis of referenced textures on load
  68218. */
  68219. InvertTextureY: boolean;
  68220. /**
  68221. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68222. */
  68223. ImportVertexColors: boolean;
  68224. /**
  68225. * Compute the normals for the model, even if normals are present in the file.
  68226. */
  68227. ComputeNormals: boolean;
  68228. /**
  68229. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68230. */
  68231. SkipMaterials: boolean;
  68232. /**
  68233. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68234. */
  68235. MaterialLoadingFailsSilently: boolean;
  68236. };
  68237. /**
  68238. * OBJ file type loader.
  68239. * This is a babylon scene loader plugin.
  68240. */
  68241. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  68242. /**
  68243. * Defines if UVs are optimized by default during load.
  68244. */
  68245. static OPTIMIZE_WITH_UV: boolean;
  68246. /**
  68247. * Invert model on y-axis (does a model scaling inversion)
  68248. */
  68249. static INVERT_Y: boolean;
  68250. /**
  68251. * Invert Y-Axis of referenced textures on load
  68252. */
  68253. static INVERT_TEXTURE_Y: boolean;
  68254. /**
  68255. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  68256. */
  68257. static IMPORT_VERTEX_COLORS: boolean;
  68258. /**
  68259. * Compute the normals for the model, even if normals are present in the file.
  68260. */
  68261. static COMPUTE_NORMALS: boolean;
  68262. /**
  68263. * Defines custom scaling of UV coordinates of loaded meshes.
  68264. */
  68265. static UV_SCALING: Vector2;
  68266. /**
  68267. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  68268. */
  68269. static SKIP_MATERIALS: boolean;
  68270. /**
  68271. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  68272. *
  68273. * Defaults to true for backwards compatibility.
  68274. */
  68275. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  68276. /**
  68277. * Defines the name of the plugin.
  68278. */
  68279. name: string;
  68280. /**
  68281. * Defines the extension the plugin is able to load.
  68282. */
  68283. extensions: string;
  68284. /** @hidden */
  68285. obj: RegExp;
  68286. /** @hidden */
  68287. group: RegExp;
  68288. /** @hidden */
  68289. mtllib: RegExp;
  68290. /** @hidden */
  68291. usemtl: RegExp;
  68292. /** @hidden */
  68293. smooth: RegExp;
  68294. /** @hidden */
  68295. vertexPattern: RegExp;
  68296. /** @hidden */
  68297. normalPattern: RegExp;
  68298. /** @hidden */
  68299. uvPattern: RegExp;
  68300. /** @hidden */
  68301. facePattern1: RegExp;
  68302. /** @hidden */
  68303. facePattern2: RegExp;
  68304. /** @hidden */
  68305. facePattern3: RegExp;
  68306. /** @hidden */
  68307. facePattern4: RegExp;
  68308. /** @hidden */
  68309. facePattern5: RegExp;
  68310. private _meshLoadOptions;
  68311. /**
  68312. * Creates loader for .OBJ files
  68313. *
  68314. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  68315. */
  68316. constructor(meshLoadOptions?: MeshLoadOptions);
  68317. private static readonly currentMeshLoadOptions;
  68318. /**
  68319. * Calls synchronously the MTL file attached to this obj.
  68320. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  68321. * Without this function materials are not displayed in the first frame (but displayed after).
  68322. * In consequence it is impossible to get material information in your HTML file
  68323. *
  68324. * @param url The URL of the MTL file
  68325. * @param rootUrl
  68326. * @param onSuccess Callback function to be called when the MTL file is loaded
  68327. * @private
  68328. */
  68329. private _loadMTL;
  68330. /**
  68331. * Instantiates a OBJ file loader plugin.
  68332. * @returns the created plugin
  68333. */
  68334. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  68335. /**
  68336. * If the data string can be loaded directly.
  68337. *
  68338. * @param data string containing the file data
  68339. * @returns if the data can be loaded directly
  68340. */
  68341. canDirectLoad(data: string): boolean;
  68342. /**
  68343. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  68344. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  68345. * @param scene the scene the meshes should be added to
  68346. * @param data the OBJ data to load
  68347. * @param rootUrl root url to load from
  68348. * @param onProgress event that fires when loading progress has occured
  68349. * @param fileName Defines the name of the file to load
  68350. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  68351. */
  68352. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  68353. meshes: AbstractMesh[];
  68354. particleSystems: IParticleSystem[];
  68355. skeletons: Skeleton[];
  68356. animationGroups: AnimationGroup[];
  68357. }>;
  68358. /**
  68359. * Imports all objects from the loaded OBJ data and adds them to the scene
  68360. * @param scene the scene the objects should be added to
  68361. * @param data the OBJ data to load
  68362. * @param rootUrl root url to load from
  68363. * @param onProgress event that fires when loading progress has occured
  68364. * @param fileName Defines the name of the file to load
  68365. * @returns a promise which completes when objects have been loaded to the scene
  68366. */
  68367. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  68368. /**
  68369. * Load into an asset container.
  68370. * @param scene The scene to load into
  68371. * @param data The data to import
  68372. * @param rootUrl The root url for scene and resources
  68373. * @param onProgress The callback when the load progresses
  68374. * @param fileName Defines the name of the file to load
  68375. * @returns The loaded asset container
  68376. */
  68377. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  68378. /**
  68379. * Read the OBJ file and create an Array of meshes.
  68380. * Each mesh contains all information given by the OBJ and the MTL file.
  68381. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  68382. *
  68383. * @param meshesNames
  68384. * @param scene Scene The scene where are displayed the data
  68385. * @param data String The content of the obj file
  68386. * @param rootUrl String The path to the folder
  68387. * @returns Array<AbstractMesh>
  68388. * @private
  68389. */
  68390. private _parseSolid;
  68391. }
  68392. }
  68393. declare module BABYLON {
  68394. /**
  68395. * STL file type loader.
  68396. * This is a babylon scene loader plugin.
  68397. */
  68398. export class STLFileLoader implements ISceneLoaderPlugin {
  68399. /** @hidden */
  68400. solidPattern: RegExp;
  68401. /** @hidden */
  68402. facetsPattern: RegExp;
  68403. /** @hidden */
  68404. normalPattern: RegExp;
  68405. /** @hidden */
  68406. vertexPattern: RegExp;
  68407. /**
  68408. * Defines the name of the plugin.
  68409. */
  68410. name: string;
  68411. /**
  68412. * Defines the extensions the stl loader is able to load.
  68413. * force data to come in as an ArrayBuffer
  68414. * we'll convert to string if it looks like it's an ASCII .stl
  68415. */
  68416. extensions: ISceneLoaderPluginExtensions;
  68417. /**
  68418. * Import meshes into a scene.
  68419. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  68420. * @param scene The scene to import into
  68421. * @param data The data to import
  68422. * @param rootUrl The root url for scene and resources
  68423. * @param meshes The meshes array to import into
  68424. * @param particleSystems The particle systems array to import into
  68425. * @param skeletons The skeletons array to import into
  68426. * @param onError The callback when import fails
  68427. * @returns True if successful or false otherwise
  68428. */
  68429. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  68430. /**
  68431. * Load into a scene.
  68432. * @param scene The scene to load into
  68433. * @param data The data to import
  68434. * @param rootUrl The root url for scene and resources
  68435. * @param onError The callback when import fails
  68436. * @returns true if successful or false otherwise
  68437. */
  68438. load(scene: Scene, data: any, rootUrl: string): boolean;
  68439. /**
  68440. * Load into an asset container.
  68441. * @param scene The scene to load into
  68442. * @param data The data to import
  68443. * @param rootUrl The root url for scene and resources
  68444. * @param onError The callback when import fails
  68445. * @returns The loaded asset container
  68446. */
  68447. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  68448. private _isBinary;
  68449. private _parseBinary;
  68450. private _parseASCII;
  68451. }
  68452. }
  68453. declare module BABYLON {
  68454. /**
  68455. * Class for generating OBJ data from a Babylon scene.
  68456. */
  68457. export class OBJExport {
  68458. /**
  68459. * Exports the geometry of a Mesh array in .OBJ file format (text)
  68460. * @param mesh defines the list of meshes to serialize
  68461. * @param materials defines if materials should be exported
  68462. * @param matlibname defines the name of the associated mtl file
  68463. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  68464. * @returns the OBJ content
  68465. */
  68466. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  68467. /**
  68468. * Exports the material(s) of a mesh in .MTL file format (text)
  68469. * @param mesh defines the mesh to extract the material from
  68470. * @returns the mtl content
  68471. */
  68472. static MTL(mesh: Mesh): string;
  68473. }
  68474. }
  68475. declare module BABYLON {
  68476. /** @hidden */
  68477. export var __IGLTFExporterExtension: number;
  68478. /**
  68479. * Interface for extending the exporter
  68480. * @hidden
  68481. */
  68482. export interface IGLTFExporterExtension {
  68483. /**
  68484. * The name of this extension
  68485. */
  68486. readonly name: string;
  68487. /**
  68488. * Defines whether this extension is enabled
  68489. */
  68490. enabled: boolean;
  68491. /**
  68492. * Defines whether this extension is required
  68493. */
  68494. required: boolean;
  68495. }
  68496. }
  68497. declare module BABYLON.GLTF2.Exporter {
  68498. /** @hidden */
  68499. export var __IGLTFExporterExtensionV2: number;
  68500. /**
  68501. * Interface for a glTF exporter extension
  68502. * @hidden
  68503. */
  68504. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  68505. /**
  68506. * Define this method to modify the default behavior before exporting a texture
  68507. * @param context The context when loading the asset
  68508. * @param babylonTexture The glTF texture info property
  68509. * @param mimeType The mime-type of the generated image
  68510. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  68511. */
  68512. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  68513. /**
  68514. * Define this method to modify the default behavior when exporting texture info
  68515. * @param context The context when loading the asset
  68516. * @param meshPrimitive glTF mesh primitive
  68517. * @param babylonSubMesh Babylon submesh
  68518. * @param binaryWriter glTF serializer binary writer instance
  68519. * @returns nullable IMeshPrimitive promise
  68520. */
  68521. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  68522. /**
  68523. * Define this method to modify the default behavior when exporting a node
  68524. * @param context The context when exporting the node
  68525. * @param node glTF node
  68526. * @param babylonNode BabylonJS node
  68527. * @returns nullable INode promise
  68528. */
  68529. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68530. /**
  68531. * Called after the exporter state changes to EXPORTING
  68532. */
  68533. onExporting?(): void;
  68534. }
  68535. }
  68536. declare module BABYLON.GLTF2.Exporter {
  68537. /**
  68538. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  68539. * @hidden
  68540. */
  68541. export class _GLTFMaterialExporter {
  68542. /**
  68543. * Represents the dielectric specular values for R, G and B
  68544. */
  68545. private static readonly _DielectricSpecular;
  68546. /**
  68547. * Allows the maximum specular power to be defined for material calculations
  68548. */
  68549. private static readonly _MaxSpecularPower;
  68550. /**
  68551. * Mapping to store textures
  68552. */
  68553. private _textureMap;
  68554. /**
  68555. * Numeric tolerance value
  68556. */
  68557. private static readonly _Epsilon;
  68558. /**
  68559. * Reference to the glTF Exporter
  68560. */
  68561. private _exporter;
  68562. constructor(exporter: _Exporter);
  68563. /**
  68564. * Specifies if two colors are approximately equal in value
  68565. * @param color1 first color to compare to
  68566. * @param color2 second color to compare to
  68567. * @param epsilon threshold value
  68568. */
  68569. private static FuzzyEquals;
  68570. /**
  68571. * Gets the materials from a Babylon scene and converts them to glTF materials
  68572. * @param scene babylonjs scene
  68573. * @param mimeType texture mime type
  68574. * @param images array of images
  68575. * @param textures array of textures
  68576. * @param materials array of materials
  68577. * @param imageData mapping of texture names to base64 textures
  68578. * @param hasTextureCoords specifies if texture coordinates are present on the material
  68579. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68580. /**
  68581. * Makes a copy of the glTF material without the texture parameters
  68582. * @param originalMaterial original glTF material
  68583. * @returns glTF material without texture parameters
  68584. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  68585. /**
  68586. * Specifies if the material has any texture parameters present
  68587. * @param material glTF Material
  68588. * @returns boolean specifying if texture parameters are present
  68589. */ private _hasTexturesPresent(material: IMaterial): boolean;
  68590. /**
  68591. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  68592. * @param babylonStandardMaterial
  68593. * @returns glTF Metallic Roughness Material representation
  68594. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  68595. /**
  68596. * Computes the metallic factor
  68597. * @param diffuse diffused value
  68598. * @param specular specular value
  68599. * @param oneMinusSpecularStrength one minus the specular strength
  68600. * @returns metallic value
  68601. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  68602. /**
  68603. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  68604. * @param glTFMaterial glTF material
  68605. * @param babylonMaterial Babylon material
  68606. */
  68607. private static _SetAlphaMode;
  68608. /**
  68609. * Converts a Babylon Standard Material to a glTF Material
  68610. * @param babylonStandardMaterial BJS Standard Material
  68611. * @param mimeType mime type to use for the textures
  68612. * @param images array of glTF image interfaces
  68613. * @param textures array of glTF texture interfaces
  68614. * @param materials array of glTF material interfaces
  68615. * @param imageData map of image file name to data
  68616. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68617. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68618. /**
  68619. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68620. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  68621. * @param mimeType mime type to use for the textures
  68622. * @param images array of glTF image interfaces
  68623. * @param textures array of glTF texture interfaces
  68624. * @param materials array of glTF material interfaces
  68625. * @param imageData map of image file name to data
  68626. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68627. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68628. /**
  68629. * Converts an image typed array buffer to a base64 image
  68630. * @param buffer typed array buffer
  68631. * @param width width of the image
  68632. * @param height height of the image
  68633. * @param mimeType mimetype of the image
  68634. * @returns base64 image string
  68635. */
  68636. private _createBase64FromCanvasAsync;
  68637. /**
  68638. * Generates a white texture based on the specified width and height
  68639. * @param width width of the texture in pixels
  68640. * @param height height of the texture in pixels
  68641. * @param scene babylonjs scene
  68642. * @returns white texture
  68643. */
  68644. private _createWhiteTexture;
  68645. /**
  68646. * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
  68647. * @param texture1 first texture to resize
  68648. * @param texture2 second texture to resize
  68649. * @param scene babylonjs scene
  68650. * @returns resized textures or null
  68651. */
  68652. private _resizeTexturesToSameDimensions;
  68653. /**
  68654. * Converts an array of pixels to a Float32Array
  68655. * Throws an error if the pixel format is not supported
  68656. * @param pixels - array buffer containing pixel values
  68657. * @returns Float32 of pixels
  68658. */
  68659. private _convertPixelArrayToFloat32;
  68660. /**
  68661. * Convert Specular Glossiness Textures to Metallic Roughness
  68662. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  68663. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  68664. * @param diffuseTexture texture used to store diffuse information
  68665. * @param specularGlossinessTexture texture used to store specular and glossiness information
  68666. * @param factors specular glossiness material factors
  68667. * @param mimeType the mime type to use for the texture
  68668. * @returns pbr metallic roughness interface or null
  68669. */
  68670. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  68671. /**
  68672. * Converts specular glossiness material properties to metallic roughness
  68673. * @param specularGlossiness interface with specular glossiness material properties
  68674. * @returns interface with metallic roughness material properties
  68675. */
  68676. private _convertSpecularGlossinessToMetallicRoughness;
  68677. /**
  68678. * Calculates the surface reflectance, independent of lighting conditions
  68679. * @param color Color source to calculate brightness from
  68680. * @returns number representing the perceived brightness, or zero if color is undefined
  68681. */
  68682. private _getPerceivedBrightness;
  68683. /**
  68684. * Returns the maximum color component value
  68685. * @param color
  68686. * @returns maximum color component value, or zero if color is null or undefined
  68687. */
  68688. private _getMaxComponent;
  68689. /**
  68690. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  68691. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68692. * @param mimeType mime type to use for the textures
  68693. * @param images array of glTF image interfaces
  68694. * @param textures array of glTF texture interfaces
  68695. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68696. * @param imageData map of image file name to data
  68697. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68698. * @returns glTF PBR Metallic Roughness factors
  68699. */
  68700. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  68701. private _getGLTFTextureSampler;
  68702. private _getGLTFTextureWrapMode;
  68703. private _getGLTFTextureWrapModesSampler;
  68704. /**
  68705. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  68706. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68707. * @param mimeType mime type to use for the textures
  68708. * @param images array of glTF image interfaces
  68709. * @param textures array of glTF texture interfaces
  68710. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  68711. * @param imageData map of image file name to data
  68712. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68713. * @returns glTF PBR Metallic Roughness factors
  68714. */
  68715. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  68716. /**
  68717. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  68718. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  68719. * @param mimeType mime type to use for the textures
  68720. * @param images array of glTF image interfaces
  68721. * @param textures array of glTF texture interfaces
  68722. * @param materials array of glTF material interfaces
  68723. * @param imageData map of image file name to data
  68724. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  68725. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  68726. private setMetallicRoughnessPbrMaterial;
  68727. private getPixelsFromTexture;
  68728. /**
  68729. * Extracts a texture from a Babylon texture into file data and glTF data
  68730. * @param babylonTexture Babylon texture to extract
  68731. * @param mimeType Mime Type of the babylonTexture
  68732. * @return glTF texture info, or null if the texture format is not supported
  68733. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  68734. /**
  68735. * Builds a texture from base64 string
  68736. * @param base64Texture base64 texture string
  68737. * @param baseTextureName Name to use for the texture
  68738. * @param mimeType image mime type for the texture
  68739. * @param images array of images
  68740. * @param textures array of textures
  68741. * @param imageData map of image data
  68742. * @returns glTF texture info, or null if the texture format is not supported
  68743. */
  68744. private _getTextureInfoFromBase64;
  68745. }
  68746. }
  68747. declare module BABYLON {
  68748. /**
  68749. * Class for holding and downloading glTF file data
  68750. */
  68751. export class GLTFData {
  68752. /**
  68753. * Object which contains the file name as the key and its data as the value
  68754. */
  68755. glTFFiles: {
  68756. [fileName: string]: string | Blob;
  68757. };
  68758. /**
  68759. * Initializes the glTF file object
  68760. */
  68761. constructor();
  68762. /**
  68763. * Downloads the glTF data as files based on their names and data
  68764. */
  68765. downloadFiles(): void;
  68766. }
  68767. }
  68768. declare module BABYLON {
  68769. /**
  68770. * Holds a collection of exporter options and parameters
  68771. */
  68772. export interface IExportOptions {
  68773. /**
  68774. * Function which indicates whether a babylon node should be exported or not
  68775. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  68776. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  68777. */
  68778. shouldExportNode?(node: Node): boolean;
  68779. /**
  68780. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  68781. * @param metadata source metadata to read from
  68782. * @returns the data to store to glTF node extras
  68783. */
  68784. metadataSelector?(metadata: any): any;
  68785. /**
  68786. * The sample rate to bake animation curves
  68787. */
  68788. animationSampleRate?: number;
  68789. /**
  68790. * Begin serialization without waiting for the scene to be ready
  68791. */
  68792. exportWithoutWaitingForScene?: boolean;
  68793. }
  68794. /**
  68795. * Class for generating glTF data from a Babylon scene.
  68796. */
  68797. export class GLTF2Export {
  68798. /**
  68799. * Exports the geometry of the scene to .gltf file format asynchronously
  68800. * @param scene Babylon scene with scene hierarchy information
  68801. * @param filePrefix File prefix to use when generating the glTF file
  68802. * @param options Exporter options
  68803. * @returns Returns an object with a .gltf file and associates texture names
  68804. * as keys and their data and paths as values
  68805. */
  68806. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68807. private static _PreExportAsync;
  68808. private static _PostExportAsync;
  68809. /**
  68810. * Exports the geometry of the scene to .glb file format asychronously
  68811. * @param scene Babylon scene with scene hierarchy information
  68812. * @param filePrefix File prefix to use when generating glb file
  68813. * @param options Exporter options
  68814. * @returns Returns an object with a .glb filename as key and data as value
  68815. */
  68816. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  68817. }
  68818. }
  68819. declare module BABYLON.GLTF2.Exporter {
  68820. /**
  68821. * @hidden
  68822. */
  68823. export class _GLTFUtilities {
  68824. /**
  68825. * Creates a buffer view based on the supplied arguments
  68826. * @param bufferIndex index value of the specified buffer
  68827. * @param byteOffset byte offset value
  68828. * @param byteLength byte length of the bufferView
  68829. * @param byteStride byte distance between conequential elements
  68830. * @param name name of the buffer view
  68831. * @returns bufferView for glTF
  68832. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  68833. /**
  68834. * Creates an accessor based on the supplied arguments
  68835. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  68836. * @param name The name of the accessor
  68837. * @param type The type of the accessor
  68838. * @param componentType The datatype of components in the attribute
  68839. * @param count The number of attributes referenced by this accessor
  68840. * @param byteOffset The offset relative to the start of the bufferView in bytes
  68841. * @param min Minimum value of each component in this attribute
  68842. * @param max Maximum value of each component in this attribute
  68843. * @returns accessor for glTF
  68844. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  68845. /**
  68846. * Calculates the minimum and maximum values of an array of position floats
  68847. * @param positions Positions array of a mesh
  68848. * @param vertexStart Starting vertex offset to calculate min and max values
  68849. * @param vertexCount Number of vertices to check for min and max values
  68850. * @returns min number array and max number array
  68851. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  68852. min: number[];
  68853. max: number[];
  68854. };
  68855. /**
  68856. * Converts a new right-handed Vector3
  68857. * @param vector vector3 array
  68858. * @returns right-handed Vector3
  68859. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  68860. /**
  68861. * Converts a Vector3 to right-handed
  68862. * @param vector Vector3 to convert to right-handed
  68863. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  68864. /**
  68865. * Converts a three element number array to right-handed
  68866. * @param vector number array to convert to right-handed
  68867. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  68868. /**
  68869. * Converts a new right-handed Vector3
  68870. * @param vector vector3 array
  68871. * @returns right-handed Vector3
  68872. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  68873. /**
  68874. * Converts a Vector3 to right-handed
  68875. * @param vector Vector3 to convert to right-handed
  68876. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  68877. /**
  68878. * Converts a three element number array to right-handed
  68879. * @param vector number array to convert to right-handed
  68880. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  68881. /**
  68882. * Converts a Vector4 to right-handed
  68883. * @param vector Vector4 to convert to right-handed
  68884. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  68885. /**
  68886. * Converts a Vector4 to right-handed
  68887. * @param vector Vector4 to convert to right-handed
  68888. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  68889. /**
  68890. * Converts a Quaternion to right-handed
  68891. * @param quaternion Source quaternion to convert to right-handed
  68892. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  68893. /**
  68894. * Converts a Quaternion to right-handed
  68895. * @param quaternion Source quaternion to convert to right-handed
  68896. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  68897. }
  68898. }
  68899. declare module BABYLON.GLTF2.Exporter {
  68900. /**
  68901. * Converts Babylon Scene into glTF 2.0.
  68902. * @hidden
  68903. */
  68904. export class _Exporter {
  68905. /**
  68906. * Stores the glTF to export
  68907. */ private _glTF: IGLTF;
  68908. /**
  68909. * Stores all generated buffer views, which represents views into the main glTF buffer data
  68910. */ private _bufferViews: IBufferView[];
  68911. /**
  68912. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  68913. */ private _accessors: IAccessor[];
  68914. /**
  68915. * Stores all the generated nodes, which contains transform and/or mesh information per node
  68916. */
  68917. private _nodes;
  68918. /**
  68919. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  68920. */
  68921. private _scenes;
  68922. /**
  68923. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  68924. */
  68925. private _meshes;
  68926. /**
  68927. * Stores all the generated material information, which represents the appearance of each primitive
  68928. */ private _materials: IMaterial[]; private _materialMap: {
  68929. [materialID: number]: number;
  68930. };
  68931. /**
  68932. * Stores all the generated texture information, which is referenced by glTF materials
  68933. */ private _textures: ITexture[];
  68934. /**
  68935. * Stores all the generated image information, which is referenced by glTF textures
  68936. */ private _images: IImage[];
  68937. /**
  68938. * Stores all the texture samplers
  68939. */ private _samplers: ISampler[];
  68940. /**
  68941. * Stores all the generated animation samplers, which is referenced by glTF animations
  68942. */
  68943. /**
  68944. * Stores the animations for glTF models
  68945. */
  68946. private _animations;
  68947. /**
  68948. * Stores the total amount of bytes stored in the glTF buffer
  68949. */
  68950. private _totalByteLength;
  68951. /**
  68952. * Stores a reference to the Babylon scene containing the source geometry and material information
  68953. */ private _babylonScene: Scene;
  68954. /**
  68955. * Stores a map of the image data, where the key is the file name and the value
  68956. * is the image data
  68957. */ private _imageData: {
  68958. [fileName: string]: {
  68959. data: Uint8Array;
  68960. mimeType: ImageMimeType;
  68961. };
  68962. };
  68963. /**
  68964. * Stores a map of the unique id of a node to its index in the node array
  68965. */
  68966. private _nodeMap;
  68967. /**
  68968. * Specifies if the Babylon scene should be converted to right-handed on export
  68969. */ private _convertToRightHandedSystem: boolean;
  68970. /**
  68971. * Baked animation sample rate
  68972. */
  68973. private _animationSampleRate;
  68974. private _options;
  68975. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  68976. private _extensions;
  68977. private static _ExtensionNames;
  68978. private static _ExtensionFactories;
  68979. private _applyExtensions; private _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; private _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; private _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  68980. private _forEachExtensions;
  68981. private _extensionsOnExporting;
  68982. /**
  68983. * Load glTF serializer extensions
  68984. */
  68985. private _loadExtensions;
  68986. /**
  68987. * Creates a glTF Exporter instance, which can accept optional exporter options
  68988. * @param babylonScene Babylon scene object
  68989. * @param options Options to modify the behavior of the exporter
  68990. */
  68991. constructor(babylonScene: Scene, options?: IExportOptions);
  68992. /**
  68993. * Registers a glTF exporter extension
  68994. * @param name Name of the extension to export
  68995. * @param factory The factory function that creates the exporter extension
  68996. */
  68997. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  68998. /**
  68999. * Un-registers an exporter extension
  69000. * @param name The name fo the exporter extension
  69001. * @returns A boolean indicating whether the extension has been un-registered
  69002. */
  69003. static UnregisterExtension(name: string): boolean;
  69004. /**
  69005. * Lazy load a local engine with premultiplied alpha set to false
  69006. */ private _getLocalEngine(): Engine;
  69007. private reorderIndicesBasedOnPrimitiveMode;
  69008. /**
  69009. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  69010. * clock-wise during export to glTF
  69011. * @param submesh BabylonJS submesh
  69012. * @param primitiveMode Primitive mode of the mesh
  69013. * @param sideOrientation the winding order of the submesh
  69014. * @param vertexBufferKind The type of vertex attribute
  69015. * @param meshAttributeArray The vertex attribute data
  69016. * @param byteOffset The offset to the binary data
  69017. * @param binaryWriter The binary data for the glTF file
  69018. */
  69019. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  69020. /**
  69021. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  69022. * clock-wise during export to glTF
  69023. * @param submesh BabylonJS submesh
  69024. * @param primitiveMode Primitive mode of the mesh
  69025. * @param sideOrientation the winding order of the submesh
  69026. * @param vertexBufferKind The type of vertex attribute
  69027. * @param meshAttributeArray The vertex attribute data
  69028. * @param byteOffset The offset to the binary data
  69029. * @param binaryWriter The binary data for the glTF file
  69030. */
  69031. private reorderTriangleFillMode;
  69032. /**
  69033. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  69034. * clock-wise during export to glTF
  69035. * @param submesh BabylonJS submesh
  69036. * @param primitiveMode Primitive mode of the mesh
  69037. * @param sideOrientation the winding order of the submesh
  69038. * @param vertexBufferKind The type of vertex attribute
  69039. * @param meshAttributeArray The vertex attribute data
  69040. * @param byteOffset The offset to the binary data
  69041. * @param binaryWriter The binary data for the glTF file
  69042. */
  69043. private reorderTriangleStripDrawMode;
  69044. /**
  69045. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  69046. * clock-wise during export to glTF
  69047. * @param submesh BabylonJS submesh
  69048. * @param primitiveMode Primitive mode of the mesh
  69049. * @param sideOrientation the winding order of the submesh
  69050. * @param vertexBufferKind The type of vertex attribute
  69051. * @param meshAttributeArray The vertex attribute data
  69052. * @param byteOffset The offset to the binary data
  69053. * @param binaryWriter The binary data for the glTF file
  69054. */
  69055. private reorderTriangleFanMode;
  69056. /**
  69057. * Writes the vertex attribute data to binary
  69058. * @param vertices The vertices to write to the binary writer
  69059. * @param byteOffset The offset into the binary writer to overwrite binary data
  69060. * @param vertexAttributeKind The vertex attribute type
  69061. * @param meshAttributeArray The vertex attribute data
  69062. * @param binaryWriter The writer containing the binary data
  69063. */
  69064. private writeVertexAttributeData;
  69065. /**
  69066. * Writes mesh attribute data to a data buffer
  69067. * Returns the bytelength of the data
  69068. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  69069. * @param meshAttributeArray Array containing the attribute data
  69070. * @param binaryWriter The buffer to write the binary data to
  69071. * @param indices Used to specify the order of the vertex data
  69072. */
  69073. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  69074. /**
  69075. * Generates glTF json data
  69076. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  69077. * @param glTFPrefix Text to use when prefixing a glTF file
  69078. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  69079. * @returns json data as string
  69080. */
  69081. private generateJSON;
  69082. /**
  69083. * Generates data for .gltf and .bin files based on the glTF prefix string
  69084. * @param glTFPrefix Text to use when prefixing a glTF file
  69085. * @returns GLTFData with glTF file data
  69086. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  69087. /**
  69088. * Creates a binary buffer for glTF
  69089. * @returns array buffer for binary data
  69090. */
  69091. private _generateBinaryAsync;
  69092. /**
  69093. * Pads the number to a multiple of 4
  69094. * @param num number to pad
  69095. * @returns padded number
  69096. */
  69097. private _getPadding;
  69098. /**
  69099. * Generates a glb file from the json and binary data
  69100. * Returns an object with the glb file name as the key and data as the value
  69101. * @param glTFPrefix
  69102. * @returns object with glb filename as key and data as value
  69103. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  69104. /**
  69105. * Sets the TRS for each node
  69106. * @param node glTF Node for storing the transformation data
  69107. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  69108. */
  69109. private setNodeTransformation;
  69110. private getVertexBufferFromMesh;
  69111. /**
  69112. * Creates a bufferview based on the vertices type for the Babylon mesh
  69113. * @param kind Indicates the type of vertices data
  69114. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  69115. * @param binaryWriter The buffer to write the bufferview data to
  69116. */
  69117. private createBufferViewKind;
  69118. /**
  69119. * The primitive mode of the Babylon mesh
  69120. * @param babylonMesh The BabylonJS mesh
  69121. */
  69122. private getMeshPrimitiveMode;
  69123. /**
  69124. * Sets the primitive mode of the glTF mesh primitive
  69125. * @param meshPrimitive glTF mesh primitive
  69126. * @param primitiveMode The primitive mode
  69127. */
  69128. private setPrimitiveMode;
  69129. /**
  69130. * Sets the vertex attribute accessor based of the glTF mesh primitive
  69131. * @param meshPrimitive glTF mesh primitive
  69132. * @param attributeKind vertex attribute
  69133. * @returns boolean specifying if uv coordinates are present
  69134. */
  69135. private setAttributeKind;
  69136. /**
  69137. * Sets data for the primitive attributes of each submesh
  69138. * @param mesh glTF Mesh object to store the primitive attribute information
  69139. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  69140. * @param binaryWriter Buffer to write the attribute data to
  69141. */
  69142. private setPrimitiveAttributesAsync;
  69143. /**
  69144. * Creates a glTF scene based on the array of meshes
  69145. * Returns the the total byte offset
  69146. * @param babylonScene Babylon scene to get the mesh data from
  69147. * @param binaryWriter Buffer to write binary data to
  69148. */
  69149. private createSceneAsync;
  69150. /**
  69151. * Creates a mapping of Node unique id to node index and handles animations
  69152. * @param babylonScene Babylon Scene
  69153. * @param nodes Babylon transform nodes
  69154. * @param binaryWriter Buffer to write binary data to
  69155. * @returns Node mapping of unique id to index
  69156. */
  69157. private createNodeMapAndAnimationsAsync;
  69158. /**
  69159. * Creates a glTF node from a Babylon mesh
  69160. * @param babylonMesh Source Babylon mesh
  69161. * @param binaryWriter Buffer for storing geometry data
  69162. * @returns glTF node
  69163. */
  69164. private createNodeAsync;
  69165. }
  69166. /**
  69167. * @hidden
  69168. *
  69169. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  69170. */
  69171. export class _BinaryWriter {
  69172. /**
  69173. * Array buffer which stores all binary data
  69174. */
  69175. private _arrayBuffer;
  69176. /**
  69177. * View of the array buffer
  69178. */
  69179. private _dataView;
  69180. /**
  69181. * byte offset of data in array buffer
  69182. */
  69183. private _byteOffset;
  69184. /**
  69185. * Initialize binary writer with an initial byte length
  69186. * @param byteLength Initial byte length of the array buffer
  69187. */
  69188. constructor(byteLength: number);
  69189. /**
  69190. * Resize the array buffer to the specified byte length
  69191. * @param byteLength
  69192. */
  69193. private resizeBuffer;
  69194. /**
  69195. * Get an array buffer with the length of the byte offset
  69196. * @returns ArrayBuffer resized to the byte offset
  69197. */
  69198. getArrayBuffer(): ArrayBuffer;
  69199. /**
  69200. * Get the byte offset of the array buffer
  69201. * @returns byte offset
  69202. */
  69203. getByteOffset(): number;
  69204. /**
  69205. * Stores an UInt8 in the array buffer
  69206. * @param entry
  69207. * @param byteOffset If defined, specifies where to set the value as an offset.
  69208. */
  69209. setUInt8(entry: number, byteOffset?: number): void;
  69210. /**
  69211. * Gets an UInt32 in the array buffer
  69212. * @param entry
  69213. * @param byteOffset If defined, specifies where to set the value as an offset.
  69214. */
  69215. getUInt32(byteOffset: number): number;
  69216. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69217. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  69218. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69219. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  69220. /**
  69221. * Stores a Float32 in the array buffer
  69222. * @param entry
  69223. */
  69224. setFloat32(entry: number, byteOffset?: number): void;
  69225. /**
  69226. * Stores an UInt32 in the array buffer
  69227. * @param entry
  69228. * @param byteOffset If defined, specifies where to set the value as an offset.
  69229. */
  69230. setUInt32(entry: number, byteOffset?: number): void;
  69231. }
  69232. }
  69233. declare module BABYLON.GLTF2.Exporter {
  69234. /**
  69235. * @hidden
  69236. * Interface to store animation data.
  69237. */
  69238. export interface _IAnimationData {
  69239. /**
  69240. * Keyframe data.
  69241. */
  69242. inputs: number[];
  69243. /**
  69244. * Value data.
  69245. */
  69246. outputs: number[][];
  69247. /**
  69248. * Animation interpolation data.
  69249. */
  69250. samplerInterpolation: AnimationSamplerInterpolation;
  69251. /**
  69252. * Minimum keyframe value.
  69253. */
  69254. inputsMin: number;
  69255. /**
  69256. * Maximum keyframe value.
  69257. */
  69258. inputsMax: number;
  69259. }
  69260. /**
  69261. * @hidden
  69262. */
  69263. export interface _IAnimationInfo {
  69264. /**
  69265. * The target channel for the animation
  69266. */
  69267. animationChannelTargetPath: AnimationChannelTargetPath;
  69268. /**
  69269. * The glTF accessor type for the data.
  69270. */
  69271. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  69272. /**
  69273. * Specifies if quaternions should be used.
  69274. */
  69275. useQuaternion: boolean;
  69276. }
  69277. /**
  69278. * @hidden
  69279. * Utility class for generating glTF animation data from BabylonJS.
  69280. */
  69281. export class _GLTFAnimation {
  69282. /**
  69283. * @ignore
  69284. *
  69285. * Creates glTF channel animation from BabylonJS animation.
  69286. * @param babylonTransformNode - BabylonJS mesh.
  69287. * @param animation - animation.
  69288. * @param animationChannelTargetPath - The target animation channel.
  69289. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  69290. * @param useQuaternion - Specifies if quaternions are used.
  69291. * @returns nullable IAnimationData
  69292. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  69293. private static _DeduceAnimationInfo;
  69294. /**
  69295. * @ignore
  69296. * Create node animations from the transform node animations
  69297. * @param babylonNode
  69298. * @param runtimeGLTFAnimation
  69299. * @param idleGLTFAnimations
  69300. * @param nodeMap
  69301. * @param nodes
  69302. * @param binaryWriter
  69303. * @param bufferViews
  69304. * @param accessors
  69305. * @param convertToRightHandedSystem
  69306. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  69307. [key: number]: number;
  69308. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69309. /**
  69310. * @ignore
  69311. * Create node animations from the animation groups
  69312. * @param babylonScene
  69313. * @param glTFAnimations
  69314. * @param nodeMap
  69315. * @param nodes
  69316. * @param binaryWriter
  69317. * @param bufferViews
  69318. * @param accessors
  69319. * @param convertToRightHandedSystem
  69320. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  69321. [key: number]: number;
  69322. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  69323. private static AddAnimation;
  69324. /**
  69325. * Create a baked animation
  69326. * @param babylonTransformNode BabylonJS mesh
  69327. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  69328. * @param animationChannelTargetPath animation target channel
  69329. * @param minFrame minimum animation frame
  69330. * @param maxFrame maximum animation frame
  69331. * @param fps frames per second of the animation
  69332. * @param inputs input key frames of the animation
  69333. * @param outputs output key frame data of the animation
  69334. * @param convertToRightHandedSystem converts the values to right-handed
  69335. * @param useQuaternion specifies if quaternions should be used
  69336. */
  69337. private static _CreateBakedAnimation;
  69338. private static _ConvertFactorToVector3OrQuaternion;
  69339. private static _SetInterpolatedValue;
  69340. /**
  69341. * Creates linear animation from the animation key frames
  69342. * @param babylonTransformNode BabylonJS mesh
  69343. * @param animation BabylonJS animation
  69344. * @param animationChannelTargetPath The target animation channel
  69345. * @param frameDelta The difference between the last and first frame of the animation
  69346. * @param inputs Array to store the key frame times
  69347. * @param outputs Array to store the key frame data
  69348. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69349. * @param useQuaternion Specifies if quaternions are used in the animation
  69350. */
  69351. private static _CreateLinearOrStepAnimation;
  69352. /**
  69353. * Creates cubic spline animation from the animation key frames
  69354. * @param babylonTransformNode BabylonJS mesh
  69355. * @param animation BabylonJS animation
  69356. * @param animationChannelTargetPath The target animation channel
  69357. * @param frameDelta The difference between the last and first frame of the animation
  69358. * @param inputs Array to store the key frame times
  69359. * @param outputs Array to store the key frame data
  69360. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  69361. * @param useQuaternion Specifies if quaternions are used in the animation
  69362. */
  69363. private static _CreateCubicSplineAnimation;
  69364. private static _GetBasePositionRotationOrScale;
  69365. /**
  69366. * Adds a key frame value
  69367. * @param keyFrame
  69368. * @param animation
  69369. * @param outputs
  69370. * @param animationChannelTargetPath
  69371. * @param basePositionRotationOrScale
  69372. * @param convertToRightHandedSystem
  69373. * @param useQuaternion
  69374. */
  69375. private static _AddKeyframeValue;
  69376. /**
  69377. * Determine the interpolation based on the key frames
  69378. * @param keyFrames
  69379. * @param animationChannelTargetPath
  69380. * @param useQuaternion
  69381. */
  69382. private static _DeduceInterpolation;
  69383. /**
  69384. * Adds an input tangent or output tangent to the output data
  69385. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  69386. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  69387. * @param outputs The animation data by keyframe
  69388. * @param animationChannelTargetPath The target animation channel
  69389. * @param interpolation The interpolation type
  69390. * @param keyFrame The key frame with the animation data
  69391. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  69392. * @param useQuaternion Specifies if quaternions are used
  69393. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  69394. */
  69395. private static AddSplineTangent;
  69396. /**
  69397. * Get the minimum and maximum key frames' frame values
  69398. * @param keyFrames animation key frames
  69399. * @returns the minimum and maximum key frame value
  69400. */
  69401. private static calculateMinMaxKeyFrames;
  69402. }
  69403. }
  69404. declare module BABYLON.GLTF2.Exporter {
  69405. /** @hidden */
  69406. export var textureTransformPixelShader: {
  69407. name: string;
  69408. shader: string;
  69409. };
  69410. }
  69411. declare module BABYLON.GLTF2.Exporter.Extensions {
  69412. /**
  69413. * @hidden
  69414. */
  69415. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  69416. /** Name of this extension */
  69417. readonly name: string;
  69418. /** Defines whether this extension is enabled */
  69419. enabled: boolean;
  69420. /** Defines whether this extension is required */
  69421. required: boolean;
  69422. /** Reference to the glTF exporter */
  69423. private _exporter;
  69424. constructor(exporter: _Exporter);
  69425. dispose(): void;
  69426. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  69427. /**
  69428. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  69429. * @param babylonTexture
  69430. * @param offset
  69431. * @param rotation
  69432. * @param scale
  69433. * @param scene
  69434. */
  69435. private _textureTransformTextureAsync;
  69436. }
  69437. }
  69438. declare module BABYLON.GLTF2.Exporter.Extensions {
  69439. /**
  69440. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  69441. */
  69442. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  69443. /** The name of this extension. */
  69444. readonly name: string;
  69445. /** Defines whether this extension is enabled. */
  69446. enabled: boolean;
  69447. /** Defines whether this extension is required */
  69448. required: boolean;
  69449. /** Reference to the glTF exporter */
  69450. private _exporter;
  69451. private _lights;
  69452. /** @hidden */
  69453. constructor(exporter: _Exporter);
  69454. /** @hidden */
  69455. dispose(): void;
  69456. /** @hidden */
  69457. onExporting(): void;
  69458. /**
  69459. * Define this method to modify the default behavior when exporting a node
  69460. * @param context The context when exporting the node
  69461. * @param node glTF node
  69462. * @param babylonNode BabylonJS node
  69463. * @returns nullable INode promise
  69464. */
  69465. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  69466. }
  69467. }
  69468. declare module BABYLON {
  69469. /**
  69470. * Class for generating STL data from a Babylon scene.
  69471. */
  69472. export class STLExport {
  69473. /**
  69474. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  69475. * @param meshes list defines the mesh to serialize
  69476. * @param download triggers the automatic download of the file.
  69477. * @param fileName changes the downloads fileName.
  69478. * @param binary changes the STL to a binary type.
  69479. * @param isLittleEndian toggle for binary type exporter.
  69480. * @returns the STL as UTF8 string
  69481. */
  69482. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  69483. }
  69484. }
  69485. declare module "babylonjs-gltf2interface" {
  69486. export = BABYLON.GLTF2;
  69487. }
  69488. /**
  69489. * Module for glTF 2.0 Interface
  69490. */
  69491. declare module BABYLON.GLTF2 {
  69492. /**
  69493. * The datatype of the components in the attribute
  69494. */
  69495. const enum AccessorComponentType {
  69496. /**
  69497. * Byte
  69498. */
  69499. BYTE = 5120,
  69500. /**
  69501. * Unsigned Byte
  69502. */
  69503. UNSIGNED_BYTE = 5121,
  69504. /**
  69505. * Short
  69506. */
  69507. SHORT = 5122,
  69508. /**
  69509. * Unsigned Short
  69510. */
  69511. UNSIGNED_SHORT = 5123,
  69512. /**
  69513. * Unsigned Int
  69514. */
  69515. UNSIGNED_INT = 5125,
  69516. /**
  69517. * Float
  69518. */
  69519. FLOAT = 5126,
  69520. }
  69521. /**
  69522. * Specifies if the attirbute is a scalar, vector, or matrix
  69523. */
  69524. const enum AccessorType {
  69525. /**
  69526. * Scalar
  69527. */
  69528. SCALAR = "SCALAR",
  69529. /**
  69530. * Vector2
  69531. */
  69532. VEC2 = "VEC2",
  69533. /**
  69534. * Vector3
  69535. */
  69536. VEC3 = "VEC3",
  69537. /**
  69538. * Vector4
  69539. */
  69540. VEC4 = "VEC4",
  69541. /**
  69542. * Matrix2x2
  69543. */
  69544. MAT2 = "MAT2",
  69545. /**
  69546. * Matrix3x3
  69547. */
  69548. MAT3 = "MAT3",
  69549. /**
  69550. * Matrix4x4
  69551. */
  69552. MAT4 = "MAT4",
  69553. }
  69554. /**
  69555. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69556. */
  69557. const enum AnimationChannelTargetPath {
  69558. /**
  69559. * Translation
  69560. */
  69561. TRANSLATION = "translation",
  69562. /**
  69563. * Rotation
  69564. */
  69565. ROTATION = "rotation",
  69566. /**
  69567. * Scale
  69568. */
  69569. SCALE = "scale",
  69570. /**
  69571. * Weights
  69572. */
  69573. WEIGHTS = "weights",
  69574. }
  69575. /**
  69576. * Interpolation algorithm
  69577. */
  69578. const enum AnimationSamplerInterpolation {
  69579. /**
  69580. * The animated values are linearly interpolated between keyframes
  69581. */
  69582. LINEAR = "LINEAR",
  69583. /**
  69584. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  69585. */
  69586. STEP = "STEP",
  69587. /**
  69588. * The animation's interpolation is computed using a cubic spline with specified tangents
  69589. */
  69590. CUBICSPLINE = "CUBICSPLINE",
  69591. }
  69592. /**
  69593. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69594. */
  69595. const enum CameraType {
  69596. /**
  69597. * A perspective camera containing properties to create a perspective projection matrix
  69598. */
  69599. PERSPECTIVE = "perspective",
  69600. /**
  69601. * An orthographic camera containing properties to create an orthographic projection matrix
  69602. */
  69603. ORTHOGRAPHIC = "orthographic",
  69604. }
  69605. /**
  69606. * The mime-type of the image
  69607. */
  69608. const enum ImageMimeType {
  69609. /**
  69610. * JPEG Mime-type
  69611. */
  69612. JPEG = "image/jpeg",
  69613. /**
  69614. * PNG Mime-type
  69615. */
  69616. PNG = "image/png",
  69617. }
  69618. /**
  69619. * The alpha rendering mode of the material
  69620. */
  69621. const enum MaterialAlphaMode {
  69622. /**
  69623. * The alpha value is ignored and the rendered output is fully opaque
  69624. */
  69625. OPAQUE = "OPAQUE",
  69626. /**
  69627. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  69628. */
  69629. MASK = "MASK",
  69630. /**
  69631. * The alpha value is used to composite the source and destination areas. The rendered output is combined with the background using the normal painting operation (i.e. the Porter and Duff over operator)
  69632. */
  69633. BLEND = "BLEND",
  69634. }
  69635. /**
  69636. * The type of the primitives to render
  69637. */
  69638. const enum MeshPrimitiveMode {
  69639. /**
  69640. * Points
  69641. */
  69642. POINTS = 0,
  69643. /**
  69644. * Lines
  69645. */
  69646. LINES = 1,
  69647. /**
  69648. * Line Loop
  69649. */
  69650. LINE_LOOP = 2,
  69651. /**
  69652. * Line Strip
  69653. */
  69654. LINE_STRIP = 3,
  69655. /**
  69656. * Triangles
  69657. */
  69658. TRIANGLES = 4,
  69659. /**
  69660. * Triangle Strip
  69661. */
  69662. TRIANGLE_STRIP = 5,
  69663. /**
  69664. * Triangle Fan
  69665. */
  69666. TRIANGLE_FAN = 6,
  69667. }
  69668. /**
  69669. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  69670. */
  69671. const enum TextureMagFilter {
  69672. /**
  69673. * Nearest
  69674. */
  69675. NEAREST = 9728,
  69676. /**
  69677. * Linear
  69678. */
  69679. LINEAR = 9729,
  69680. }
  69681. /**
  69682. * Minification filter. All valid values correspond to WebGL enums
  69683. */
  69684. const enum TextureMinFilter {
  69685. /**
  69686. * Nearest
  69687. */
  69688. NEAREST = 9728,
  69689. /**
  69690. * Linear
  69691. */
  69692. LINEAR = 9729,
  69693. /**
  69694. * Nearest Mip-Map Nearest
  69695. */
  69696. NEAREST_MIPMAP_NEAREST = 9984,
  69697. /**
  69698. * Linear Mipmap Nearest
  69699. */
  69700. LINEAR_MIPMAP_NEAREST = 9985,
  69701. /**
  69702. * Nearest Mipmap Linear
  69703. */
  69704. NEAREST_MIPMAP_LINEAR = 9986,
  69705. /**
  69706. * Linear Mipmap Linear
  69707. */
  69708. LINEAR_MIPMAP_LINEAR = 9987,
  69709. }
  69710. /**
  69711. * S (U) wrapping mode. All valid values correspond to WebGL enums
  69712. */
  69713. const enum TextureWrapMode {
  69714. /**
  69715. * Clamp to Edge
  69716. */
  69717. CLAMP_TO_EDGE = 33071,
  69718. /**
  69719. * Mirrored Repeat
  69720. */
  69721. MIRRORED_REPEAT = 33648,
  69722. /**
  69723. * Repeat
  69724. */
  69725. REPEAT = 10497,
  69726. }
  69727. /**
  69728. * glTF Property
  69729. */
  69730. interface IProperty {
  69731. /**
  69732. * Dictionary object with extension-specific objects
  69733. */
  69734. extensions?: {
  69735. [key: string]: any;
  69736. };
  69737. /**
  69738. * Application-Specific data
  69739. */
  69740. extras?: any;
  69741. }
  69742. /**
  69743. * glTF Child of Root Property
  69744. */
  69745. interface IChildRootProperty extends IProperty {
  69746. /**
  69747. * The user-defined name of this object
  69748. */
  69749. name?: string;
  69750. }
  69751. /**
  69752. * Indices of those attributes that deviate from their initialization value
  69753. */
  69754. interface IAccessorSparseIndices extends IProperty {
  69755. /**
  69756. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69757. */
  69758. bufferView: number;
  69759. /**
  69760. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69761. */
  69762. byteOffset?: number;
  69763. /**
  69764. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  69765. */
  69766. componentType: AccessorComponentType;
  69767. }
  69768. /**
  69769. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  69770. */
  69771. interface IAccessorSparseValues extends IProperty {
  69772. /**
  69773. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  69774. */
  69775. bufferView: number;
  69776. /**
  69777. * The offset relative to the start of the bufferView in bytes. Must be aligned
  69778. */
  69779. byteOffset?: number;
  69780. }
  69781. /**
  69782. * Sparse storage of attributes that deviate from their initialization value
  69783. */
  69784. interface IAccessorSparse extends IProperty {
  69785. /**
  69786. * The number of attributes encoded in this sparse accessor
  69787. */
  69788. count: number;
  69789. /**
  69790. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  69791. */
  69792. indices: IAccessorSparseIndices;
  69793. /**
  69794. * Array of size count times number of components, storing the displaced accessor attributes pointed by indices. Substituted values must have the same componentType and number of components as the base accessor
  69795. */
  69796. values: IAccessorSparseValues;
  69797. }
  69798. /**
  69799. * A typed view into a bufferView. A bufferView contains raw binary data. An accessor provides a typed view into a bufferView or a subset of a bufferView similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer
  69800. */
  69801. interface IAccessor extends IChildRootProperty {
  69802. /**
  69803. * The index of the bufferview
  69804. */
  69805. bufferView?: number;
  69806. /**
  69807. * The offset relative to the start of the bufferView in bytes
  69808. */
  69809. byteOffset?: number;
  69810. /**
  69811. * The datatype of components in the attribute
  69812. */
  69813. componentType: AccessorComponentType;
  69814. /**
  69815. * Specifies whether integer data values should be normalized
  69816. */
  69817. normalized?: boolean;
  69818. /**
  69819. * The number of attributes referenced by this accessor
  69820. */
  69821. count: number;
  69822. /**
  69823. * Specifies if the attribute is a scalar, vector, or matrix
  69824. */
  69825. type: AccessorType;
  69826. /**
  69827. * Maximum value of each component in this attribute
  69828. */
  69829. max?: number[];
  69830. /**
  69831. * Minimum value of each component in this attribute
  69832. */
  69833. min?: number[];
  69834. /**
  69835. * Sparse storage of attributes that deviate from their initialization value
  69836. */
  69837. sparse?: IAccessorSparse;
  69838. }
  69839. /**
  69840. * Targets an animation's sampler at a node's property
  69841. */
  69842. interface IAnimationChannel extends IProperty {
  69843. /**
  69844. * The index of a sampler in this animation used to compute the value for the target
  69845. */
  69846. sampler: number;
  69847. /**
  69848. * The index of the node and TRS property to target
  69849. */
  69850. target: IAnimationChannelTarget;
  69851. }
  69852. /**
  69853. * The index of the node and TRS property that an animation channel targets
  69854. */
  69855. interface IAnimationChannelTarget extends IProperty {
  69856. /**
  69857. * The index of the node to target
  69858. */
  69859. node: number;
  69860. /**
  69861. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  69862. */
  69863. path: AnimationChannelTargetPath;
  69864. }
  69865. /**
  69866. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69867. */
  69868. interface IAnimationSampler extends IProperty {
  69869. /**
  69870. * The index of an accessor containing keyframe input values, e.g., time
  69871. */
  69872. input: number;
  69873. /**
  69874. * Interpolation algorithm
  69875. */
  69876. interpolation?: AnimationSamplerInterpolation;
  69877. /**
  69878. * The index of an accessor, containing keyframe output values
  69879. */
  69880. output: number;
  69881. }
  69882. /**
  69883. * A keyframe animation
  69884. */
  69885. interface IAnimation extends IChildRootProperty {
  69886. /**
  69887. * An array of channels, each of which targets an animation's sampler at a node's property
  69888. */
  69889. channels: IAnimationChannel[];
  69890. /**
  69891. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  69892. */
  69893. samplers: IAnimationSampler[];
  69894. }
  69895. /**
  69896. * Metadata about the glTF asset
  69897. */
  69898. interface IAsset extends IChildRootProperty {
  69899. /**
  69900. * A copyright message suitable for display to credit the content creator
  69901. */
  69902. copyright?: string;
  69903. /**
  69904. * Tool that generated this glTF model. Useful for debugging
  69905. */
  69906. generator?: string;
  69907. /**
  69908. * The glTF version that this asset targets
  69909. */
  69910. version: string;
  69911. /**
  69912. * The minimum glTF version that this asset targets
  69913. */
  69914. minVersion?: string;
  69915. }
  69916. /**
  69917. * A buffer points to binary geometry, animation, or skins
  69918. */
  69919. interface IBuffer extends IChildRootProperty {
  69920. /**
  69921. * The uri of the buffer. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri
  69922. */
  69923. uri?: string;
  69924. /**
  69925. * The length of the buffer in bytes
  69926. */
  69927. byteLength: number;
  69928. }
  69929. /**
  69930. * A view into a buffer generally representing a subset of the buffer
  69931. */
  69932. interface IBufferView extends IChildRootProperty {
  69933. /**
  69934. * The index of the buffer
  69935. */
  69936. buffer: number;
  69937. /**
  69938. * The offset into the buffer in bytes
  69939. */
  69940. byteOffset?: number;
  69941. /**
  69942. * The lenth of the bufferView in bytes
  69943. */
  69944. byteLength: number;
  69945. /**
  69946. * The stride, in bytes
  69947. */
  69948. byteStride?: number;
  69949. }
  69950. /**
  69951. * An orthographic camera containing properties to create an orthographic projection matrix
  69952. */
  69953. interface ICameraOrthographic extends IProperty {
  69954. /**
  69955. * The floating-point horizontal magnification of the view. Must not be zero
  69956. */
  69957. xmag: number;
  69958. /**
  69959. * The floating-point vertical magnification of the view. Must not be zero
  69960. */
  69961. ymag: number;
  69962. /**
  69963. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  69964. */
  69965. zfar: number;
  69966. /**
  69967. * The floating-point distance to the near clipping plane
  69968. */
  69969. znear: number;
  69970. }
  69971. /**
  69972. * A perspective camera containing properties to create a perspective projection matrix
  69973. */
  69974. interface ICameraPerspective extends IProperty {
  69975. /**
  69976. * The floating-point aspect ratio of the field of view
  69977. */
  69978. aspectRatio?: number;
  69979. /**
  69980. * The floating-point vertical field of view in radians
  69981. */
  69982. yfov: number;
  69983. /**
  69984. * The floating-point distance to the far clipping plane
  69985. */
  69986. zfar?: number;
  69987. /**
  69988. * The floating-point distance to the near clipping plane
  69989. */
  69990. znear: number;
  69991. }
  69992. /**
  69993. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  69994. */
  69995. interface ICamera extends IChildRootProperty {
  69996. /**
  69997. * An orthographic camera containing properties to create an orthographic projection matrix
  69998. */
  69999. orthographic?: ICameraOrthographic;
  70000. /**
  70001. * A perspective camera containing properties to create a perspective projection matrix
  70002. */
  70003. perspective?: ICameraPerspective;
  70004. /**
  70005. * Specifies if the camera uses a perspective or orthographic projection
  70006. */
  70007. type: CameraType;
  70008. }
  70009. /**
  70010. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  70011. */
  70012. interface IImage extends IChildRootProperty {
  70013. /**
  70014. * The uri of the image. Relative paths are relative to the .gltf file. Instead of referencing an external file, the uri can also be a data-uri. The image format must be jpg or png
  70015. */
  70016. uri?: string;
  70017. /**
  70018. * The image's MIME type
  70019. */
  70020. mimeType?: ImageMimeType;
  70021. /**
  70022. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  70023. */
  70024. bufferView?: number;
  70025. }
  70026. /**
  70027. * Material Normal Texture Info
  70028. */
  70029. interface IMaterialNormalTextureInfo extends ITextureInfo {
  70030. /**
  70031. * The scalar multiplier applied to each normal vector of the normal texture
  70032. */
  70033. scale?: number;
  70034. }
  70035. /**
  70036. * Material Occlusion Texture Info
  70037. */
  70038. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  70039. /**
  70040. * A scalar multiplier controlling the amount of occlusion applied
  70041. */
  70042. strength?: number;
  70043. }
  70044. /**
  70045. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  70046. */
  70047. interface IMaterialPbrMetallicRoughness {
  70048. /**
  70049. * The material's base color factor
  70050. */
  70051. baseColorFactor?: number[];
  70052. /**
  70053. * The base color texture
  70054. */
  70055. baseColorTexture?: ITextureInfo;
  70056. /**
  70057. * The metalness of the material
  70058. */
  70059. metallicFactor?: number;
  70060. /**
  70061. * The roughness of the material
  70062. */
  70063. roughnessFactor?: number;
  70064. /**
  70065. * The metallic-roughness texture
  70066. */
  70067. metallicRoughnessTexture?: ITextureInfo;
  70068. }
  70069. /**
  70070. * The material appearance of a primitive
  70071. */
  70072. interface IMaterial extends IChildRootProperty {
  70073. /**
  70074. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of pbrMetallicRoughness apply
  70075. */
  70076. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  70077. /**
  70078. * The normal map texture
  70079. */
  70080. normalTexture?: IMaterialNormalTextureInfo;
  70081. /**
  70082. * The occlusion map texture
  70083. */
  70084. occlusionTexture?: IMaterialOcclusionTextureInfo;
  70085. /**
  70086. * The emissive map texture
  70087. */
  70088. emissiveTexture?: ITextureInfo;
  70089. /**
  70090. * The RGB components of the emissive color of the material. These values are linear. If an emissiveTexture is specified, this value is multiplied with the texel values
  70091. */
  70092. emissiveFactor?: number[];
  70093. /**
  70094. * The alpha rendering mode of the material
  70095. */
  70096. alphaMode?: MaterialAlphaMode;
  70097. /**
  70098. * The alpha cutoff value of the material
  70099. */
  70100. alphaCutoff?: number;
  70101. /**
  70102. * Specifies whether the material is double sided
  70103. */
  70104. doubleSided?: boolean;
  70105. }
  70106. /**
  70107. * Geometry to be rendered with the given material
  70108. */
  70109. interface IMeshPrimitive extends IProperty {
  70110. /**
  70111. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  70112. */
  70113. attributes: {
  70114. [name: string]: number;
  70115. };
  70116. /**
  70117. * The index of the accessor that contains the indices
  70118. */
  70119. indices?: number;
  70120. /**
  70121. * The index of the material to apply to this primitive when rendering
  70122. */
  70123. material?: number;
  70124. /**
  70125. * The type of primitives to render. All valid values correspond to WebGL enums
  70126. */
  70127. mode?: MeshPrimitiveMode;
  70128. /**
  70129. * An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only POSITION, NORMAL, and TANGENT supported) to their deviations in the Morph Target
  70130. */
  70131. targets?: {
  70132. [name: string]: number;
  70133. }[];
  70134. }
  70135. /**
  70136. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  70137. */
  70138. interface IMesh extends IChildRootProperty {
  70139. /**
  70140. * An array of primitives, each defining geometry to be rendered with a material
  70141. */
  70142. primitives: IMeshPrimitive[];
  70143. /**
  70144. * Array of weights to be applied to the Morph Targets
  70145. */
  70146. weights?: number[];
  70147. }
  70148. /**
  70149. * A node in the node hierarchy
  70150. */
  70151. interface INode extends IChildRootProperty {
  70152. /**
  70153. * The index of the camera referenced by this node
  70154. */
  70155. camera?: number;
  70156. /**
  70157. * The indices of this node's children
  70158. */
  70159. children?: number[];
  70160. /**
  70161. * The index of the skin referenced by this node
  70162. */
  70163. skin?: number;
  70164. /**
  70165. * A floating-point 4x4 transformation matrix stored in column-major order
  70166. */
  70167. matrix?: number[];
  70168. /**
  70169. * The index of the mesh in this node
  70170. */
  70171. mesh?: number;
  70172. /**
  70173. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  70174. */
  70175. rotation?: number[];
  70176. /**
  70177. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  70178. */
  70179. scale?: number[];
  70180. /**
  70181. * The node's translation along the x, y, and z axes
  70182. */
  70183. translation?: number[];
  70184. /**
  70185. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  70186. */
  70187. weights?: number[];
  70188. }
  70189. /**
  70190. * Texture sampler properties for filtering and wrapping modes
  70191. */
  70192. interface ISampler extends IChildRootProperty {
  70193. /**
  70194. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  70195. */
  70196. magFilter?: TextureMagFilter;
  70197. /**
  70198. * Minification filter. All valid values correspond to WebGL enums
  70199. */
  70200. minFilter?: TextureMinFilter;
  70201. /**
  70202. * S (U) wrapping mode. All valid values correspond to WebGL enums
  70203. */
  70204. wrapS?: TextureWrapMode;
  70205. /**
  70206. * T (V) wrapping mode. All valid values correspond to WebGL enums
  70207. */
  70208. wrapT?: TextureWrapMode;
  70209. }
  70210. /**
  70211. * The root nodes of a scene
  70212. */
  70213. interface IScene extends IChildRootProperty {
  70214. /**
  70215. * The indices of each root node
  70216. */
  70217. nodes: number[];
  70218. }
  70219. /**
  70220. * Joints and matrices defining a skin
  70221. */
  70222. interface ISkin extends IChildRootProperty {
  70223. /**
  70224. * The index of the accessor containing the floating-point 4x4 inverse-bind matrices. The default is that each matrix is a 4x4 identity matrix, which implies that inverse-bind matrices were pre-applied
  70225. */
  70226. inverseBindMatrices?: number;
  70227. /**
  70228. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  70229. */
  70230. skeleton?: number;
  70231. /**
  70232. * Indices of skeleton nodes, used as joints in this skin. The array length must be the same as the count property of the inverseBindMatrices accessor (when defined)
  70233. */
  70234. joints: number[];
  70235. }
  70236. /**
  70237. * A texture and its sampler
  70238. */
  70239. interface ITexture extends IChildRootProperty {
  70240. /**
  70241. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  70242. */
  70243. sampler?: number;
  70244. /**
  70245. * The index of the image used by this texture
  70246. */
  70247. source: number;
  70248. }
  70249. /**
  70250. * Reference to a texture
  70251. */
  70252. interface ITextureInfo extends IProperty {
  70253. /**
  70254. * The index of the texture
  70255. */
  70256. index: number;
  70257. /**
  70258. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  70259. */
  70260. texCoord?: number;
  70261. }
  70262. /**
  70263. * The root object for a glTF asset
  70264. */
  70265. interface IGLTF extends IProperty {
  70266. /**
  70267. * An array of accessors. An accessor is a typed view into a bufferView
  70268. */
  70269. accessors?: IAccessor[];
  70270. /**
  70271. * An array of keyframe animations
  70272. */
  70273. animations?: IAnimation[];
  70274. /**
  70275. * Metadata about the glTF asset
  70276. */
  70277. asset: IAsset;
  70278. /**
  70279. * An array of buffers. A buffer points to binary geometry, animation, or skins
  70280. */
  70281. buffers?: IBuffer[];
  70282. /**
  70283. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  70284. */
  70285. bufferViews?: IBufferView[];
  70286. /**
  70287. * An array of cameras
  70288. */
  70289. cameras?: ICamera[];
  70290. /**
  70291. * Names of glTF extensions used somewhere in this asset
  70292. */
  70293. extensionsUsed?: string[];
  70294. /**
  70295. * Names of glTF extensions required to properly load this asset
  70296. */
  70297. extensionsRequired?: string[];
  70298. /**
  70299. * An array of images. An image defines data used to create a texture
  70300. */
  70301. images?: IImage[];
  70302. /**
  70303. * An array of materials. A material defines the appearance of a primitive
  70304. */
  70305. materials?: IMaterial[];
  70306. /**
  70307. * An array of meshes. A mesh is a set of primitives to be rendered
  70308. */
  70309. meshes?: IMesh[];
  70310. /**
  70311. * An array of nodes
  70312. */
  70313. nodes?: INode[];
  70314. /**
  70315. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  70316. */
  70317. samplers?: ISampler[];
  70318. /**
  70319. * The index of the default scene
  70320. */
  70321. scene?: number;
  70322. /**
  70323. * An array of scenes
  70324. */
  70325. scenes?: IScene[];
  70326. /**
  70327. * An array of skins. A skin is defined by joints and matrices
  70328. */
  70329. skins?: ISkin[];
  70330. /**
  70331. * An array of textures
  70332. */
  70333. textures?: ITexture[];
  70334. }
  70335. /**
  70336. * The glTF validation results
  70337. * @ignore
  70338. */
  70339. interface IGLTFValidationResults {
  70340. info: {
  70341. generator: string;
  70342. hasAnimations: boolean;
  70343. hasDefaultScene: boolean;
  70344. hasMaterials: boolean;
  70345. hasMorphTargets: boolean;
  70346. hasSkins: boolean;
  70347. hasTextures: boolean;
  70348. maxAttributesUsed: number;
  70349. primitivesCount: number
  70350. };
  70351. issues: {
  70352. messages: Array<string>;
  70353. numErrors: number;
  70354. numHints: number;
  70355. numInfos: number;
  70356. numWarnings: number;
  70357. truncated: boolean
  70358. };
  70359. mimeType: string;
  70360. uri: string;
  70361. validatedAt: string;
  70362. validatorVersion: string;
  70363. }
  70364. /**
  70365. * The glTF validation options
  70366. */
  70367. interface IGLTFValidationOptions {
  70368. /** Uri to use */
  70369. uri?: string;
  70370. /** Function used to load external resources */
  70371. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  70372. /** Boolean indicating that we need to validate accessor data */
  70373. validateAccessorData?: boolean;
  70374. /** max number of issues allowed */
  70375. maxIssues?: number;
  70376. /** Ignored issues */
  70377. ignoredIssues?: Array<string>;
  70378. /** Value to override severy settings */
  70379. severityOverrides?: Object;
  70380. }
  70381. /**
  70382. * The glTF validator object
  70383. * @ignore
  70384. */
  70385. interface IGLTFValidator {
  70386. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70387. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  70388. }
  70389. }
  70390. declare module BABYLON {
  70391. /** @hidden */
  70392. export var cellPixelShader: {
  70393. name: string;
  70394. shader: string;
  70395. };
  70396. }
  70397. declare module BABYLON {
  70398. /** @hidden */
  70399. export var cellVertexShader: {
  70400. name: string;
  70401. shader: string;
  70402. };
  70403. }
  70404. declare module BABYLON {
  70405. export class CellMaterial extends BABYLON.PushMaterial {
  70406. private _diffuseTexture;
  70407. diffuseTexture: BABYLON.BaseTexture;
  70408. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  70409. computeHighLevel: boolean;
  70410. private _disableLighting;
  70411. disableLighting: boolean;
  70412. private _maxSimultaneousLights;
  70413. maxSimultaneousLights: number;
  70414. private _renderId;
  70415. constructor(name: string, scene: BABYLON.Scene);
  70416. needAlphaBlending(): boolean;
  70417. needAlphaTesting(): boolean;
  70418. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70419. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70420. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70421. getAnimatables(): BABYLON.IAnimatable[];
  70422. getActiveTextures(): BABYLON.BaseTexture[];
  70423. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70424. dispose(forceDisposeEffect?: boolean): void;
  70425. getClassName(): string;
  70426. clone(name: string): CellMaterial;
  70427. serialize(): any;
  70428. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  70429. }
  70430. }
  70431. declare module BABYLON {
  70432. export class CustomShaderStructure {
  70433. FragmentStore: string;
  70434. VertexStore: string;
  70435. constructor();
  70436. }
  70437. export class ShaderSpecialParts {
  70438. constructor();
  70439. Fragment_Begin: string;
  70440. Fragment_Definitions: string;
  70441. Fragment_MainBegin: string;
  70442. Fragment_Custom_Diffuse: string;
  70443. Fragment_Before_Lights: string;
  70444. Fragment_Before_Fog: string;
  70445. Fragment_Custom_Alpha: string;
  70446. Fragment_Before_FragColor: string;
  70447. Vertex_Begin: string;
  70448. Vertex_Definitions: string;
  70449. Vertex_MainBegin: string;
  70450. Vertex_Before_PositionUpdated: string;
  70451. Vertex_Before_NormalUpdated: string;
  70452. Vertex_MainEnd: string;
  70453. }
  70454. export class CustomMaterial extends BABYLON.StandardMaterial {
  70455. static ShaderIndexer: number;
  70456. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  70457. FragmentShader: string;
  70458. VertexShader: string;
  70459. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70460. ReviewUniform(name: string, arr: string[]): string[];
  70461. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  70462. constructor(name: string, scene: BABYLON.Scene);
  70463. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  70464. Fragment_Begin(shaderPart: string): CustomMaterial;
  70465. Fragment_Definitions(shaderPart: string): CustomMaterial;
  70466. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  70467. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  70468. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  70469. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  70470. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  70471. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  70472. Vertex_Begin(shaderPart: string): CustomMaterial;
  70473. Vertex_Definitions(shaderPart: string): CustomMaterial;
  70474. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  70475. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  70476. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  70477. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  70478. }
  70479. }
  70480. declare module BABYLON {
  70481. export class ShaderAlebdoParts {
  70482. constructor();
  70483. Fragment_Begin: string;
  70484. Fragment_Definitions: string;
  70485. Fragment_MainBegin: string;
  70486. Fragment_Custom_Albedo: string;
  70487. Fragment_Before_Lights: string;
  70488. Fragment_Custom_MetallicRoughness: string;
  70489. Fragment_Custom_MicroSurface: string;
  70490. Fragment_Before_Fog: string;
  70491. Fragment_Custom_Alpha: string;
  70492. Fragment_Before_FragColor: string;
  70493. Vertex_Begin: string;
  70494. Vertex_Definitions: string;
  70495. Vertex_MainBegin: string;
  70496. Vertex_Before_PositionUpdated: string;
  70497. Vertex_Before_NormalUpdated: string;
  70498. Vertex_MainEnd: string;
  70499. }
  70500. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  70501. static ShaderIndexer: number;
  70502. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  70503. FragmentShader: string;
  70504. VertexShader: string;
  70505. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  70506. ReviewUniform(name: string, arr: string[]): string[];
  70507. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  70508. constructor(name: string, scene: BABYLON.Scene);
  70509. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  70510. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  70511. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  70512. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  70513. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  70514. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  70515. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  70516. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  70517. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  70518. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  70519. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  70520. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  70521. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  70522. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  70523. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  70524. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  70525. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  70526. }
  70527. }
  70528. declare module BABYLON {
  70529. /** @hidden */
  70530. export var firePixelShader: {
  70531. name: string;
  70532. shader: string;
  70533. };
  70534. }
  70535. declare module BABYLON {
  70536. /** @hidden */
  70537. export var fireVertexShader: {
  70538. name: string;
  70539. shader: string;
  70540. };
  70541. }
  70542. declare module BABYLON {
  70543. export class FireMaterial extends BABYLON.PushMaterial {
  70544. private _diffuseTexture;
  70545. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70546. private _distortionTexture;
  70547. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70548. private _opacityTexture;
  70549. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  70550. diffuseColor: BABYLON.Color3;
  70551. speed: number;
  70552. private _scaledDiffuse;
  70553. private _renderId;
  70554. private _lastTime;
  70555. constructor(name: string, scene: BABYLON.Scene);
  70556. needAlphaBlending(): boolean;
  70557. needAlphaTesting(): boolean;
  70558. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70559. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70560. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70561. getAnimatables(): BABYLON.IAnimatable[];
  70562. getActiveTextures(): BABYLON.BaseTexture[];
  70563. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70564. getClassName(): string;
  70565. dispose(forceDisposeEffect?: boolean): void;
  70566. clone(name: string): FireMaterial;
  70567. serialize(): any;
  70568. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  70569. }
  70570. }
  70571. declare module BABYLON {
  70572. /** @hidden */
  70573. export var furPixelShader: {
  70574. name: string;
  70575. shader: string;
  70576. };
  70577. }
  70578. declare module BABYLON {
  70579. /** @hidden */
  70580. export var furVertexShader: {
  70581. name: string;
  70582. shader: string;
  70583. };
  70584. }
  70585. declare module BABYLON {
  70586. export class FurMaterial extends BABYLON.PushMaterial {
  70587. private _diffuseTexture;
  70588. diffuseTexture: BABYLON.BaseTexture;
  70589. private _heightTexture;
  70590. heightTexture: BABYLON.BaseTexture;
  70591. diffuseColor: BABYLON.Color3;
  70592. furLength: number;
  70593. furAngle: number;
  70594. furColor: BABYLON.Color3;
  70595. furOffset: number;
  70596. furSpacing: number;
  70597. furGravity: BABYLON.Vector3;
  70598. furSpeed: number;
  70599. furDensity: number;
  70600. furOcclusion: number;
  70601. furTexture: BABYLON.DynamicTexture;
  70602. private _disableLighting;
  70603. disableLighting: boolean;
  70604. private _maxSimultaneousLights;
  70605. maxSimultaneousLights: number;
  70606. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  70607. private _renderId;
  70608. private _furTime;
  70609. constructor(name: string, scene: BABYLON.Scene);
  70610. furTime: number;
  70611. needAlphaBlending(): boolean;
  70612. needAlphaTesting(): boolean;
  70613. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70614. updateFur(): void;
  70615. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70616. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70617. getAnimatables(): BABYLON.IAnimatable[];
  70618. getActiveTextures(): BABYLON.BaseTexture[];
  70619. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70620. dispose(forceDisposeEffect?: boolean): void;
  70621. clone(name: string): FurMaterial;
  70622. serialize(): any;
  70623. getClassName(): string;
  70624. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  70625. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  70626. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  70627. }
  70628. }
  70629. declare module BABYLON {
  70630. /** @hidden */
  70631. export var gradientPixelShader: {
  70632. name: string;
  70633. shader: string;
  70634. };
  70635. }
  70636. declare module BABYLON {
  70637. /** @hidden */
  70638. export var gradientVertexShader: {
  70639. name: string;
  70640. shader: string;
  70641. };
  70642. }
  70643. declare module BABYLON {
  70644. export class GradientMaterial extends BABYLON.PushMaterial {
  70645. private _maxSimultaneousLights;
  70646. maxSimultaneousLights: number;
  70647. topColor: BABYLON.Color3;
  70648. topColorAlpha: number;
  70649. bottomColor: BABYLON.Color3;
  70650. bottomColorAlpha: number;
  70651. offset: number;
  70652. scale: number;
  70653. smoothness: number;
  70654. private _disableLighting;
  70655. disableLighting: boolean;
  70656. private _renderId;
  70657. constructor(name: string, scene: BABYLON.Scene);
  70658. needAlphaBlending(): boolean;
  70659. needAlphaTesting(): boolean;
  70660. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70661. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70662. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70663. getAnimatables(): BABYLON.IAnimatable[];
  70664. dispose(forceDisposeEffect?: boolean): void;
  70665. clone(name: string): GradientMaterial;
  70666. serialize(): any;
  70667. getClassName(): string;
  70668. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  70669. }
  70670. }
  70671. declare module BABYLON {
  70672. /** @hidden */
  70673. export var gridPixelShader: {
  70674. name: string;
  70675. shader: string;
  70676. };
  70677. }
  70678. declare module BABYLON {
  70679. /** @hidden */
  70680. export var gridVertexShader: {
  70681. name: string;
  70682. shader: string;
  70683. };
  70684. }
  70685. declare module BABYLON {
  70686. /**
  70687. * The grid materials allows you to wrap any shape with a grid.
  70688. * Colors are customizable.
  70689. */
  70690. export class GridMaterial extends BABYLON.PushMaterial {
  70691. /**
  70692. * Main color of the grid (e.g. between lines)
  70693. */
  70694. mainColor: BABYLON.Color3;
  70695. /**
  70696. * Color of the grid lines.
  70697. */
  70698. lineColor: BABYLON.Color3;
  70699. /**
  70700. * The scale of the grid compared to unit.
  70701. */
  70702. gridRatio: number;
  70703. /**
  70704. * Allows setting an offset for the grid lines.
  70705. */
  70706. gridOffset: BABYLON.Vector3;
  70707. /**
  70708. * The frequency of thicker lines.
  70709. */
  70710. majorUnitFrequency: number;
  70711. /**
  70712. * The visibility of minor units in the grid.
  70713. */
  70714. minorUnitVisibility: number;
  70715. /**
  70716. * The grid opacity outside of the lines.
  70717. */
  70718. opacity: number;
  70719. /**
  70720. * Determine RBG output is premultiplied by alpha value.
  70721. */
  70722. preMultiplyAlpha: boolean;
  70723. private _opacityTexture;
  70724. opacityTexture: BABYLON.BaseTexture;
  70725. private _gridControl;
  70726. private _renderId;
  70727. /**
  70728. * constructor
  70729. * @param name The name given to the material in order to identify it afterwards.
  70730. * @param scene The scene the material is used in.
  70731. */
  70732. constructor(name: string, scene: BABYLON.Scene);
  70733. /**
  70734. * Returns wehter or not the grid requires alpha blending.
  70735. */
  70736. needAlphaBlending(): boolean;
  70737. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70738. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70739. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70740. /**
  70741. * Dispose the material and its associated resources.
  70742. * @param forceDisposeEffect will also dispose the used effect when true
  70743. */
  70744. dispose(forceDisposeEffect?: boolean): void;
  70745. clone(name: string): GridMaterial;
  70746. serialize(): any;
  70747. getClassName(): string;
  70748. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  70749. }
  70750. }
  70751. declare module BABYLON {
  70752. /** @hidden */
  70753. export var lavaPixelShader: {
  70754. name: string;
  70755. shader: string;
  70756. };
  70757. }
  70758. declare module BABYLON {
  70759. /** @hidden */
  70760. export var lavaVertexShader: {
  70761. name: string;
  70762. shader: string;
  70763. };
  70764. }
  70765. declare module BABYLON {
  70766. export class LavaMaterial extends BABYLON.PushMaterial {
  70767. private _diffuseTexture;
  70768. diffuseTexture: BABYLON.BaseTexture;
  70769. noiseTexture: BABYLON.BaseTexture;
  70770. fogColor: BABYLON.Color3;
  70771. speed: number;
  70772. movingSpeed: number;
  70773. lowFrequencySpeed: number;
  70774. fogDensity: number;
  70775. private _lastTime;
  70776. diffuseColor: BABYLON.Color3;
  70777. private _disableLighting;
  70778. disableLighting: boolean;
  70779. private _unlit;
  70780. unlit: boolean;
  70781. private _maxSimultaneousLights;
  70782. maxSimultaneousLights: number;
  70783. private _scaledDiffuse;
  70784. private _renderId;
  70785. constructor(name: string, scene: BABYLON.Scene);
  70786. needAlphaBlending(): boolean;
  70787. needAlphaTesting(): boolean;
  70788. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70789. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70790. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70791. getAnimatables(): BABYLON.IAnimatable[];
  70792. getActiveTextures(): BABYLON.BaseTexture[];
  70793. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70794. dispose(forceDisposeEffect?: boolean): void;
  70795. clone(name: string): LavaMaterial;
  70796. serialize(): any;
  70797. getClassName(): string;
  70798. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  70799. }
  70800. }
  70801. declare module BABYLON {
  70802. /** @hidden */
  70803. export var mixPixelShader: {
  70804. name: string;
  70805. shader: string;
  70806. };
  70807. }
  70808. declare module BABYLON {
  70809. /** @hidden */
  70810. export var mixVertexShader: {
  70811. name: string;
  70812. shader: string;
  70813. };
  70814. }
  70815. declare module BABYLON {
  70816. export class MixMaterial extends BABYLON.PushMaterial {
  70817. /**
  70818. * Mix textures
  70819. */
  70820. private _mixTexture1;
  70821. mixTexture1: BABYLON.BaseTexture;
  70822. private _mixTexture2;
  70823. mixTexture2: BABYLON.BaseTexture;
  70824. /**
  70825. * Diffuse textures
  70826. */
  70827. private _diffuseTexture1;
  70828. diffuseTexture1: BABYLON.Texture;
  70829. private _diffuseTexture2;
  70830. diffuseTexture2: BABYLON.Texture;
  70831. private _diffuseTexture3;
  70832. diffuseTexture3: BABYLON.Texture;
  70833. private _diffuseTexture4;
  70834. diffuseTexture4: BABYLON.Texture;
  70835. private _diffuseTexture5;
  70836. diffuseTexture5: BABYLON.Texture;
  70837. private _diffuseTexture6;
  70838. diffuseTexture6: BABYLON.Texture;
  70839. private _diffuseTexture7;
  70840. diffuseTexture7: BABYLON.Texture;
  70841. private _diffuseTexture8;
  70842. diffuseTexture8: BABYLON.Texture;
  70843. /**
  70844. * Uniforms
  70845. */
  70846. diffuseColor: BABYLON.Color3;
  70847. specularColor: BABYLON.Color3;
  70848. specularPower: number;
  70849. private _disableLighting;
  70850. disableLighting: boolean;
  70851. private _maxSimultaneousLights;
  70852. maxSimultaneousLights: number;
  70853. private _renderId;
  70854. constructor(name: string, scene: BABYLON.Scene);
  70855. needAlphaBlending(): boolean;
  70856. needAlphaTesting(): boolean;
  70857. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70858. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70859. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70860. getAnimatables(): BABYLON.IAnimatable[];
  70861. getActiveTextures(): BABYLON.BaseTexture[];
  70862. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70863. dispose(forceDisposeEffect?: boolean): void;
  70864. clone(name: string): MixMaterial;
  70865. serialize(): any;
  70866. getClassName(): string;
  70867. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  70868. }
  70869. }
  70870. declare module BABYLON {
  70871. /** @hidden */
  70872. export var normalPixelShader: {
  70873. name: string;
  70874. shader: string;
  70875. };
  70876. }
  70877. declare module BABYLON {
  70878. /** @hidden */
  70879. export var normalVertexShader: {
  70880. name: string;
  70881. shader: string;
  70882. };
  70883. }
  70884. declare module BABYLON {
  70885. export class NormalMaterial extends BABYLON.PushMaterial {
  70886. private _diffuseTexture;
  70887. diffuseTexture: BABYLON.BaseTexture;
  70888. diffuseColor: BABYLON.Color3;
  70889. private _disableLighting;
  70890. disableLighting: boolean;
  70891. private _maxSimultaneousLights;
  70892. maxSimultaneousLights: number;
  70893. private _renderId;
  70894. constructor(name: string, scene: BABYLON.Scene);
  70895. needAlphaBlending(): boolean;
  70896. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  70897. needAlphaTesting(): boolean;
  70898. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70899. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70900. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70901. getAnimatables(): BABYLON.IAnimatable[];
  70902. getActiveTextures(): BABYLON.BaseTexture[];
  70903. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70904. dispose(forceDisposeEffect?: boolean): void;
  70905. clone(name: string): NormalMaterial;
  70906. serialize(): any;
  70907. getClassName(): string;
  70908. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  70909. }
  70910. }
  70911. declare module BABYLON {
  70912. /** @hidden */
  70913. export var shadowOnlyPixelShader: {
  70914. name: string;
  70915. shader: string;
  70916. };
  70917. }
  70918. declare module BABYLON {
  70919. /** @hidden */
  70920. export var shadowOnlyVertexShader: {
  70921. name: string;
  70922. shader: string;
  70923. };
  70924. }
  70925. declare module BABYLON {
  70926. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  70927. private _renderId;
  70928. private _activeLight;
  70929. constructor(name: string, scene: BABYLON.Scene);
  70930. shadowColor: BABYLON.Color3;
  70931. needAlphaBlending(): boolean;
  70932. needAlphaTesting(): boolean;
  70933. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70934. activeLight: BABYLON.IShadowLight;
  70935. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70936. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70937. clone(name: string): ShadowOnlyMaterial;
  70938. serialize(): any;
  70939. getClassName(): string;
  70940. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  70941. }
  70942. }
  70943. declare module BABYLON {
  70944. /** @hidden */
  70945. export var simplePixelShader: {
  70946. name: string;
  70947. shader: string;
  70948. };
  70949. }
  70950. declare module BABYLON {
  70951. /** @hidden */
  70952. export var simpleVertexShader: {
  70953. name: string;
  70954. shader: string;
  70955. };
  70956. }
  70957. declare module BABYLON {
  70958. export class SimpleMaterial extends BABYLON.PushMaterial {
  70959. private _diffuseTexture;
  70960. diffuseTexture: BABYLON.BaseTexture;
  70961. diffuseColor: BABYLON.Color3;
  70962. private _disableLighting;
  70963. disableLighting: boolean;
  70964. private _maxSimultaneousLights;
  70965. maxSimultaneousLights: number;
  70966. private _renderId;
  70967. constructor(name: string, scene: BABYLON.Scene);
  70968. needAlphaBlending(): boolean;
  70969. needAlphaTesting(): boolean;
  70970. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  70971. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  70972. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  70973. getAnimatables(): BABYLON.IAnimatable[];
  70974. getActiveTextures(): BABYLON.BaseTexture[];
  70975. hasTexture(texture: BABYLON.BaseTexture): boolean;
  70976. dispose(forceDisposeEffect?: boolean): void;
  70977. clone(name: string): SimpleMaterial;
  70978. serialize(): any;
  70979. getClassName(): string;
  70980. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  70981. }
  70982. }
  70983. declare module BABYLON {
  70984. /** @hidden */
  70985. export var skyPixelShader: {
  70986. name: string;
  70987. shader: string;
  70988. };
  70989. }
  70990. declare module BABYLON {
  70991. /** @hidden */
  70992. export var skyVertexShader: {
  70993. name: string;
  70994. shader: string;
  70995. };
  70996. }
  70997. declare module BABYLON {
  70998. /**
  70999. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  71000. * @see https://doc.babylonjs.com/extensions/sky
  71001. */
  71002. export class SkyMaterial extends BABYLON.PushMaterial {
  71003. /**
  71004. * Defines the overall luminance of sky in interval ]0, 1[.
  71005. */
  71006. luminance: number;
  71007. /**
  71008. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  71009. */
  71010. turbidity: number;
  71011. /**
  71012. * Defines the sky appearance (light intensity).
  71013. */
  71014. rayleigh: number;
  71015. /**
  71016. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  71017. */
  71018. mieCoefficient: number;
  71019. /**
  71020. * Defines the amount of haze particles following the Mie scattering theory.
  71021. */
  71022. mieDirectionalG: number;
  71023. /**
  71024. * Defines the distance of the sun according to the active scene camera.
  71025. */
  71026. distance: number;
  71027. /**
  71028. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  71029. * "inclined".
  71030. */
  71031. inclination: number;
  71032. /**
  71033. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  71034. * an object direction and a reference direction.
  71035. */
  71036. azimuth: number;
  71037. /**
  71038. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  71039. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  71040. */
  71041. sunPosition: BABYLON.Vector3;
  71042. /**
  71043. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  71044. * .sunPosition property.
  71045. */
  71046. useSunPosition: boolean;
  71047. /**
  71048. * Defines an offset vector used to get a horizon offset.
  71049. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  71050. */
  71051. cameraOffset: BABYLON.Vector3;
  71052. private _cameraPosition;
  71053. private _renderId;
  71054. /**
  71055. * Instantiates a new sky material.
  71056. * This material allows to create dynamic and texture free
  71057. * effects for skyboxes by taking care of the atmosphere state.
  71058. * @see https://doc.babylonjs.com/extensions/sky
  71059. * @param name Define the name of the material in the scene
  71060. * @param scene Define the scene the material belong to
  71061. */
  71062. constructor(name: string, scene: BABYLON.Scene);
  71063. /**
  71064. * Specifies if the material will require alpha blending
  71065. * @returns a boolean specifying if alpha blending is needed
  71066. */
  71067. needAlphaBlending(): boolean;
  71068. /**
  71069. * Specifies if this material should be rendered in alpha test mode
  71070. * @returns false as the sky material doesn't need alpha testing.
  71071. */
  71072. needAlphaTesting(): boolean;
  71073. /**
  71074. * Get the texture used for alpha test purpose.
  71075. * @returns null as the sky material has no texture.
  71076. */
  71077. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71078. /**
  71079. * Get if the submesh is ready to be used and all its information available.
  71080. * Child classes can use it to update shaders
  71081. * @param mesh defines the mesh to check
  71082. * @param subMesh defines which submesh to check
  71083. * @param useInstances specifies that instances should be used
  71084. * @returns a boolean indicating that the submesh is ready or not
  71085. */
  71086. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71087. /**
  71088. * Binds the submesh to this material by preparing the effect and shader to draw
  71089. * @param world defines the world transformation matrix
  71090. * @param mesh defines the mesh containing the submesh
  71091. * @param subMesh defines the submesh to bind the material to
  71092. */
  71093. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71094. /**
  71095. * Get the list of animatables in the material.
  71096. * @returns the list of animatables object used in the material
  71097. */
  71098. getAnimatables(): BABYLON.IAnimatable[];
  71099. /**
  71100. * Disposes the material
  71101. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  71102. */
  71103. dispose(forceDisposeEffect?: boolean): void;
  71104. /**
  71105. * Makes a duplicate of the material, and gives it a new name
  71106. * @param name defines the new name for the duplicated material
  71107. * @returns the cloned material
  71108. */
  71109. clone(name: string): SkyMaterial;
  71110. /**
  71111. * Serializes this material in a JSON representation
  71112. * @returns the serialized material object
  71113. */
  71114. serialize(): any;
  71115. /**
  71116. * Gets the current class name of the material e.g. "SkyMaterial"
  71117. * Mainly use in serialization.
  71118. * @returns the class name
  71119. */
  71120. getClassName(): string;
  71121. /**
  71122. * Creates a sky material from parsed material data
  71123. * @param source defines the JSON representation of the material
  71124. * @param scene defines the hosting scene
  71125. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71126. * @returns a new sky material
  71127. */
  71128. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  71129. }
  71130. }
  71131. declare module BABYLON {
  71132. /** @hidden */
  71133. export var terrainPixelShader: {
  71134. name: string;
  71135. shader: string;
  71136. };
  71137. }
  71138. declare module BABYLON {
  71139. /** @hidden */
  71140. export var terrainVertexShader: {
  71141. name: string;
  71142. shader: string;
  71143. };
  71144. }
  71145. declare module BABYLON {
  71146. export class TerrainMaterial extends BABYLON.PushMaterial {
  71147. private _mixTexture;
  71148. mixTexture: BABYLON.BaseTexture;
  71149. private _diffuseTexture1;
  71150. diffuseTexture1: BABYLON.Texture;
  71151. private _diffuseTexture2;
  71152. diffuseTexture2: BABYLON.Texture;
  71153. private _diffuseTexture3;
  71154. diffuseTexture3: BABYLON.Texture;
  71155. private _bumpTexture1;
  71156. bumpTexture1: BABYLON.Texture;
  71157. private _bumpTexture2;
  71158. bumpTexture2: BABYLON.Texture;
  71159. private _bumpTexture3;
  71160. bumpTexture3: BABYLON.Texture;
  71161. diffuseColor: BABYLON.Color3;
  71162. specularColor: BABYLON.Color3;
  71163. specularPower: number;
  71164. private _disableLighting;
  71165. disableLighting: boolean;
  71166. private _maxSimultaneousLights;
  71167. maxSimultaneousLights: number;
  71168. private _renderId;
  71169. constructor(name: string, scene: BABYLON.Scene);
  71170. needAlphaBlending(): boolean;
  71171. needAlphaTesting(): boolean;
  71172. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71173. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71174. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71175. getAnimatables(): BABYLON.IAnimatable[];
  71176. getActiveTextures(): BABYLON.BaseTexture[];
  71177. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71178. dispose(forceDisposeEffect?: boolean): void;
  71179. clone(name: string): TerrainMaterial;
  71180. serialize(): any;
  71181. getClassName(): string;
  71182. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  71183. }
  71184. }
  71185. declare module BABYLON {
  71186. /** @hidden */
  71187. export var triplanarPixelShader: {
  71188. name: string;
  71189. shader: string;
  71190. };
  71191. }
  71192. declare module BABYLON {
  71193. /** @hidden */
  71194. export var triplanarVertexShader: {
  71195. name: string;
  71196. shader: string;
  71197. };
  71198. }
  71199. declare module BABYLON {
  71200. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  71201. mixTexture: BABYLON.BaseTexture;
  71202. private _diffuseTextureX;
  71203. diffuseTextureX: BABYLON.BaseTexture;
  71204. private _diffuseTextureY;
  71205. diffuseTextureY: BABYLON.BaseTexture;
  71206. private _diffuseTextureZ;
  71207. diffuseTextureZ: BABYLON.BaseTexture;
  71208. private _normalTextureX;
  71209. normalTextureX: BABYLON.BaseTexture;
  71210. private _normalTextureY;
  71211. normalTextureY: BABYLON.BaseTexture;
  71212. private _normalTextureZ;
  71213. normalTextureZ: BABYLON.BaseTexture;
  71214. tileSize: number;
  71215. diffuseColor: BABYLON.Color3;
  71216. specularColor: BABYLON.Color3;
  71217. specularPower: number;
  71218. private _disableLighting;
  71219. disableLighting: boolean;
  71220. private _maxSimultaneousLights;
  71221. maxSimultaneousLights: number;
  71222. private _renderId;
  71223. constructor(name: string, scene: BABYLON.Scene);
  71224. needAlphaBlending(): boolean;
  71225. needAlphaTesting(): boolean;
  71226. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71227. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71228. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71229. getAnimatables(): BABYLON.IAnimatable[];
  71230. getActiveTextures(): BABYLON.BaseTexture[];
  71231. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71232. dispose(forceDisposeEffect?: boolean): void;
  71233. clone(name: string): TriPlanarMaterial;
  71234. serialize(): any;
  71235. getClassName(): string;
  71236. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  71237. }
  71238. }
  71239. declare module BABYLON {
  71240. /** @hidden */
  71241. export var waterPixelShader: {
  71242. name: string;
  71243. shader: string;
  71244. };
  71245. }
  71246. declare module BABYLON {
  71247. /** @hidden */
  71248. export var waterVertexShader: {
  71249. name: string;
  71250. shader: string;
  71251. };
  71252. }
  71253. declare module BABYLON {
  71254. export class WaterMaterial extends BABYLON.PushMaterial {
  71255. renderTargetSize: BABYLON.Vector2;
  71256. private _bumpTexture;
  71257. bumpTexture: BABYLON.BaseTexture;
  71258. diffuseColor: BABYLON.Color3;
  71259. specularColor: BABYLON.Color3;
  71260. specularPower: number;
  71261. private _disableLighting;
  71262. disableLighting: boolean;
  71263. private _maxSimultaneousLights;
  71264. maxSimultaneousLights: number;
  71265. /**
  71266. * @param {number}: Represents the wind force
  71267. */
  71268. windForce: number;
  71269. /**
  71270. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  71271. */
  71272. windDirection: BABYLON.Vector2;
  71273. /**
  71274. * @param {number}: Wave height, represents the height of the waves
  71275. */
  71276. waveHeight: number;
  71277. /**
  71278. * @param {number}: Bump height, represents the bump height related to the bump map
  71279. */
  71280. bumpHeight: number;
  71281. /**
  71282. * @param {boolean}: Add a smaller moving bump to less steady waves.
  71283. */
  71284. private _bumpSuperimpose;
  71285. bumpSuperimpose: boolean;
  71286. /**
  71287. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  71288. */
  71289. private _fresnelSeparate;
  71290. fresnelSeparate: boolean;
  71291. /**
  71292. * @param {boolean}: bump Waves modify the reflection.
  71293. */
  71294. private _bumpAffectsReflection;
  71295. bumpAffectsReflection: boolean;
  71296. /**
  71297. * @param {number}: The water color blended with the refraction (near)
  71298. */
  71299. waterColor: BABYLON.Color3;
  71300. /**
  71301. * @param {number}: The blend factor related to the water color
  71302. */
  71303. colorBlendFactor: number;
  71304. /**
  71305. * @param {number}: The water color blended with the reflection (far)
  71306. */
  71307. waterColor2: BABYLON.Color3;
  71308. /**
  71309. * @param {number}: The blend factor related to the water color (reflection, far)
  71310. */
  71311. colorBlendFactor2: number;
  71312. /**
  71313. * @param {number}: Represents the maximum length of a wave
  71314. */
  71315. waveLength: number;
  71316. /**
  71317. * @param {number}: Defines the waves speed
  71318. */
  71319. waveSpeed: number;
  71320. /**
  71321. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  71322. * will avoid calculating useless pixels in the pixel shader of the water material.
  71323. */
  71324. disableClipPlane: boolean;
  71325. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  71326. private _mesh;
  71327. private _refractionRTT;
  71328. private _reflectionRTT;
  71329. private _reflectionTransform;
  71330. private _lastTime;
  71331. private _lastDeltaTime;
  71332. private _renderId;
  71333. private _useLogarithmicDepth;
  71334. private _waitingRenderList;
  71335. private _imageProcessingConfiguration;
  71336. private _imageProcessingObserver;
  71337. /**
  71338. * Gets a boolean indicating that current material needs to register RTT
  71339. */
  71340. readonly hasRenderTargetTextures: boolean;
  71341. /**
  71342. * Constructor
  71343. */
  71344. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  71345. useLogarithmicDepth: boolean;
  71346. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71347. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  71348. addToRenderList(node: any): void;
  71349. enableRenderTargets(enable: boolean): void;
  71350. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  71351. readonly renderTargetsEnabled: boolean;
  71352. needAlphaBlending(): boolean;
  71353. needAlphaTesting(): boolean;
  71354. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  71355. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  71356. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  71357. private _createRenderTargets;
  71358. getAnimatables(): BABYLON.IAnimatable[];
  71359. getActiveTextures(): BABYLON.BaseTexture[];
  71360. hasTexture(texture: BABYLON.BaseTexture): boolean;
  71361. dispose(forceDisposeEffect?: boolean): void;
  71362. clone(name: string): WaterMaterial;
  71363. serialize(): any;
  71364. getClassName(): string;
  71365. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  71366. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  71367. }
  71368. }
  71369. declare module BABYLON {
  71370. /** @hidden */
  71371. export var asciiartPixelShader: {
  71372. name: string;
  71373. shader: string;
  71374. };
  71375. }
  71376. declare module BABYLON {
  71377. /**
  71378. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  71379. *
  71380. * It basically takes care rendering the font front the given font size to a texture.
  71381. * This is used later on in the postprocess.
  71382. */
  71383. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  71384. private _font;
  71385. private _text;
  71386. private _charSize;
  71387. /**
  71388. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71389. */
  71390. readonly charSize: number;
  71391. /**
  71392. * Create a new instance of the Ascii Art FontTexture class
  71393. * @param name the name of the texture
  71394. * @param font the font to use, use the W3C CSS notation
  71395. * @param text the caracter set to use in the rendering.
  71396. * @param scene the scene that owns the texture
  71397. */
  71398. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71399. /**
  71400. * Gets the max char width of a font.
  71401. * @param font the font to use, use the W3C CSS notation
  71402. * @return the max char width
  71403. */
  71404. private getFontWidth;
  71405. /**
  71406. * Gets the max char height of a font.
  71407. * @param font the font to use, use the W3C CSS notation
  71408. * @return the max char height
  71409. */
  71410. private getFontHeight;
  71411. /**
  71412. * Clones the current AsciiArtTexture.
  71413. * @return the clone of the texture.
  71414. */
  71415. clone(): AsciiArtFontTexture;
  71416. /**
  71417. * Parses a json object representing the texture and returns an instance of it.
  71418. * @param source the source JSON representation
  71419. * @param scene the scene to create the texture for
  71420. * @return the parsed texture
  71421. */
  71422. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  71423. }
  71424. /**
  71425. * Option available in the Ascii Art Post Process.
  71426. */
  71427. export interface IAsciiArtPostProcessOptions {
  71428. /**
  71429. * The font to use following the w3c font definition.
  71430. */
  71431. font?: string;
  71432. /**
  71433. * The character set to use in the postprocess.
  71434. */
  71435. characterSet?: string;
  71436. /**
  71437. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71438. * This number is defined between 0 and 1;
  71439. */
  71440. mixToTile?: number;
  71441. /**
  71442. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71443. * This number is defined between 0 and 1;
  71444. */
  71445. mixToNormal?: number;
  71446. }
  71447. /**
  71448. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  71449. *
  71450. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71451. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  71452. */
  71453. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  71454. /**
  71455. * The font texture used to render the char in the post process.
  71456. */
  71457. private _asciiArtFontTexture;
  71458. /**
  71459. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  71460. * This number is defined between 0 and 1;
  71461. */
  71462. mixToTile: number;
  71463. /**
  71464. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  71465. * This number is defined between 0 and 1;
  71466. */
  71467. mixToNormal: number;
  71468. /**
  71469. * Instantiates a new Ascii Art Post Process.
  71470. * @param name the name to give to the postprocess
  71471. * @camera the camera to apply the post process to.
  71472. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  71473. */
  71474. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  71475. }
  71476. }
  71477. declare module BABYLON {
  71478. /** @hidden */
  71479. export var digitalrainPixelShader: {
  71480. name: string;
  71481. shader: string;
  71482. };
  71483. }
  71484. declare module BABYLON {
  71485. /**
  71486. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  71487. *
  71488. * It basically takes care rendering the font front the given font size to a texture.
  71489. * This is used later on in the postprocess.
  71490. */
  71491. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  71492. private _font;
  71493. private _text;
  71494. private _charSize;
  71495. /**
  71496. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  71497. */
  71498. readonly charSize: number;
  71499. /**
  71500. * Create a new instance of the Digital Rain FontTexture class
  71501. * @param name the name of the texture
  71502. * @param font the font to use, use the W3C CSS notation
  71503. * @param text the caracter set to use in the rendering.
  71504. * @param scene the scene that owns the texture
  71505. */
  71506. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  71507. /**
  71508. * Gets the max char width of a font.
  71509. * @param font the font to use, use the W3C CSS notation
  71510. * @return the max char width
  71511. */
  71512. private getFontWidth;
  71513. /**
  71514. * Gets the max char height of a font.
  71515. * @param font the font to use, use the W3C CSS notation
  71516. * @return the max char height
  71517. */
  71518. private getFontHeight;
  71519. /**
  71520. * Clones the current DigitalRainFontTexture.
  71521. * @return the clone of the texture.
  71522. */
  71523. clone(): DigitalRainFontTexture;
  71524. /**
  71525. * Parses a json object representing the texture and returns an instance of it.
  71526. * @param source the source JSON representation
  71527. * @param scene the scene to create the texture for
  71528. * @return the parsed texture
  71529. */
  71530. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  71531. }
  71532. /**
  71533. * Option available in the Digital Rain Post Process.
  71534. */
  71535. export interface IDigitalRainPostProcessOptions {
  71536. /**
  71537. * The font to use following the w3c font definition.
  71538. */
  71539. font?: string;
  71540. /**
  71541. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71542. * This number is defined between 0 and 1;
  71543. */
  71544. mixToTile?: number;
  71545. /**
  71546. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71547. * This number is defined between 0 and 1;
  71548. */
  71549. mixToNormal?: number;
  71550. }
  71551. /**
  71552. * DigitalRainPostProcess helps rendering everithing in digital rain.
  71553. *
  71554. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71555. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  71556. */
  71557. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  71558. /**
  71559. * The font texture used to render the char in the post process.
  71560. */
  71561. private _digitalRainFontTexture;
  71562. /**
  71563. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  71564. * This number is defined between 0 and 1;
  71565. */
  71566. mixToTile: number;
  71567. /**
  71568. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  71569. * This number is defined between 0 and 1;
  71570. */
  71571. mixToNormal: number;
  71572. /**
  71573. * Instantiates a new Digital Rain Post Process.
  71574. * @param name the name to give to the postprocess
  71575. * @camera the camera to apply the post process to.
  71576. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  71577. */
  71578. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  71579. }
  71580. }
  71581. declare module BABYLON {
  71582. /** @hidden */
  71583. export var oceanPostProcessPixelShader: {
  71584. name: string;
  71585. shader: string;
  71586. };
  71587. }
  71588. declare module BABYLON {
  71589. /**
  71590. * Option available in the Ocean Post Process.
  71591. */
  71592. export interface IOceanPostProcessOptions {
  71593. /**
  71594. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71595. */
  71596. reflectionSize?: number | {
  71597. width: number;
  71598. height: number;
  71599. } | {
  71600. ratio: number;
  71601. };
  71602. /**
  71603. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  71604. */
  71605. refractionSize?: number | {
  71606. width: number;
  71607. height: number;
  71608. } | {
  71609. ratio: number;
  71610. };
  71611. }
  71612. /**
  71613. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  71614. *
  71615. * Simmply add it to your scene and let the nerd that lives in you have fun.
  71616. * Example usage:
  71617. * var pp = new OceanPostProcess("myOcean", camera);
  71618. * pp.reflectionEnabled = true;
  71619. * pp.refractionEnabled = true;
  71620. */
  71621. export class OceanPostProcess extends BABYLON.PostProcess {
  71622. /**
  71623. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  71624. */
  71625. /**
  71626. * Sets weither or not the real-time reflection is enabled on the ocean.
  71627. * Is set to true, the reflection mirror texture will be used as reflection texture.
  71628. */
  71629. reflectionEnabled: boolean;
  71630. /**
  71631. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  71632. */
  71633. /**
  71634. * Sets weither or not the real-time refraction is enabled on the ocean.
  71635. * Is set to true, the refraction render target texture will be used as refraction texture.
  71636. */
  71637. refractionEnabled: boolean;
  71638. /**
  71639. * Gets wether or not the post-processes is supported by the running hardware.
  71640. * This requires draw buffer supports.
  71641. */
  71642. readonly isSupported: boolean;
  71643. /**
  71644. * This is the reflection mirror texture used to display reflections on the ocean.
  71645. * By default, render list is empty.
  71646. */
  71647. reflectionTexture: BABYLON.MirrorTexture;
  71648. /**
  71649. * This is the refraction render target texture used to display refraction on the ocean.
  71650. * By default, render list is empty.
  71651. */
  71652. refractionTexture: BABYLON.RenderTargetTexture;
  71653. private _time;
  71654. private _cameraRotation;
  71655. private _cameraViewMatrix;
  71656. private _reflectionEnabled;
  71657. private _refractionEnabled;
  71658. private _geometryRenderer;
  71659. /**
  71660. * Instantiates a new Ocean Post Process.
  71661. * @param name the name to give to the postprocess.
  71662. * @camera the camera to apply the post process to.
  71663. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  71664. */
  71665. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  71666. /**
  71667. * Returns the appropriate defines according to the current configuration.
  71668. */
  71669. private _getDefines;
  71670. /**
  71671. * Computes the current camera rotation as the shader requires a camera rotation.
  71672. */
  71673. private _computeCameraRotation;
  71674. }
  71675. }
  71676. declare module BABYLON {
  71677. /** @hidden */
  71678. export var brickProceduralTexturePixelShader: {
  71679. name: string;
  71680. shader: string;
  71681. };
  71682. }
  71683. declare module BABYLON {
  71684. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  71685. private _numberOfBricksHeight;
  71686. private _numberOfBricksWidth;
  71687. private _jointColor;
  71688. private _brickColor;
  71689. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71690. updateShaderUniforms(): void;
  71691. numberOfBricksHeight: number;
  71692. numberOfBricksWidth: number;
  71693. jointColor: BABYLON.Color3;
  71694. brickColor: BABYLON.Color3;
  71695. /**
  71696. * Serializes this brick procedural texture
  71697. * @returns a serialized brick procedural texture object
  71698. */
  71699. serialize(): any;
  71700. /**
  71701. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  71702. * @param parsedTexture defines parsed texture data
  71703. * @param scene defines the current scene
  71704. * @param rootUrl defines the root URL containing brick procedural texture information
  71705. * @returns a parsed Brick Procedural BABYLON.Texture
  71706. */
  71707. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  71708. }
  71709. }
  71710. declare module BABYLON {
  71711. /** @hidden */
  71712. export var cloudProceduralTexturePixelShader: {
  71713. name: string;
  71714. shader: string;
  71715. };
  71716. }
  71717. declare module BABYLON {
  71718. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  71719. private _skyColor;
  71720. private _cloudColor;
  71721. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71722. updateShaderUniforms(): void;
  71723. skyColor: BABYLON.Color4;
  71724. cloudColor: BABYLON.Color4;
  71725. /**
  71726. * Serializes this cloud procedural texture
  71727. * @returns a serialized cloud procedural texture object
  71728. */
  71729. serialize(): any;
  71730. /**
  71731. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  71732. * @param parsedTexture defines parsed texture data
  71733. * @param scene defines the current scene
  71734. * @param rootUrl defines the root URL containing cloud procedural texture information
  71735. * @returns a parsed Cloud Procedural BABYLON.Texture
  71736. */
  71737. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  71738. }
  71739. }
  71740. declare module BABYLON {
  71741. /** @hidden */
  71742. export var fireProceduralTexturePixelShader: {
  71743. name: string;
  71744. shader: string;
  71745. };
  71746. }
  71747. declare module BABYLON {
  71748. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  71749. private _time;
  71750. private _speed;
  71751. private _autoGenerateTime;
  71752. private _fireColors;
  71753. private _alphaThreshold;
  71754. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71755. updateShaderUniforms(): void;
  71756. render(useCameraPostProcess?: boolean): void;
  71757. static readonly PurpleFireColors: BABYLON.Color3[];
  71758. static readonly GreenFireColors: BABYLON.Color3[];
  71759. static readonly RedFireColors: BABYLON.Color3[];
  71760. static readonly BlueFireColors: BABYLON.Color3[];
  71761. autoGenerateTime: boolean;
  71762. fireColors: BABYLON.Color3[];
  71763. time: number;
  71764. speed: BABYLON.Vector2;
  71765. alphaThreshold: number;
  71766. /**
  71767. * Serializes this fire procedural texture
  71768. * @returns a serialized fire procedural texture object
  71769. */
  71770. serialize(): any;
  71771. /**
  71772. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  71773. * @param parsedTexture defines parsed texture data
  71774. * @param scene defines the current scene
  71775. * @param rootUrl defines the root URL containing fire procedural texture information
  71776. * @returns a parsed Fire Procedural BABYLON.Texture
  71777. */
  71778. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  71779. }
  71780. }
  71781. declare module BABYLON {
  71782. /** @hidden */
  71783. export var grassProceduralTexturePixelShader: {
  71784. name: string;
  71785. shader: string;
  71786. };
  71787. }
  71788. declare module BABYLON {
  71789. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  71790. private _grassColors;
  71791. private _groundColor;
  71792. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71793. updateShaderUniforms(): void;
  71794. grassColors: BABYLON.Color3[];
  71795. groundColor: BABYLON.Color3;
  71796. /**
  71797. * Serializes this grass procedural texture
  71798. * @returns a serialized grass procedural texture object
  71799. */
  71800. serialize(): any;
  71801. /**
  71802. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  71803. * @param parsedTexture defines parsed texture data
  71804. * @param scene defines the current scene
  71805. * @param rootUrl defines the root URL containing grass procedural texture information
  71806. * @returns a parsed Grass Procedural BABYLON.Texture
  71807. */
  71808. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  71809. }
  71810. }
  71811. declare module BABYLON {
  71812. /** @hidden */
  71813. export var marbleProceduralTexturePixelShader: {
  71814. name: string;
  71815. shader: string;
  71816. };
  71817. }
  71818. declare module BABYLON {
  71819. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  71820. private _numberOfTilesHeight;
  71821. private _numberOfTilesWidth;
  71822. private _amplitude;
  71823. private _jointColor;
  71824. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71825. updateShaderUniforms(): void;
  71826. numberOfTilesHeight: number;
  71827. amplitude: number;
  71828. numberOfTilesWidth: number;
  71829. jointColor: BABYLON.Color3;
  71830. /**
  71831. * Serializes this marble procedural texture
  71832. * @returns a serialized marble procedural texture object
  71833. */
  71834. serialize(): any;
  71835. /**
  71836. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  71837. * @param parsedTexture defines parsed texture data
  71838. * @param scene defines the current scene
  71839. * @param rootUrl defines the root URL containing marble procedural texture information
  71840. * @returns a parsed Marble Procedural BABYLON.Texture
  71841. */
  71842. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  71843. }
  71844. }
  71845. declare module BABYLON {
  71846. /** @hidden */
  71847. export var normalMapProceduralTexturePixelShader: {
  71848. name: string;
  71849. shader: string;
  71850. };
  71851. }
  71852. declare module BABYLON {
  71853. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  71854. private _baseTexture;
  71855. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71856. updateShaderUniforms(): void;
  71857. render(useCameraPostProcess?: boolean): void;
  71858. resize(size: any, generateMipMaps: any): void;
  71859. baseTexture: BABYLON.Texture;
  71860. /**
  71861. * Serializes this normal map procedural texture
  71862. * @returns a serialized normal map procedural texture object
  71863. */
  71864. serialize(): any;
  71865. /**
  71866. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  71867. * @param parsedTexture defines parsed texture data
  71868. * @param scene defines the current scene
  71869. * @param rootUrl defines the root URL containing normal map procedural texture information
  71870. * @returns a parsed Normal Map Procedural BABYLON.Texture
  71871. */
  71872. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  71873. }
  71874. }
  71875. declare module BABYLON {
  71876. /** @hidden */
  71877. export var perlinNoiseProceduralTexturePixelShader: {
  71878. name: string;
  71879. shader: string;
  71880. };
  71881. }
  71882. declare module BABYLON {
  71883. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  71884. time: number;
  71885. timeScale: number;
  71886. translationSpeed: number;
  71887. private _currentTranslation;
  71888. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71889. updateShaderUniforms(): void;
  71890. render(useCameraPostProcess?: boolean): void;
  71891. resize(size: any, generateMipMaps: any): void;
  71892. /**
  71893. * Serializes this perlin noise procedural texture
  71894. * @returns a serialized perlin noise procedural texture object
  71895. */
  71896. serialize(): any;
  71897. /**
  71898. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  71899. * @param parsedTexture defines parsed texture data
  71900. * @param scene defines the current scene
  71901. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  71902. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  71903. */
  71904. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  71905. }
  71906. }
  71907. declare module BABYLON {
  71908. /** @hidden */
  71909. export var roadProceduralTexturePixelShader: {
  71910. name: string;
  71911. shader: string;
  71912. };
  71913. }
  71914. declare module BABYLON {
  71915. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  71916. private _roadColor;
  71917. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71918. updateShaderUniforms(): void;
  71919. roadColor: BABYLON.Color3;
  71920. /**
  71921. * Serializes this road procedural texture
  71922. * @returns a serialized road procedural texture object
  71923. */
  71924. serialize(): any;
  71925. /**
  71926. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  71927. * @param parsedTexture defines parsed texture data
  71928. * @param scene defines the current scene
  71929. * @param rootUrl defines the root URL containing road procedural texture information
  71930. * @returns a parsed Road Procedural BABYLON.Texture
  71931. */
  71932. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  71933. }
  71934. }
  71935. declare module BABYLON {
  71936. /** @hidden */
  71937. export var starfieldProceduralTexturePixelShader: {
  71938. name: string;
  71939. shader: string;
  71940. };
  71941. }
  71942. declare module BABYLON {
  71943. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  71944. private _time;
  71945. private _alpha;
  71946. private _beta;
  71947. private _zoom;
  71948. private _formuparam;
  71949. private _stepsize;
  71950. private _tile;
  71951. private _brightness;
  71952. private _darkmatter;
  71953. private _distfading;
  71954. private _saturation;
  71955. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71956. updateShaderUniforms(): void;
  71957. time: number;
  71958. alpha: number;
  71959. beta: number;
  71960. formuparam: number;
  71961. stepsize: number;
  71962. zoom: number;
  71963. tile: number;
  71964. brightness: number;
  71965. darkmatter: number;
  71966. distfading: number;
  71967. saturation: number;
  71968. /**
  71969. * Serializes this starfield procedural texture
  71970. * @returns a serialized starfield procedural texture object
  71971. */
  71972. serialize(): any;
  71973. /**
  71974. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  71975. * @param parsedTexture defines parsed texture data
  71976. * @param scene defines the current scene
  71977. * @param rootUrl defines the root URL containing startfield procedural texture information
  71978. * @returns a parsed Starfield Procedural BABYLON.Texture
  71979. */
  71980. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  71981. }
  71982. }
  71983. declare module BABYLON {
  71984. /** @hidden */
  71985. export var woodProceduralTexturePixelShader: {
  71986. name: string;
  71987. shader: string;
  71988. };
  71989. }
  71990. declare module BABYLON {
  71991. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  71992. private _ampScale;
  71993. private _woodColor;
  71994. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  71995. updateShaderUniforms(): void;
  71996. ampScale: number;
  71997. woodColor: BABYLON.Color3;
  71998. /**
  71999. * Serializes this wood procedural texture
  72000. * @returns a serialized wood procedural texture object
  72001. */
  72002. serialize(): any;
  72003. /**
  72004. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  72005. * @param parsedTexture defines parsed texture data
  72006. * @param scene defines the current scene
  72007. * @param rootUrl defines the root URL containing wood procedural texture information
  72008. * @returns a parsed Wood Procedural BABYLON.Texture
  72009. */
  72010. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  72011. }
  72012. }